Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
April 2008
- 1 participants
- 373 discussions
r363 - in trunk/lutinvcs/lutinvcs-core/src: main/java/org/codelutin/vcs main/java/org/codelutin/vcs/ui/model test/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:32 +0000 (Sat, 05 Apr 2008)
New Revision: 363
Removed:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java
Log:
refactor PRovider, Handler and Connexion
Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,138 +0,0 @@
-/* *##%
-* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
-* Benjamin Poussin, Tony Chemit
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*##%*/
-package org.codelutin.vcs;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.util.StringUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ServiceLoader;
-
-/**
- * TODO
- *
- * @author chemit
- * @see VCSConfig
- * @see VCSHandler
- */
-(a)org.codelutin.i18n.I18nable
-public class VCSHandlerFactory {
-
- static protected final Log log = LogFactory.getLog(VCSHandlerFactory.class);
-
- static private VCSHandlerFactory instance;
-
- /** current config to use */
- private VCSConfig config;
-
- /** current vcs handler to use */
- private VCSHandler handler;
-
- /** providers availables */
- private List<VCSProvider> providers;
-
-
- public static VCSHandlerFactory getInstance() {
- if (instance == null) {
- instance = new VCSHandlerFactory();
- }
- return instance;
- }
-
- public static VCSConfig getConfig() {
- VCSHandlerFactory factory = getInstance();
- assertConfigIsNotNull(factory.config);
- return factory.config;
- }
-
- public static void setConfig(VCSConfig value) {
- getInstance().config = value;
- }
-
- public static VCSHandler getHandler() {
- final VCSHandlerFactory factory = getInstance();
- if (factory.handler == null) {
- synchronized (factory) {
- factory.handler = newHandler(getConfig());
- }
- }
- return factory.handler;
- }
-
- /**
- * instanciate a new handler, using a previously instanciate handler config.
- * <p/>
- * the method will produce a runtime exception if config is null and not init.
- *
- * @param config config to use
- * @return the new handler instance
- */
- public static VCSHandler newHandler(VCSConfig config) {
- VCSHandlerFactory factory = getInstance();
-
- assertConfigIsInit(config);
- VCSProvider<?, ?> provider = factory.getProvider(config.getType().name().toUpperCase());
- if (provider == null) {
- throw new IllegalArgumentException("could not find a provider for type " + config.getType());
- }
- return provider.newInstance(getConfig());
- }
-
- private VCSHandlerFactory() {
- long t0 = System.nanoTime();
- providers = new ArrayList<VCSProvider>();
- for (VCSProvider provider : ServiceLoader.load(VCSProvider.class)) {
- providers.add(provider);
- if (log.isDebugEnabled()) {
- log.debug("find " + provider);
- }
- }
- log.info("found " + providers.size() + " provider(s) " + providers.toString() + " in " + StringUtil.convertTime(t0, System.nanoTime()));
- for (VCSProvider provider : providers) {
- log.info(provider.getName() + " [" + provider + ']');
- }
- }
-
- private VCSProvider getProvider(String type) {
- for (VCSProvider provider : providers) {
- if (type.equals(provider.getName().toUpperCase())) {
- return provider;
- }
- }
- throw new IllegalArgumentException("could not found a provier for " + config);
- }
-
- private static void assertConfigIsNotNull(VCSConfig vcsConfig) {
- if (vcsConfig == null) {
- throw new VCSRuntimeException(_("lutinvcs.error.init.no.config", VCSHandlerFactory.class.getName()));
- }
- }
-
- private static void assertConfigIsInit(VCSConfig config) {
- assertConfigIsNotNull(config);
- if (!config.isInit()) {
- throw new VCSRuntimeException(_("lutinvcs.error.init.config", config));
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,280 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
-* Benjamin Poussin, Tony Chemit
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.vcs.ui.model;
-
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSState;
-
-import javax.swing.ListSelectionModel;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Simple Table model to display list of VCSFileState
- *
- * @author chemit
- */
-public abstract class AbstractVCSFileStatesModel extends javax.swing.table.AbstractTableModel {
-
- protected final String name;
-
- protected List<VCSFileState> data;
-
- protected final String[] columnNames;
-
- private static final long serialVersionUID = 4697917831388337369L;
-
- protected AbstractVCSFileStatesModel(String name, String[] columnNames) {
- super();
- this.name = name;
- this.columnNames = columnNames;
- }
-
- public List<VCSFileState> getData() {
- return data;
- }
-
- public String getName() {
- return name;
- }
-
- public int getColumnCount() {
- return columnNames.length;
- }
-
- public int getRowCount() {
- return data == null ? 0 : data.size();
- }
-
- /*@Override
- public Class<?> getColumnClass(int columnIndex) {
- return String.class;
- }*/
-
- @Override
- public String getColumnName(int columnIndex) {
- return _(columnNames[columnIndex]);
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // read only data
- return false;
- }
-
- @Override
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- // read only data
- }
-
-
- public void setData(List<VCSFileState> states) {
- if (data != null) {
- data.clear();
- data.addAll(states);
- } else {
- data = new ArrayList<VCSFileState>(states);
- }
- fireTableDataChanged();
- }
-
- public void addData(VCSFileState... states) {
- if (data != null) {
- data.addAll(Arrays.asList(states));
- } else {
- data = new ArrayList<VCSFileState>(Arrays.asList(states));
- }
- fireTableDataChanged();
- }
-
- public void removeData(VCSFileState... states) {
- if (isEmpty()) {
- return;
- }
- data.removeAll(Arrays.asList(states));
- fireTableDataChanged();
- }
-
- protected boolean isEmpty() {
- return data == null || data.isEmpty();
- }
-
- public void clear() {
- if (isEmpty()) {
- return;
- }
- data.clear();
- fireTableDataChanged();
- }
-
- public VCSFileState[] getData(VCSAction action) {
- if (isEmpty()) {
- return new VCSFileState[0];
- }
- List<VCSFileState> list = new ArrayList<VCSFileState>(data);
- for (Iterator<VCSFileState> it = list.iterator(); it.hasNext();) {
- VCSFileState fileState = it.next();
- List<VCSAction> actions = fileState.getState().getActions();
- if (!actions.contains(action)) {
- it.remove();
- }
- }
- return list.toArray(new VCSFileState[list.size()]);
- }
-
- /**
- * restrict in model, only lines with given action enabled
- *
- * @param action current action to filter
- * @param selectionModel current selection where to filter
- * @param reset if <code>true</code> means take
- */
- public void select(VCSAction action, ListSelectionModel selectionModel, boolean reset) {
- if (isEmpty()) {
- return;
- }
- selectionModel.setValueIsAdjusting(true);
- if (reset) {
- selectionModel.clearSelection();
- }
- for (int i = 0; i < data.size(); i++) {
- VCSFileState fileState = data.get(i);
- List<VCSAction> actions = fileState.getState().getActions();
- if (reset) {
- if (actions.contains(action)) {
- selectionModel.addSelectionInterval(i, i);
- }
- } else if (!actions.contains(action)) {
- selectionModel.removeSelectionInterval(i, i);
- }
- }
- selectionModel.setValueIsAdjusting(false);
- }
-
- public VCSFileState[] getData(VCSState action) {
- if (isEmpty()) {
- return new VCSFileState[0];
- }
- List<VCSFileState> list = new ArrayList<VCSFileState>(data);
- for (Iterator<VCSFileState> it = list.iterator(); it.hasNext();) {
- VCSFileState fileState = it.next();
- if (!action.equals(fileState.getState())) {
- it.remove();
- }
- }
- return list.toArray(new VCSFileState[list.size()]);
- }
-
- public VCSState[] getStates() {
- if (isEmpty()) {
- return new VCSState[0];
- }
- List<VCSState> result = new ArrayList<VCSState>();
- for (VCSFileState vcsFileState : data) {
- VCSState state = vcsFileState.getState();
- if (state != null && !result.contains(state)) {
- result.add(state);
- }
- }
- return result.toArray(new VCSState[result.size()]);
- }
-
- public VCSAction[] getActions() {
- if (isEmpty()) {
- return new VCSAction[0];
- }
- List<VCSAction> result = new ArrayList<VCSAction>();
- for (VCSState vcsFileState : getStates()) {
- List<VCSAction> action = vcsFileState.getActions();
- for (VCSAction vcsAction : action) {
- if (vcsAction != null && !result.contains(vcsAction)) {
- result.add(vcsAction);
- }
- }
- }
- return result.toArray(new VCSAction[result.size()]);
- }
-
- public VCSFileState[] getData(ListSelectionModel selectionModel) {
- if (isEmpty() || selectionModel.isSelectionEmpty()) {
- return new VCSFileState[0];
- }
- List<VCSFileState> list = new ArrayList<VCSFileState>();
- for (int i = 0, max = size(); i < max; i++) {
- if (selectionModel.isSelectedIndex(i)) {
- list.add(data.get(i));
- }
- }
- return list.toArray(new VCSFileState[list.size()]);
- }
-
- public VCSAction[] getActions(ListSelectionModel selectionModel) {
- if (isEmpty() || selectionModel.isSelectionEmpty()) {
- return new VCSAction[0];
- }
- List<VCSAction> result = new ArrayList<VCSAction>();
- for (VCSState vcsFileState : getStates(selectionModel)) {
- List<VCSAction> action = vcsFileState.getActions();
- for (VCSAction vcsAction : action) {
- if (vcsAction != null && !result.contains(vcsAction)) {
- result.add(vcsAction);
- }
- }
- }
- return result.toArray(new VCSAction[result.size()]);
- }
-
- public VCSState[] getStates(ListSelectionModel selectionModel) {
- if (isEmpty() || selectionModel.isSelectionEmpty()) {
- return new VCSState[0];
- }
- List<VCSState> result = new ArrayList<VCSState>();
- for (int i = 0, max = size(); i < max; i++) {
- if (selectionModel.isSelectedIndex(i)) {
- VCSFileState vcsFileState = data.get(i);
- VCSState state = vcsFileState.getState();
- if (state != null && !result.contains(state)) {
- result.add(state);
- }
- }
- }
- return result.toArray(new VCSState[result.size()]);
- }
-
-
- @Override
- public String toString() {
- return super.toString() + "<name:" + name + ", size:" + (isEmpty() ? "0" : size()) + '>';
- }
-
- public void refresh(VCSState... states) {
- //TODO launch refreshaction on given states
-
- }
-
-
- public int size() {
- return data.size();
- }
-}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,19 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * This program is free software; you
- * can redistribute it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. This program is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
- */
-package org.codelutin.vcs;
-
-/** @author chemit */
-public @interface MethodTest {
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,68 +0,0 @@
-package org.codelutin.vcs;
-
-import static org.codelutin.vcs.VCSType.SVN;
-
-import java.io.File;
-import java.util.List;
-
-public class RepositoryStateTest extends VCSTest {
- static protected int start, last;
-
- static protected int[] interval;
-
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- vcsType = SVN;
- resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
- initVCS();
- }
-
- protected void tearDownVars() throws Exception {
- resetConfiguration = null;
- vcsType = null;
- disposeVCS();
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Demarrage du scenario
- // /////////////////////////////////////////////////////////////////////////
-
- static List<File> list, list2;
-
- static VCSState state;
-
- static long rev1, rev2, rev3;
-
- @MethodTest
- public final void testObtainFileState() {
- //fail("Not yet implemented"); // TODO
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Methodes utiles
- // /////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(VCSState stateToTest, String command) {
- setCommand(start, last, stateToTest, command);
- }
-
- protected void setCommand(int pStart, int pLast, VCSState stateToTest,
- String command) {
- state = stateToTest;
- if (!(pStart == start && pLast == last)) {
- start = pStart;
- last = pLast;
- interval = context.getIndex(pStart, pLast);
- }
- log.info("[state:" + state + "] [" + command + "] on interval ["
- + start + "," + last + "]");
- }
-
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,251 +0,0 @@
-package org.codelutin.vcs;
-
-import static org.codelutin.vcs.VCSLocalData.FILE;
-import static org.codelutin.vcs.VCSState.MISSING;
-import static org.codelutin.vcs.VCSState.MODIFIED;
-import static org.codelutin.vcs.VCSState.OUT_OF_DATE;
-import static org.codelutin.vcs.VCSState.OUT_OF_DATE_AND_MODIFIED;
-import static org.codelutin.vcs.VCSState.UNKNOWN;
-import static org.codelutin.vcs.VCSState.UNVERSIONNED;
-import static org.codelutin.vcs.VCSState.UP_TO_DATE;
-
-import java.io.File;
-import static java.io.File.separator;
-import java.util.ArrayList;
-import static java.util.Arrays.asList;
-import java.util.List;
-
-/**
- * VCSFileStateManager Tester.
- *
- * @author <Authors name>
- * @version 1.0
- * @since <pre>10/14/2007</pre>
- */
-public class VCSFileStateManagerTest extends VCSTest {
-
- static protected int start, last;
- static protected int[] interval;
-
- static protected VCSHandler svnhandler;
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- vcsType = VCSType.SVN;
- resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
-
- initVCS();
-
- }
-
- protected void tearDownVars() throws Exception {
- resetConfiguration = null;
- vcsType = null;
- disposeVCS();
- }
-
- ///////////////////////////////////////////////////////////////////////////
- /// Demarrage du scenario
- ///////////////////////////////////////////////////////////////////////////
-
- static List<File> list, list2;
- static List<VCSFileState> listS, list2S;
- static VCSState state;
- static long rev1, rev2, rev3;
-
- @MethodTest
- public void testUnknowState() throws Exception {
-
- // get n files unexisiting files and assert state is unknown
- setCommand(0, 2, UNKNOWN, "");
-
- list = context.getFile(VCSLocalData.FILE, interval);
-
- listS = new ArrayList<VCSFileState>();
- for (File file : list)
- listS.add(VCSFileStateManager.getState(handler, false, file));
- list2S = asList(VCSFileStateManager.getState(handler, false, list));
- assertEquals(listS, list2S);
-
- assertFileState(list, listS, null, false);
-
- assertFileState(list, listS, state, true);
-
- listS = new ArrayList<VCSFileState>();
- for (File file : list)
- listS.add(VCSFileStateManager.getState(handler, true, file));
-
- assertFileState(list, asList(
- VCSFileStateManager.getState(handler, true, list)), state, true);
-
- list2 = context.getFile(VCSLocalData.FILE, "subdir" + separator,
- interval);
-
- assertFileState(list2, list2S, state, true);
-
- }
-
- @MethodTest
- public void testUnversionnedState() throws Exception {
-
- // create n files and assert that state is unversionned
- setCommand(UNVERSIONNED, "");
-
- list = context.create(VCSLocalData.FILE, interval);
- assertFileState(list, listS, state, true);
-
- list2 = context.create(VCSLocalData.FILE, "subdir" + separator,
- interval);
- assertFileState(list2, list2S, state, true);
- }
-
- @MethodTest
- public void testUpToDateState() throws Exception {
-
- // add n files and assert to state is up to date
-
- setCommand(UP_TO_DATE, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- rev1 = handler.add(list, FILE.getCommitMessage("add", this));
-
- assertFileState(list, listS, state, true);
- }
-
- @MethodTest
- public void testMissingState() throws Exception {
-
- // delete locally 5 file and assert to state is missing
-
- setCommand(MISSING, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- context.delete(VCSLocalData.FILE, interval);
-
- assertFileState(list, listS, state, true);
-
- for (File file : list) handler.update(file);
-
- assertFileState(list, listS, UP_TO_DATE, true);
-
- }
-
-
- @MethodTest
- public void testModifiedState() throws Exception {
-
- // modify 5 file and assert to state is modified
-
- setCommand(MODIFIED, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- for (File file : list) modifyFile(file, 10, 'a');
-
- listS = asList(VCSFileStateManager.getState(handler, true, list));
- assertFileState(list, listS, state, true);
-
- handler.revert(list);
- listS = asList(VCSFileStateManager.getState(handler, true, list));
- assertFileState(list, listS, UP_TO_DATE, true);
- }
-
-
- @MethodTest
- public void testOutOfDateState() throws Exception {
-
- // commit n files, revert to first version and assert to state is
- // out to date
-
- setCommand(OUT_OF_DATE, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- for (File file : list) modifyFile(file, 10, 'a');
- listS = asList(VCSFileStateManager.getState(handler, true, list));
- assertFileState(list, listS, MODIFIED, true);
-
- /*rev2 = handler.commit(list, FILE.getCommitMessage("commit one", this));
-
- final SVNRevision revision = SVNRevision.create(rev1);
-
- for (File file : list) handler.update(file, revision);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
-
- context.delete(VCSLocalData.FILE, interval);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, MISSING, true);
-
- for (File file : list) handler.update(file, revision);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
- */
-
- }
-
- @MethodTest
- public void testOutOfDateAndModifiedState() throws Exception {
-
- // modified n files, revert to first version and assert to state is out
- // to date
-
- setCommand(OUT_OF_DATE_AND_MODIFIED, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- for (File file : list) modifyFile(file, 20, 'b');
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
-
- //final SVNRevision revision = SVNRevision.create(rev1);
-
- handler.revert(list);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, OUT_OF_DATE, true);
-
- for (File file : list) modifyFile(file, 15, 'c');
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
-
- handler.revert(list);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, OUT_OF_DATE, true);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- /// Methodes utiles
- ///////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(VCSState stateToTest, String command) {
- setCommand(start, last, stateToTest, command);
- }
-
- protected void setCommand(int pStart, int pLast, VCSState stateToTest,
- String command) {
- state = stateToTest;
- if (!(pStart == start && pLast == last)) {
- start = pStart;
- last = pLast;
- interval = context.getIndex(pStart, pLast);
- }
-
- log.info("[state:" + state + "] [" + command + "] on interval [" + start + "," + last + "]");
- }
-
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,582 +0,0 @@
-package org.codelutin.vcs;
-
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This junit test class tests all methods of the implementation of a VCSHandler <code>XXX</code> (says CVS, or SVN)
- * The VCSType used is junit_<code>XXX</code>
- * The remote database is name is isis-fish-vcs-test_junit
- * The local database name is isis-fish-vcs-test_junit_<code>XXX</code>
- */
-public abstract class VCSHandlerTest extends VCSTest {
-
- //static protected final String patternFile = "_file_{0}.txt";
- //static protected final String patternDirectory = "_directory_{0}.txt";
-
- private static int start, last;
- private static int[] interval;
-
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
- }
-
- protected void tearDownVars() {
- resetConfiguration = null;
- vcsType = null;
- }
-
- //TODO Should test configuration ?
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Tests des cas limites
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @MethodTest
- public void testAddWithNullFileList() throws Exception {
- try {
- handler.add(null, VCSLocalData.FILE.getCommitMessage("add", this));
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- @MethodTest
- public void testAddUnExistantFiles() throws Exception {
- // try to add non existing file
-
- List<File> files = context.getFile(VCSLocalData.FILE, 0, 1);
-
- long rev = handler.add(files, VCSLocalData.FILE.getCommitMessage("add unexistant ", this));
- assertEquals(rev, -1);
-
- }
-
-
- @MethodTest
- public void testAddUnExistantFilesWithNoCommit() throws Exception {
- try {
- handler.add(null, null);
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- @MethodTest
- public void testDeleteNullFileList() throws Exception {
- try {
- handler.delete(null, "");
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- @MethodTest
- public void testDeleteNullFileListWithNocommit() throws Exception {
- try {
- handler.delete(null, null);
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Preparation repository et working copy
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @MethodTest
- public void testCreateRemoteDatabaseDirectory() throws Exception {
-
- // assert remote database does not exists
- try {
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote", this), "");
- } catch (VCSException e) {
- // this is ok for this time :)
- // we just wants to be sure the remote database directory does not exists any longer
- }
-
- // create remote directory
- handler.makeRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("mkdir remote", this), "");
-
- // assert remote directory exist now
-
- }
-
- @MethodTest
- public void testCheckoutDatabaseDirectory() throws Exception {
-
- handler.deleteWorkingCopy();
-
- // assert local directory not exists
- assertFalse(getLocalDatabaseFile().exists());
-
- handler.initWorkingCopy();
-
- // assert directory exists and contains vcs configuration directory in this file
- assertTrue(getLocalDatabaseFile().exists());
-
- assertTrue(new File(getLocalDatabaseFile(), handler.getConfLocalDirname()).exists());
-
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Demarrage du scenario
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- static List<File> list;
-
- @MethodTest
- public void testAddFiles() throws Exception {
- setCommand(0, 4, "add with commit");
- list = context.create(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
- handler.add(list, VCSLocalData.FILE.getCommitMessage("add", this));
-
- assertState(list, VCSState.UP_TO_DATE);
-
- }
-
- @MethodTest
- public void testAddDirectories() throws Exception {
- setCommand(0, 4, "add with commit");
- list = context.create(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
-
- handler.add(list, VCSLocalData.DIRECTORY.getCommitMessage("add", this));
-
- assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testAddFilesWithNoCommit() throws Exception {
- setCommand(5, 9, "add with no commit");
- list = context.create(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
- handler.add(list, null);
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testAddDirectoriesWithNoCommit() throws Exception {
- list = context.create(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
- handler.add(list, null);
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testCommitAddFiles() throws Exception {
- setCommand(5, 9, "commit unadded");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.FILE.getCommitMessage("commit unadded", this));
-
- assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testCommitAddDirectories() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.DIRECTORY.getCommitMessage("commit unadded", this));
-
- assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testDeleteFiles() throws Exception {
- setCommand(7, 9, "delete with commit");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, VCSLocalData.FILE.getCommitMessage("delete", this));
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testDeleteDirectories() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, VCSLocalData.DIRECTORY.getCommitMessage("delete", this));
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testDeleteFilesWithNocommit() throws Exception {
- setCommand(4, 6, "delete with no commit");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, null);
-
- assertState(list, VCSState.UNKNOWN);
- }
-
-
- @MethodTest
- public void testDeleteDirectoriesWithNocommit() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, null);
-
- assertState(list, VCSState.UNKNOWN);
-
- }
-
- @MethodTest
- public void testCommitDeleteFiles() throws Exception {
- setCommand(4, 6, "commit undeleted");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.FILE.getCommitMessage("commit undeleted", this));
-
- // when commit a deleted file, we do not delete locally file
- // => so this is a unversioned file
- assertState(list, VCSState.UNVERSIONNED);
-
- // we delete files by hand...
- context.delete(VCSLocalData.FILE, interval);
-
- }
-
- @MethodTest
- public void testCommitDeleteDirectories() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.DIRECTORY.getCommitMessage("commit undeleted",
- this));
-
- // when commit a deleted directory, direcotry is deleted !!! Find why ?
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testGetLocalStorageNames() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "getLocalStorageNames");
-
- List<String> excepted = new ArrayList<String>();
-
- list = context.getFile(VCSLocalData.FILE, interval);
- //list.addAll(context.getFile(VCSLocalData.DIRECTORY, interval));
- for (File f : list) if (f.isFile()) excepted.add(f.getName());
-
- List<String> list2 =
- handler.getLocalStorageNames(getLocalDatabaseFile());
-
- assertEquals(excepted.size(), list2.size());
-
- for (String filename : excepted) {
- assertTrue("should have found a " + filename +
- " file in result but we do not! ",
- list2.contains(filename));
- }
-
- }
-
- @MethodTest
- public void testGetRemoteStorageNames() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "getRemoteStorageNames");
-
- list = context.getFile(VCSLocalData.FILE, interval);
- //list.addAll(context.getFile(VCSLocalData.DIRECTORY, interval));
-
- List<String> list2 =
- handler.getRemoteStorageNames(getLocalDatabaseFile());
-
- assertEquals(list.size(), list2.size());
-
- // we can not know the style of encoded remote name ?
- //for (File f : list) assertTrue(list2.contains(f));
- }
-
- @MethodTest
- public void testIsOnRemote() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "isOnRemote");
-
- list = context.getFile(VCSLocalData.FILE, interval);
- list.addAll(context.getFile(VCSLocalData.DIRECTORY, interval));
-
- for (File f : list) assertTrue(handler.isOnRemote(f));
-
- assertFalse(handler.isOnRemote(new File(getLocalDatabaseFile(),
- "nonExistingFile")));
-
- }
-
- @MethodTest
- public void testRevert() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "revert");
-
- //TODO we only test on file (I don't think you can have
- // a modified directory ? should be check...)
- list = context.getFile(VCSLocalData.FILE, interval);
-
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.revert(list);
-
- // revert on a normal file should have no effect
- assertState(list, VCSState.UP_TO_DATE);
-
- for (File f : list) {
- // we know that file is 0, change it to 10 (with 10 a for example)
- modifyFile(f, 10);
- }
- assertState(list, VCSState.MODIFIED);
-
- handler.revert(list);
-
- // we came back to file with size = 0
-
- assertState(list, VCSState.UP_TO_DATE);
- for (File f : list) assertEquals(f.length(), 0);
-
- // a non existing file can not be revert of course....
- File file = new File(getLocalDatabaseFile(), "nonExistingFile");
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- }
-
- // now file exists, but still can not revert it since it is not
- // versionned
- file.createNewFile();
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- } finally {
- file.delete();
- }
- }
-
- @MethodTest
- public void testUpdate() throws Exception {
-
- // at this point of the scenario, we only have a [0-3] (files/directories) left on local and remote
- setCommand(0, 3, "update");
-
- //TODO we only test on file (I don't think you can have a modified directory ? should be check...)
- list = context.getFile(VCSLocalData.FILE, interval);
-
- assertState(list, VCSState.UP_TO_DATE);
-
- File f = list.get(0);
-
- handler.update(f);
-
- // update a non remoted modfied file should have no effect
- assertState(list, VCSState.UP_TO_DATE);
-
- // we know that file is 0, change it to 10 (with 10 a for example)
- modifyFile(f, 20);
-
- // file is modified now
- assertState(f, VCSState.MODIFIED);
-
- // we can not update a modifed file
- try {
- handler.update(f);
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- }
-
- Object fileRevision = handler.getRevision(f);
-
- // delete file
- VCSLocalData.FILE.delete(f);
-
- // update it from remote vcs
- handler.update(f);
-
- // back to normal after update
- assertState(f, VCSState.UP_TO_DATE);
-
- assertEquals(fileRevision, handler.getRevision(f));
-
- // a non existing file can not be revert of course....
- File file = new File(getLocalDatabaseFile(), "nonExistingFile");
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- }
-
- // now file exists, but still can not revert it since it is not versionned
- file.createNewFile();
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- } finally {
- file.delete();
- }
-
- }
-
-
- @MethodTest
- public void testIsUpToDate() throws Exception {
-
- // at this point of the scenario, we only have a [0-3] (files/directories) left on local and remote
- setCommand(0, 3, "isUpToDate");
-
- list = context.getFile(VCSLocalData.FILE, interval);
-
- assertTrue(list.size() > 0);
-
- assertState(list, VCSState.UP_TO_DATE);
-
- for (File f : list) assertTrue(handler.isUpToDate(f));
-
- File f = list.get(0);
-
- Object oldRev = handler.getRevision(f);
-
- // modify file : so file is no more upTodate
- modifyFile(f, 30);
-
- assertFalse(handler.isUpToDate(f));
-
- // commit file
- handler.commit(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("commit for test", this));
-
- assertTrue(handler.isUpToDate(f));
-
- // delete file from local working copy, so file is no more upToDate
- VCSLocalData.FILE.delete(f);
-
- assertFalse(handler.isUpToDate(f));
-
- // go back to previous version
- handler.update(f, oldRev);
-
- // now local file is out up to date : older revision than on remote repository
- assertFalse(handler.isUpToDate(f));
-
- // delete file from remote repository, so file is no more upToDate
- try {
- handler.delete(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("delete", this));
- // we can not delete a non updated file
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- handler.revert(getOneFileAsList(f));
- }
-
- // go back to head
- handler.update(f);
-
- assertTrue(handler.isUpToDate(f));
-
- handler.delete(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("delete", this));
-
- assertFalse(handler.isUpToDate(f));
-
- // read file : file is uptodate
-
- f.createNewFile();
-
- handler.add(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("readd", this));
-
- assertTrue(handler.isUpToDate(f));
-
- // a non existing file can not be up to date of course...
- File file = new File(getLocalDatabaseFile(), "nonExistingFile");
- assertFalse(handler.isUpToDate(file));
-
- // now file exists, but still not up to date
- file.createNewFile();
- try {
- assertFalse(handler.isUpToDate(file));
- } finally {
- file.delete();
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Suppression du repository et working copy
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @MethodTest
- public void testDeleteRemoteDir() throws Exception {
-
- // delete remote directory
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote", this), "");
-
- // assert remote directory doe not exist any more
-
- }
-
- @MethodTest
- public void testDeleteWorkingCopy() throws Exception {
-
- handler.deleteWorkingCopy();
-
- // assert local directory does not exists any longer
- assertFalse(getLocalDatabaseFile().exists());
-
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// M�thodes utiles
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(int start, int last, String command) {
- if (!(start == VCSHandlerTest.start && last == VCSHandlerTest.last)) {
- VCSHandlerTest.start = start;
- VCSHandlerTest.last = last;
- VCSHandlerTest.interval = context.getIndex(start, last);
- }
-
- log.info("[" + command + "] on interval [" + VCSHandlerTest.start + "," + VCSHandlerTest.last + "]");
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,134 +0,0 @@
-/* *##%
-* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
-* Benjamin Poussin, Tony Chemit
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*##%*/
-package org.codelutin.vcs;
-
-import junit.framework.TestCase;
-import org.codelutin.i18n.I18n;
-
-
-/**
- * Test vcs properties at init time. TODO Redo it with new init proccess
- *
- * @author chemit
- * @version 1.0
- * @since <pre>12/09/2007</pre>
- */
-public class VCSInitTest extends TestCase {
-
- static {
- // init i18n
- I18n.init();
- }
-
- public void testFirstLaunchWithCVS() throws Exception {
-// init = new OldVCSInit(
-// VCSType.CVS,
-// new VersionNumber(1,1,0),
-// null
-// );
-// assertTrue(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(init.newVCSProperties.getProperty(VCS_TYPE_REPO), VCSTypeRepo.NONE);
- }
-
- public void testFirstLaunchWithSVN_onHEAD() throws Exception {
-// init = new OldVCSInit(
-// VCSType.SVN,
-// new VersionNumber(1,1,0),
-// null
-// );
-// assertTrue(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(init.newVCSProperties.getProperty(VCS_TYPE_REPO), VCSTypeRepo.HEAD);
- }
-
- public void testFirstLaunchWithSVN_onTAG() throws Exception {
-// init = new OldVCSInit(
-// VCSType.SVN,
-// new VersionNumber(3,0,19),
-// null
-// );
-// assertTrue(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(VCSTypeRepo.TAG,init.newVCSProperties.getProperty(VCS_TYPE_REPO));
- }
-
- public void testPreviousWasCVSNewIsCVS() throws Exception {
-// URI uri = getClass().getResource("/.isis-config-3_cvs").toURI();
-// init = new OldVCSInit(
-// VCSType.CVS,
-// new VersionNumber(1,1,0),
-// uri
-// );
-// assertFalse(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(VCSTypeRepo.NONE,init.newVCSProperties.getProperty(VCS_TYPE_REPO));
- }
-
- public void testPreviousWasCVSNewIsSVN() throws Exception {
-// URI uri = getClass().getResource("/.isis-config-3_cvs").toURI();
-// init = new OldVCSInit(
-// VCSType.SVN,
-// new VersionNumber(1,1,0),
-// uri
-// );
-// assertFalse(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertTrue(init.isTypeChanged());
-// assertTrue(init.needMigration());
-// assertEquals(VCSTypeRepo.HEAD,init.newVCSProperties.getProperty(VCS_TYPE_REPO));
- }
-
- public void testPreviousWasSVNNewIsTAG() throws Exception {
- //TODO
- }
-
- public void testPreviousWasSVNNewIsHEAD() throws Exception {
- //TODO
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,112 +0,0 @@
-package org.codelutin.vcs;
-
-import junit.framework.TestCase;
-import org.codelutin.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import static java.text.MessageFormat.format;
-
-/**
- * Util for our local files and directories with a pattern for name,
- * when VCSHandlerTest operation (exist, create, delete).
- *
- * @see VCSHandlerTest
- */
-public enum VCSLocalData {
-
- DIRECTORY("_directory_{0}", "{0} directory by test {1}#{2} at {3}") {
-
- boolean delete(File f) throws IOException {
- return FileUtil.deleteRecursively(f) && f.delete();
- }
- boolean create(File f) throws IOException {
- return f.mkdirs();
- }
- },
-
- FILE("_file_{0}.txt", "{0} file by test {1}#{2} at {3}") {
-
- boolean delete(File f) throws IOException {
- return f.delete();
- }
- boolean create(File f) throws IOException {
- if (!f.getParentFile().exists()) f.getParentFile().mkdirs();
- return f.createNewFile();
- }
- };
-
- abstract boolean create(File f) throws IOException;
-
- abstract boolean delete(File f) throws IOException;
-
- private String pattern;
-
- private String commitPattern;
-
- VCSLocalData(String pattern, String commitPattern) {
- this.commitPattern = commitPattern;
- this.pattern = pattern;
- }
-
- public boolean exists(File root, int... index) {
- for (int i : index)
- if (!getFile(root, i).exists()) return false;
- return true;
- }
-
- public File getFile(File root, int index) {
- return new File(root, format(pattern, index));
- }
-
- public File[] getFile(File root, int... index) {
- File[] result = new File[index.length];
- for (int i1 = 0; i1 < index.length; i1++) {
- int i = index[i1];
- result[i1] = getFile(root, i);
- }
- return result;
- }
-
- public void create(File root, int... index) throws IOException {
- for (int anIndex : index) create(getFile(root, anIndex));
-
- }
-
- public void create(File root, String prefix, int... index) throws IOException {
- for (int anIndex : index) create(getFile(root, prefix, anIndex));
-
- }
-
- private File getFile(File root, String prefix, int anIndex) {
- return new File(root, prefix + format(pattern, anIndex));
- }
-
- public String getFilename(String prefix, int anIndex) {
- return prefix + format(pattern, anIndex);
- }
-
- public boolean delete(File root, int index) throws IOException {
- final File file = getFile(root, index);
- return delete(file);
- }
-
- public boolean delete(File root, int... index) throws IOException {
- for (int i : index)
- if (!delete(root, i)) return false;
- return true;
- }
-
- public String getCommitMessage(String command, TestCase test) {
- return format(commitPattern, command, test.getClass(), test.getName(), new java.util.Date());
- }
-
- public File[] getFile(File root, String prefix, int[] index) {
- File[] result = new File[index.length];
- for (int i1 = 0; i1 < index.length; i1++) {
- int i = index[i1];
- result[i1] = getFile(root, prefix, i);
- }
- return result;
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,60 +0,0 @@
-package org.codelutin.vcs;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class VCSLocalDataContext {
-
- File root;
- private List<File> result;
-
-
- public VCSLocalDataContext(File root) {
- this.root = root;
- }
-
- public boolean exist(VCSLocalData type, int... index) {
- return type.exists(root, index);
- }
-
- public List<File> getFile(VCSLocalData type, int... index) {
- final File[] files = type.getFile(root, index);
- if (result == null) result = new ArrayList<File>();
- else result.clear();
- result.addAll(Arrays.asList(files));
- List<File> res = new ArrayList<File>();
- res.addAll(result);
- return res;
- }
-
- public List<File> create(VCSLocalData type, int... index) throws IOException {
- type.create(root, index);
- return getFile(type, index);
- }
-
- public List<File> create(VCSLocalData type, String prefix, int... index) throws IOException {
- type.create(root, prefix, index);
- return getFile(type, prefix, index);
- }
-
- public List<File> getFile(VCSLocalData type, String prefix, int[] index) {
- final File[] files = type.getFile(root, prefix, index);
- List<File> res = new ArrayList<File>();
- res.addAll(Arrays.asList(files));
- return res;
- }
-
- public void delete(VCSLocalData type, int... index) throws IOException {
- type.delete(root, index);
- }
-
- public int[] getIndex(int first, int last) {
- final int size = last - first;
- int[] result = new int[size + 1];
- for (int i = 0; i <= size; i++) result[i] = i + first;
- return result;
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,235 +0,0 @@
-package org.codelutin.vcs;
-
-import junit.framework.Assert;
-import org.codelutin.util.FileUtil;
-import static org.codelutin.vcs.VCSState.UNVERSIONNED_OR_MISSING;
-import static org.codelutin.vcs.VCSType.SVN;
-import org.codelutin.vcs.util.VCSHelper;
-
-import java.io.File;
-import static java.io.File.separator;
-import java.util.ArrayList;
-import java.util.List;
-
-public class VCSStateTest extends VCSTest {
- static protected int start, last;
-
- static protected int[] interval;
-
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- VCSTest.vcsType = SVN;
- VCSTest.resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
-
- initVCS();
- }
-
- protected void tearDownVars() throws Exception {
- VCSTest.resetConfiguration = null;
- VCSTest.vcsType = null;
- disposeVCS();
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Demarrage du scenario
- // /////////////////////////////////////////////////////////////////////////
-
- static List<File> list, list2;
-
- static VCSState state;
-
- static long rev1, rev2, rev3;
-
- @MethodTest
- public void testRemotePathFromLocalFile() throws Exception {
-
- // get n files unexisiting files and assert state is unknown
- setCommand(0, 2, VCSState.UNKNOWN, "conversion from local file to "
- + "remote module path");
-
- list = context.getFile(VCSLocalData.FILE, interval);
-
- for (int i = 0; i < list.size(); i++) {
- Assert.assertEquals(VCSHelper.getRemoteRelativePath(list.get(i), VCSTest.handler),
- VCSLocalData.FILE.getFilename("", i));
- }
-
- list2 = context.create(VCSLocalData.FILE, "subdir" + separator, interval);
- for (int i = 0; i < list2.size(); i++) {
- String expected = VCSHelper.getRemoteRelativePath(list2.get(i),
- VCSTest.handler);
- String actual = VCSHelper.convertToRemoteName(VCSLocalData.FILE
- .getFilename("subdir" + File.separator, i));
- System.out.println("excepted " + expected + " actual " + actual);
- Assert.assertEquals(expected, VCSHelper.convertToRemoteName(actual));
- }
- FileUtil.deleteRecursively(new File(VCSHandlerFactory.getConfig().getLocalDatabasePath(), "subdir"));
- }
-
- @MethodTest
- public void testUnknowState() throws Exception {
-
- // get n files unexisiting files and assert state is unknown
- setCommand(0, 2, VCSState.UNKNOWN, "");
-
- list = context.getFile(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, state);
-
- list2 = context.getFile(VCSLocalData.FILE, "subdir" + separator, interval);
- VCSTest.assertState(list2, state);
- }
-
- @MethodTest
- public void testUnversionnedState() throws Exception {
-
- // create n files and assert that state is unversionned
- setCommand(VCSState.UNVERSIONNED, "");
-
- context.create(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, state);
- }
-
- @MethodTest
- public void testUnversionnedOrMissingState() throws Exception {
-
- // create n files and assert that state is unversionned
- setCommand(VCSState.UNVERSIONNED_OR_MISSING, "");
-
- context.create(VCSLocalData.FILE, "subdir" + separator, interval);
- VCSTest.assertState(list2, UNVERSIONNED_OR_MISSING);
- }
-
- @MethodTest
- public void testUpToDateState() throws Exception {
-
- // add n files and assert to state is up to date
-
- setCommand(VCSState.UP_TO_DATE, "");
-
- rev1 = VCSTest.handler.add(new ArrayList<File>(list),
- VCSLocalData.FILE.getCommitMessage("add", this));
-
- VCSTest.assertState(list, state);
-
- }
-
- @MethodTest
- public void testMissingState() throws Exception {
-
- // delete locally 5 file and assert to state is missing
-
- setCommand(VCSState.MISSING, "");
-
- context.delete(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, state);
-
- update(list);
- VCSTest.assertState(list, VCSState.UP_TO_DATE);
- final File subdir = new File(VCSTest.databaseDirectory, "subdir");
- context.create(VCSLocalData.FILE, "subdir" + separator, interval);
- VCSTest.handler.add(getOneFileAsList(subdir), VCSLocalData.FILE.getCommitMessage(
- "add sub files", this));
-
- VCSTest.handler.add(list2, VCSLocalData.FILE.getCommitMessage("add sub files", this));
- VCSTest.assertState(list2, VCSState.UP_TO_DATE);
-
- FileUtil.deleteRecursively(subdir);
-
- context.create(VCSLocalData.FILE, "subdir" + separator, interval);
-
- VCSTest.assertState(list2, UNVERSIONNED_OR_MISSING);
-
- }
-
- @MethodTest
- public void testModifiedState() throws Exception {
-
- // modify 5 file and assert to state is modified
-
- setCommand(VCSState.MODIFIED, "");
-
- modifyFile(list, 30, 'h');
- VCSTest.assertState(list, state);
-
- VCSTest.handler.revert(list);
- VCSTest.assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testOutOfDateState() throws Exception {
-
- // commit n files, revert to first version and assert to state is
- // out to date
-
- setCommand(VCSState.OUT_OF_DATE, "");
-
- modifyFile(list, 45, 'j');
- VCSTest.assertState(list, VCSState.MODIFIED);
-
- /*rev2 = VCSTest.handler.commit(list, VCSLocalData.FILE.getCommitMessage("commit one", this));
- final SVNRevision revision = SVNRevision.create(rev1);
-
- update(list, revision);
- VCSTest.assertState(list, state);
-
- context.delete(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, VCSState.MISSING);
-
- update(list, revision);
- VCSTest.assertState(list, state);*/
-
- }
-
- @MethodTest
- public void testOutOfDateAndModifiedState() throws Exception {
-
- // modified n files, revert to first version and assert to state is out
- // to date
-
- setCommand(VCSState.OUT_OF_DATE_AND_MODIFIED, "");
-
- modifyFile(list, 14, 'n');
-
- VCSTest.assertState(list, state);
-
- VCSTest.handler.revert(list);
-
- VCSTest.assertState(list, VCSState.OUT_OF_DATE);
-
- modifyFile(list, 46, 'o');
-
- VCSTest.assertState(list, state);
-
- VCSTest.handler.revert(list);
-
- VCSTest.assertState(list, VCSState.OUT_OF_DATE);
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Methodes utiles
- // /////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(VCSState stateToTest, String command) {
- setCommand(start, last, stateToTest, command);
- }
-
- protected void setCommand(int pStart, int pLast, VCSState stateToTest,
- String command) {
- state = stateToTest;
- if (!(pStart == start && pLast == last)) {
- start = pStart;
- last = pLast;
- interval = context.getIndex(pStart, pLast);
- }
- VCSTest.log.info("[state:" + state + "] [" + command + "] on interval ["
- + start + "," + last + "]");
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,324 +0,0 @@
-package org.codelutin.vcs;
-
-import junit.framework.TestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.log.LutinLogFactory;
-import org.codelutin.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * abstract test for a vcs should be implements by any new vcs handler
- *
- * @author chemit
- */
-public abstract class VCSTest extends TestCase {
-
- static protected Boolean resetConfiguration;
-
- static protected VCSType vcsType;
-
- /** method to be invoked before first test */
- protected abstract void setUpVars();
-
- /**
- * method to be inocked after last test
- *
- * @throws Exception TODO
- */
- protected abstract void tearDownVars() throws Exception;
-
- /** flag to says we have already invoked setVars method */
- static protected boolean init = false;
-
- static protected VCSConfig config;
-
- static protected File databaseDirectory;
-
- static protected File oldConfig;
-
- static protected VCSHandler handler;
-
- static protected int nbTests;
-
- static protected int currentTest = 0;
-
- static {
- System.setProperty("org.apache.commons.logging.LogFactory", LutinLogFactory.class.getName());
- }
-
- protected static Log log = LogFactory.getLog(VCSTest.class);
-
- protected void resetConfig() throws Exception {
- log.info(" process " + currentTest + "/" + nbTests + " tests for "
- + getClass());
- tearDownVars();
- log.info(" == pause for one second, waiting for next test...");
- Thread.sleep(100);
- nbTests = currentTest = 0;
- config = null;
- handler = null;
- databaseDirectory = null;
- init = false;
-
- // push back previous configuration file
- String path = oldConfig.getAbsolutePath();
- FileUtil.copy(oldConfig, new File(path.substring(0, path.length() - 4)));
- oldConfig.delete();
- }
-
- private static String originalLocalDatabaseName;
- private static String originalRemoteDatabaseName;
-
- protected void initConfig() throws Exception {
- try {
- setUpVars();
-
- long timestamp = System.nanoTime();
-
- nbTests = getNbTests();
-
- log.info("[" + timestamp + "] found " + nbTests + " tests for " + getClass());
-
- File dConfig = new File(System.getProperty("user.home"), ".isis-config-3");
-
- if (dConfig.exists()) {
- oldConfig = new File(dConfig.getParentFile(), dConfig.getName() + "_old");
- FileUtil.copy(dConfig, oldConfig);
- }
-
- //IsisFish.init();
- //TODO force type load(vcsType);
-
- //config = IsisContext.get().getVcsConfig();
- config = null;
-
- String lname = config.getLocalDatabasePath().getName();
- String rname = config.getRemoteDatabase();
- if (originalLocalDatabaseName == null) {
- originalLocalDatabaseName = lname;
- originalRemoteDatabaseName = rname;
- } else {
- lname = originalLocalDatabaseName;
- rname = originalRemoteDatabaseName;
- }
- //IsisVcsConfig.LOCAL_DATABASE_PROPERTY_KEY.setCurrentValue(lname + timestamp);
-
- //IsisVcsConfig.REMOTE_DATABASE_PROPERTY_KEY.setCurrentValue( rname + timestamp);
-
- try {
- config.validate();
-
- } catch (VCSRuntimeException e) {
- log.fatal("Fill missing properties in configuration file ["
- + config.getSource() + "]");
- System.exit(1);
- }
-
- assertTrue(config.isInit());
-
- handler = VCSHandlerFactory.getHandler();
- //handler = IsisContext.get().getVCSHanler();
-
- assertNotNull(handler);
-
- databaseDirectory = config.getLocalDatabasePath();
-
- log.info("localDatabase : [" + databaseDirectory + "]");
- log.info("remoteDatabase : [" + config.getRemoteDatabasePath()
- + "]");
- log.info("remote url : [" + handler.getRemoteUrl() + "]");
- log.debug("handler : " + handler);
- init = true;
- } catch (Exception e) {
- log.error("could not load Default VCSHandler ", e);
- fail();
- }
- }
-
- protected void postInitConfig() throws VCSException {
- // init root of working copy (check it out if it the first use)
- handler.initWorkingCopy();
- assertTrue(databaseDirectory != null && databaseDirectory.exists());
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- if (!init) {
- initConfig();
- }
- currentTest++;
- log.debug(" (" + currentTest + "/" + nbTests + ") : " + this);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- log.debug(" (" + currentTest + "/" + nbTests + ") : " + this);
- if (currentTest == nbTests)
- resetConfig();
- }
-
- protected int getNbTests() {
- int result = 0;
- for (java.lang.reflect.Method method : getClass().getMethods())
- if (method.isAnnotationPresent(MethodTest.class))
- result++;
-
- assertTrue("find no test methods marked with annotation "
- + MethodTest.class + "in class " + getClass(), result > 0);
- return result;
- }
-
- protected MethodTest getMethodTest() {
- try {
-
- return getClass().getMethod(getName()).getAnnotation(
- MethodTest.class);
-
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected File getLocalDatabaseFile() {
- return VCSHandlerFactory.getConfig().getLocalDatabasePath();
- }
-
- protected void update(List<File> list) throws VCSException {
- for (File file : list)
- handler.update(file);
- }
-
- protected void update(List<File> list, VCSRevision revision)
- throws VCSException {
- for (File file : list)
- handler.update(file, revision);
- }
-
- public static void assertState(List<File> files, VCSState status)
- throws VCSException {
- for (File file : files) {
- final VCSState state = handler.getState(file, new ArrayList());
- if (state != status)
- fail("state required [" + status + "] but found [" + state
- + "] for files " + file);
- }
- }
-
- public static void assertFileState(List<File> list,
- List<VCSFileState> files, VCSState status, boolean synch)
- throws VCSException {
- if (synch)
- VCSFileStateManager.doSynch(handler, list);
- VCSState state;
- for (VCSFileState file : files) {
- try {
- state = file.getState();
- if (state != status)
- fail("state required [" + status + "] but found [" + state
- + "] for files " + file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- public static void assertState(File file, VCSState status)
- throws VCSException {
- final VCSState vcsStatus = handler.getState(file, new ArrayList());
- if (vcsStatus != status)
- fail("state required [" + status + "] but found [" + vcsStatus
- + "] for file " + file);
- }
-
- protected void modifyFile(List<File> f) throws IOException {
- modifyFile(f, 10, 'a');
- for (File file : f) {
- modifyFile(file, 10, 'a');
- }
- }
-
- protected void modifyFile(List<File> f, int newSize) throws IOException {
- modifyFile(f, newSize, 'b');
- }
-
- protected void modifyFile(List<File> f, int newSize, char c)
- throws IOException {
- for (File file : f)
- modifyFile(file, newSize, c);
- }
-
- protected void modifyFile(File f, int newSize) throws IOException {
- modifyFile(f, newSize, 'a');
- }
-
- protected void modifyFile(File f, int newSize, char c) throws IOException {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < newSize; i++)
- sb.append(c);
- FileUtil.writeString(f, sb.toString());
- }
-
- protected List<File> getOneFileAsList(File f) {
- List<File> result = new ArrayList<File>();
- result.add(f);
- return result;
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Preparation repository et working copy
- // /////////////////////////////////////////////////////////////////////////
- protected void initVCS() throws VCSException {
- // assert remote database does not exists
- try {
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote",
- this), "");
- } catch (VCSException e) {
- // this is ok for this time :)
- // we just wants to be sure the remote database directory does not
- // exists any longer
- }
-
- // create remote directory
- handler.makeRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("mkdir remote", this),
- "");
-
- handler.deleteWorkingCopy();
-
- // assert local directory not exists
- assertFalse(getLocalDatabaseFile().exists());
-
- handler.initWorkingCopy();
-
- // assert directory exists and contains vcs configuration directory in
- // this file
- assertTrue(getLocalDatabaseFile().exists());
- assertTrue(new File(getLocalDatabaseFile(), handler
- .getConfLocalDirname()).exists());
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Suppression du repository et working copy
- // /////////////////////////////////////////////////////////////////////////
-
- protected void disposeVCS() throws Exception {
-
- // delete remote directory
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote",
- this), "");
-
- // delete local working copy
- handler.deleteWorkingCopy();
-
- // assert local directory does not exists any longer
- assertFalse(getLocalDatabaseFile().exists());
-
- }
-
-}
1
0
r362 - in trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs: . ui ui/handler ui/model
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:17 +0000 (Sat, 05 Apr 2008)
New Revision: 362
Added:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSEntriesTableModel.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java
Modified:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java
Log:
refactor PRovider, Handler and Connexion
Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java (from rev 353, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -0,0 +1,145 @@
+/* *##%
+* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
+* Benjamin Poussin, Tony Chemit
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*##%*/
+package org.codelutin.vcs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.StringUtil;
+import org.codelutin.vcs.runner.VCSActionManager;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+/**
+ * This classes acts as a factory of {@link VCSProvider}, and {@link VCSConnexion}.
+ *
+ * @author chemit
+ * @see VCSConnexionConfig
+ * @see VCSConnexion
+ * @see VCSProvider
+ * @see VCSHandler
+ */
+(a)org.codelutin.i18n.I18nable
+public class VCSFactory implements VCSConnexionEventListener {
+
+ static protected final Log log = LogFactory.getLog(VCSFactory.class);
+
+ /** shared instance */
+ static protected VCSFactory instance;
+
+ /** providers availables */
+ protected List<VCSProvider> providers;
+
+ /** connexions opened */
+ protected List<VCSConnexion> connexions;
+
+ /** action manager */
+ protected VCSActionManager actionManager;
+
+ protected static VCSFactory getInstance() {
+ if (instance == null) {
+ instance = new VCSFactory();
+ }
+ return instance;
+ }
+
+ public static VCSActionManager getActionManager() {
+ return getInstance().actionManager;
+ }
+
+ /**
+ * instanciate a new connexion.
+ * <p/>
+ * the method will produce a runtime exception if config is null and not init.
+ *
+ * @param mode mode of connexion required
+ * @param config config to use @return the new connexion instance
+ * @return instanicate and init connexion (but not opened).
+ */
+ public static VCSConnexion newConnexion(VCSConnexionMode mode, VCSConnexionConfig config) {
+
+ VCSFactory factory = getInstance();
+ VCSProvider<?, ?> provider;
+
+ // obtain matching provider
+ provider = factory.getProvider(config.getType().name().toUpperCase());
+
+ // make sure provider is init
+ provider.init();
+
+ // delegate instanciation of connexion to provider
+ VCSConnexion connexion = provider.newConnection(mode, config);
+
+ // init connexion
+ connexion.init(config);
+
+ // register connexion
+ connexion.addVCSConnexionEventListener(factory);
+ return connexion;
+ }
+
+ public VCSProvider getProvider(String type) {
+ VCSFactory factory = getInstance();
+ for (VCSProvider provider : factory.providers) {
+ if (type.equals(provider.getName().toUpperCase())) {
+ return provider;
+ }
+ }
+ throw new IllegalArgumentException("could not find a provider for type " + type);
+ }
+
+ public VCSConnexion[] getConnexions() {
+ return connexions.toArray(new VCSConnexion[connexions.size()]);
+ }
+
+ public void open(VCSConnexionEvent event) {
+ // register connexion as active
+ connexions.add(event.getSource());
+ if (connexions.size() == 1) {
+ // first connexion to be opened, open actionManager
+ getActionManager().open();
+ }
+ }
+
+ public void close(VCSConnexionEvent event) {
+ // remove connexion from active
+ connexions.remove(event.getSource());
+ if (connexions.isEmpty()) {
+ // close actionManager ?
+ getActionManager().close();
+ }
+ }
+
+ protected VCSFactory() {
+ long t0 = System.nanoTime();
+ providers = new ArrayList<VCSProvider>();
+ for (VCSProvider provider : ServiceLoader.load(VCSProvider.class)) {
+ providers.add(provider);
+ }
+ log.info("found " + providers.size() + " provider(s) " + providers.toString() + " in " + StringUtil.convertTime(t0, System.nanoTime()));
+ for (VCSProvider provider : providers) {
+ log.info(provider.getName() + " [" + provider + ']');
+ }
+ actionManager = new VCSActionManager();
+ connexions = new ArrayList<VCSConnexion>();
+ }
+
+}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -27,6 +27,8 @@
};
/** model name for synchronize all tab ui */
+ public static final String SYNCH_MODEL_PROPERTY = "modelSynch";
+
public static final String SYNCH_ALL_MODEL_PROPERTY = "modelSynchAll";
/** model name for synchronize local tab ui */
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,14 +15,13 @@
package org.codelutin.vcs.ui.handler;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.runner.VCSActionManager;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.ui.VCSUIConstants;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.model.ConfirmUIModel;
import java.beans.PropertyChangeEvent;
+import java.util.List;
/**
* Abstract ConfirmUI handler
@@ -31,14 +30,6 @@
*/
public abstract class AbstractConfirmUIHandler extends AbstractUIHandler<ConfirmUIModel> {
- protected final VCSActionManager actionManager;
-
-
- protected AbstractConfirmUIHandler(VCSHandler handler) {
- super(handler);
- this.actionManager = new VCSActionManager(handler);
- }
-
protected abstract void updateUI();
protected abstract void updateMessageUI();
@@ -62,11 +53,11 @@
throw new IllegalStateException("unimplemented property changed : " + evt);
}
- public void doAction(String commitMessage, AbstractVCSFileStatesModel model) {
+ public void doAction(String commitMessage, AbstractVCSEntriesTableModel model) {
VCSAction action = getModel().getAction();
- VCSFileState[] data = selectData(model, action, false);
+ List<VCSEntry> entries = model.filter(action, model.getDisplayedEntries(getSelectionModel()));
if (action.isCommit()) {
getModel().addCommitMessage(commitMessage);
@@ -76,10 +67,10 @@
}
if (log.isDebugEnabled()) {
- log.debug("action:" + action + ", message:" + commitMessage + ", nb files:" + data.length);
+ log.debug("action:" + action + ", message:" + commitMessage + ", nb files:" + entries.size());
}
- actionManager.add(action, data);
+ getActionManager().add(action, entries.toArray(new VCSEntry[entries.size()]), commitMessage);
// dispose ui
getUi().dispose();
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,21 +15,16 @@
package org.codelutin.vcs.ui.handler;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.ui.model.DiffUIModel;
-import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel;
+import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.ui.VCSUIConstants;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
+import org.codelutin.vcs.ui.model.DiffUIModel;
import java.beans.PropertyChangeEvent;
/** @author chemit */
public abstract class AbstractDiffUIHandler extends AbstractUIHandler<DiffUIModel> {
- protected AbstractDiffUIHandler(VCSHandler handler) {
- super(handler);
- }
-
public void propertyChange(PropertyChangeEvent evt) {
//if (log.isDebugEnabled()) {
log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
@@ -37,14 +32,14 @@
String action = evt.getPropertyName();
if (VCSUIConstants.TAB_PROPERTY_CHANGED.equals(action)) {
- doSelectTab((SimpleVCSFileStatesModel) evt.getNewValue());
+ doSelectTab((AbstractVCSEntriesTableModel) evt.getNewValue());
} else {
if (VCSUIConstants.FILE_PROPERTY_CHANGED.equals(action)) {
- doSelectFile((VCSFileState) evt.getNewValue());
+ doSelectFile((VCSEntry) evt.getNewValue());
} else {
try {
VCSAction vcsAction = VCSAction.valueOf(action.toUpperCase());
- doAction(vcsAction, (VCSFileState) evt.getNewValue());
+ doAction(vcsAction, (VCSEntry) evt.getNewValue());
} catch (IllegalArgumentException e) {
// ignore ite
}
@@ -52,11 +47,11 @@
}
}
- public abstract void doSelectTab(SimpleVCSFileStatesModel action);
+ public abstract void doSelectTab(AbstractVCSEntriesTableModel action);
- public abstract void doSelectFile(VCSFileState model);
+ public abstract void doSelectFile(VCSEntry model);
- public abstract void doAction(VCSAction action, VCSFileState model);
+ public abstract void doAction(VCSAction action, VCSEntry model);
public abstract void gotoNextDiff();
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,51 +15,38 @@
package org.codelutin.vcs.ui.handler;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel;
-import org.codelutin.vcs.ui.model.SynchUIModel;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.VCSUIConstants;
+import org.codelutin.vcs.ui.model.SynchUIModel;
import java.beans.PropertyChangeEvent;
/** @author chemit */
public abstract class AbstractSynchUIHandler extends AbstractUIHandler<SynchUIModel> {
- protected AbstractSynchUIHandler(VCSHandler handler) {
- super(handler);
- }
-
public void propertyChange(PropertyChangeEvent evt) {
//if (log.isDebugEnabled()) {
log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
//}
String action = evt.getPropertyName();
- SimpleVCSFileStatesModel model = (SimpleVCSFileStatesModel) evt.getNewValue();
+
if (VCSUIConstants.TAB_PROPERTY_CHANGED.equals(action)) {
- doSelectTabAction(model);
+ doSelectLocation((VCSEntryLocation) evt.getNewValue());
} else if (action.endsWith("All")) {
try {
String actionName = action.substring(0, action.length() - 3);
VCSAction vcsAction = VCSAction.valueOf(actionName.toUpperCase());
- doAllAction(vcsAction, model);
+ doAllAction(vcsAction);
} catch (IllegalArgumentException e) {
// ignore it ?
}
- } else {
- try {
- VCSAction vcsAction = VCSAction.valueOf(action.toUpperCase());
- doSelectAction(vcsAction, model);
- } catch (IllegalArgumentException e) {
- // ignore it ?
- }
-
}
}
- public abstract void doSelectAction(VCSAction action, SimpleVCSFileStatesModel model);
+ //public abstract void doSelectAction(VCSAction action);
- public abstract void doAllAction(VCSAction action, SimpleVCSFileStatesModel model);
+ public abstract void doAllAction(VCSAction action);
- public abstract void doSelectTabAction(SimpleVCSFileStatesModel action);
+ public abstract void doSelectLocation(VCSEntryLocation action);
}
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -16,20 +16,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.vcs.VCSFactory;
+import org.codelutin.vcs.runner.VCSActionManager;
import org.codelutin.vcs.ui.model.AbstractUIModel;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSHandler;
-import javax.swing.ListSelectionModel;
import javax.swing.JDialog;
+import javax.swing.ListSelectionModel;
import java.beans.PropertyChangeListener;
/** @author chemit */
public abstract class AbstractUIHandler<M extends AbstractUIModel> implements PropertyChangeListener {
- protected static Log log = LogFactory.getLog(AbstractConfirmUIHandler.class);
+ protected static Log log = LogFactory.getLog(AbstractUIHandler.class);
public abstract M getModel();
@@ -37,17 +35,6 @@
public abstract ListSelectionModel getSelectionModel();
- /** vcs handler to use (lazy instanciation) */
- protected VCSHandler handler;
-
- public VCSHandler getHandler() {
- return handler;
- }
-
- protected AbstractUIHandler(VCSHandler handler) {
- this.handler = handler;
- }
-
public void init() {
if (getModel() == null) {
throw new IllegalStateException("no model was defined for " + this);
@@ -55,9 +42,7 @@
getModel().addPropertyChangeListener(this);
}
- protected VCSFileState[] selectData(AbstractVCSFileStatesModel model, VCSAction action, boolean b) {
- ListSelectionModel selectionModel = getSelectionModel();
- model.select(action, selectionModel, b);
- return model.getData(selectionModel);
+ protected VCSActionManager getActionManager() {
+ return VCSFactory.getActionManager();
}
}
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -17,7 +17,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSHandler;
import javax.swing.AbstractAction;
@@ -28,19 +27,13 @@
protected VCSAction action;
- protected transient VCSHandler handler;
-
private static final long serialVersionUID = 1074145285171920255L;
- public VCSAbsractAction(VCSHandler handler) {
- this.handler = handler;
+ public VCSAbsractAction() {
}
public void setAction(VCSAction action) {
this.action = action;
}
- public VCSHandler getHandler() {
- return handler;
- }
}
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -16,8 +16,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSException;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -29,28 +31,35 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(AbstractUIModel.class);
-
/** support for change properties support */
protected PropertyChangeSupport changeSupport;
+ protected final AbstractVCSEntriesTableModel model;
- public abstract void setData(List<VCSFileState> states);
+ protected AbstractUIModel() {
+ model = new SimpleVCSEntriesTableModelImpl(getClass().getSimpleName());
+ }
- public abstract void addData(List<VCSFileState> states);
+ public AbstractVCSEntriesTableModel getModel() {
+ return model;
+ }
- public abstract void removeData(List<VCSFileState> states);
+ public void populate(VCSConnexion connexion) throws VCSException {
+ getModel().populate(connexion, System.nanoTime());
+ }
- protected void splitStates(List<VCSFileState> states, List<VCSFileState> local, List<VCSFileState> remote) {
- for (VCSFileState state : states) {
- if (state.getState() != null && state.getState().isLocal()) {
- local.add(state);
- }
- if (state.getState() != null && state.getState().isRemote()) {
- remote.add(state);
- }
- }
+ public void populate(VCSConnexion connexion, List<String> relativeLocalPaths, VCSEntryLocation location) throws VCSException {
+ getModel().populate(connexion, relativeLocalPaths, location, System.nanoTime());
}
+ public void populate(VCSEntryLocation location, VCSEntry[] datas) {
+ getModel().populate(location, datas);
+ }
+
+ public void refresh(List<VCSEntry> entries) {
+ getModel().refresh(entries, System.nanoTime());
+ }
+
public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
if (listener == null) {
return;
Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSEntriesTableModel.java (from rev 345, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSEntriesTableModel.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSEntriesTableModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -0,0 +1,187 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
+* Benjamin Poussin, Tony Chemit
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.vcs.ui.model;
+
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.vcs.VCSAction;
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSEntries;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.util.VCSEntriesImpl;
+
+import javax.swing.ListSelectionModel;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Simple Table model to display list of VCSFileState
+ *
+ * @author chemit
+ */
+public abstract class AbstractVCSEntriesTableModel extends javax.swing.table.AbstractTableModel implements VCSEntries {
+
+ protected final String name;
+
+ /** column names */
+ protected final String[] columnNames;
+
+ protected VCSEntryLocation location;
+
+ /** delegate model */
+ protected final transient VCSEntries delegate;
+
+ /** displayed entries */
+ protected final transient List<VCSEntry> displayedEntries;
+
+ private static final long serialVersionUID = 4697917831388337369L;
+
+ protected AbstractVCSEntriesTableModel(String name, String[] columnNames) {
+ super();
+ this.name = name;
+ this.columnNames = columnNames;
+ this.displayedEntries = new ArrayList<VCSEntry>();
+ this.delegate = new VCSEntriesImpl();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public VCSEntryLocation getLocation() {
+ return location;
+ }
+
+ public List<VCSEntry> getDisplayedEntries(ListSelectionModel selectionModel) {
+ return selectionModel == null ? new ArrayList<VCSEntry>(displayedEntries) : filter(selectionModel, displayedEntries);
+ }
+
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ public int getRowCount() {
+ return displayedEntries.size();
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return _(columnNames[columnIndex]);
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // read only data
+ return false;
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ // read only data
+ }
+
+ public void setLocation(VCSEntryLocation location) {
+ this.location = location;
+ displayedEntries.clear();
+ displayedEntries.addAll(filter(location, getEntries()));
+ fireTableDataChanged();
+ }
+
+ public VCSAction[] getActions(ListSelectionModel selectionModel) {
+ return getActions(getDisplayedEntries(selectionModel));
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name:" + name + ", size:" + (getRowCount()) + '>';
+ }
+
+ //===================================================================================================//
+ // === delegate methods =============================================================================//
+ //===================================================================================================//
+
+ public List<VCSEntry> getEntries() {
+ return delegate.getEntries();
+ }
+
+ public List<VCSEntry> filter(VCSAction action, List<VCSEntry> entries) {
+ return delegate.filter(action, entries);
+ }
+
+ public List<VCSEntry> filter(VCSConnexion connexion, List<VCSEntry> entries) {
+ return delegate.filter(connexion, entries);
+ }
+
+ public List<VCSEntry> filter(VCSEntryLocation location, List<VCSEntry> entries) {
+ return delegate.filter(location, entries);
+ }
+
+ public List<VCSEntry> filter(VCSState state, List<VCSEntry> entries) {
+ return delegate.filter(state, entries);
+ }
+
+ public List<VCSEntry> filter(ListSelectionModel selectionModel, List<VCSEntry> entries) {
+ return delegate.filter(selectionModel, entries);
+ }
+
+ public void populate(VCSConnexion connexion, long timestamp) throws VCSException {
+ delegate.populate(connexion, timestamp);
+ updateEntries();
+ }
+
+ public void populate(VCSConnexion connexion, List<String> relativeLocalPaths, VCSEntryLocation location, long timestamp) throws VCSException {
+ delegate.populate(connexion, relativeLocalPaths, location, timestamp);
+ updateEntries();
+ }
+
+ public void populate(VCSEntryLocation location, VCSEntry[] states) {
+ clear();
+ this.location = location;
+ delegate.populate(location, states);
+ updateEntries();
+ }
+
+ public void refresh(List<VCSEntry> entries, long timestamp) throws IllegalStateException {
+ delegate.refresh(entries, timestamp);
+ updateEntries();
+ }
+
+ public VCSAction[] getActions(List<VCSEntry> entries) {
+ return delegate.getActions(entries);
+ }
+
+ public VCSState[] getStates(List<VCSEntry> entries) {
+ return delegate.getStates(entries);
+ }
+
+ public void clear() {
+ delegate.clear();
+ displayedEntries.clear();
+ fireTableDataChanged();
+ }
+
+ protected void updateEntries() {
+ displayedEntries.clear();
+ displayedEntries.addAll(filter(location, delegate.getEntries()));
+ fireTableDataChanged();
+ }
+}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,9 +15,9 @@
package org.codelutin.vcs.ui.model;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import static org.codelutin.vcs.ui.VCSUIConstants.ACTION_PROPERTY_CHANGED;
-import static org.codelutin.vcs.ui.VCSUIConstants.CONFIRM_MODEL_PROPERTY;
import static org.codelutin.vcs.ui.VCSUIConstants.MESSAGE_HISTORY_PROPERTY_CHANGED;
import java.util.ArrayList;
@@ -30,22 +30,12 @@
*/
public class ConfirmUIModel extends AbstractUIModel {
- /** list of states */
- protected SimpleVCSFileStatesModel model;
-
/** history of commit messages */
protected List<String> commitMessages;
/** current action to fired */
protected VCSAction action;
- public AbstractVCSFileStatesModel getModel() {
- if (model == null) {
- model = new SimpleVCSFileStatesModel(CONFIRM_MODEL_PROPERTY);
- }
- return model;
- }
-
public VCSAction getAction() {
return action;
}
@@ -57,12 +47,6 @@
return commitMessages;
}
- public void setAction(VCSAction action) {
- this.action = action;
- // never propagate old action, since need always the property changed
- firePropertyChange(ACTION_PROPERTY_CHANGED, null, action);
- }
-
public void addCommitMessage(String commitMessage) {
if (commitMessage != null && !commitMessage.isEmpty() && !getCommitMessages().contains(commitMessage)) {
// add message in history
@@ -71,16 +55,11 @@
}
}
- public void setData(List<VCSFileState> states) {
- getModel().setData(states);
+ public void init(VCSAction action, VCSEntryLocation location, VCSEntry[] states) {
+ this.action = action;
+ model.clear();
+ model.populate(location, states);
+ // never propagate old action, since need always the property changed
+ firePropertyChange(ACTION_PROPERTY_CHANGED, null, action);
}
-
- public void addData(List<VCSFileState> states) {
- getModel().addData(states.toArray(new VCSFileState[states.size()]));
- }
-
- public void removeData(List<VCSFileState> states) {
- getModel().removeData(states.toArray(new VCSFileState[states.size()]));
- }
-
}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -17,7 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.VCSHandler;
import java.beans.PropertyChangeListener;
@@ -44,7 +44,7 @@
protected VCSHandler handler;
/** map of models */
- protected VCSFileState model;
+ protected VCSEntry model;
/** support for change properties support */
protected PropertyChangeSupport changeSupport;
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,16 +15,10 @@
package org.codelutin.vcs.ui.model;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.VCSUIConstants;
-import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_ALL_MODEL_PROPERTY;
-import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_LOCAL_MODEL_PROPERTY;
-import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_REMOTE_MODEL_PROPERTY;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Model of a repository
*
@@ -32,122 +26,40 @@
*/
public class DiffUIModel extends AbstractUIModel {
- /** local root : wroking copy */
- protected URL leftRoot;
- /** remote root : remote url */
- protected URL rightRoot;
-
- /** map of models */
- protected List<SimpleVCSFileStatesModel> models;
-
- /** current tab displayed */
- protected AbstractVCSFileStatesModel tabModel;
-
/** current file displayed */
- protected VCSFileState fileModel;
+ protected VCSEntry fileModel;
/** current action to fired */
protected VCSAction action;
- public DiffUIModel() {
- }
+ private VCSEntryLocation location;
- public DiffUIModel(URL leftRoot, URL rightRoot) {
- this.leftRoot = leftRoot;
- this.rightRoot = rightRoot;
+ public void setLocation(VCSEntryLocation location) {
+ VCSEntryLocation oldLocation = this.location;
+ getModel().setLocation(location);
+ this.location = location;
+ firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldLocation, location);
}
- public AbstractVCSFileStatesModel getTabModel() {
- return tabModel;
- }
- public void setTabModel(AbstractVCSFileStatesModel tabModel) {
- AbstractVCSFileStatesModel oldTabModel = this.tabModel;
- this.tabModel = tabModel;
- firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldTabModel, tabModel);
- }
-
- public void setFileModel(VCSFileState fileModel) {
- VCSFileState oldFileModel = this.fileModel;
+ public void setFileModel(VCSEntry fileModel) {
+ VCSEntry oldFileModel = this.fileModel;
this.fileModel = fileModel;
- firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldFileModel, tabModel);
+ firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldFileModel, fileModel);
}
- public AbstractVCSFileStatesModel getTabModel(String tabModel) {
- return getModel(tabModel);
- }
-
- public void setLeftRoot(URL leftRoot) {
- this.leftRoot = leftRoot;
- }
-
- public void setRightRoot(URL rightRoot) {
- this.rightRoot = rightRoot;
- }
-
- public SimpleVCSFileStatesModel getModel(String modelName) {
- SimpleVCSFileStatesModel tableModel = null;
- for (SimpleVCSFileStatesModel model : getModels()) {
- if (modelName.equals(model.getName())) {
- tableModel = model;
- break;
- }
- }
- if (tableModel == null) {
- getModels().add(tableModel = new SimpleVCSFileStatesModel(modelName));
- }
- return tableModel;
- }
-
public void doAllAction(VCSAction action) {
- if (tabModel == null) {
- return;
- }
this.action = action;
- firePropertyChange(action.name().toLowerCase() + "All", null, tabModel);
+ firePropertyChange(action.name().toLowerCase() + "All", null, model);
}
- public void setData(List<VCSFileState> states) {
- getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states);
- List<VCSFileState> local = new ArrayList<VCSFileState>();
- List<VCSFileState> remote = new ArrayList<VCSFileState>();
- splitStates(states, local, remote);
- getModel(SYNCH_LOCAL_MODEL_PROPERTY).setData(local);
- getModel(SYNCH_REMOTE_MODEL_PROPERTY).setData(remote);
- }
-
- public void addData(List<VCSFileState> states) {
- getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states);
- List<VCSFileState> local = new ArrayList<VCSFileState>();
- List<VCSFileState> remote = new ArrayList<VCSFileState>();
- splitStates(states, local, remote);
- getModel(SYNCH_LOCAL_MODEL_PROPERTY).addData(local.toArray(new VCSFileState[local.size()]));
- getModel(SYNCH_REMOTE_MODEL_PROPERTY).addData(remote.toArray(new VCSFileState[remote.size()]));
- }
-
- public void removeData(List<VCSFileState> states) {
- getModel(SYNCH_ALL_MODEL_PROPERTY).removeData(states.toArray(new VCSFileState[states.size()]));
- List<VCSFileState> local = new ArrayList<VCSFileState>();
- List<VCSFileState> remote = new ArrayList<VCSFileState>();
- splitStates(states, local, remote);
- getModel(SYNCH_LOCAL_MODEL_PROPERTY).removeData(local.toArray(new VCSFileState[local.size()]));
- getModel(SYNCH_REMOTE_MODEL_PROPERTY).removeData(remote.toArray(new VCSFileState[remote.size()]));
- }
-
public void doAction(VCSAction action) {
- if (tabModel == null) {
- return;
- }
this.action = action;
- firePropertyChange(action.name().toLowerCase(), null, tabModel);
+ firePropertyChange(action.name().toLowerCase(), null, model);
}
- protected List<SimpleVCSFileStatesModel> getModels() {
- if (models == null) {
- models = new ArrayList<SimpleVCSFileStatesModel>();
- }
- return models;
+ public VCSEntryLocation getLocation() {
+ return location;
}
-
}
\ No newline at end of file
Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -0,0 +1,52 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs.ui.model;
+
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.ui.VCSUIConstants;
+
+/** @author chemit */
+public class SimpleVCSEntriesTableModelImpl extends AbstractVCSEntriesTableModel {
+
+ private static final long serialVersionUID = -6397327068709720165L;
+
+ protected SimpleVCSEntriesTableModelImpl(String name) {
+
+ super(name, VCSUIConstants.SIMPLE_COLUMNS_NAMES);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ if (getRowCount() == 0) {
+ return null;
+ }
+ VCSEntry item = displayedEntries.get(rowIndex);
+ Object result = null;
+ if (columnIndex == 0) {
+ // get module
+ result = item.getRelativeLocalPath();
+ } else if (columnIndex == 1) {
+ // get file
+ result = item.getFile().getName();
+ } else if (columnIndex == 2) {
+ // get status
+ VCSState state = item.getState();
+ result = state == null ? null : state.libelle();
+ }
+ return result;
+ }
+
+
+}
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,17 +15,9 @@
package org.codelutin.vcs.ui.model;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.VCSUIConstants;
-import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_ALL_MODEL_PROPERTY;
-import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_LOCAL_MODEL_PROPERTY;
-import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_REMOTE_MODEL_PROPERTY;
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Model of a repository
*
@@ -33,106 +25,18 @@
*/
public class SynchUIModel extends AbstractUIModel {
- /** local root : wroking copy */
- protected File localRoot;
-
- /** remote root : remote url */
- protected URL remoteRoot;
-
- /** map of models */
- protected List<SimpleVCSFileStatesModel> models;
-
- /** current tab displayed */
- protected AbstractVCSFileStatesModel tabModel;
-
- /** current action to fired */
+ /** current action to be fired */
protected VCSAction action;
- public SynchUIModel() {
+ public void setLocation(VCSEntryLocation location) {
+ VCSEntryLocation oldLocation = getModel().getLocation();
+ getModel().setLocation(location);
+ firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldLocation, location);
}
- public SynchUIModel(File localRoot, URL remoteRoot) {
- this.localRoot = localRoot;
- this.remoteRoot = remoteRoot;
- }
-
- public AbstractVCSFileStatesModel getTabModel() {
- return tabModel;
- }
-
- public void setTabModel(AbstractVCSFileStatesModel tabModel) {
- AbstractVCSFileStatesModel oldTabModel = this.tabModel;
- this.tabModel = tabModel;
- firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldTabModel, tabModel);
- }
-
- public AbstractVCSFileStatesModel getTabModel(String tabModel) {
- return getModel(tabModel);
- }
-
- public void setLocalRoot(File localRoot) {
- this.localRoot = localRoot;
- }
-
- public void setRemoteRoot(URL remoteRoot) {
- this.remoteRoot = remoteRoot;
- }
-
- public SimpleVCSFileStatesModel getModel(String modelName) {
- SimpleVCSFileStatesModel tableModel = null;
- for (SimpleVCSFileStatesModel model : getModels()) {
- if (modelName.equals(model.getName())) {
- tableModel = model;
- break;
- }
- }
- if (tableModel == null) {
- getModels().add(tableModel = new SimpleVCSFileStatesModel(modelName));
- }
- return tableModel;
- }
-
- public void setData(List<VCSFileState> states) {
- getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states);
- List<VCSFileState> local = new ArrayList<VCSFileState>();
- List<VCSFileState> remote = new ArrayList<VCSFileState>();
- splitStates(states, local, remote);
- getModel(SYNCH_LOCAL_MODEL_PROPERTY).setData(local);
- getModel(SYNCH_REMOTE_MODEL_PROPERTY).setData(remote);
- }
-
- public void addData(List<VCSFileState> states) {
- getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states);
- List<VCSFileState> local = new ArrayList<VCSFileState>();
- List<VCSFileState> remote = new ArrayList<VCSFileState>();
- splitStates(states, local, remote);
- getModel(SYNCH_LOCAL_MODEL_PROPERTY).addData(local.toArray(new VCSFileState[local.size()]));
- getModel(SYNCH_REMOTE_MODEL_PROPERTY).addData(remote.toArray(new VCSFileState[remote.size()]));
- }
-
- public void removeData(List<VCSFileState> states) {
- getModel(SYNCH_ALL_MODEL_PROPERTY).removeData(states.toArray(new VCSFileState[states.size()]));
- List<VCSFileState> local = new ArrayList<VCSFileState>();
- List<VCSFileState> remote = new ArrayList<VCSFileState>();
- splitStates(states, local, remote);
- getModel(SYNCH_LOCAL_MODEL_PROPERTY).removeData(local.toArray(new VCSFileState[local.size()]));
- getModel(SYNCH_REMOTE_MODEL_PROPERTY).removeData(remote.toArray(new VCSFileState[remote.size()]));
- }
-
public void doAllAction(VCSAction action) {
- if (tabModel == null) {
- return;
- }
this.action = action;
- firePropertyChange(action.name().toLowerCase() + "All", null, tabModel);
+ firePropertyChange(action.name().toLowerCase() + "All", null, model);
}
- protected List<SimpleVCSFileStatesModel> getModels() {
- if (models == null) {
- models = new ArrayList<SimpleVCSFileStatesModel>();
- }
- return models;
- }
-
-
}
1
0
r361 - trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:02 +0000 (Sat, 05 Apr 2008)
New Revision: 361
Modified:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java 2008-04-05 20:36:45 UTC (rev 360)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java 2008-04-05 20:37:02 UTC (rev 361)
@@ -15,10 +15,7 @@
package org.codelutin.vcs.runner;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSHandlerEvent;
-import org.codelutin.vcs.VCSHandlerEventListener;
+import org.codelutin.vcs.VCSEntry;
import java.util.concurrent.PriorityBlockingQueue;
@@ -29,10 +26,10 @@
*
* @author chemit
*/
-public class VCSActionManager implements VCSHandlerEventListener {
+public class VCSActionManager {
/** special item to add in queue to stop the thread */
- protected static final QueueItem STOP_ITEM = new QueueItem(null, new VCSFileState[0]);
+ protected static final QueueItem STOP_ITEM = new QueueItem(null, new VCSEntry[0], null);
/** vcs actions runner thread */
protected VCSActionThread thread;
@@ -40,54 +37,60 @@
/** queue */
protected PriorityBlockingQueue<QueueItem> queue;
- public VCSActionManager(VCSHandler handler) {
+ public VCSActionManager() {
queue = new PriorityBlockingQueue<QueueItem>(1024);
- thread = new VCSActionThread(handler, queue);
- handler.addVCSHandlerEventListener(this);
}
- public boolean add(VCSAction action, VCSFileState[] states) {
- QueueItem queueItem = new QueueItem(action, states);
+ public boolean add(VCSAction action, VCSEntry[] states, String message) {
+ QueueItem queueItem = new QueueItem(action, states, message);
return queue.add(queueItem);
}
- public void init(VCSHandlerEvent event) {
+ public void open() {
+ if (thread != null) {
+ // thread is already opend
+ throw new IllegalStateException("thread is already opened");
+ }
+ (thread = new VCSActionThread(queue)).start();
}
- public void open(VCSHandlerEvent event) {
- thread.start();
- }
-
- public void close(VCSHandlerEvent event) {
- thread.handler.removeVCSHandlerEventListener(this);
+ public void close() {
if (!queue.isEmpty()) {
queue.clear();
}
queue.add(VCSActionManager.STOP_ITEM);
+ // remove thread reference: threas was stopped, and can not be any longer restart...
+ thread = null;
}
/** @author chemit */
public static class QueueItem implements Comparable<QueueItem> {
protected long time;
- protected VCSFileState[] states;
+
+ protected VCSEntry[] entries;
protected VCSAction action;
+ protected String message;
-
- public QueueItem(VCSAction action, VCSFileState[] states) {
+ public QueueItem(VCSAction action, VCSEntry[] entries, String message) {
this.time = System.nanoTime();
- this.states = states;
+ this.entries = entries;
this.action = action;
+ this.message = message;
}
public VCSAction getAction() {
return action;
}
- public VCSFileState[] getStates() {
- return states;
+ public VCSEntry[] getEntries() {
+ return entries;
}
+ public String getMessage() {
+ return message;
+ }
+
@Override
public boolean equals(Object o) {
return this == o || o instanceof QueueItem && time == ((QueueItem) o).time;
@@ -100,7 +103,7 @@
@Override
public String toString() {
- return super.toString() + ", time:" + time + ", action:" + action + ", size:" + (states == null ? 0 : states.length);
+ return super.toString() + ", time:" + time + ", action:" + action + ", size:" + (entries == null ? 0 : entries.length);
}
public int compareTo(QueueItem o) {
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java 2008-04-05 20:36:45 UTC (rev 360)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java 2008-04-05 20:37:02 UTC (rev 361)
@@ -17,7 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSException;
import java.util.Date;
import java.util.concurrent.BlockingQueue;
@@ -31,12 +31,8 @@
/** queue */
protected BlockingQueue<VCSActionManager.QueueItem> queue;
- /** handler to use for vcs operations */
- protected VCSHandler handler;
-
- public VCSActionThread(VCSHandler handler, BlockingQueue<VCSActionManager.QueueItem> queue) {
- super("VCSAction Thread [" + handler + "]");
- this.handler = handler;
+ public VCSActionThread(BlockingQueue<VCSActionManager.QueueItem> queue) {
+ super("VCSActionThread");
this.queue = queue;
}
@@ -47,8 +43,6 @@
VCSActionManager.QueueItem item = null;
try {
while (run) {
- // item qui sert a faire la simulation courante
-
log.info("waiting for action...");
item = queue.take();
if (item.getAction() == null) {
@@ -67,8 +61,9 @@
log.info("Stop " + getName() + " at " + new Date());
}
- protected void doAction(VCSActionManager.QueueItem item) {
- log.info("Just take " + item);
+ protected void doAction(VCSActionManager.QueueItem item) throws VCSException {
+ log.info(item);
+ //TODO
switch (item.getAction()) {
case ADD:
break;
@@ -93,5 +88,4 @@
}
}
-
}
1
0
r360 - trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:36:45 +0000 (Sat, 05 Apr 2008)
New Revision: 360
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties
trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties 2008-04-05 20:36:34 UTC (rev 359)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties 2008-04-05 20:36:45 UTC (rev 360)
@@ -9,6 +9,9 @@
lutinvcs.action.revert=revert
lutinvcs.action.update=update
lutinvcs.error.checkout.dir=Can''t checkout dir {0}
+lutinvcs.location.all=All
+lutinvcs.location.local=Local
+lutinvcs.location.remote=Remote
lutinvcs.state.missing=missing
lutinvcs.state.modified=modified
lutinvcs.state.outofdate=out of date
Modified: trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties 2008-04-05 20:36:34 UTC (rev 359)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties 2008-04-05 20:36:45 UTC (rev 360)
@@ -9,6 +9,9 @@
lutinvcs.action.revert=Rollback
lutinvcs.action.update=Update
lutinvcs.error.checkout.dir=Ne peut pas uploader le fichier ''{0}''
+lutinvcs.location.all=All
+lutinvcs.location.local=Local
+lutinvcs.location.remote=Remote
lutinvcs.state.missing=non pr\u00E9sent
lutinvcs.state.modified=modifi\u00E9
lutinvcs.state.outofdate=obsol\u00E8te
1
0
r359 - in trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs: . util
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:36:34 +0000 (Sat, 05 Apr 2008)
New Revision: 359
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -24,7 +24,6 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Collection;
-import java.util.EnumSet;
import java.util.List;
/**
@@ -33,38 +32,32 @@
* @author chemit
*/
-public interface VCSHandler {
+public interface VCSHandler<C extends VCSConnexion> {
- /** @return the location to local working copy */
- File getLocalDatabasePath();
-
/**
* init working copy, says if it is the first we use it it, we will checkout
* the databaseDirectory directory
*
+ * @param connexion vcs connexion to use
* @throws VCSException if any exception while init
*/
- void initWorkingCopy() throws VCSException;
+ void initWorkingCopy(C connexion) throws VCSException;
- /** delete the local working copy with all his files */
- void deleteWorkingCopy();
+ /**
+ * delete the local working copy with all his files
+ *
+ * @param connexion vcs connexion to use
+ */
+ void deleteWorkingCopy(C connexion);
- /** @return the complete remote url to acces repository */
- String getRemoteUrl();
-
- /** @return the config used by this handler */
- VCSConfig getConfig();
-
/**
- * @return a
- * <code>FilenameFilter<code> to detect all files and directories in a vcs working copy that
+ * @return a <code>FilenameFilter<code> to detect all files and directories in a vcs working copy that
* must be handled by vcs
*/
FilenameFilter getVersionnableFilenameFilter();
/**
- * @return a
- * <code>FileFilter<code> to detect all files and directories in a vcs working copy that
+ * @return a <code>FileFilter<code> to detect all files and directories in a vcs working copy that
* must be handled by vcs
*/
FileFilter getVersionnableFileFilter();
@@ -82,174 +75,190 @@
*/
String getConfLocalEntriesFilename();
- VCSState getState(File fileState, Collection tmp) throws VCSException;
+ VCSState getState(C connexion, File file, Collection tmp) throws VCSException;
- VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException;
+ VCSState getState(C connexion, File file, Collection tmp, boolean noremote) throws VCSException;
/**
- * @param file file to test
+ * @param connexion vcs connexion to use
+ * @param file file to test
* @return <code>true</code> if <code>file</code> is on remote
* repository, <code>false</code> otherwise.
*/
- boolean isOnRemote(File file);
+ boolean isOnRemote(C connexion, File file);
/**
- * @param file file to test
+ * @param connexion vcs connexion to use
+ * @param file file to test
* @return <code>true</code> if file is uptodate,<code>false</code>
* otherwise.
* @throws VCSException if any exception while operation
*/
- boolean isUpToDate(File file) throws VCSException;
+ boolean isUpToDate(C connexion, File file) throws VCSException;
/**
- * @param file file to test
+ * @param connexion vcs connexion to use
+ * @param file file to test
* @return <code>true</code> if file is handled by VCS,<code>false</code>
* otherwise.
*/
- boolean isVersionnableFile(File file);
+ boolean isVersionnableFile(C connexion, File file);
/**
* add on remote repository somes directories
*
+ * @param connexion vcs connexion to use
* @param commitMessage commit message
* @param dirNames names of the directories to create on remote repository (could
* used multi-level directories)
* @throws VCSException if any exception while operation
*/
- void makeRemoteDir(String commitMessage, String... dirNames)
+ void makeRemoteDir(C connexion, String commitMessage, String... dirNames)
throws VCSException;
/**
* delete on remote repository somes directories
*
+ * @param connexion vcs connexion to use
* @param commitMessage commit message
* @param dirNames names of the directories to delete on remote repository (could
* used multi-level directories)
* @throws VCSException if any exception while operation
*/
- void deleteRemoteDir(String commitMessage, String... dirNames)
+ void deleteRemoteDir(C connexion, String commitMessage, String... dirNames)
throws VCSException;
/**
* add a list of files into repository
*
- * @param files files to add
- * @param msg message for VCS commit, if <code>null</code> then no commit
- * is performed
+ * @param connexion vcs connexion to use
+ * @param files files to add
+ * @param msg message for VCS commit, if <code>null</code> then no commit
+ * is performed
* @return revision of the operation
* @throws VCSException if any exception while operation
*/
- long add(List<File> files, String msg) throws VCSException;
+ long add(C connexion, List<File> files, String msg) throws VCSException;
// void add(File file, String msg) throws VCSException;
/**
* delete a list of files from repository
*
- * @param files files to delete
- * @param msg message for VCS commit, if <code>null</code> then no commit
- * is performed
+ * @param connexion vcs connexion to use
+ * @param files files to delete
+ * @param msg message for VCS commit, if <code>null</code> then no commit
+ * is performed
* @throws VCSException if any exception while operation
*/
- void delete(List<File> files, String msg) throws VCSException;
+ void delete(C connexion, List<File> files, String msg) throws VCSException;
/**
* revert a list of files from repository
*
- * @param files files to revert
+ * @param connexion vcs connexion to use
+ * @param files files to revert
* @throws VCSException if any exception while operation
*/
- void revert(List<File> files) throws VCSException;
+ void revert(C connexion, List<File> files) throws VCSException;
/**
* commit a list of files into repository
*
- * @param files files to commit
- * @param msg message for VCS commit
+ * @param connexion vcs connexion to use
+ * @param files files to commit
+ * @param msg message for VCS commit
* @return revision of the operation
* @throws VCSException if any exception while operation
*/
- long commit(List<File> files, String msg) throws VCSException;
+ long commit(C connexion, List<File> files, String msg) throws VCSException;
/**
* update a file to repository to a certain revision
*
- * @param file file to update
- * @param revision object representing a revision for the current VCS
+ * @param connexion vcs connexion to use
+ * @param file file to update
+ * @param revision object representing a revision for the current VCS
* @throws VCSException if any exception while operation
*/
- void update(File file, Object revision) throws VCSException;
+ void update(C connexion, File file, Object revision) throws VCSException;
/**
* update a file to repository
*
- * @param file file to update
+ * @param connexion vcs connexion to use
+ * @param file file to update
* @throws VCSException if any exception while operation
*/
- void update(File file) throws VCSException;
+ void update(C connexion, File file) throws VCSException;
/**
* checkout a module from repository to a local file
*
- * @param destDir local file where to checkout
- * @param module module's name to checkout
- * @param recurse flag to say to recurse checkout or not.
+ * @param connexion vcs connexion to use
+ * @param destDir local file where to checkout
+ * @param module module's name to checkout
+ * @param recurse flag to say to recurse checkout or not.
* @throws VCSException if any exception while operation
*/
- void checkout(File destDir, String module, boolean recurse)
- throws VCSException;
+ void checkout(C connexion, File destDir, String module, boolean recurse) throws VCSException;
- void checkoutFile(File destDir, String module) throws VCSException;
+ void checkoutFile(C connexion, File destDir, String module) throws VCSException;
- long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException;
+ long checkoutOnlyTheDirectory(C connexion, File root, Object revision) throws VCSException;
/**
* TODO This is not the good place : VCS != Storage
*
+ * @param connexion vcs connexion to use
* @param directory directory to treate
* @return TODO
* @throws VCSException TODO
*/
- List<String> getRemoteStorageNames(File directory) throws VCSException;
+ List<String> getRemoteStorageNames(C connexion, File directory) throws VCSException;
/**
* TODO This is not the good place : VCS != Storage
*
+ * @param connexion vcs connexion to use
* @param directory directory to treate
* @return TODO
*/
- List<String> getLocalStorageNames(File directory);
+ List<String> getLocalStorageNames(C connexion, File directory);
/**
- * @param f local file to treate
+ * @param connexion vcs connexion to use
+ * @param f local file to treate
* @return current local revision of a file
* @throws VCSException TODO
*/
- Object getRevision(File f) throws VCSException;
+ Object getRevision(C connexion, File f) throws VCSException;
/**
* Obtain the list of log entries for the file
*
+ * @param connexion vcs connexion to use
* @param startRevision TODO
* @param endRevision TODO
* @param file file to treate
* @return list of log entries for this file between two revisions
* @throws VCSException if any exception while grabbing infos
*/
- List getLog(Object startRevision, Object endRevision, File file)
+ List getLog(C connexion, Object startRevision, Object endRevision, File file)
throws VCSException;
/**
* obtain the content of a file for a specific revision
*
- * @param file file to obtain
- * @param revision revision treated
+ * @param connexion vcs connexion to use
+ * @param file file to obtain
+ * @param revision revision treated
* @return the content of the file on repository for the specific revision
* passed as arguement.
* @throws VCSException if any exception while operation
* @throws java.io.IOException TODO
*/
- String getFileContent(File file, Object revision) throws VCSException, IOException;
+ String getFileContent(C connexion, File file, Object revision) throws VCSException, IOException;
/**
* Build the changelog for <code>file</code> from current revision of this
@@ -263,19 +272,21 @@
* <li>commit message</li>
* </ul>
*
- * @param file file to treate
+ * @param connexion vcs connexion to use
+ * @param file file to treate
* @return a string representation of change log for the local file to the
* head ?
* @throws VCSException if any exception while building changelog
*/
- String getChangeLog(File file) throws VCSException;
+ String getChangeLog(C connexion, File file) throws VCSException;
/**
* Generate in the ouputstream the diff between the current revision of the
* local file against headest revision on repository. <br>
* If file is uptodate, then does nothing.
*
- * @param file the file to treate
+ * @param connexion vcs connexion to use
+ * @param file the file to treate
* @return the diff
* @throws VCSException inf any exception while building diff, such as :
* <ul>
@@ -286,7 +297,7 @@
* </ul>
* @throws java.io.IOException if io problem with streams
*/
- String getDiff(File file) throws VCSException, IOException;
+ String getDiff(C connexion, File file) throws VCSException, IOException;
/**
* Generate in the ouputstream the diff between the current revision of the
@@ -294,6 +305,7 @@
* repository. <br>
* If file is uptodate, then does nothing.
*
+ * @param connexion vcs connexion to use
* @param file the file to treate
* @param againstRevision the against revision to use
* @return the diff
@@ -306,28 +318,9 @@
* </ul>
* @throws java.io.IOException if problem with streams
*/
- String getDiff(File file, Object againstRevision) throws VCSException, IOException;
+ String getDiff(C connexion, File file, Object againstRevision) throws VCSException, IOException;
- /**
- * test if connection is ok
- *
- * @throws VCSException if any problem
- */
- void testConnection() throws VCSException;
- boolean hasProtocoleChanged() throws VCSException;
+ boolean hasProtocoleChanged(C connexion) throws VCSException;
- void addVCSHandlerEventListener(VCSHandlerEventListener l);
-
- void removeVCSHandlerEventListener(VCSHandlerEventListener l);
-
- void open();
-
- void close();
-
- EnumSet<VCSAction> getAuthorizedActions();
-
- public boolean isConnected();
-
- public boolean hasWriteAccess();
}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -14,8 +14,6 @@
*/
package org.codelutin.vcs;
-import java.util.List;
-
/**
* The contract to be realized to provide vcs communication.
* <p/>
@@ -25,36 +23,30 @@
* @see VCSHandler
* @see VCSConnexion
*/
-public interface VCSProvider<H extends VCSHandler, C extends VCSConnexion> {
+public interface VCSProvider<C extends VCSConnexion, H extends VCSHandler<C>> {
/** @return the identifier of the vcs provider (eg SVN, CVS, MOCK) */
String getName();
- /** @return list of known connexions. */
- List<C> getConnexions();
-
/**
* return a new VCSHandler instance for given config.
*
* @return the cached instance of handler
- * @throws IllegalStateException if handler was not init via {@link #newInstance(VCSConfig)}
+ * @throws IllegalStateException if provider was not init via {@link #init()}
*/
H getHandler() throws IllegalStateException;
- /**
- * return a new VCSHandler instance for given config.
- *
- * @param config svn handler config
- * @return the new instance
- * @throws IllegalStateException if any pb while init handler
- */
- H newInstance(VCSConfig config) throws IllegalStateException;
+ /** init the provider */
+ void init();
/**
+ * Instanciate an new connexion for a given config, and init it.
+ *
* @param mode the mode required
* @param config the config to be used
* @return the new connexion initializd <b>but not opened</b>.
+ * @throws IllegalStateException if provider was not init via {@link #init()}
*/
- C newConnection(VCSConnexionMode mode, VCSConfig config);
+ C newConnection(VCSConnexionMode mode, VCSConnexionConfig config) throws IllegalStateException;
}
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -14,29 +14,62 @@
*/
package org.codelutin.vcs.util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ListenerSet;
import org.codelutin.vcs.ConnectionState;
+import org.codelutin.vcs.VCSAction;
import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSConnexionEvent;
+import org.codelutin.vcs.VCSConnexionEvent.Type;
+import org.codelutin.vcs.VCSConnexionEventListener;
import org.codelutin.vcs.VCSConnexionMode;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSProvider;
+import org.codelutin.vcs.VCSState;
import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
import java.net.URI;
-import java.util.Map;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
/** @author chemit */
public abstract class AbstractVCSConnexion implements VCSConnexion {
- public static final String OPTION_LOGIN = "login";
- public static final String OPTION_PASSWORD = "password";
- public static final String OPTION_PASSPHRASE = "passphrase";
- public static final String OPTION_KEY_FILE = "keyfile";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static protected final Log log = LogFactory.getLog(AbstractVCSConnexion.class);
protected File localRoot;
protected URI remoteRoot;
protected VCSConnexionMode mode;
protected ConnectionState state;
- protected Map<String, String> options;
+ protected VCSConnexionConfig config;
+ protected VCSProvider<AbstractVCSConnexion, ?> provider;
+
+ protected ListenerSet<VCSConnexionEventListener> listeners = new ListenerSet<VCSConnexionEventListener>();
+
+ @SuppressWarnings({"unchecked"})
+ protected AbstractVCSConnexion(VCSConnexionMode mode, VCSProvider provider) {
+ this.mode = mode;
+ this.provider = provider;
+ }
+
+ public VCSHandler<AbstractVCSConnexion> getHandler() throws IllegalStateException {
+ return getProvider().getHandler();
+ }
+
+ public VCSProvider<AbstractVCSConnexion, ?> getProvider() {
+ return provider;
+ }
+
public File getWorkingCopy() throws IllegalStateException {
checkInit();
return localRoot;
@@ -52,9 +85,8 @@
return mode;
}
- public Map<String, String> getOptions() throws IllegalStateException {
- checkInit();
- return options;
+ public VCSConnexionConfig getConfig() throws IllegalStateException {
+ return config;
}
public boolean isOpen() throws IllegalStateException {
@@ -72,6 +104,180 @@
return state == ConnectionState.ERROR;
}
+ public void addVCSConnexionEventListener(VCSConnexionEventListener l) {
+ listeners.add(l);
+ }
+
+ public void removeVCSConnexionEventListener(VCSConnexionEventListener l) {
+ listeners.remove(l);
+ }
+
+ public void initWorkingCopy() throws VCSException {
+ getHandler().initWorkingCopy(this);
+ }
+
+ public void deleteWorkingCopy() {
+ getHandler().deleteWorkingCopy(this);
+ }
+
+ public FilenameFilter getVersionnableFilenameFilter() {
+ return getHandler().getVersionnableFilenameFilter();
+ }
+
+ public FileFilter getVersionnableFileFilter() {
+ return getHandler().getVersionnableFileFilter();
+ }
+
+ public String getConfLocalDirname() {
+ return getHandler().getConfLocalDirname();
+ }
+
+ public String getConfLocalEntriesFilename() {
+ return getHandler().getConfLocalEntriesFilename();
+ }
+
+ public VCSState getState(File fileState, Collection tmp) throws VCSException {
+ return getHandler().getState(this, fileState, tmp);
+ }
+
+ public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
+ return getHandler().getState(this, file, tmp, noremote);
+ }
+
+ public boolean isOnRemote(File file) {
+ return getHandler().isOnRemote(this, file);
+ }
+
+ public boolean isUpToDate(File file) throws VCSException {
+ return getHandler().isUpToDate(this, file);
+ }
+
+ public boolean isVersionnableFile(File file) {
+ return getHandler().isVersionnableFile(this, file);
+ }
+
+ public void makeRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ getHandler().makeRemoteDir(this, commitMessage, dirNames);
+ }
+
+ public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ getHandler().deleteRemoteDir(this, commitMessage, dirNames);
+ }
+
+ public long add(List<File> files, String msg) throws VCSException {
+ return getHandler().add(this, files, msg);
+ }
+
+ public void delete(List<File> files, String msg) throws VCSException {
+ getHandler().delete(this, files, msg);
+ }
+
+ public void revert(List<File> files) throws VCSException {
+ getHandler().revert(this, files);
+ }
+
+ public long commit(List<File> files, String msg) throws VCSException {
+ return getHandler().commit(this, files, msg);
+ }
+
+ public void update(File file, Object revision) throws VCSException {
+ getHandler().update(this, file, revision);
+ }
+
+ public void update(File file) throws VCSException {
+ getHandler().update(this, file);
+ }
+
+ public void checkout(File destDir, String module, boolean recurse) throws VCSException {
+ getHandler().checkout(this, destDir, module, recurse);
+ }
+
+ public void checkoutFile(File destDir, String module) throws VCSException {
+ getHandler().checkoutFile(this, destDir, module);
+ }
+
+ public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
+ return getHandler().checkoutOnlyTheDirectory(this, root, revision);
+ }
+
+ public List<String> getRemoteStorageNames(File directory) throws VCSException {
+ return getHandler().getRemoteStorageNames(this, directory);
+ }
+
+ public List<String> getLocalStorageNames(File directory) {
+ return getHandler().getLocalStorageNames(this, directory);
+ }
+
+ public Object getRevision(File f) throws VCSException {
+ return getHandler().getRevision(this, f);
+ }
+
+ public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
+ return getHandler().getLog(this, startRevision, endRevision, file);
+ }
+
+ public String getFileContent(File file, Object revision) throws VCSException, IOException {
+ return getHandler().getFileContent(this, file, revision);
+ }
+
+ public String getChangeLog(File file) throws VCSException {
+ return getHandler().getChangeLog(this, file);
+ }
+
+ public String getDiff(File file) throws VCSException, IOException {
+ return getHandler().getDiff(this, file);
+ }
+
+ public String getDiff(File file, Object againstRevision) throws VCSException, IOException {
+ return getHandler().getDiff(this, file, againstRevision);
+ }
+
+ public boolean hasProtocoleChanged() throws VCSException {
+ return getHandler().hasProtocoleChanged(this);
+ }
+
+ /**
+ * Obtain the set of permitted vcs actions.
+ *
+ * @return the EnumSet of authorized action according to current vcs config
+ */
+ public EnumSet<VCSAction> getAuthorizedActions() {
+ boolean canWrite = hasWriteAccess();
+ EnumSet<VCSAction> result = EnumSet.noneOf(VCSAction.class);
+ for (VCSAction vcsAction : VCSAction.values()) {
+ if (!vcsAction.isWrite() || canWrite) {
+ result.add(vcsAction);
+ }
+ }
+ return result;
+ }
+
+ public boolean hasWriteAccess() {
+ return !getConfig().isUseSshConnexion() && getMode() != VCSConnexionMode.ANONYMOUS;
+ }
+
+ public void addVCSHandlerEventListener(VCSConnexionEventListener l) {
+ listeners.add(l);
+ }
+
+ public void removeVCSHandlerEventListener(VCSConnexionEventListener l) {
+ listeners.remove(l);
+ }
+
+ protected void fireOpen() {
+ VCSConnexionEvent e = new VCSConnexionEvent(this, Type.OPEN);
+ for (VCSConnexionEventListener l : listeners) {
+ l.open(e);
+ }
+ }
+
+ protected void fireClose() {
+ VCSConnexionEvent e = new VCSConnexionEvent(this, Type.CLOSE);
+ for (VCSConnexionEventListener l : listeners) {
+ l.close(e);
+ }
+ }
+
protected void checkInit() throws IllegalStateException {
if (state == null) {
throw new IllegalStateException("connexion was not init");
@@ -85,4 +291,5 @@
}
}
+
}
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -21,15 +21,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
import org.codelutin.util.FileUtil;
-import org.codelutin.util.ListenerSet;
-import org.codelutin.vcs.VCSHandlerEvent.Type;
+import org.codelutin.vcs.VCSConnexion;
import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSHandlerEventListener;
-import org.codelutin.vcs.VCSHandlerEvent;
import org.codelutin.vcs.VCSRuntimeException;
-import org.codelutin.vcs.VCSAction;
+import org.codelutin.vcs.VCSTypeRepo;
import java.io.File;
import java.io.FileFilter;
@@ -37,14 +34,13 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.EnumSet;
/**
* abstract VCSHandler base with usefull methods that does not need vcs specific code.
*
* @author chemit
*/
-public abstract class AbstractVCSHandler implements VCSHandler {
+public abstract class AbstractVCSHandler<C extends VCSConnexion> implements VCSHandler<C> {
/** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(AbstractVCSHandler.class);
@@ -58,13 +54,13 @@
protected final FileFilter versionnableFileFilter;
protected final String confLocalDirName;
protected final String confLocalEntriesFilename;
+ public static final String LOCAL_SEP = File.separator;
+ public static final String LOCAL_SEP_PATTERN = "\\".equals(LOCAL_SEP) ?
+ LOCAL_SEP + LOCAL_SEP : LOCAL_SEP;
+ public static final String REMOTE_SEP = "/";
+ public static final String REMOTE_SEP_PATTERN = "/";
- protected final VCSConfig config;
-
- protected ListenerSet<VCSHandlerEventListener> listeners = new ListenerSet<VCSHandlerEventListener>();
-
- protected AbstractVCSHandler(VCSConfig config, final String vCSConfLocalDirName, String vCSConfLocalEntriesFilename) {
- this.config = config;
+ protected AbstractVCSHandler(final String vCSConfLocalDirName, String vCSConfLocalEntriesFilename) {
this.confLocalDirName = vCSConfLocalDirName;
this.confLocalEntriesFilename = vCSConfLocalEntriesFilename;
this.versionnableFilenameFilter = new FilenameFilter() {
@@ -77,24 +73,8 @@
return dir.isFile() || (!vCSConfLocalDirName.equals(dir.getName()) && !"CVS".equals(dir.getName()));
}
};
- fireInit();
}
- public VCSConfig getConfig() {
- return config;
- }
-
- public File getLocalDatabasePath() {
- return config.getLocalDatabasePath();
- }
-
- public void deleteWorkingCopy() {
- if (getLocalDatabasePath().exists()) {
- FileUtil.deleteRecursively(getLocalDatabasePath());
- getLocalDatabasePath().delete();
- }
- }
-
public FilenameFilter getVersionnableFilenameFilter() {
return versionnableFilenameFilter;
}
@@ -111,12 +91,19 @@
return confLocalEntriesFilename;
}
- public boolean isVersionnableFile(File file) {
+ public boolean isVersionnableFile(C connexion, File file) {
assertFileExists(file, "file is empty or non existant");
return !confLocalDirName.equalsIgnoreCase(file.getName());
}
- public List<String> getLocalStorageNames(File directory) {
+ public void deleteWorkingCopy(C connexion) {
+ if (connexion.getConfig().getLocalDatabasePath().exists()) {
+ FileUtil.deleteRecursively(connexion.getConfig().getLocalDatabasePath());
+ connexion.getConfig().getLocalDatabasePath().delete();
+ }
+ }
+
+ public List<String> getLocalStorageNames(C connexion, File directory) {
List<String> result = new ArrayList<String>();
if (directory.exists()) {
getFiles0(directory, result, "");
@@ -125,49 +112,24 @@
return result;
}
- public void addVCSHandlerEventListener(VCSHandlerEventListener l) {
- listeners.add(l);
- }
-
- public void removeVCSHandlerEventListener(VCSHandlerEventListener l) {
- listeners.remove(l);
- }
-
- public void open() {
- fireOpen();
- }
-
- public void close() {
- fireClose();
- }
-
- protected void fireInit() {
- VCSHandlerEvent e = new VCSHandlerEvent(this, Type.INIT);
- for (VCSHandlerEventListener l : listeners) {
- l.init(e);
+ public void doCheckoutDir(C connexion, File... dirs) {
+ for (File dir : dirs) {
+ try {
+ if (!dir.exists() || !isFileInWorkingCopy(dir, this, connexion, true)) {
+ checkoutOnlyTheDirectory(connexion, dir, null);
+ }
+ } catch (Exception eee) {
+ log.warn(_("lutinvcs.error.checkout.dir", dir), eee);
+ break;
+ }
}
}
- protected void fireOpen() {
- VCSHandlerEvent e = new VCSHandlerEvent(this, Type.OPEN);
- for (VCSHandlerEventListener l : listeners) {
- l.open(e);
- }
+ protected void assertFileExists(File file, String msg) {
+ if (file == null || !file.exists())
+ throw new VCSRuntimeException(msg + " (file passed : [" + file + "])");
}
- protected void fireClose() {
- VCSHandlerEvent e = new VCSHandlerEvent(this, Type.CLOSE);
- for (VCSHandlerEventListener l : listeners) {
- l.close(e);
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- close();
- }
-
protected void getFiles0(File directory, List<String> result, String prefix) {
//TODO put the hardcored value in a property!!!
if (directory.getName().equals("data")) return;
@@ -183,32 +145,132 @@
}
}
- protected void assertFileExists(File file, String msg) {
- if (file == null || !file.exists())
- throw new VCSRuntimeException(msg + " (file passed : [" + file + "])");
+ public static boolean isFileInWorkingCopy(File parent, String name, VCSHandler handler, VCSConnexion connexion, boolean underVCS) {
+ if (parent == null || name == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInWorkingCopy can not be invoked with some null parameter but was. [" + parent + "," + name + "," +
+ handler + "]");
+ return isFileInWorkingCopy(new File(parent, name), handler, connexion, underVCS);
}
+ public static boolean isFileInWorkingCopy(File file, VCSHandler handler, VCSConnexion connexion, boolean underVCS) {
+ if (file == null || handler == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInWorkingCopy can not be invoked with some null parameter but was. [" + file + "," + handler + "]");
+ String rootPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath();
+ String localPath = file.getAbsolutePath();
+ if (localPath.startsWith(rootPath) && !underVCS) {
+ return true;
+ }
+ final File realDir = file.isDirectory() ? file : file.getParentFile();
+ return isFileInCheckedDir(realDir, handler);
+ }
+
+ public static boolean isFileInCheckedDir(File file, VCSHandler handler) {
+ if (file == null || handler == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInCheckedDir can not be invoked with some null parameter but was. [" + file + "," + handler + "]");
+ final File realDir = file.isDirectory() ? file : file.getParentFile();
+ return (new File(realDir, handler.getConfLocalDirname()).exists());
+
+ }
+
+ public static void assertFileInWC(File file, VCSHandler handler, VCSConnexion connexion) {
+ if (!isFileInWorkingCopy(file, handler, connexion, false))
+ throw new VCSRuntimeException("the file [" + file + "] is not in the working copy [" + connexion.getConfig().getLocalDatabasePath() + "]");
+ }
+
+ public static String getRemoteRelativePath(File f, VCSHandler handler, VCSConnexion connexion) {
+ if (!isFileInWorkingCopy(f, handler, connexion, false)) return null;
+ //System.out.println("file on vcs working copy : "+f);
+ String rootPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath();
+ String localPath = f.getAbsolutePath();
+ if (!localPath.startsWith(rootPath)) return null;
+ localPath = localPath.substring(rootPath.length() + 1);
+ return convertToRemoteName(localPath);
+ }
+
+ public static String getLocalRelativePath(String remoteRelativePath, VCSHandler handler, VCSConnexion connexion) {
+ String localPath = convertToLocalName(remoteRelativePath);
+ final File file = new File(connexion.getConfig().getLocalDatabasePath(), localPath);
+ if (!isFileInWorkingCopy(file, handler, connexion, false)) return null;
+ return localPath;
+ }
+
+ public static String convertToRemoteName(String txt) {
+ return txt.replaceAll(LOCAL_SEP_PATTERN, REMOTE_SEP);
+ }
+
+ public static String convertToLocalName(String txt) {
+ return txt.replaceAll(REMOTE_SEP_PATTERN, LOCAL_SEP);
+ }
+
/**
- * Obtain the set of permitted vcs actions.
- *
- * @return the EnumSet of authorized action according to current vcs config
+ * @param typeRepo the type of repo to used
+ * @param remotePath the unclean remote path to use
+ * @return the remote path from the old one according to given type repo
*/
- public EnumSet<VCSAction> getAuthorizedActions() {
- boolean canWrite = hasWriteAccess();
- EnumSet<VCSAction> result = EnumSet.noneOf(VCSAction.class);
- for (VCSAction vcsAction : VCSAction.values()) {
- if (!vcsAction.isWrite() || canWrite) {
- result.add(vcsAction);
- }
+ public static String getRemotePath(VCSTypeRepo typeRepo, String remotePath) {
+ String result = cleanRemotePath(remotePath);
+ switch (typeRepo) {
+ case BRANCH:
+ case TAG:
+ result = remotePath + '/' + typeRepo.getPath();
+ break;
+ case HEAD:
+ result = remotePath;
+ break;
}
return result;
}
- public boolean isConnected() {
- return getConfig().isConnected();
+ /**
+ * @param typeRepo the type of repo to use
+ * @param version the version to use
+ * @return the remoteDatabase according to type of repo and version
+ */
+ public static String getRemoteDatabase(VCSTypeRepo typeRepo, String version) {
+ String result = null;
+ switch (typeRepo) {
+ case BRANCH:
+ case TAG:
+ result = version;
+ break;
+ case HEAD:
+ result = VCSTypeRepo.HEAD.getPath();
+ break;
+ }
+ return result;
}
- public boolean hasWriteAccess() {
- return !getConfig().isReadOnly();
+ /**
+ * to clean a remote path from typeRepo suffix.
+ * <p/>
+ * For example, having a url svn://XXX/trunk then remove /trunk.
+ * <p/>
+ * Or if having svn://XXX/branches/YYY then remove /branches/YYY
+ * Or if having svn://XXX/tags/YYY then remove /tags/YYY
+ *
+ * @param remotePath the remote path to clean
+ * @return the cleaned remote path
+ */
+ public static String cleanRemotePath(String remotePath) {
+ int pos = remotePath.indexOf(VCSTypeRepo.BRANCH.getPath());
+ if (pos > -1) {
+ // found a branch
+ remotePath = remotePath.substring(0, pos - 1);
+ } else {
+ pos = remotePath.indexOf(VCSTypeRepo.HEAD.getPath());
+ if (pos > -1) {
+ // found a branch
+ remotePath = remotePath.substring(0, pos - 1);
+ } else {
+ pos = remotePath.indexOf(VCSTypeRepo.TAG.getPath());
+ if (pos > -1) {
+ // found a tag
+ remotePath = remotePath.substring(0, pos - 1);
+ } else {
+ // remote path was clean
+ }
+ }
+ }
+ return remotePath;
}
}
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -14,70 +14,76 @@
*/
package org.codelutin.vcs.util;
-import org.codelutin.vcs.VCSConfig;
import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSConnexionMode;
import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.VCSProvider;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
/**
* base implementation of provider with a cached handler and list of connexions
*
* @author chemit
*/
-public abstract class AbstractVCSProvider<H extends VCSHandler, C extends VCSConnexion> implements VCSProvider<H, C> {
+public abstract class AbstractVCSProvider<C extends VCSConnexion, H extends VCSHandler<C>> implements VCSProvider<C, H> {
protected H handler;
- protected List<C> connexions;
-
protected final String name;
private final Class<H> handlerImpl;
+ private final Class<C> connexionImpl;
- protected AbstractVCSProvider(String name, Class<H> handlerImpl) {
+ protected AbstractVCSProvider(String name, Class<H> handlerImpl, Class<C> connexionImpl) {
this.name = name;
this.handlerImpl = handlerImpl;
+ this.connexionImpl = connexionImpl;
}
public final String getName() {
return name;
}
- public List<C> getConnexions() {
- if (connexions == null) {
- connexions = new java.util.ArrayList<C>();
- }
- return connexions;
- }
-
public H getHandler() throws IllegalStateException {
checkHandlerInit();
return handler;
}
- public H newInstance(VCSConfig config) throws IllegalStateException {
- if (handler != null) {
- return handler;
- }
+ public C newConnection(VCSConnexionMode mode, VCSConnexionConfig config) throws IllegalStateException {
+ checkHandlerInit();
try {
- return handlerImpl.getConstructor(VCSConfig.class).newInstance(config);
+ C connexion = connexionImpl.getConstructor(VCSConnexionMode.class, getClass()).newInstance(mode, this);
+ connexion.init(config);
+ return connexion;
} catch (InstantiationException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
} catch (IllegalAccessException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
} catch (InvocationTargetException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
} catch (NoSuchMethodException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
}
}
+ public void init() {
+ if (handler == null) {
+ try {
+ handler = handlerImpl.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ }
+ }
+ }
+
protected void checkHandlerInit() throws IllegalStateException {
if (handler == null) {
throw new IllegalStateException("handler was not init in " + this);
}
}
+
}
1
0
r358 - trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:36:07 +0000 (Sat, 05 Apr 2008)
New Revision: 358
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java
Log:
use VCSEntryLocation as property to VCSState
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java 2008-04-05 20:35:25 UTC (rev 357)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java 2008-04-05 20:36:07 UTC (rev 358)
@@ -30,7 +30,7 @@
* <br/>
* The only action for this state is to delete the file, nothing else.
*/
- UP_TO_DATE("uptodate", n_("lutinvcs.state.uptodate"), false, false, DELETE),
+ UP_TO_DATE("uptodate", n_("lutinvcs.state.uptodate"), VCSEntryLocation.ALL, DELETE),
/**
* when a local file matches a remote copy but not the latest one.
@@ -42,8 +42,7 @@
* <li>{@link VCSAction#CHANGELOG}</li>
* </ul>
*/
- OUT_OF_DATE("outofdate", n_("lutinvcs.state.outofdate"), false, true,
- UPDATE, DIFF, CHANGELOG),
+ OUT_OF_DATE("outofdate", n_("lutinvcs.state.outofdate"), VCSEntryLocation.REMOTE, UPDATE, DIFF, CHANGELOG),
/**
* when a local file does not matches his remote latest copy, but is based
@@ -56,8 +55,7 @@
* <li>{@link VCSAction#DIFF}</li>
* </ul>
*/
- MODIFIED("modified", n_("lutinvcs.state.modified"), true, false,
- COMMIT, OVERWRITE_AND_UPDATE, REVERT, DIFF),
+ MODIFIED("modified", n_("lutinvcs.state.modified"), VCSEntryLocation.LOCAL, COMMIT, OVERWRITE_AND_UPDATE, REVERT, DIFF),
/**
* when a local file does not match the working version remote copy and
@@ -71,9 +69,7 @@
* <li>{@link VCSAction#CHANGELOG}</li>
* </ul>
*/
- OUT_OF_DATE_AND_MODIFIED("outofdateAndModified",
- n_("lutinvcs.state.outofdateAndModified"), true, true,
- OVERWRITE_AND_UPDATE, REVERT, DIFF, CHANGELOG),
+ OUT_OF_DATE_AND_MODIFIED("outofdateAndModified", n_("lutinvcs.state.outofdateAndModified"), VCSEntryLocation.ALL, OVERWRITE_AND_UPDATE, REVERT, DIFF, CHANGELOG),
/**
* when a local file does not exist on remote repository.
@@ -82,7 +78,7 @@
* <li>{@link VCSAction#ADD}</li>
* </ul>
*/
- UNVERSIONNED("unversionned", n_("lutinvcs.state.unversionned"), true, false, ADD, REVERT),
+ UNVERSIONNED("unversionned", n_("lutinvcs.state.unversionned"), VCSEntryLocation.LOCAL, ADD, REVERT),
/**
* when a file exists on remote repository but not locally.
@@ -91,7 +87,7 @@
* <li>{@link VCSAction#UPDATE}</li>
* </ul>
*/
- MISSING("missing", n_("lutinvcs.state.missing"), false, true, UPDATE),
+ MISSING("missing", n_("lutinvcs.state.missing"), VCSEntryLocation.REMOTE, UPDATE),
/**
* when a file is unversionned or missing : this special and durty state
@@ -107,35 +103,34 @@
* <p/>
* </ul>
*/
- UNVERSIONNED_OR_MISSING("unversionnedOrMissing",
- n_("lutinvcs.state.unversionnedOrMissing"), true, true, ADD, UPDATE),
+ UNVERSIONNED_OR_MISSING("unversionnedOrMissing", n_("lutinvcs.state.unversionnedOrMissing"), VCSEntryLocation.LOCAL, ADD, UPDATE),
- REMOVED("removed", n_("lutinvcs.state.removed"), true, false, DELETE, REVERT),
+ REMOVED("removed", n_("lutinvcs.state.removed"), VCSEntryLocation.LOCAL, DELETE, REVERT),
/** to deal with other cases (...) */
- UNKNOWN("unknown", n_("lutinvcs.state.unknown"), true, false);
+ UNKNOWN("unknown", n_("lutinvcs.state.unknown"), null);
/** libelle to be used */
private final String libelle;
/** key of the state */
private final String key;
- /** flag to indicate if state is on a local file */
- private final boolean local;
- /** flag to indicate if state is on a remote file */
- private final boolean remote;
+
/** VCSAction associated with this state */
private final List<VCSAction> actions;
- VCSState(String key, String libelle, boolean local, boolean remote, VCSAction... actions) {
+ /** location of the state */
+ private VCSEntryLocation location;
+
+ VCSState(String key, String libelle, VCSEntryLocation location, VCSAction... actions) {
+ this.location = location;
this.libelle = libelle;
List<VCSAction> actions1 = new ArrayList<VCSAction>(Arrays.asList(actions));
// refresh action is enabled for all states
actions1.add(VCSAction.REFRESH);
this.actions = Collections.unmodifiableList(actions1);
this.key = key;
- this.local = local;
- this.remote = remote;
+
}
public String libelle() {
@@ -150,12 +145,16 @@
return key;
}
+ public VCSEntryLocation getLocation() {
+ return location;
+ }
+
public boolean isLocal() {
- return local;
+ return location != VCSEntryLocation.REMOTE;
}
public boolean isRemote() {
- return remote;
+ return location != VCSEntryLocation.LOCAL;
}
public boolean authorizeAction(VCSAction... actions) {
1
0
r357 - in trunk/lutinvcs: lutinvcs-api/src/main/java/org/codelutin/vcs lutinvcs-core/src/main/java/org/codelutin/vcs lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:35:25 +0000 (Sat, 05 Apr 2008)
New Revision: 357
Removed:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSFileState.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSUIAction.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateImpl.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateManager.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java
Log:
delete old code
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSFileState.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSFileState.java 2008-04-05 20:33:02 UTC (rev 356)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSFileState.java 2008-04-05 20:35:25 UTC (rev 357)
@@ -1,60 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * This program is free software; you
- * can redistribute it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. This program is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
- */
-package org.codelutin.vcs;
-
-import java.io.File;
-import java.io.Serializable;
-
-/** @author chemit */
-public interface VCSFileState extends Serializable {
-
- boolean existLocally();
-
- String getLocalPath();
-
- String getModuleName();
-
- String getModuleRelativeFileName();
-
- String[] getFileNamePath();
-
- String getRemotePath();
-
- VCSState getState();
-
- long getTimestamp();
-
- File getFile();
-
- String getChangeLog();
-
- Long getRev();
-
- VCSAction getAction();
-
- void resetState();
-
- boolean wasSynch();
-
- boolean isLocallySynch();
-
- void doSynch(VCSHandler handler, long timestamp);
-
- void doSynch(VCSHandler handler, long timestamp, boolean ifFileChanged);
-
- void setChangeLog(String changeLog);
-
- void setAction(VCSAction action);
-}
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSUIAction.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSUIAction.java 2008-04-05 20:33:02 UTC (rev 356)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSUIAction.java 2008-04-05 20:35:25 UTC (rev 357)
@@ -1,23 +0,0 @@
-package org.codelutin.vcs;
-
-import javax.swing.JDialog;
-import java.util.List;
-
-/**
- * a VCSUIAction represents an action to realize on a file in working copy
- * or on remote repository with an possible ui interaction.
- * <p/>
- * This is the highest api level for vcs using
- * <p/>
- * The method {@link #doAction(JDialog, org.codelutin.vcs.VCSHandler , List)} fired the action
- * on a list of states
- */
-public interface VCSUIAction {
- /**
- * @param dialog the dialog where action was asked
- * @param handler vcshandler to use
- * @param states list of VCSFileState to treate
- * @throws VCSException if any exception while operation
- */
- void doAction(JDialog dialog, VCSHandler handler, List<VCSFileState> states) throws VCSException;
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateImpl.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateImpl.java 2008-04-05 20:33:02 UTC (rev 356)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateImpl.java 2008-04-05 20:35:25 UTC (rev 357)
@@ -1,268 +0,0 @@
-package org.codelutin.vcs;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.vcs.util.VCSHelper;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * This class represents the vcs state of a file in a working copy or on remote
- * repository.
- * <br/>
- * For a defined file in a working copy, we only use a instance of the
- * class, {@link VCSFileStateManager} is responsible of instanciate thoses
- * objects and store them in a cache.
- * <br/>
- * use method {@link #doSynch(VCSHandler,long)} to doSynch whatever
- * local file state.
- * use method {@link #doSynch(VCSHandler,long,boolean)} to doSynch only
- * if local file state changed (with true value)
- *
- * @see VCSState
- * @see VCSFileStateManager
- */
-public class VCSFileStateImpl implements VCSFileState, Serializable {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static protected final Log log = LogFactory.getLog(VCSFileStateImpl.class);
-
- /**
- * working copy file to deal with (could not exists in file only exists
- * on remote repository)
- */
- protected File file;
- /** a optional module name (if defined, will change getModuleRelativeFileName behavior) */
- protected String moduleName;
- /**
- * relative path on local file system (use File.separator) to root of local
- * working copy
- */
- protected String localPath;
- /**
- * relative path on remote repository (use '/' (should be Remote.separator)
- * to root of this repository
- */
- protected String remotePath;
- /** timestamp of last doSynch or -1 if no doSynch was previously done */
- protected long timestamp;
- /** state of the file */
- protected VCSState state;
- /**
- * index used to identify uniquely each instance (hashcode of
- * file.getAbsolutePath())
- */
- protected int key;
- /** revision of this file, or null if unversionned */
- protected Long rev;
- /** changeLog of the file */
- protected String changeLog;
- /** diff of the file */
- protected String diff;
- /** action to be programmed for this state */
- protected VCSAction action;
-
- private static final long serialVersionUID = -815443990862836772L;
-
- /**
- * protected access restriction : you should not instanciate directly
- * this class, but use {@link VCSFileStateManager} to do it.
- *
- * @param handler the vcs handler used with this working copy
- * @param file file to be handled
- */
- public VCSFileStateImpl(VCSHandler handler, File file) {
- this.file = file;
- this.key = file.getAbsolutePath().hashCode();
- String path = file.getAbsolutePath();
- String rootPath = handler.getLocalDatabasePath().getAbsolutePath();
-
- if (!path.startsWith(rootPath)) {
- throw new VCSRuntimeException("could not create a VCSFileState " +
- "for a file not in the root working copy registered in " +
- "vcsHandler, but was : [" + file + " ::" +
- handler.getLocalDatabasePath() + " ]");
- }
- if (file.equals(handler.getConfig().getLocalDatabasePath())) {
- this.localPath = "";
- } else {
-
- this.localPath = path.substring(rootPath.length() + 1);
- }
- // by default moduleName is the first dir of localpath (if any)
- int index = this.localPath.indexOf(File.separator);
- if (index == -1) {
- // this is a module directory
- this.moduleName = this.localPath;
- this.localPath = "";
- } else {
- this.moduleName = this.localPath.substring(0, index);
- }
-
- resetState();
- }
-
- public boolean existLocally() {
- return file.exists();
- }
-
- public String getLocalPath() {
- return localPath;
- }
-
- public String getModuleName() {
- return moduleName;
- }
-
- public String getModuleRelativeFileName() {
- return "".equals(moduleName) ? getLocalPath() :
- "".equals(localPath) ? "" : localPath.substring(moduleName.length() + 1);
- }
-
- public String[] getFileNamePath() {
- // TODO Should use File.separator
- return getModuleRelativeFileName().split(File.separator);
- }
-
- public String getRemotePath() {
- if (remotePath == null)
- remotePath = VCSHelper.convertToRemoteName(localPath);
- return remotePath;
- }
-
- public VCSState getState() {
- return state;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- public File getFile() {
- return file;
- }
-
- public String getChangeLog() {
- return changeLog;
- }
-
- public Long getRev() {
- return rev;
- }
-
- public VCSAction getAction() {
- return action;
- }
-
- /**
- * reset synch for this instance : after this invocation,
- * the method {@link #wasSynch()} will return <code>true</code> to means
- * that no synch info are available.
- */
- public void resetState() {
- state = null;
- timestamp = -1;
- }
-
- /**
- * @return <code>true</code> if there at least one invocation of
- * {@link #doSynch(VCSHandler,long)} or
- * {@link #doSynch(VCSHandler,long,boolean)}
- * was made and no invocation of {@link #resetState()}
- * was made after.
- */
- public boolean wasSynch() {
- return state != null && timestamp != -1;
- }
-
- /**
- * @return <code>true</code> if this instance <code>wasSynch</code> and
- * the file was not modified since last synch.
- */
- public boolean isLocallySynch() {
- return wasSynch() && timestamp <= file.lastModified();
- }
-
- /**
- * doSynch this instance with remote repository and put a new timestamp
- * the one passed as parameter.
- *
- * @param handler vcs handler to use
- * @param timestamp the new synch timestamp
- */
- public void doSynch(VCSHandler handler, long timestamp) {
- doSynch(handler, timestamp, false);
- }
-
- /**
- * doSynch this instance with remote repository and put a new timestamp
- * the one passed as parameter.
- * Do not doSynch if <code>ifFileChanged</code> is <code>true</code>
- * and file was not modify since last synch.
- *
- * @param handler vcs handler to use
- * @param timestamp the new synch timestamp
- * @param ifFileChanged if <code>true</code> will doSynch only if file
- * was locally modified after last doSynch
- */
- public void doSynch(VCSHandler handler, long timestamp,
- boolean ifFileChanged) {
- //TODO should deal with possibility of file existed but no more...
- boolean needSynch = !wasSynch() ||
- !ifFileChanged || timestamp <= file.lastModified();
-
- try {
- if (needSynch) {
- this.timestamp = timestamp;
- Collection tmp = new ArrayList();
- this.state = handler.getState(file, tmp);
- if (!tmp.isEmpty()) this.rev = (Long) tmp.iterator().next();
- log.info(" new synch " + this);
- }
- } catch (VCSException e) {
- log.warn("could not acquire state for " + this + " : " + e.getMessage());
- resetState();
- }
- }
-
- @Override
- public boolean equals(Object o) {
- return this == o || !(o == null || getClass() != o.getClass()) &&
- localPath.equals(((VCSFileStateImpl) o).localPath);
- }
-
- @Override
- public int hashCode() {
- return localPath.hashCode();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(localPath).append('(').append(key).append(')').
- append('|').append(state).append('|').append(timestamp);
- return sb.toString();
- }
-
- @Override
- public VCSFileStateImpl clone() throws CloneNotSupportedException {
- return (VCSFileStateImpl) super.clone();
- }
-
-
- public void setChangeLog(String changeLog) {
- this.changeLog = changeLog;
- }
-
- public void setAction(VCSAction action) {
- this.action = action;
- }
-
- public void setState(VCSState state) {
- this.state = state;
- }
-}
-
Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateManager.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateManager.java 2008-04-05 20:33:02 UTC (rev 356)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFileStateManager.java 2008-04-05 20:35:25 UTC (rev 357)
@@ -1,276 +0,0 @@
-/* ##%
-* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
-* Benjamin Poussin, Tony Chemit
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*##%*/
-package org.codelutin.vcs;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.TreeMap;
-
-/**
- * Classe responsable de la gestion des {@link VCSFileStateImpl}.
- * <p/>
- * Elle permet leur instanciation, et g�re un cache de ces objets, la politique
- * �tant de n'instancier qu'une seule fois et ensuite d'utiliser les methodes de
- * synchronisations.
- * <br/>
- * TODO Doc
- * {@link #doSynch()}
- * {@link #getState(long,File)} ()}
- * {@link #doAdd(VCSHandler,File)}
- * {@link #doDelete(File)}
- * {@link #doClear()}
- * {@link #doReset()}
- *
- * @author chemit
- */
-public class VCSFileStateManager {
-
- protected static VCSHandler getVCSHanler() {
- return VCSHandlerFactory.getHandler();
- }
-
- static public List<VCSFileState> doScan(VCSHandler handler, File root, boolean changeLog,
- VCSState... states) throws VCSException {
- // TODO on devrait changer l'algorithme, pour ne recuperer
- // TODO que ce qui est reellement est necessaire
-
- // recupereration des fichier locaux
- List<String> localFileNames = handler.getLocalStorageNames(root);
-
- // recuperation des fichiers distants
- List<String> remoteFileNames = handler.getRemoteStorageNames(root);
-
- // recuperation des fichiers uniquement presents sur le repository distant
- List<String> newRemoteName = new ArrayList<String>(remoteFileNames);
- newRemoteName.removeAll(localFileNames);
-
- List<VCSFileState> vcsstates = new ArrayList<VCSFileState>();
-
- long timestamp = System.nanoTime();
-
- for (String filePath : localFileNames) {
- File f = new File(root, filePath);
- vcsstates.add(getState(timestamp, f));
- }
-
- for (String filePath : newRemoteName) {
- File f = new File(root, filePath);
- vcsstates.add(getState(timestamp, f));
- }
-
- final List<VCSFileState> result = filter(vcsstates, states);
- if (changeLog) {
- // compute all change log for selected files
- for (VCSFileState vcsFileState : result)
- vcsFileState.setChangeLog(handler.getChangeLog(vcsFileState.getFile()));
- }
- return result;
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / methodes getState(XXX) pour obtenir des etats du cache (avec creation
- // / si besoin est)
- // /////////////////////////////////////////////////////////////////////////
-
- static public VCSFileState getState(long timestamp, File f) {
- return getState(getVCSHanler(), timestamp, f);
- }
-
- static public VCSFileState getState(boolean synch, File f) {
- return getState(getVCSHanler(), synch, f);
- }
-
- static public VCSFileState getState(VCSHandler handler, boolean synch,
- File f) {
- VCSFileState result;
- synchronized (cache) {
- final int key = getKey(f);
- result = cache.get(key);
- if (result == null) {
- result = doAdd(handler, f);
- }
- if (synch) {
- result.doSynch(handler, System.nanoTime());
- }
- }
- return result;
- }
-
- static public VCSFileState getState(VCSHandler handler, long timestamp, File f) {
- VCSFileState result;
- synchronized (cache) {
- final int key = getKey(f);
- result = cache.get(key);
- if (result == null) {
- result = doAdd(handler, f);
- }
- result.doSynch(handler, timestamp);
- }
- return result;
- }
-
- static public VCSFileState[] getState(VCSHandler handler, boolean synch,
- Collection<File> f) {
- VCSFileState[] result = new VCSFileState[f.size()];
-
- int index = 0;
- for (File file : f) {
- result[index] = getState(handler, synch, file);
- index++;
- }
- return result;
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / methodes doSynch(XXX) pour synchroniser les �tats du cache
- // /////////////////////////////////////////////////////////////////////////
-
- static public void doSynch() {
- doSynch(getVCSHanler(), false, System.nanoTime());
- }
-
- static public void doSynch(VCSHandler handler, boolean ifFileChanged,
- long timestamp) {
- synchronized (cache) {
- for (Integer hashcode : cache.keySet()) {
- cache.get(hashcode).doSynch(handler, timestamp, ifFileChanged);
- }
- }
- }
-
- static public void doSynch(VCSHandler handler, Collection<File> files) {
- doSynch(handler, false, System.nanoTime(), files);
- }
-
- static public void doSynch(VCSHandler handler, boolean ifFileChanged,
- long timestamp, Collection<File> files) {
- synchronized (cache) {
- for (File file : files) {
- VCSFileState vcsFileState = cache.get(getKey(file));
- if (vcsFileState == null)
- vcsFileState = doAdd(getVCSHanler(), file);
- vcsFileState.doSynch(handler, timestamp, ifFileChanged);
- }
- }
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // methodes protected doAdd(XXX) pour ajouter directement des etats au cache
- // /////////////////////////////////////////////////////////////////////////
-
- static protected VCSFileState doAdd(VCSHandler handler, File f) {
- VCSFileState result;
- synchronized (cache) {
- final int key = getKey(f);
- cache.put(key, result = new VCSFileStateImpl(handler, f));
- log.debug("[cache size:" + cache.size() + "] : " + result);
- }
- return result;
- }
-
- // ////////////////////////////////////////////////////////////////////////
- // methodes doDelete(XXX) pour supprimer des etats du cache
- // ////////////////////////////////////////////////////////////////////////
-
- static public void doDelete(File file) {
- synchronized (cache) {
- cache.remove(getKey(file));
- }
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / clean cache methods
- // /////////////////////////////////////////////////////////////////////////
-
- static public void doReset() {
- synchronized (cache) {
- for (Integer hashcode : cache.keySet()) {
- cache.get(hashcode).resetState();
- }
- }
- }
-
- static public void doClear() {
- synchronized (cache) {
- cache.clear();
- }
- }
-
- protected VCSFileStateManager() {
- }
-
- static private int getKey(File file) {
- return file.getAbsolutePath().hashCode();
- }
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static protected final Log log = LogFactory
- .getLog(VCSFileStateManager.class);
-
- /** cache of VCSFileState, keys are relativePath.hashCode of each entry */
- static final protected java.util.Map<Integer, VCSFileState> cache = new TreeMap<Integer, VCSFileState>();
-
- // /////////////////////////////////////////////////////////////////////////
- // / utils methods (filter and explode from VCSAction and VCSState)
- // /////////////////////////////////////////////////////////////////////////
- @SuppressWarnings({"unchecked"})
- static public List<VCSFileState>[] explode(List<VCSFileState> source,
- VCSState... wanted) {
- if (wanted.length == 0)
- wanted = VCSState.values();
- int nbState = wanted.length;
- List<VCSFileState>[] result = new List[nbState];
- for (int i = 0; i < nbState; i++) {
- result[i] = new ArrayList<VCSFileState>();
- }
- List<VCSState> states = java.util.Arrays.asList(wanted);
- VCSState state;
- int index;
- for (VCSFileState fileState : source) {
- state = fileState.getState();
- if ((index = states.indexOf(state)) > -1) {
- result[index].add(fileState);
- }
- }
- return result;
- }
-
- static public List<VCSFileState> filter(List<VCSFileState> source,
- VCSState... wanted) {
- List<VCSFileState> result = new ArrayList<VCSFileState>();
- List<VCSState> states = java.util.Arrays.asList(wanted);
-
- if (wanted.length == 0) {
- return result;
- }
- for (VCSFileState fileState : source) {
- VCSState currentState = fileState.getState();
- if (states.contains(currentState)) {
- result.add(fileState);
- }
- }
- return result;
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java 2008-04-05 20:33:02 UTC (rev 356)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java 2008-04-05 20:35:25 UTC (rev 357)
@@ -1,49 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * This program is free software; you
- * can redistribute it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. This program is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
- */
-package org.codelutin.vcs.ui.model;
-
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSState;
-import org.codelutin.vcs.ui.VCSUIConstants;
-
-/** @author chemit */
-public class SimpleVCSFileStatesModel extends AbstractVCSFileStatesModel {
-
- private static final long serialVersionUID = -7592705623128585146L;
-
- public SimpleVCSFileStatesModel(String name) {
- super(name, VCSUIConstants.SIMPLE_COLUMNS_NAMES);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex) {
- if (isEmpty()) return null;
- VCSFileState item = data.get(rowIndex);
- Object result = null;
- if (columnIndex == 0) {
- // get module
- result = item.getModuleName();
- } else if (columnIndex == 1) {
- // get file
- result = item.getModuleRelativeFileName();
- } else if (columnIndex == 2) {
- // get status
- VCSState state = item.getState();
- result = state == null ? null : state.libelle();
- }
- return result;
- }
-
-
-}
\ No newline at end of file
1
0
r356 - trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:33:02 +0000 (Sat, 05 Apr 2008)
New Revision: 356
Removed:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConfig.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEvent.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEventListener.java
Log:
deletec VCSConfig and VCSHandlerEvents
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConfig.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConfig.java 2008-04-05 20:32:29 UTC (rev 355)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConfig.java 2008-04-05 20:33:02 UTC (rev 356)
@@ -1,97 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package org.codelutin.vcs;
-
-import java.io.File;
-
-/**
- * Contract to be realised by a VCS config used in VCSHandler
- *
- * @author chemit
- */
-public interface VCSConfig {
-
- /**
- * find out if a connection to remote vcs servsder can be etablished.
- * <p/>
- * Note : The method is safe and will not throw any exception.
- *
- * @return <code>true</code> if connection to remote vcs server can be
- * etablished.
- */
- boolean canConnect();
-
- /** @return <code>true</code> if handler is connected to remote vcs server */
- boolean isConnected();
-
- /** @return the current connexion state */
- ConnectionState getConnectionState();
-
- /** @return the type of vcs used */
- VCSType getType();
-
- /** @return <code>true</code> if ssh connexion is used */
- boolean isUseSshConnexion();
-
- /** @return the url of hostname */
- String getHostName();
-
- /** @return location of the private ssh2 key file */
- File getKeyFile();
-
- /** @return the user connexion login */
- String getUserName();
-
- /** @return <code>true</code> if user ssh2 pair keys use a passphrase */
- boolean isNoPassPhrase();
-
- String getPassphrase();
-
- /** @return the full location path of the remote container of module */
- String getRemotePath();
-
- /** @return the name of remote module */
- String getRemoteDatabase();
-
- /** @return the full url path to the remote repository (with module name include) */
- String getRemoteDatabasePath();
-
- File getLocalDatabasePath();
-
- /** @return the type of reposotory used (head,tags,branches,...) */
- VCSTypeRepo getTypeRepo();
-
- /** @return <code>true</code> if no connexion is etablish at current time */
- boolean isOffline();
-
- /** @return <code>true</code> if remote repository is read-only */
-
- boolean isReadOnly();
-
- /** @return <code>true</code> if vcs handler is finely init */
-
- boolean isInit();
-
- /** method to validate vcs configuration. */
- void validate();
-
- void setUseSshConnexion(boolean useSshConnexion);
-
- File getSource();
-}
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEvent.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEvent.java 2008-04-05 20:32:29 UTC (rev 355)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEvent.java 2008-04-05 20:33:02 UTC (rev 356)
@@ -1,51 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * This program is free software; you
- * can redistribute it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. This program is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
- */
-package org.codelutin.vcs;
-
-import java.util.EventObject;
-
-/**
- * Events to be used while {@link VCSHandler} life cycle.
- *
- * @author chemit
- * @see VCSHandlerEventListener
- * @see VCSHandler
- */
-public class VCSHandlerEvent extends EventObject {
-
- private static final long serialVersionUID = 1L;
-
- protected Type type;
-
- public enum Type {
- INIT, OPEN, CLOSE
- }
-
- /**
- * Constructs a prototypical Event.
- *
- * @param source The object on which the Event initially occurred.
- * @param type type of event
- * @throws IllegalArgumentException if source is null.
- */
- public VCSHandlerEvent(Object source, Type type) {
- super(source);
- this.type = type;
- }
-
- public Type getType() {
- return type;
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEventListener.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEventListener.java 2008-04-05 20:32:29 UTC (rev 355)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEventListener.java 2008-04-05 20:33:02 UTC (rev 356)
@@ -1,47 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * This program is free software; you
- * can redistribute it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. This program is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
- */
-package org.codelutin.vcs;
-
-import java.util.EventListener;
-
-/**
- * A listener on {@link org.codelutin.vcs.VCSHandler}
- *
- * @author chemit
- */
-public interface VCSHandlerEventListener extends EventListener {
-
- /**
- * call when vcs handler was successfull init
- *
- * @param event current event
- */
- public void init(VCSHandlerEvent event);
-
- /**
- * call when vcs handler was successfull open
- *
- * @param event current event
- */
- public void open(VCSHandlerEvent event);
-
- /**
- * call when vcs handler was closed
- *
- * @param event current event
- */
- public void close(VCSHandlerEvent event);
-
-}
\ No newline at end of file
1
0
r355 - in trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs: . util
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:32:29 +0000 (Sat, 05 Apr 2008)
New Revision: 355
Added:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntriesImpl.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java
Removed:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSHelper.java
Log:
introduce VCSEntry, VCSEntries, VCSConnexion and VCSConnexionConfig
introduc default implementations
delete VCSHelper
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java 2008-04-05 20:31:28 UTC (rev 354)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -1,96 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * This program is free software; you
- * can redistribute it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. This program is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
- */
-package org.codelutin.vcs;
-
-import java.io.File;
-import java.net.URI;
-import java.util.Map;
-
-/**
- * Contract to be realized for a connexion to a vcs.
- * <p/>
- * The method {@link #init(VCSConfig, VCSHandler)} must be invoked before using the connexion.
- *
- * @author chemit
- */
-public interface VCSConnexion {
-
- /**
- * @return the working copy used, can be null if no working copy exists.
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- File getWorkingCopy() throws IllegalStateException;
-
- /**
- * @return the URI used to connect to vcs
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- URI getRemoteURI() throws IllegalStateException;
-
- /**
- * @return the mode of this connexion
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- VCSConnexionMode getMode() throws IllegalStateException;
-
- /**
- * @return options to be used by this connexion
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- Map<String, String> getOptions() throws IllegalStateException;
-
- /**
- * Initialise the connexion.
- * <p/>
- * If connexion can not be established, then the method {@link #hasFailed()} will always
- * return <code>true</code>.
- *
- * @param config config to be used to initialize the connexion.
- * @param handler handler to be used to initialize the connexion.
- */
- void init(VCSConfig config, VCSHandler handler);
-
- /**
- * Close connexion.
- *
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- void open() throws IllegalStateException;
-
- /**
- * Close connexion.
- *
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- void close() throws IllegalStateException;
-
- /**
- * @return <code>true</code> if connexion is opened, <code>false</code> otherwise
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- boolean isOpen() throws IllegalStateException;
-
- /**
- * @return <code>true</code> if connexion is closed, <code>false</code> otherwise
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- boolean isClosed() throws IllegalStateException;
-
- /**
- * @return <code>true</code> if connexion has failed, <code>false</code> otherwise
- * @throws IllegalStateException if {@link #init(VCSConfig, VCSHandler)} was not invoked before.
- */
- boolean hasFailed() throws IllegalStateException;
-}
Added: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,384 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Contract to be realized for a connexion to a vcs.
+ * <p/>
+ * The method {@link #init(VCSConnexionConfig)} must be invoked before using the connexion.
+ * <p/>
+ * Note: you should not instanciate directly this class but use
+ * {@link org.codelutin.vcs.VCSProvider#newConnection(org.codelutin.vcs.VCSConnexionMode , VCSConnexionConfig)} instead.
+ *
+ * @author chemit
+ */
+public interface VCSConnexion {
+
+ VCSProvider getProvider();
+
+ /**
+ * @return the working copy used, can be null if no working copy exists.
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ File getWorkingCopy() throws IllegalStateException;
+
+ /**
+ * @return the URI used to connect to vcs
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ URI getRemoteURI() throws IllegalStateException;
+
+ /**
+ * @return the mode of this connexion
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ VCSConnexionMode getMode() throws IllegalStateException;
+
+ /**
+ * Initialize the connexion.
+ * <p/>
+ * If connexion can not be established, then the method {@link #hasFailed()} will always
+ * return <code>true</code>.
+ *
+ * @param config config to be used to initialize the connexion.
+ */
+ void init(VCSConnexionConfig config);
+
+ /**
+ * @return the config of the connexion
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ VCSConnexionConfig getConfig() throws IllegalStateException;
+
+ /**
+ * test if connection is ok
+ *
+ * @throws VCSException if any problem
+ */
+ void testConnection() throws VCSException;
+
+ /**
+ * Close connexion.
+ *
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ void open() throws IllegalStateException;
+
+ /**
+ * Close connexion.
+ *
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ void close() throws IllegalStateException;
+
+ /**
+ * @return <code>true</code> if connexion is opened, <code>false</code> otherwise
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ boolean isOpen() throws IllegalStateException;
+
+ /**
+ * @return <code>true</code> if connexion is closed, <code>false</code> otherwise
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ boolean isClosed() throws IllegalStateException;
+
+ /**
+ * @return <code>true</code> if connexion has failed, <code>false</code> otherwise
+ * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before.
+ */
+ boolean hasFailed() throws IllegalStateException;
+
+ /** @param l the listener to add */
+ void addVCSConnexionEventListener(VCSConnexionEventListener l);
+
+ /** @param l the listener to remove */
+ void removeVCSConnexionEventListener(VCSConnexionEventListener l);
+
+ /**
+ * init working copy, says if it is the first we use it it, we will checkout
+ * the databaseDirectory directory
+ *
+ * @throws VCSException if any exception while init
+ */
+ void initWorkingCopy() throws VCSException;
+
+ /** delete the local working copy with all his files */
+ void deleteWorkingCopy();
+
+ /**
+ * @return a <code>FilenameFilter<code> to detect all files and directories in a vcs working copy that
+ * must be handled by vcs
+ */
+ FilenameFilter getVersionnableFilenameFilter();
+
+ /**
+ * @return a <code>FileFilter<code> to detect all files and directories in a vcs working copy that
+ * must be handled by vcs
+ */
+ FileFilter getVersionnableFileFilter();
+
+ /**
+ * @return name of directory used by vcs to store in working copy, a data's
+ * directory configuration (e.g CVS for cvs and .svn for svn)
+ */
+ String getConfLocalDirname();
+
+ /**
+ * @return name of the file used by vcs to store in working copy
+ * configuration directory entries of data's directory (e.g Entries
+ * for cvs and entries for svn)
+ */
+ String getConfLocalEntriesFilename();
+
+ VCSState getState(File fileState, Collection tmp) throws VCSException;
+
+ VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException;
+
+ /**
+ * @param file file to test
+ * @return <code>true</code> if <code>file</code> is on remote
+ * repository, <code>false</code> otherwise.
+ */
+ boolean isOnRemote(File file);
+
+ /**
+ * @param file file to test
+ * @return <code>true</code> if file is uptodate,<code>false</code>
+ * otherwise.
+ * @throws VCSException if any exception while operation
+ */
+ boolean isUpToDate(File file) throws VCSException;
+
+ /**
+ * @param file file to test
+ * @return <code>true</code> if file is handled by VCS,<code>false</code>
+ * otherwise.
+ */
+ boolean isVersionnableFile(File file);
+
+ /**
+ * add on remote repository somes directories
+ *
+ * @param commitMessage commit message
+ * @param dirNames names of the directories to create on remote repository (could
+ * used multi-level directories)
+ * @throws VCSException if any exception while operation
+ */
+ void makeRemoteDir(String commitMessage, String... dirNames)
+ throws VCSException;
+
+ /**
+ * delete on remote repository somes directories
+ *
+ * @param commitMessage commit message
+ * @param dirNames names of the directories to delete on remote repository (could
+ * used multi-level directories)
+ * @throws VCSException if any exception while operation
+ */
+ void deleteRemoteDir(String commitMessage, String... dirNames)
+ throws VCSException;
+
+ /**
+ * add a list of files into repository
+ *
+ * @param files files to add
+ * @param msg message for VCS commit, if <code>null</code> then no commit
+ * is performed
+ * @return revision of the operation
+ * @throws VCSException if any exception while operation
+ */
+ long add(List<File> files, String msg) throws VCSException;
+
+ // void add(File file, String msg) throws VCSException;
+
+ /**
+ * delete a list of files from repository
+ *
+ * @param files files to delete
+ * @param msg message for VCS commit, if <code>null</code> then no commit
+ * is performed
+ * @throws VCSException if any exception while operation
+ */
+ void delete(List<File> files, String msg) throws VCSException;
+
+ /**
+ * revert a list of files from repository
+ *
+ * @param files files to revert
+ * @throws VCSException if any exception while operation
+ */
+ void revert(List<File> files) throws VCSException;
+
+ /**
+ * commit a list of files into repository
+ *
+ * @param files files to commit
+ * @param msg message for VCS commit
+ * @return revision of the operation
+ * @throws VCSException if any exception while operation
+ */
+ long commit(List<File> files, String msg) throws VCSException;
+
+ /**
+ * update a file to repository to a certain revision
+ *
+ * @param file file to update
+ * @param revision object representing a revision for the current VCS
+ * @throws VCSException if any exception while operation
+ */
+ void update(File file, Object revision) throws VCSException;
+
+ /**
+ * update a file to repository
+ *
+ * @param file file to update
+ * @throws VCSException if any exception while operation
+ */
+ void update(File file) throws VCSException;
+
+ /**
+ * checkout a module from repository to a local file
+ *
+ * @param destDir local file where to checkout
+ * @param module module's name to checkout
+ * @param recurse flag to say to recurse checkout or not.
+ * @throws VCSException if any exception while operation
+ */
+ void checkout(File destDir, String module, boolean recurse) throws VCSException;
+
+ void checkoutFile(File destDir, String module) throws VCSException;
+
+ long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException;
+
+ /**
+ * TODO This is not the good place : VCS != Storage
+ *
+ * @param directory directory to treate
+ * @return TODO
+ * @throws VCSException TODO
+ */
+ List<String> getRemoteStorageNames(File directory) throws VCSException;
+
+ /**
+ * TODO This is not the good place : VCS != Storage
+ *
+ * @param directory directory to treate
+ * @return TODO
+ */
+ List<String> getLocalStorageNames(File directory);
+
+ /**
+ * @param f local file to treate
+ * @return current local revision of a file
+ * @throws VCSException TODO
+ */
+ Object getRevision(File f) throws VCSException;
+
+ /**
+ * Obtain the list of log entries for the file
+ *
+ * @param startRevision TODO
+ * @param endRevision TODO
+ * @param file file to treate
+ * @return list of log entries for this file between two revisions
+ * @throws VCSException if any exception while grabbing infos
+ */
+ List getLog(Object startRevision, Object endRevision, File file)
+ throws VCSException;
+
+ /**
+ * obtain the content of a file for a specific revision
+ *
+ * @param file file to obtain
+ * @param revision revision treated
+ * @return the content of the file on repository for the specific revision
+ * passed as arguement.
+ * @throws VCSException if any exception while operation
+ * @throws java.io.IOException TODO
+ */
+ String getFileContent(File file, Object revision) throws VCSException, IOException;
+
+ /**
+ * Build the changelog for <code>file</code> from current revision of this
+ * local file against head repository head version. For each revision
+ * between current revision and head revision of this file, we give the
+ * following informations :
+ * <ul>
+ * <li>revision number</li>
+ * <li>author</li>
+ * <li>date</li>
+ * <li>commit message</li>
+ * </ul>
+ *
+ * @param file file to treate
+ * @return a string representation of change log for the local file to the
+ * head ?
+ * @throws VCSException if any exception while building changelog
+ */
+ String getChangeLog(File file) throws VCSException;
+
+ /**
+ * Generate in the ouputstream the diff between the current revision of the
+ * local file against headest revision on repository. <br>
+ * If file is uptodate, then does nothing.
+ *
+ * @param file the file to treate
+ * @return the diff
+ * @throws VCSException inf any exception while building diff, such as :
+ * <ul>
+ * <li>unversionned file</li>
+ * <li>unexistant file locally</li>
+ * <li>locally modified file ?</li>
+ * <li>...</li>
+ * </ul>
+ * @throws java.io.IOException if io problem with streams
+ */
+ String getDiff(File file) throws VCSException, IOException;
+
+ /**
+ * Generate in the ouputstream the diff between the current revision of the
+ * local file against another revision (<code>againstRevision</code>) on
+ * repository. <br>
+ * If file is uptodate, then does nothing.
+ *
+ * @param file the file to treate
+ * @param againstRevision the against revision to use
+ * @return the diff
+ * @throws VCSException inf any exception while building diff, such as :
+ * <ul>
+ * <li>unversionned file</li>
+ * <li>unexistant file locally</li>
+ * <li>locally modified file ?</li>
+ * <li>...</li>
+ * </ul>
+ * @throws java.io.IOException if problem with streams
+ */
+ String getDiff(File file, Object againstRevision) throws VCSException, IOException;
+
+ /**
+ * @return <code>true</code> if protocol has changed between config and working copy
+ * @throws VCSException if any pb
+ */
+ boolean hasProtocoleChanged() throws VCSException;
+}
Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java (from rev 345, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConfig.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,67 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package org.codelutin.vcs;
+
+import java.io.File;
+
+/**
+ * Contract to be realized by a VCSConnexion configuration.
+ * <p/>
+ * This class has no logic, ans is a <code>POJO</code>.
+ *
+ * @author chemit
+ */
+public interface VCSConnexionConfig {
+
+ /** @return the type of vcs used */
+ VCSType getType();
+
+ /** @return <code>true</code> if ssh connexion is used */
+ boolean isUseSshConnexion();
+
+ /** @return the url of hostname */
+ String getHostName();
+
+ /** @return location of the private ssh2 key file */
+ File getKeyFile();
+
+ /** @return the user connexion login */
+ String getUserName();
+
+ /** @return <code>true</code> if user ssh2 pair keys use a passphrase */
+ boolean isNoPassPhrase();
+
+ String getPassphrase();
+
+ /** @return the full location path of the remote container of module */
+ String getRemotePath();
+
+ /** @return the name of remote module */
+ String getRemoteDatabase();
+
+ /** @return the full url path to the remote repository (with module name include) */
+ String getRemoteDatabasePath();
+
+ File getLocalDatabasePath();
+
+ /** @return the type of reposotory used (head,tags,branches,...) */
+ VCSTypeRepo getTypeRepo();
+
+ void setUseSshConnexion(boolean newValue);
+}
\ No newline at end of file
Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java (from rev 345, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEvent.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,56 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs;
+
+import java.util.EventObject;
+
+/**
+ * Events to be used while {@link org.codelutin.vcs.VCSHandler} life cycle.
+ *
+ * @author chemit
+ * @see org.codelutin.vcs.VCSHandlerEventListener
+ * @see org.codelutin.vcs.VCSHandler
+ */
+public class VCSConnexionEvent extends EventObject {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Type state;
+
+ public enum Type {
+ OPEN, CLOSE
+ }
+
+ /**
+ * Constructs a prototypical Event.
+ *
+ * @param source The object on which the Event initially occurred.
+ * @param type type of event
+ * @throws IllegalArgumentException if source is null.
+ */
+ public VCSConnexionEvent(VCSConnexion source, Type type) {
+ super(source);
+ this.state = type;
+ }
+
+ @Override
+ public VCSConnexion getSource() {
+ return (VCSConnexion) super.getSource();
+ }
+
+ public Type getState() {
+ return state;
+ }
+}
\ No newline at end of file
Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java (from rev 345, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandlerEventListener.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,38 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs;
+
+/**
+ * A listener on {@link VCSConnexion} life cycle
+ *
+ * @author chemit
+ */
+public interface VCSConnexionEventListener extends java.util.EventListener {
+
+ /**
+ * call when vcs connexion was successfull open
+ *
+ * @param event current event
+ */
+ public void open(VCSConnexionEvent event);
+
+ /**
+ * call when vcs connexion was closed
+ *
+ * @param event current event
+ */
+ public void close(VCSConnexionEvent event);
+
+}
\ No newline at end of file
Added: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,121 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs;
+
+import javax.swing.ListSelectionModel;
+import java.util.List;
+
+/** @author chemit */
+public interface VCSEntries {
+
+ /**
+ * Discover and Populate with all local and remote entries.
+ *
+ * @param timestamp gloabal timestamp to apply
+ * @param connexion connexion used to populate
+ * @throws VCSException if any pb with vcs io
+ */
+ void populate(VCSConnexion connexion, long timestamp) throws VCSException;
+
+ /**
+ * Populate with no discovering for a given list of local relative paths for a given location type.
+ * <p/>
+ * Note : <b>We always used the filesystem path separator to encode paths.</b>
+ *
+ * @param relativeLocalPaths list of local relative path to populate
+ * @param location location to be used
+ * @param timestamp gloabal timestamp to apply
+ * @param connexion connexion used tro refresh
+ * @throws VCSException if any pb with vcs io
+ */
+ void populate(VCSConnexion connexion, List<String> relativeLocalPaths, VCSEntryLocation location, long timestamp) throws VCSException;
+
+ /**
+ * Populate from pre-computed entries. No discovering is done, nor vcs io operations.
+ *
+ * @param location given location to use
+ * @param states pre-computed states to populate
+ */
+ void populate(VCSEntryLocation location, VCSEntry[] states);
+
+ /**
+ * refresh state of the entry.
+ *
+ * @param entries entries to refresh
+ * @param timestamp global timestamp to apply
+ * @throws IllegalStateException if entry was never populated
+ */
+ void refresh(List<VCSEntry> entries, long timestamp) throws IllegalStateException;
+
+ /**
+ * obtain the list of all entries.
+ *
+ * @return list of all entries
+ * @throws IllegalStateException if entry was never populated
+ */
+ List<VCSEntry> getEntries() throws IllegalStateException;
+
+ /**
+ * obtain the list of all entries for a given connexion
+ *
+ * @param connexion filter connexion
+ * @param entries entries to filter
+ * @return list of all entries for a given connexion
+ */
+ List<VCSEntry> filter(VCSConnexion connexion, List<VCSEntry> entries);
+
+ /**
+ * obtain the list of all entries for a given location
+ *
+ * @param location filter location
+ * @param entries entries to filter
+ * @return list of all entries for a given connexion
+ */
+ List<VCSEntry> filter(VCSEntryLocation location, List<VCSEntry> entries);
+
+ /**
+ * obtain the list of all entries for a given state
+ *
+ * @param state filter state
+ * @param entries entries to filter
+ * @return list of all entries for a given connexion
+ */
+ List<VCSEntry> filter(VCSState state, List<VCSEntry> entries);
+
+ /**
+ * obtain the list of all entries for a given selection model
+ *
+ * @param selectionModel filter from selection model
+ * @param entries entries to filter
+ * @return list of all entries for a given connexion
+ */
+ List<VCSEntry> filter(ListSelectionModel selectionModel, List<VCSEntry> entries);
+
+ /**
+ * obtain the list of all entries for a given action
+ *
+ * @param action filter state
+ * @param entries entries to filter
+ * @return list of all entries for a given connexion
+ */
+ List<VCSEntry> filter(VCSAction action, List<VCSEntry> entries);
+
+ VCSAction[] getActions(List<VCSEntry> entries);
+
+ VCSState[] getStates(List<VCSEntry> entries);
+
+ /** clear the list of entries. */
+ void clear();
+}
Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java (from rev 345, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSFileState.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,121 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.Serializable;
+
+/** @author chemit */
+public interface VCSEntry extends Serializable {
+
+ /**
+ * Populate the state of the entry, this method calls {@link #refresh(long)} method.
+ *
+ * @param timestamp gloabal timestamp to apply
+ * @throws VCSException if anypb with vcs io
+ */
+ void populate(long timestamp) throws VCSException;
+
+ /**
+ * refresh state of the entry.
+ *
+ * @param timestamp global timestamp to apply
+ * @throws IllegalStateException if entry was never populated
+ * @throws VCSException if anypb with vcs io
+ */
+ void refresh(long timestamp) throws IllegalStateException, VCSException;
+
+ /**
+ * Obtain the relative path from root repository to the entry.
+ * <p/>
+ * Note: <b>We use the filesystem path separator, could not be the same on remote</b>
+ *
+ * @return the relativePath from local root repository to the entry
+ */
+ String getRelativeLocalPath();
+
+ /**
+ * Obtain the relative path from root repository to the entry.
+ * <p/>
+ * Note: <b>We use the '/' as path separator, could not be the same on local</b>
+ *
+ * @return the relativePath from remote root repository to the entry
+ */
+ String getRelativeRemotePath();
+
+ /**
+ * Obtain the projected entry on local working copy.
+ * <p/>
+ * Note : <b> the file could not exists.
+ *
+ * @return the local file represented by this entry
+ */
+ File getFile();
+
+ /** @return connexion used */
+ VCSConnexion getConnexion();
+
+ /**
+ * @return the location of entry
+ * @throws IllegalStateException if entry was never populated
+ * @see VCSEntryLocation
+ */
+ VCSEntryLocation getLocation() throws IllegalStateException;
+
+ /**
+ * @return the last state found for the entry
+ * @throws IllegalStateException if entry was never populated
+ */
+ VCSState getState() throws IllegalStateException;
+
+ /**
+ * @return the timestamp of the last state synchronization for the entry
+ * @throws IllegalStateException if entry was never populated
+ */
+ long getTimestamp() throws IllegalStateException;
+
+ /**
+ * @return the rev of entry
+ * @throws IllegalStateException if entry was never populated
+ */
+ String getRev() throws IllegalStateException;
+
+ /**
+ * @return the changelog of entry from local aginst remote
+ * @throws IllegalStateException if entry was never populated
+ */
+ BufferedReader getChangeLog() throws IllegalStateException;
+
+ /**
+ * @return the diff of entry from local aginst remote
+ * @throws IllegalStateException if entry was never populated
+ */
+ BufferedReader getDiff() throws IllegalStateException;
+
+ /**
+ * @return the local entry content
+ * @throws IllegalStateException if entry was never populated, or entry is a directory
+ */
+ BufferedReader getLocalContent() throws IllegalStateException;
+
+ /**
+ * @return the remote entry content
+ * @throws IllegalStateException if entry was never populated, or entry is a directory
+ */
+ BufferedReader getRemoteContent() throws IllegalStateException;
+
+ void setState(VCSState state);
+}
\ No newline at end of file
Added: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,130 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs.util;
+
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSType;
+import org.codelutin.vcs.VCSTypeRepo;
+
+import java.io.File;
+
+/** @author chemit */
+public class VCSConnexionConfigImpl implements VCSConnexionConfig {
+
+ private VCSType type;
+ private boolean useSshConnexion;
+ private String hostName;
+ private File keyFile;
+ private String userName;
+ private boolean noPassPhrase;
+ private String passPhrase;
+ private String remotePath;
+ private String remoteDatabase;
+ private VCSTypeRepo typeRepo;
+ private File localDatabasePath;
+
+
+ public VCSType getType() {
+ return type;
+ }
+
+ public boolean isUseSshConnexion() {
+ return useSshConnexion;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public File getKeyFile() {
+ return keyFile;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public boolean isNoPassPhrase() {
+ return noPassPhrase;
+ }
+
+ public String getPassphrase() {
+ return passPhrase;
+ }
+
+ public String getRemotePath() {
+ return remotePath;
+ }
+
+ public String getRemoteDatabase() {
+ return remoteDatabase;
+ }
+
+ public String getRemoteDatabasePath() {
+ return remotePath + '/' + remoteDatabase;
+ }
+
+ public File getLocalDatabasePath() {
+ return localDatabasePath;
+ }
+
+ public VCSTypeRepo getTypeRepo() {
+ return typeRepo;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public void setKeyFile(File keyFile) {
+ this.keyFile = keyFile;
+ }
+
+ public void setLocalDatabasePath(File localDatabasePath) {
+ this.localDatabasePath = localDatabasePath;
+ }
+
+ public void setNoPassPhrase(boolean noPassPhrase) {
+ this.noPassPhrase = noPassPhrase;
+ }
+
+ public void setPassPhrase(String passPhrase) {
+ this.passPhrase = passPhrase;
+ }
+
+ public void setRemoteDatabase(String remoteDatabase) {
+ this.remoteDatabase = remoteDatabase;
+ }
+
+ public void setRemotePath(String remotePath) {
+ this.remotePath = remotePath;
+ }
+
+ public void setType(VCSType type) {
+ this.type = type;
+ }
+
+ public void setTypeRepo(VCSTypeRepo typeRepo) {
+ this.typeRepo = typeRepo;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public void setUseSshConnexion(boolean useSshConnexion) {
+ this.useSshConnexion = useSshConnexion;
+ }
+}
Added: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntriesImpl.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntriesImpl.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntriesImpl.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,201 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs.util;
+
+import org.codelutin.vcs.VCSAction;
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSEntries;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSState;
+
+import javax.swing.ListSelectionModel;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Collections;
+import java.util.Arrays;
+
+/** @author chemit */
+public class VCSEntriesImpl implements VCSEntries {
+
+ protected List<VCSEntry> entries;
+
+ public void populate(VCSConnexion connexion, long timestamp) throws VCSException {
+
+ List<String> localFiles = connexion.getLocalStorageNames(connexion.getWorkingCopy());
+
+ List<String> remoteFiles = transformToLocal(connexion.getRemoteStorageNames(connexion.getWorkingCopy()));
+
+ List<String> allFiles = new ArrayList<String>();
+
+ // detect location all from remote files
+ for (Iterator<String> it = remoteFiles.iterator(); it.hasNext();) {
+ String relativePath = it.next();
+ if (localFiles.contains(relativePath)) {
+ allFiles.add(relativePath);
+ it.remove();
+ localFiles.remove(relativePath);
+ }
+ }
+
+ // detect location all from local files
+ for (Iterator<String> it = localFiles.iterator(); it.hasNext();) {
+ String relativePath = it.next();
+ if (remoteFiles.contains(relativePath)) {
+ allFiles.add(relativePath);
+ it.remove();
+ remoteFiles.remove(relativePath);
+ }
+ }
+
+ populate(connexion, localFiles, VCSEntryLocation.LOCAL, timestamp);
+ populate(connexion, remoteFiles, VCSEntryLocation.REMOTE, timestamp);
+ populate(connexion, allFiles, VCSEntryLocation.ALL, timestamp);
+
+ }
+
+ public void populate(VCSConnexion connexion, List<String> relativeLocalPaths, VCSEntryLocation location, long timestamp) throws VCSException {
+ if (entries == null) {
+ entries = new ArrayList<VCSEntry>();
+ }
+ for (String relativeLocalPath : relativeLocalPaths) {
+ VCSEntry entry = new VCSEntryImpl(connexion, relativeLocalPath);
+ entry.populate(timestamp);
+ entries.add(entry);
+ }
+ }
+
+ public void populate(VCSEntryLocation location, VCSEntry[] entries) {
+ if (this.entries == null) {
+ this.entries = new ArrayList<VCSEntry>();
+ }
+ this.entries.addAll(Arrays.asList(entries));
+ }
+
+ public void refresh(List<VCSEntry> entries, long timestamp) throws IllegalStateException {
+ checkPopulated();
+ }
+
+ public List<VCSEntry> getEntries() throws IllegalStateException {
+ checkPopulated();
+ // always return a copy of the list, to be safe...
+ return new ArrayList<VCSEntry>(entries);
+ }
+
+ public List<VCSEntry> filter(VCSConnexion connexion, List<VCSEntry> entries) {
+ List<VCSEntry> result = new ArrayList<VCSEntry>();
+ for (VCSEntry entry : entries) {
+ if (connexion.equals(entry.getConnexion())) {
+ result.add(entry);
+ }
+ }
+ return result;
+ }
+
+ public List<VCSEntry> filter(VCSEntryLocation location, List<VCSEntry> entries) {
+ if (location == VCSEntryLocation.ALL) {
+ return new ArrayList<VCSEntry>(entries);
+ }
+ List<VCSEntry> result = new ArrayList<VCSEntry>();
+ for (VCSEntry entry : entries) {
+ VCSEntryLocation vcsEntryLocation = entry.getLocation();
+ if (vcsEntryLocation == VCSEntryLocation.ALL || location.equals(vcsEntryLocation)) {
+ result.add(entry);
+ }
+ }
+ return result;
+ }
+
+ public List<VCSEntry> filter(VCSState state, List<VCSEntry> entries) {
+ List<VCSEntry> result = new ArrayList<VCSEntry>();
+ for (VCSEntry entry : entries) {
+ if (state.equals(entry.getState())) {
+ result.add(entry);
+ }
+ }
+ return result;
+ }
+
+ public List<VCSEntry> filter(ListSelectionModel selectionModel, List<VCSEntry> entries) {
+ if (entries.isEmpty() || selectionModel.isSelectionEmpty()) {
+ return Collections.emptyList();
+ }
+ List<VCSEntry> list = new ArrayList<VCSEntry>();
+ for (int i = 0, max = entries.size(); i < max; i++) {
+ if (selectionModel.isSelectedIndex(i)) {
+ list.add(entries.get(i));
+ }
+ }
+ return list;
+ }
+
+ public List<VCSEntry> filter(VCSAction action, List<VCSEntry> entries) {
+ List<VCSEntry> result = new ArrayList<VCSEntry>();
+ for (VCSEntry entry : entries) {
+ if (entry.getState().getActions().contains(action)) {
+ result.add(entry);
+ }
+ }
+ return result;
+ }
+
+ public void clear() {
+ //checkPopulated();
+ if (entries != null) {
+ entries.clear();
+ }
+ }
+
+
+ public VCSAction[] getActions(List<VCSEntry> entries) {
+ List<VCSAction> result = new ArrayList<VCSAction>();
+ for (VCSState vcsFileState : getStates(entries)) {
+ List<VCSAction> action = vcsFileState.getActions();
+ for (VCSAction vcsAction : action) {
+ if (vcsAction != null && !result.contains(vcsAction)) {
+ result.add(vcsAction);
+ }
+ }
+ }
+ return result.toArray(new VCSAction[result.size()]);
+ }
+
+ public VCSState[] getStates(List<VCSEntry> entries) {
+ List<VCSState> result = new ArrayList<VCSState>();
+ for (VCSEntry entry : entries) {
+ VCSState state = entry.getState();
+ if (state != null && !result.contains(state)) {
+ result.add(state);
+ }
+ }
+ return result.toArray(new VCSState[result.size()]);
+ }
+
+ protected List<String> transformToLocal(List<String> relativeRemotePath) {
+ List<String> result = new ArrayList<String>(relativeRemotePath.size());
+ for (String s : relativeRemotePath) {
+ result.add(AbstractVCSHandler.convertToLocalName(s));
+ }
+ return result;
+ }
+
+ protected void checkPopulated() throws IllegalStateException {
+ if (entries == null) {
+ throw new IllegalStateException(this + " was not populated...");
+ }
+ }
+}
Added: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -0,0 +1,127 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.vcs.util;
+
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.VCSException;
+
+import java.io.BufferedReader;
+import java.io.File;
+
+/** @author chemit */
+public class VCSEntryImpl implements VCSEntry {
+
+ protected transient final VCSConnexion connexion;
+
+ protected final String relativeLocalPath;
+
+ protected final String relativeRemotePath;
+
+ protected final File localFile;
+
+ protected VCSState state;
+
+ protected long timestamp;
+
+ protected String rev;
+ private static final long serialVersionUID = -6628119456256629555L;
+
+ public VCSEntryImpl(VCSConnexion connexion, String relativeLocalPath) {
+ this.connexion = connexion;
+ this.relativeLocalPath = relativeLocalPath;
+ this.relativeRemotePath = AbstractVCSHandler.convertToRemoteName(relativeLocalPath);
+ this.localFile = new File(connexion.getWorkingCopy(), relativeLocalPath);
+ }
+
+ public void populate(long timestamp) throws VCSException {
+ this.timestamp = timestamp;
+ this.state = connexion.getState(new File(connexion.getWorkingCopy(), relativeLocalPath), null);
+ }
+
+ public void refresh(long timestamp) throws IllegalStateException, VCSException {
+ checkPopulated();
+ populate(timestamp);
+ }
+
+ public String getRelativeLocalPath() {
+ return relativeLocalPath;
+ }
+
+ public String getRelativeRemotePath() {
+ return relativeRemotePath;
+ }
+
+ public File getFile() {
+ return localFile;
+ }
+
+ public VCSConnexion getConnexion() {
+ return connexion;
+ }
+
+ public VCSEntryLocation getLocation() throws IllegalStateException {
+ checkPopulated();
+ return state.getLocation();
+ }
+
+ public VCSState getState() throws IllegalStateException {
+ checkPopulated();
+ return state;
+ }
+
+ public long getTimestamp() throws IllegalStateException {
+ checkPopulated();
+ return timestamp;
+ }
+
+ public String getRev() throws IllegalStateException {
+ checkPopulated();
+ return rev;
+ }
+
+ public BufferedReader getChangeLog() throws IllegalStateException {
+ checkPopulated();
+ return null;
+ }
+
+ public BufferedReader getDiff() throws IllegalStateException {
+ checkPopulated();
+ return null;
+ }
+
+ public BufferedReader getLocalContent() throws IllegalStateException {
+ checkPopulated();
+ return null;
+ }
+
+ public BufferedReader getRemoteContent() throws IllegalStateException {
+ checkPopulated();
+ return null;
+ }
+
+ public void setState(VCSState state) {
+ this.state = state;
+ }
+
+ protected void checkPopulated() throws IllegalStateException {
+ if (timestamp == -1) {
+ throw new IllegalStateException(this + " was not populated");
+ }
+ }
+
+}
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSHelper.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSHelper.java 2008-04-05 20:31:28 UTC (rev 354)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSHelper.java 2008-04-05 20:32:29 UTC (rev 355)
@@ -1,194 +0,0 @@
-/* *##%
-* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
-* Benjamin Poussin, Tony Chemit
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*##%*/
-package org.codelutin.vcs.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSRuntimeException;
-import org.codelutin.vcs.VCSTypeRepo;
-
-import java.io.File;
-
-(a)org.codelutin.i18n.I18nable
-public class VCSHelper {
-
- private static final String LOCAL_SEP = File.separator;
- private static final String LOCAL_SEP_PATTERN = "\\".equals(LOCAL_SEP) ?
- LOCAL_SEP + LOCAL_SEP : LOCAL_SEP;
- private static final String REMOTE_SEP = "/";
- private static final String REMOTE_SEP_PATTERN = "/";
-
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(VCSHelper.class);
-
- public static boolean isFileInWorkingCopy(File parent, String name, VCSHandler handler, boolean underVCS) {
- if (parent == null || name == null)
- throw new RuntimeException(VCSHelper.class.getName() +
- "#isFileInWorkingCopy can not be invoked with some " +
- "null parameter but was. [" + parent + "," + name + "," +
- handler + "]");
- return isFileInWorkingCopy(new File(parent, name), handler, underVCS);
- }
-
- public static boolean isFileInWorkingCopy(File file, VCSHandler handler, boolean underVCS) {
- if (file == null || handler == null)
- throw new RuntimeException(VCSHelper.class.getName() +
- "#isFileInWorkingCopy can not be invoked with some " +
- "null parameter but was. [" + file + "," + handler + "]");
- String rootPath = handler.getConfig().getLocalDatabasePath().getAbsolutePath();
- String localPath = file.getAbsolutePath();
- if (localPath.startsWith(rootPath) && !underVCS) {
- return true;
- }
- final File realDir = file.isDirectory() ? file : file.getParentFile();
- return isFileInCheckedDir(realDir, handler);
- }
-
- public static boolean isFileInCheckedDir(File file, VCSHandler handler) {
- if (file == null || handler == null)
- throw new RuntimeException(VCSHelper.class.getName() +
- "#isFileInCheckedDir can not be invoked with some " +
- "null parameter but was. [" + file + "," + handler + "]");
- final File realDir = file.isDirectory() ? file : file.getParentFile();
- return (new File(realDir, handler.getConfLocalDirname()).exists());
-
- }
-
- public static void assertFileInWC(File file, VCSHandler handler) {
- if (!isFileInWorkingCopy(file, handler, false))
- throw new VCSRuntimeException("the file [" + file +
- "] is not in the working copy [" +
- handler.getLocalDatabasePath() + "]");
- }
-
- public static String getRemoteRelativePath(File f, VCSHandler handler) {
- if (!isFileInWorkingCopy(f, handler, false)) return null;
- //System.out.println("file on vcs working copy : "+f);
- String rootPath = handler.getConfig().getLocalDatabasePath().getAbsolutePath();
- String localPath = f.getAbsolutePath();
- if (!localPath.startsWith(rootPath)) return null;
- localPath = localPath.substring(rootPath.length() + 1);
- return convertToRemoteName(localPath);
- }
-
- public static String getLocalRelativePath(String remoteRelativePath, VCSHandler handler) {
- String localPath = convertToLocalName(remoteRelativePath);
- final File file = new File(handler.getConfig().getLocalDatabasePath(), localPath);
- if (!isFileInWorkingCopy(file, handler, false)) return null;
- return localPath;
- }
-
- public static String convertToRemoteName(String txt) {
- return txt.replaceAll(LOCAL_SEP_PATTERN, REMOTE_SEP);
- }
-
- public static String convertToLocalName(String txt) {
- return txt.replaceAll(REMOTE_SEP_PATTERN, LOCAL_SEP);
- }
-
- public static void doCheckoutDir(VCSHandler handler, File... dirs) {
- for (File dir : dirs) {
- try {
- if (!dir.exists() || !isFileInWorkingCopy(dir, handler, true)) {
- handler.checkoutOnlyTheDirectory(dir, null);
- }
- } catch (Exception eee) {
- log.warn(_("lutinvcs.error.checkout.dir", dir), eee);
- break;
- }
- }
- }
-
- /**
- * @param typeRepo the type of repo to used
- * @param remotePath the unclean remote path to use
- * @return the remote path from the old one according to given type repo
- */
- public static String getRemotePath(VCSTypeRepo typeRepo, String remotePath) {
- String result = cleanRemotePath(remotePath);
- switch (typeRepo) {
- case BRANCH:
- case TAG:
- result = remotePath + '/' + typeRepo.getPath();
- break;
- case HEAD:
- result = remotePath;
- break;
- }
- return result;
- }
-
- /**
- * @param typeRepo the type of repo to use
- * @param version the version to use
- * @return the remoteDatabase according to type of repo and version
- */
- public static String getRemoteDatabase(VCSTypeRepo typeRepo, String version) {
- String result = null;
- switch (typeRepo) {
- case BRANCH:
- case TAG:
- result = version;
- break;
- case HEAD:
- result = VCSTypeRepo.HEAD.getPath();
- break;
- }
- return result;
- }
-
- /**
- * to clean a remote path from typeRepo suffix.
- * <p/>
- * For example, having a url svn://XXX/trunk then remove /trunk.
- * <p/>
- * Or if having svn://XXX/branches/YYY then remove /branches/YYY
- * Or if having svn://XXX/tags/YYY then remove /tags/YYY
- *
- * @param remotePath the remote path to clean
- * @return the cleaned remote path
- */
- public static String cleanRemotePath(String remotePath) {
- int pos = remotePath.indexOf(VCSTypeRepo.BRANCH.getPath());
- if (pos > -1) {
- // found a branch
- remotePath = remotePath.substring(0, pos - 1);
- } else {
- pos = remotePath.indexOf(VCSTypeRepo.HEAD.getPath());
- if (pos > -1) {
- // found a branch
- remotePath = remotePath.substring(0, pos - 1);
- } else {
- pos = remotePath.indexOf(VCSTypeRepo.TAG.getPath());
- if (pos > -1) {
- // found a tag
- remotePath = remotePath.substring(0, pos - 1);
- } else {
- // remote path was clean
- }
- }
- }
- return remotePath;
- }
-
-}
\ No newline at end of file
1
0
r354 - trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:31:28 +0000 (Sat, 05 Apr 2008)
New Revision: 354
Added:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntryLocation.java
Log:
introduce VCSEntryLocation
Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntryLocation.java (from rev 345, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSAction.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntryLocation.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntryLocation.java 2008-04-05 20:31:28 UTC (rev 354)
@@ -0,0 +1,65 @@
+/* ##%
+* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
+* Benjamin Poussin, Tony Chemit
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*##%*/
+package org.codelutin.vcs;
+
+import static org.codelutin.i18n.I18n._;
+import static org.codelutin.i18n.I18n.n_;
+
+/**
+ * a VCSEntryLocation represents where a {@link VCSEntry} was found, should be :
+ * <p/>
+ * <ul>
+ * <li>{@link #ALL} : if entry is both on local and on remote</li>
+ * <li>{@link #LOCAL} : if entry is only on local </li>
+ * <li>{@link #REMOTE} : if entryis only on remote</li>
+ * <p/>
+ * </ul>
+ * VCSAction represents an action that can be realized on a file in working
+ * copy or on remote repository.
+ * <p/>
+ * Each <code>VCSAction</code> has 4 properties :
+ * <ul>
+ * <li>libelle : i18n to be used for this action</li>
+ * <li>visible : flag to say if action should be visible in ui</li>
+ * <li>backup : flag to say if this action need backup</li>
+ * <li>write : flag to say if this action need write access to repository</li>
+ * </ul>
+ *
+ * @author chemit
+ */
+(a)org.codelutin.i18n.I18nable
+public enum VCSEntryLocation {
+ ALL(n_("lutinvcs.location.all")),
+ LOCAL(n_("lutinvcs.location.local")),
+ REMOTE(n_("lutinvcs.location.remote")),
+ UNKNOW(n_("lutinvcs.location.unknown"));
+
+ /** libelle of location */
+ private final String libelle;
+
+
+ public String getLibelle() {
+ return _(libelle);
+ }
+
+ VCSEntryLocation(String libelle) {
+ this.libelle = libelle;
+ }
+}
\ No newline at end of file
1
0