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
r393 - in trunk/lutinvcs: lutinvcs-api/src/main/java/org/codelutin/vcs lutinvcs-api/src/main/java/org/codelutin/vcs/type lutinvcs-api/src/main/java/org/codelutin/vcs/util lutinvcs-core/src/main/java/org/codelutin/vcs lutinvcs-provider-svn/src/main/java/org/codelutin/vcs lutinvcs-ui/src/test/java/org/codelutin/vcs/ui
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 10:18:35 +0000 (Sun, 06 Apr 2008)
New Revision: 393
Removed:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSType.java
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java
Log:
remove VCSType as an Enum, type of provider is a simple String, to allow using new provier without any change in api code :)
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java 2008-04-06 10:11:00 UTC (rev 392)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java 2008-04-06 10:18:35 UTC (rev 393)
@@ -18,7 +18,6 @@
* ##% */
package org.codelutin.vcs;
-import org.codelutin.vcs.type.VCSType;
import org.codelutin.vcs.type.VCSTypeRepo;
import java.io.File;
@@ -33,7 +32,7 @@
public interface VCSConnexionConfig {
/** @return the type of vcs used */
- VCSType getType();
+ String getType();
/** @return <code>true</code> if ssh connexion is used */
boolean isUseSshConnexion();
@@ -81,7 +80,7 @@
void setRemotePath(String remotePath);
- void setType(VCSType type);
+ void setType(String type);
void setTypeRepo(VCSTypeRepo typeRepo);
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSType.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSType.java 2008-04-06 10:11:00 UTC (rev 392)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSType.java 2008-04-06 10:18:35 UTC (rev 393)
@@ -1,31 +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.type;
-
-/**
- * This type-safe class representing a type of vcs (SVN,CVS,...)
- *
- * @author chemit
- */
-public enum VCSType {
-
- CVS, SVN, MOCK
-
-}
Modified: 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 2008-04-06 10:11:00 UTC (rev 392)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java 2008-04-06 10:18:35 UTC (rev 393)
@@ -15,7 +15,6 @@
package org.codelutin.vcs.util;
import org.codelutin.vcs.VCSConnexionConfig;
-import org.codelutin.vcs.type.VCSType;
import org.codelutin.vcs.type.VCSTypeRepo;
import java.io.File;
@@ -23,7 +22,7 @@
/** @author chemit */
public class VCSConnexionConfigImpl implements VCSConnexionConfig {
- protected VCSType type;
+ protected String type;
protected boolean useSshConnexion;
protected String hostName;
protected File keyFile;
@@ -35,7 +34,7 @@
protected VCSTypeRepo typeRepo;
protected File localDatabasePath;
- public VCSType getType() {
+ public String getType() {
return type;
}
@@ -111,7 +110,7 @@
this.remotePath = remotePath;
}
- public void setType(VCSType type) {
+ public void setType(String type) {
this.type = type;
}
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 10:11:00 UTC (rev 392)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 10:18:35 UTC (rev 393)
@@ -22,10 +22,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.util.StringUtil;
+import org.codelutin.vcs.event.VCSConnexionEvent;
+import org.codelutin.vcs.event.VCSConnexionEventListener;
import org.codelutin.vcs.runner.VCSActionManager;
import org.codelutin.vcs.type.VCSConnexionMode;
-import org.codelutin.vcs.event.VCSConnexionEventListener;
-import org.codelutin.vcs.event.VCSConnexionEvent;
import java.util.ArrayList;
import java.util.List;
@@ -83,7 +83,7 @@
VCSProvider<?, ?> provider;
// obtain matching provider
- provider = factory.getProvider(config.getType().name().toUpperCase());
+ provider = factory.getProvider(config.getType().toUpperCase());
// delegate instanciation of connexion to provider
VCSConnexion connexion = provider.newConnection(mode, config);
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-06 10:11:00 UTC (rev 392)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-06 10:18:35 UTC (rev 393)
@@ -43,6 +43,7 @@
private static boolean libraryInit;
public SVNProvider() {
+
super("SVN", SVNHandler.class, SVNConnexion.class);
setupLibrary();
@@ -107,6 +108,8 @@
public static SVNRepository getAnonymousConnection(String url) throws VCSException {
+ setupLibrary();
+
SVNURL testRepositoryURL;
try {
testRepositoryURL = SVNURL.parseURIEncoded(url);
@@ -157,28 +160,10 @@
}
}
- public static void setupLibrary() {
- if (libraryInit) {
- return;
- }
- libraryInit = true;
- /*
- * For using over http:// and https://
- */
- DAVRepositoryFactory.setup();
-
- /*
- * For using over svn:// and svn+xxx://
- */
- SVNRepositoryFactoryImpl.setup();
-
- /*
- * For using over file:///
- */
- FSRepositoryFactory.setup();
- }
-
/**
+ * TODO This method is specifi to IsisFish, must be removed from here.
+ * TODO Implement a IsisSVNProvider ?
+ *
* @param typeRepo the type of repo we want to use if possible
* @param uncleanRemotePath remote path (could be unclean)
* @param databaseVersion the database version to use
@@ -231,4 +216,25 @@
log.info("required:" + typeRepo + " available:" + result);
return result;
}
+
+ static void setupLibrary() {
+ if (libraryInit) {
+ return;
+ }
+ libraryInit = true;
+ /*
+ * For using over http:// and https://
+ */
+ DAVRepositoryFactory.setup();
+
+ /*
+ * For using over svn:// and svn+xxx://
+ */
+ SVNRepositoryFactoryImpl.setup();
+
+ /*
+ * For using over file:///
+ */
+ FSRepositoryFactory.setup();
+ }
}
Modified: trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-06 10:11:00 UTC (rev 392)
+++ trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-06 10:18:35 UTC (rev 393)
@@ -16,12 +16,11 @@
import org.codelutin.i18n.I18n;
import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSFactory;
import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.type.VCSEntryLocation;
-import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.type.VCSState;
-import org.codelutin.vcs.VCSFactory;
-import org.codelutin.vcs.type.VCSType;
import org.codelutin.vcs.ui.model.SynchUIModel;
import org.codelutin.vcs.util.VCSConnexionConfigImpl;
import org.codelutin.vcs.util.VCSEntryImpl;
@@ -58,7 +57,7 @@
public static VCSConnexion initVCS(File root) {
VCSConnexionConfigImpl config = new VCSConnexionConfigImpl();
- config.setType(VCSType.MOCK);
+ config.setType("MOCK");
config.setLocalDatabasePath(root);
VCSConnexion connexion = VCSFactory.newConnexion(VCSConnexionMode.ANONYMOUS, config);
connexion.init(config);
1
0
r392 - in trunk/lutinvcs: lutinvcs-api/src/main/java/org/codelutin/vcs/util lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock lutinvcs-provider-svn/src/main/java/org/codelutin/vcs lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn lutinvcs-provider-svn/src/test/java/org/codelutin/vcs/impl/svn
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 10:11:00 +0000 (Sun, 06 Apr 2008)
New Revision: 392
Added:
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNEventLoggerHandler.java
Removed:
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHelper.java
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/AbstractVCSHandler.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java
trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java
trunk/lutinvcs/lutinvcs-provider-svn/src/test/java/org/codelutin/vcs/impl/svn/FindTypeRepoTest.java
Log:
remove SVNHelper (logic for connexion should be only in SVNConnexion) but for convience we put it in SVNProvider
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-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -39,7 +39,6 @@
/** @author chemit */
public abstract class AbstractVCSConnexion<H extends VCSHandler> implements VCSConnexion<H> {
- /** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(AbstractVCSConnexion.class);
protected File localRoot;
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-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -42,7 +42,6 @@
*/
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);
public static final String LOCAL_SEP = File.separator;
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-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -20,6 +20,8 @@
import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.VCSProvider;
import org.codelutin.vcs.type.VCSConnexionMode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* base implementation of provider.
@@ -28,6 +30,8 @@
*/
public class AbstractVCSProvider<C extends VCSConnexion, H extends VCSHandler<C>> implements VCSProvider<C, H> {
+ static protected final Log log = LogFactory.getLog(AbstractVCSProvider.class);
+
/** name of ne provider */
protected final String name;
@@ -67,7 +71,10 @@
}
try {
connexion = connexionImpl.getConstructor(VCSConnexionMode.class, handlerImpl).newInstance(mode, handler);
+
+ // always init connexion from his config
connexion.init(config);
+
return connexion;
} catch (Exception e) {
throw new RuntimeException(_("lutinvcs.error.provider.init.connexion", connexionImpl, this, e.getCause()));
Modified: trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java 2008-04-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -16,6 +16,7 @@
import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.type.VCSConnectionState;
import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
import org.netbeans.lib.cvsclient.CVSRoot;
@@ -35,6 +36,7 @@
public void init(VCSConnexionConfig config) {
//TODO
this.config = config;
+ this.state = VCSConnectionState.INIT;
}
public void testConnection() throws VCSException {
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -28,8 +28,8 @@
}
public void init(VCSConnexionConfig config) {
+ this.config = config;
state = VCSConnectionState.INIT;
- this.config = config;
}
public void testConnection() throws VCSException {
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -16,11 +16,23 @@
import org.codelutin.vcs.impl.svn.SVNConnexion;
import org.codelutin.vcs.impl.svn.SVNHandler;
+import org.codelutin.vcs.type.VCSTypeRepo;
+import org.codelutin.vcs.util.AbstractVCSHandler;
import org.codelutin.vcs.util.AbstractVCSProvider;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNNodeKind;
+import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
+import org.tmatesoft.svn.core.io.SVNRepository;
+import org.tmatesoft.svn.core.wc.ISVNOptions;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+import java.util.Arrays;
+
/**
* SVN Provider
*
@@ -28,17 +40,195 @@
*/
public class SVNProvider extends AbstractVCSProvider<SVNConnexion, SVNHandler> {
+ private static boolean libraryInit;
+
public SVNProvider() {
super("SVN", SVNHandler.class, SVNConnexion.class);
- // For using over http:// and https://
+ setupLibrary();
+ }
+
+ /**
+ * Test if a anonymous svn connection can be openned.
+ *
+ * @param url the svn url to test
+ * @return <code>true</code> if connection is ok,<code>false</code> otherwise.
+ * @throws org.codelutin.vcs.VCSException if could not compute the SVNURL
+ */
+ public boolean testAnonymousConnection(String url) throws VCSException {
+ boolean result = true;
+
+ SVNRepository repository = getAnonymousConnection(url);
+ try {
+ repository.testConnection();
+ } catch (SVNException e) {
+ result = false;
+ } finally {
+ if (repository != null) {
+ try {
+ repository.closeSession();
+ } catch (Exception e) {
+ log.warn(e);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Test if a anonymous svn connection can be openned.
+ *
+ * @param url the svn url to test
+ * @param username user name
+ * @param privateKeyFilePath the file to used as protected key file
+ * @param passphrase passphrase to use
+ * @return <code>true</code> if connection is ok,<code>false</code> otherwise.
+ * @throws org.codelutin.vcs.VCSException if could not compute the SVNURL
+ */
+ public static boolean testSSHConnection(String url, String username, String privateKeyFilePath, char[] passphrase) throws VCSException {
+ boolean result = true;
+
+ SVNRepository repository = getSSHConnection(url, username, privateKeyFilePath, passphrase);
+ try {
+ repository.testConnection();
+ } catch (SVNException e) {
+ result = false;
+ } finally {
+ if (repository != null) {
+ try {
+ repository.closeSession();
+ } catch (Exception e) {
+ log.warn(e);
+ }
+ }
+ }
+ return result;
+ }
+
+ public static SVNRepository getAnonymousConnection(String url) throws VCSException {
+
+ SVNURL testRepositoryURL;
+ try {
+ testRepositoryURL = SVNURL.parseURIEncoded(url);
+ } catch (SVNException e) {
+ throw new VCSException(e);
+ }
+ SVNRepository repository;
+ try {
+ ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
+ SVNClientManager manager = SVNClientManager.newInstance(options, "anonymous", "anonymous");
+ repository = manager.createRepository(testRepositoryURL, false);
+ repository.testConnection();
+ return repository;
+ } catch (SVNException e) {
+ throw new VCSException(e);
+ }
+ }
+
+ public static SVNRepository getSSHConnection(String url, String username, String privateKeyFilePath, char[] passphrase) throws VCSException {
+
+ setupLibrary();
+
+ SVNURL testRepositoryURL;
+ try {
+ testRepositoryURL = SVNURL.parseURIEncoded(url);
+ } catch (SVNException e) {
+ throw new VCSException(e);
+ }
+ SVNRepository repository;
+ try {
+ ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
+ System.setProperty("svnkit.ssh2.key", privateKeyFilePath);
+ System.setProperty("svnkit.ssh2.username", username);
+ if (passphrase != null && passphrase.length > 0) {
+ System.setProperty("svnkit.ssh2.passphrase", Arrays.toString(passphrase));
+ }
+ //System.setProperty("svnkit.ssh2.passphrase", "");
+ //System.setProperty("svnkit.ssh2.password", "");
+ //System.setProperty("svnkit.ssh2.port", "22");
+
+ // instanciate svn client manager
+ SVNClientManager manager = SVNClientManager.newInstance(options);
+ repository = manager.createRepository(testRepositoryURL, false);
+ repository.testConnection();
+ return repository;
+ } catch (SVNException e) {
+ throw new VCSException(e);
+ }
+ }
+
+ public static void setupLibrary() {
+ if (libraryInit) {
+ return;
+ }
+ libraryInit = true;
+ /*
+ * For using over http:// and https://
+ */
DAVRepositoryFactory.setup();
- // For using over svn:// and svn+xxx://
+ /*
+ * For using over svn:// and svn+xxx://
+ */
SVNRepositoryFactoryImpl.setup();
- // For using over file:///
+ /*
+ * For using over file:///
+ */
FSRepositoryFactory.setup();
}
+ /**
+ * @param typeRepo the type of repo we want to use if possible
+ * @param uncleanRemotePath remote path (could be unclean)
+ * @param databaseVersion the database version to use
+ * @param hostName the hostname to use
+ * @return the typeRepo to use
+ * @throws org.codelutin.vcs.VCSException if could not compute SVNURL to tests
+ */
+ public static VCSTypeRepo findTypeRepo(VCSTypeRepo typeRepo,
+ String uncleanRemotePath,
+ String databaseVersion,
+ String hostName) throws VCSException {
+
+
+ VCSTypeRepo result;
+
+ String remotePath = AbstractVCSHandler.getRemotePath(typeRepo, uncleanRemotePath);
+ String remoteDatabase = AbstractVCSHandler.getRemoteDatabase(typeRepo, databaseVersion);
+ StringBuilder sb = new StringBuilder("svn://").append(hostName);
+ sb.append("/").append(remotePath);
+ String url = sb.toString();
+ log.info("try svn url " + url + " (" + remoteDatabase + ")");
+
+ SVNRepository repository;
+ try {
+ repository = getAnonymousConnection(url);
+ } catch (VCSException e) {
+ log.warn(e);
+ return null;
+ }
+
+ try {
+ SVNNodeKind kind = repository.checkPath(remoteDatabase, SVNRevision.HEAD.getNumber());
+ log.info("kind node found for " + remoteDatabase + " : " + kind);
+ // typeRepo type is ok, use it
+ if (kind == SVNNodeKind.NONE) {
+ // could not found the remote database
+ if (typeRepo == VCSTypeRepo.HEAD) {
+ // this is a fatal error since head always exists
+ throw new VCSRuntimeException("could not found svn trunk " + url + " (" + repository.getLocation() + ")");
+ } else {
+ result = VCSTypeRepo.HEAD;
+ }
+ } else {
+ // was found, so keep it
+ result = typeRepo;
+ }
+ } catch (SVNException e) {
+ throw new VCSRuntimeException(e);
+ }
+ log.info("required:" + typeRepo + " available:" + result);
+ return result;
+ }
}
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java 2008-04-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -18,6 +18,7 @@
import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSRuntimeException;
+import org.codelutin.vcs.SVNProvider;
import org.codelutin.vcs.type.VCSConnectionState;
import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
@@ -90,19 +91,19 @@
// add our svn event logger TODO Remake this logger or use the
// DebugLog from svnkit ?
- ourClientManager.setEventHandler(new SVNHelper.SVNEventLoggerHandler());
+ ourClientManager.setEventHandler(new SVNEventLoggerHandler());
+ this.state = VCSConnectionState.INIT;
} catch (SVNException e) {
// TODO I18N
+ this.state = VCSConnectionState.ERROR;
+
throw new VCSRuntimeException("could not compute repository url ", e);
}
}
@Override
public void close() throws IllegalStateException {
- checkInit();
- if (!isOpen()) {
- return;
- }
+ checkOpen();
//TODO to be done
log.info(this);
}
@@ -130,7 +131,7 @@
File path = getConfig().getKeyFile();
try {
String passphrase = getConfig().getPassphrase();
- SVNHelper.testSSHConnection(repositoryURL.toString(), getConfig().getUserName(), path == null ? null : path.getAbsolutePath(), passphrase == null ? new char[0] : passphrase.toCharArray());
+ SVNProvider.testSSHConnection(repositoryURL.toString(), getConfig().getUserName(), path == null ? null : path.getAbsolutePath(), passphrase == null ? new char[0] : passphrase.toCharArray());
return;
} catch (VCSException e) {
log.warn(_("lutinvcs.error.vcs.no.ssh.connection", getConfig().getUserName(), path));
@@ -139,7 +140,7 @@
// do not use ssh connection
getConfig().setUseSshConnexion(false);
// try to test with a anonymous connection
- SVNHelper.testAnonymousConnection(repositoryURL.toString());
+ SVNProvider.testAnonymousConnection(repositoryURL.toString());
}
@@ -161,4 +162,5 @@
return repositoryURL;
}
+
}
Added: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNEventLoggerHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNEventLoggerHandler.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNEventLoggerHandler.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -0,0 +1,239 @@
+/**
+ * # #% 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.impl.svn;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.SVNCancelException;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.wc.ISVNEventHandler;
+import org.tmatesoft.svn.core.wc.SVNEvent;
+import org.tmatesoft.svn.core.wc.SVNEventAction;
+import org.tmatesoft.svn.core.wc.SVNStatusType;
+
+/**
+ * A svn logger
+ *
+ * @author chemit
+ */
+public class SVNEventLoggerHandler implements ISVNEventHandler {
+
+ static private Log log = LogFactory.getLog(SVNEventLoggerHandler.class);
+
+ /*
+ * progress is currently reserved for future purposes and now is always
+ * ISVNEventHandler.UNKNOWN
+ */
+
+ public boolean handleEventWC(SVNEvent event, double progress) {
+ /*
+ * Gets the current action. An action is represented by
+ * SVNEventAction.
+ */
+ SVNEventAction action = event.getAction();
+ String trace = null;
+ if (action == SVNEventAction.ADD) {
+ /*
+ * The item is scheduled for addition.
+ */
+ trace = "A ";
+ } else if (action == SVNEventAction.COPY) {
+ /*
+ * The item is scheduled for addition with history (copied, in
+ * other words).
+ */
+ trace = "A + ";
+ } else if (action == SVNEventAction.REVERT) {
+ /*
+ * The item is scheduled for revertion.
+ */
+ trace = "R ";
+ } else if (action == SVNEventAction.DELETE) {
+ /*
+ * The item is scheduled for deletion.
+ */
+ trace = "D ";
+ } else if (action == SVNEventAction.LOCKED) {
+ /*
+ * The item is locked.
+ */
+ trace = "L ";
+ } else if (action == SVNEventAction.LOCK_FAILED) {
+ /*
+ * Locking operation failed.
+ */
+ trace = "failed to lock ";
+ }
+
+ if (trace != null) {
+ logInfo(trace, event);
+ return true;
+ }
+
+ return false;
+
+ }
+
+ public boolean handleEventCommit(SVNEvent event, double progress) {
+ /*
+ * Gets the current action. An action is represented by
+ * SVNEventAction. In case of a commit an action can be determined
+ * via comparing SVNEvent.getAction() with
+ * SVNEventAction.COMMIT_-like constants.
+ */
+ SVNEventAction action = event.getAction();
+ String trace = null;
+ if (action == SVNEventAction.COMMIT_COMPLETED) {
+ trace = "Complete ";
+ } else if (action == SVNEventAction.COMMIT_MODIFIED) {
+ trace = "Sending ";
+ } else if (action == SVNEventAction.COMMIT_DELETED) {
+ trace = "Deleting ";
+ } else if (action == SVNEventAction.COMMIT_REPLACED) {
+ trace = "Replacing ";
+ } else if (action == SVNEventAction.COMMIT_DELTA_SENT) {
+ trace = "Transmitting file data....";
+ } else if (action == SVNEventAction.COMMIT_ADDED) {
+ /*
+ * Gets the MIME-type of the item.
+ */
+ String mimeType = event.getMimeType();
+ if (SVNProperty.isBinaryMimeType(mimeType)) {
+ /*
+ * If the item is a binary file
+ */
+ trace = "Adding (bin) ";
+ } else {
+ trace = "Adding ";
+ }
+ }
+
+ if (trace != null) {
+ logInfo(trace, event);
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean handleEventUpdate(SVNEvent event, double progress) {
+ /*
+ * Gets the current action. An action is represented by
+ * SVNEventAction. In case of an update an action can be determined
+ * via comparing SVNEvent.getAction() and
+ * SVNEventAction.UPDATE_-like constants.
+ */
+ SVNEventAction action = event.getAction();
+ String pathChangeType = null;
+ String trace = null;
+ if (action == SVNEventAction.UPDATE_ADD) {
+ /*
+ * the item was added
+ */
+ pathChangeType = "A";
+ } else if (action == SVNEventAction.UPDATE_DELETE) {
+ /*
+ * the item was deleted
+ */
+ pathChangeType = "D";
+ } else if (action == SVNEventAction.UPDATE_UPDATE) {
+
+ /*
+ * Find out in details what state the item is (after having been
+ * updated).
+ *
+ * Gets the status of file/directory item contents. It is
+ * SVNStatusType who contains information on the state of an
+ * item.
+ */
+ SVNStatusType contentsStatus = event.getContentsStatus();
+ if (contentsStatus == SVNStatusType.CHANGED) {
+ /*
+ * the item was modified in the repository (got the changes
+ * from the repository
+ */
+ pathChangeType = "U";
+ } else if (contentsStatus == SVNStatusType.CONFLICTED) {
+ /*
+ * The file item is in a state of Conflict. That is, changes
+ * received from the repository during an update, overlap
+ * with local changes the user has in his working copy.
+ */
+ pathChangeType = "C";
+ } else if (contentsStatus == SVNStatusType.MERGED) {
+ /*
+ * The file item was merGed (those changes that came from
+ * the repository did not overlap local changes and were
+ * merged into the file).
+ */
+ pathChangeType = "G";
+ }
+
+ } else if (action == SVNEventAction.UPDATE_EXTERNAL) {
+ /* for externals definitions */
+ trace = "Fetching external item into '"
+ + event.getFile().getAbsolutePath() + "'";
+ trace += "\nExternal at revision " + event.getRevision();
+
+ } else if (action == SVNEventAction.UPDATE_COMPLETED) {
+ /*
+ * Updating the working copy is completed. Prints out the
+ * revision.
+ */
+ trace = "At revision " + event.getRevision();
+ }
+
+ if (trace != null) {
+ logInfo(trace, event);
+ return true;
+ }
+
+ if (pathChangeType != null) {
+ logInfo(trace, event);
+ return true;
+
+ }
+ return false;
+ }
+
+ protected void logInfo(String trace, SVNEvent event) {
+ final String anObject = event.getAction() + "";
+ if (!"update_none".equals(anObject)
+ && !"status_completed".equals(anObject))
+ log.debug("-- svn log on file [" + event.getPath()
+ + "] action [" + event.getAction() + "] : " + trace);
+ }
+
+ public void handleEvent(SVNEvent event, double progress)
+ throws SVNException {
+ /*
+ * Gets the current action. An action is represented by
+ * SVNEventAction.
+ */
+ if (handleEventWC(event, progress))
+ return;
+ if (handleEventCommit(event, progress))
+ return;
+ if (handleEventUpdate(event, progress))
+ return;
+
+ logInfo("unkown event ", event);
+ }
+
+ public void checkCancelled() throws SVNCancelException {
+
+ }
+}
Deleted: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHelper.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHelper.java 2008-04-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHelper.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -1,461 +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.impl.svn;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.vcs.VCSException;
-import org.codelutin.vcs.util.AbstractVCSHandler;
-import org.codelutin.vcs.VCSRuntimeException;
-import org.codelutin.vcs.type.VCSTypeRepo;
-import org.tmatesoft.svn.core.SVNCancelException;
-import org.tmatesoft.svn.core.SVNException;
-import org.tmatesoft.svn.core.SVNNodeKind;
-import org.tmatesoft.svn.core.SVNProperty;
-import org.tmatesoft.svn.core.SVNURL;
-import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
-import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
-import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
-import org.tmatesoft.svn.core.io.SVNRepository;
-import org.tmatesoft.svn.core.wc.ISVNEventHandler;
-import org.tmatesoft.svn.core.wc.ISVNOptions;
-import org.tmatesoft.svn.core.wc.SVNClientManager;
-import org.tmatesoft.svn.core.wc.SVNEvent;
-import org.tmatesoft.svn.core.wc.SVNEventAction;
-import org.tmatesoft.svn.core.wc.SVNRevision;
-import org.tmatesoft.svn.core.wc.SVNStatusType;
-import org.tmatesoft.svn.core.wc.SVNWCUtil;
-
-import java.util.Arrays;
-
-/**
- * A helper for SVN to test connection, find a svn url...
- *
- * @author chemit
- */
-
-public class SVNHelper {
- public static boolean libraryInit = false;
-
- static protected final Log log = LogFactory.getLog(SVNHelper.class);
-
- /**
- * Test if a anonymous svn connection can be openned.
- *
- * @param url the svn url to test
- * @return <code>true</code> if connection is ok,<code>false</code> otherwise.
- * @throws VCSException if could not compute the SVNURL
- */
- public static boolean testAnonymousConnection(String url) throws VCSException {
- boolean result = true;
-
- SVNRepository repository = getAnonymousConnection(url);
- try {
- repository.testConnection();
- } catch (SVNException e) {
- result = false;
- } finally {
- if (repository != null) {
- try {
- repository.closeSession();
- } catch (Exception e) {
- log.warn(e);
- }
- }
- }
- return result;
- }
-
- /**
- * Test if a anonymous svn connection can be openned.
- *
- * @param url the svn url to test
- * @param username user name
- * @param privateKeyFilePath the file to used as private key file
- * @param passphrase passphrase to use
- * @return <code>true</code> if connection is ok,<code>false</code> otherwise.
- * @throws VCSException if could not compute the SVNURL
- */
- public static boolean testSSHConnection(String url, String username, String privateKeyFilePath, char[] passphrase) throws VCSException {
- boolean result = true;
-
- SVNRepository repository = getSSHConnection(url, username, privateKeyFilePath, passphrase);
- try {
- repository.testConnection();
- } catch (SVNException e) {
- result = false;
- } finally {
- if (repository != null) {
- try {
- repository.closeSession();
- } catch (Exception e) {
- log.warn(e);
- }
- }
- }
- return result;
- }
-
- public static SVNRepository getAnonymousConnection(String url) throws VCSException {
-
- setupLibrary();
-
- SVNURL testRepositoryURL;
- try {
- testRepositoryURL = SVNURL.parseURIEncoded(url);
- } catch (SVNException e) {
- throw new VCSException(e);
- }
- SVNRepository repository;
- try {
- ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
- SVNClientManager manager = SVNClientManager.newInstance(options, "anonymous", "anonymous");
- repository = manager.createRepository(testRepositoryURL, false);
- repository.testConnection();
- return repository;
- } catch (SVNException e) {
- throw new VCSException(e);
- }
- }
-
- public static SVNRepository getSSHConnection(String url, String username, String privateKeyFilePath, char[] passphrase) throws VCSException {
-
- setupLibrary();
-
- SVNURL testRepositoryURL;
- try {
- testRepositoryURL = SVNURL.parseURIEncoded(url);
- } catch (SVNException e) {
- throw new VCSException(e);
- }
- SVNRepository repository;
- try {
- ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
- System.setProperty("svnkit.ssh2.key", privateKeyFilePath);
- System.setProperty("svnkit.ssh2.username", username);
- if (passphrase != null && passphrase.length > 0) {
- System.setProperty("svnkit.ssh2.passphrase", Arrays.toString(passphrase));
- }
- //System.setProperty("svnkit.ssh2.passphrase", "");
- //System.setProperty("svnkit.ssh2.password", "");
- //System.setProperty("svnkit.ssh2.port", "22");
-
- // instanciate svn client manager
- SVNClientManager manager = SVNClientManager.newInstance(options);
- repository = manager.createRepository(testRepositoryURL, false);
- repository.testConnection();
- return repository;
- } catch (SVNException e) {
- throw new VCSException(e);
- }
- }
-
- /**
- * @param typeRepo the type of repo we want to use if possible
- * @param uncleanRemotePath remote path (could be unclean)
- * @param databaseVersion the database version to use
- * @param hostName the hostname to use
- * @return the typeRepo to use
- * @throws VCSException if could not compute SVNURL to tests
- */
- public static VCSTypeRepo findTypeRepo(VCSTypeRepo typeRepo,
- String uncleanRemotePath,
- String databaseVersion,
- String hostName) throws VCSException {
-
-
- VCSTypeRepo result;
-
- String remotePath = AbstractVCSHandler.getRemotePath(typeRepo, uncleanRemotePath);
- String remoteDatabase = AbstractVCSHandler.getRemoteDatabase(typeRepo, databaseVersion);
- StringBuilder sb = new StringBuilder("svn://").append(hostName);
- sb.append("/").append(remotePath);
- String url = sb.toString();
- log.info("try svn url " + url + " (" + remoteDatabase + ")");
-
- SVNRepository repository;
- try {
- repository = getAnonymousConnection(url);
- } catch (VCSException e) {
- log.warn(e);
- return null;
- }
-
- try {
- SVNNodeKind kind = repository.checkPath(remoteDatabase, SVNRevision.HEAD.getNumber());
- log.info("kind node found for " + remoteDatabase + " : " + kind);
- // typeRepo type is ok, use it
- if (kind == SVNNodeKind.NONE) {
- // could not found the remote database
- if (typeRepo == VCSTypeRepo.HEAD) {
- // this is a fatal error since head always exists
- throw new VCSRuntimeException("could not found svn trunk " + url + " (" + repository.getLocation() + ")");
- } else {
- result = VCSTypeRepo.HEAD;
- }
- } else {
- // was found, so keep it
- result = typeRepo;
- }
- } catch (SVNException e) {
- throw new VCSRuntimeException(e);
- }
- log.info("required:" + typeRepo + " available:" + result);
- return result;
- }/*
- * Initializes the library to work with a repository via different
- * protocols.
- */
-
- public static void setupLibrary() {
- if (libraryInit) {
- return;
- }
- libraryInit = true;
- /*
- * For using over http:// and https://
- */
- DAVRepositoryFactory.setup();
-
- /*
- * For using over svn:// and svn+xxx://
- */
- SVNRepositoryFactoryImpl.setup();
-
- /*
- * For using over file:///
- */
- FSRepositoryFactory.setup();
- }
-
- /**
- * A svn logger
- *
- * @author chemit
- */
- public static class SVNEventLoggerHandler implements ISVNEventHandler {
-
- static private Log log = LogFactory.getLog(SVNEventLoggerHandler.class);
-
- /*
- * progress is currently reserved for future purposes and now is always
- * ISVNEventHandler.UNKNOWN
- */
-
- public boolean handleEventWC(SVNEvent event, double progress) {
- /*
- * Gets the current action. An action is represented by
- * SVNEventAction.
- */
- SVNEventAction action = event.getAction();
- String trace = null;
- if (action == SVNEventAction.ADD) {
- /*
- * The item is scheduled for addition.
- */
- trace = "A ";
- } else if (action == SVNEventAction.COPY) {
- /*
- * The item is scheduled for addition with history (copied, in
- * other words).
- */
- trace = "A + ";
- } else if (action == SVNEventAction.REVERT) {
- /*
- * The item is scheduled for revertion.
- */
- trace = "R ";
- } else if (action == SVNEventAction.DELETE) {
- /*
- * The item is scheduled for deletion.
- */
- trace = "D ";
- } else if (action == SVNEventAction.LOCKED) {
- /*
- * The item is locked.
- */
- trace = "L ";
- } else if (action == SVNEventAction.LOCK_FAILED) {
- /*
- * Locking operation failed.
- */
- trace = "failed to lock ";
- }
-
- if (trace != null) {
- logInfo(trace, event);
- return true;
- }
-
- return false;
-
- }
-
- public boolean handleEventCommit(SVNEvent event, double progress) {
- /*
- * Gets the current action. An action is represented by
- * SVNEventAction. In case of a commit an action can be determined
- * via comparing SVNEvent.getAction() with
- * SVNEventAction.COMMIT_-like constants.
- */
- SVNEventAction action = event.getAction();
- String trace = null;
- if (action == SVNEventAction.COMMIT_COMPLETED) {
- trace = "Complete ";
- } else if (action == SVNEventAction.COMMIT_MODIFIED) {
- trace = "Sending ";
- } else if (action == SVNEventAction.COMMIT_DELETED) {
- trace = "Deleting ";
- } else if (action == SVNEventAction.COMMIT_REPLACED) {
- trace = "Replacing ";
- } else if (action == SVNEventAction.COMMIT_DELTA_SENT) {
- trace = "Transmitting file data....";
- } else if (action == SVNEventAction.COMMIT_ADDED) {
- /*
- * Gets the MIME-type of the item.
- */
- String mimeType = event.getMimeType();
- if (SVNProperty.isBinaryMimeType(mimeType)) {
- /*
- * If the item is a binary file
- */
- trace = "Adding (bin) ";
- } else {
- trace = "Adding ";
- }
- }
-
- if (trace != null) {
- logInfo(trace, event);
- return true;
- }
-
- return false;
- }
-
- public boolean handleEventUpdate(SVNEvent event, double progress) {
- /*
- * Gets the current action. An action is represented by
- * SVNEventAction. In case of an update an action can be determined
- * via comparing SVNEvent.getAction() and
- * SVNEventAction.UPDATE_-like constants.
- */
- SVNEventAction action = event.getAction();
- String pathChangeType = null;
- String trace = null;
- if (action == SVNEventAction.UPDATE_ADD) {
- /*
- * the item was added
- */
- pathChangeType = "A";
- } else if (action == SVNEventAction.UPDATE_DELETE) {
- /*
- * the item was deleted
- */
- pathChangeType = "D";
- } else if (action == SVNEventAction.UPDATE_UPDATE) {
-
- /*
- * Find out in details what state the item is (after having been
- * updated).
- *
- * Gets the status of file/directory item contents. It is
- * SVNStatusType who contains information on the state of an
- * item.
- */
- SVNStatusType contentsStatus = event.getContentsStatus();
- if (contentsStatus == org.tmatesoft.svn.core.wc.SVNStatusType.CHANGED) {
- /*
- * the item was modified in the repository (got the changes
- * from the repository
- */
- pathChangeType = "U";
- } else if (contentsStatus == org.tmatesoft.svn.core.wc.SVNStatusType.CONFLICTED) {
- /*
- * The file item is in a state of Conflict. That is, changes
- * received from the repository during an update, overlap
- * with local changes the user has in his working copy.
- */
- pathChangeType = "C";
- } else if (contentsStatus == org.tmatesoft.svn.core.wc.SVNStatusType.MERGED) {
- /*
- * The file item was merGed (those changes that came from
- * the repository did not overlap local changes and were
- * merged into the file).
- */
- pathChangeType = "G";
- }
-
- } else if (action == SVNEventAction.UPDATE_EXTERNAL) {
- /* for externals definitions */
- trace = "Fetching external item into '"
- + event.getFile().getAbsolutePath() + "'";
- trace += "\nExternal at revision " + event.getRevision();
-
- } else if (action == SVNEventAction.UPDATE_COMPLETED) {
- /*
- * Updating the working copy is completed. Prints out the
- * revision.
- */
- trace = "At revision " + event.getRevision();
- }
-
- if (trace != null) {
- logInfo(trace, event);
- return true;
- }
-
- if (pathChangeType != null) {
- logInfo(trace, event);
- return true;
-
- }
- return false;
- }
-
- protected void logInfo(String trace, SVNEvent event) {
- final String anObject = event.getAction() + "";
- if (!"update_none".equals(anObject)
- && !"status_completed".equals(anObject))
- log.debug("-- svn log on file [" + event.getPath()
- + "] action [" + event.getAction() + "] : " + trace);
- }
-
- public void handleEvent(SVNEvent event, double progress)
- throws SVNException {
- /*
- * Gets the current action. An action is represented by
- * SVNEventAction.
- */
- if (handleEventWC(event, progress))
- return;
- if (handleEventCommit(event, progress))
- return;
- if (handleEventUpdate(event, progress))
- return;
-
- logInfo("unkown event ", event);
- }
-
- public void checkCancelled() throws SVNCancelException {
-
- }
- }
-}
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/test/java/org/codelutin/vcs/impl/svn/FindTypeRepoTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/test/java/org/codelutin/vcs/impl/svn/FindTypeRepoTest.java 2008-04-06 10:00:07 UTC (rev 391)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/test/java/org/codelutin/vcs/impl/svn/FindTypeRepoTest.java 2008-04-06 10:11:00 UTC (rev 392)
@@ -2,6 +2,7 @@
import junit.framework.TestCase;
import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.SVNProvider;
import org.codelutin.vcs.type.VCSTypeRepo;
/**
@@ -23,7 +24,7 @@
vcsTypeRepo = VCSTypeRepo.BRANCH;
path = "svnroot/isis-fish-data";
version = "3.1.0";
- result = SVNHelper.findTypeRepo(vcsTypeRepo, path, version, hostname);
+ result = SVNProvider.findTypeRepo(vcsTypeRepo, path, version, hostname);
assertEquals(VCSTypeRepo.BRANCH, result);
}
@@ -31,11 +32,11 @@
vcsTypeRepo = VCSTypeRepo.BRANCH;
version = "3.0.0";
path = "svnroot/isis-fish-data";
- result = SVNHelper.findTypeRepo(vcsTypeRepo, path, version, hostname);
+ result = SVNProvider.findTypeRepo(vcsTypeRepo, path, version, hostname);
assertEquals(VCSTypeRepo.HEAD, result);
try {
path = "svnroot/sis-fish-data";
- result = SVNHelper.findTypeRepo(vcsTypeRepo, path, version, hostname);
+ result = SVNProvider.findTypeRepo(vcsTypeRepo, path, version, hostname);
fail();
} catch (Exception e) {
assertTrue(true);
@@ -46,7 +47,7 @@
vcsTypeRepo = VCSTypeRepo.HEAD;
path = "svnroot/isis-fish-data";
version = "3.0.0";
- result = SVNHelper.findTypeRepo(vcsTypeRepo, path, version, hostname);
+ result = SVNProvider.findTypeRepo(vcsTypeRepo, path, version, hostname);
assertEquals(VCSTypeRepo.HEAD, result);
}
@@ -55,7 +56,7 @@
path = "svnroot/sis-fish-data";
version = "3.0.0";
try {
- result = SVNHelper.findTypeRepo(vcsTypeRepo, path, version, hostname);
+ result = SVNProvider.findTypeRepo(vcsTypeRepo, path, version, hostname);
fail();
} catch (Exception e) {
assertTrue(true);
1
0
r391 - in trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs: type util
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 10:00:07 +0000 (Sun, 06 Apr 2008)
New Revision: 391
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java
Log:
use UNDEFINED state, instead of null state to test if connexion was init
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java 2008-04-06 09:57:57 UTC (rev 390)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java 2008-04-06 10:00:07 UTC (rev 391)
@@ -31,7 +31,10 @@
/** connexion was not init */
UNDEFINED,
- /** connexion was init, but not opened (default state after instanciate a new connexion from {@link VCSProvider#newConnection(VCSConnexionMode, VCSConnexionConfig)} */
+ /**
+ * connexion was init, but not opened (default state after instanciate a new connexion from
+ * {@link VCSProvider#newConnection(VCSConnexionMode, VCSConnexionConfig)}
+ */
INIT,
/** connexion was successfull opened, via {@link VCSConnexion#open()} */
OPEN,
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-06 09:57:57 UTC (rev 390)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-06 10:00:07 UTC (rev 391)
@@ -56,6 +56,8 @@
this.mode = mode;
this.handler = handler;
this.handler.setConnexion(this);
+ // by default, state is undefined before init
+ state = VCSConnectionState.UNDEFINED;
}
public H getHandler() throws IllegalStateException {
@@ -259,7 +261,7 @@
}
protected void checkInit() throws IllegalStateException {
- if (state == null) {
+ if (state == VCSConnectionState.UNDEFINED) {
throw new IllegalStateException(_("lutinvcs.error.connexion.noinit", this));
}
}
1
0
r390 - in trunk/lutinvcs: lutinvcs-api/src/main/java/org/codelutin/vcs/event lutinvcs-api/src/main/java/org/codelutin/vcs/type lutinvcs-api/src/main/java/org/codelutin/vcs/util lutinvcs-core/src/main/java/org/codelutin/vcs lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 09:57:57 +0000 (Sun, 06 Apr 2008)
New Revision: 390
Added:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java
Removed:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/ConnectionState.java
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java
Log:
introduce VCSConnexionState instead of ConnexionState
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java 2008-04-06 09:49:11 UTC (rev 389)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -15,26 +15,21 @@
package org.codelutin.vcs.event;
import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.type.VCSConnectionState;
import java.util.EventObject;
/**
- * Events to be used while {@link org.codelutin.vcs.VCSHandler} life cycle.
+ * Events to be used while {@link VCSConnexion} 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;
+ protected VCSConnectionState state;
- public enum Type {
- OPEN, CLOSE
- }
-
/**
* Constructs a prototypical Event.
*
@@ -42,7 +37,7 @@
* @param type type of event
* @throws IllegalArgumentException if source is null.
*/
- public VCSConnexionEvent(VCSConnexion source, Type type) {
+ public VCSConnexionEvent(VCSConnexion source, VCSConnectionState type) {
super(source);
this.state = type;
}
@@ -52,7 +47,7 @@
return (VCSConnexion) super.getSource();
}
- public Type getState() {
+ public VCSConnectionState getState() {
return state;
}
}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java 2008-04-06 09:49:11 UTC (rev 389)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -26,13 +26,13 @@
*
* @param event current event
*/
- public void open(VCSConnexionEvent event);
+ public void onConnexionOpened(VCSConnexionEvent event);
/**
* call when vcs connexion was closed
*
* @param event current event
*/
- public void close(VCSConnexionEvent event);
+ public void onConnexionClosed(VCSConnexionEvent event);
}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/ConnectionState.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/ConnectionState.java 2008-04-06 09:49:11 UTC (rev 389)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/ConnectionState.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -1,37 +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.type;
-
-/**
- * Une enumeration pour definir l'�tat du connexion � un serveur vcs.
- *
- * @author chemit
- */
-public enum ConnectionState {
- /** lorsque la connexion a �t� initialis�e (valid�e) mais pas ouverte */
- INIT,
- /** lorsque la connexion n'a pas encore initialis�e */
- UNDEFINED,
- /** lorsque la connexion est ok, mais que l'on est pas connect� */
- OFF_LINE,
- /** lorsque la connexion est �tablie avec succes */
- ON_LINE,
- /** lorsque la connexion a tent�e de s'initialiser sans succes */
- ERROR
-}
Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java (from rev 375, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/ConnectionState.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/type/VCSConnectionState.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -0,0 +1,43 @@
+/*
+* \#\#% 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.type;
+
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSProvider;
+
+/**
+ * All states of a {@link VCSConnexion}.
+ *
+ * @author chemit
+ */
+public enum VCSConnectionState {
+
+ /** connexion was not init */
+ UNDEFINED,
+ /** connexion was init, but not opened (default state after instanciate a new connexion from {@link VCSProvider#newConnection(VCSConnexionMode, VCSConnexionConfig)} */
+ INIT,
+ /** connexion was successfull opened, via {@link VCSConnexion#open()} */
+ OPEN,
+ /** connexion was successfull opened, via {@link VCSConnexion#close()} */
+ CLOSE,
+
+ /** connexion was not successfull opened, via {@link VCSConnexion#open()} */
+ ERROR
+}
\ No newline at end of file
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-06 09:49:11 UTC (rev 389)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -20,12 +20,11 @@
import org.codelutin.util.ListenerSet;
import org.codelutin.vcs.VCSConnexion;
import org.codelutin.vcs.VCSConnexionConfig;
-import org.codelutin.vcs.event.VCSConnexionEvent;
-import org.codelutin.vcs.event.VCSConnexionEvent.Type;
-import org.codelutin.vcs.event.VCSConnexionEventListener;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.type.ConnectionState;
+import org.codelutin.vcs.event.VCSConnexionEvent;
+import org.codelutin.vcs.event.VCSConnexionEventListener;
+import org.codelutin.vcs.type.VCSConnectionState;
import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.type.VCSState;
@@ -46,7 +45,7 @@
protected File localRoot;
protected URI remoteRoot;
protected VCSConnexionMode mode;
- protected ConnectionState state;
+ protected VCSConnectionState state;
protected VCSConnexionConfig config;
protected H handler;
@@ -84,17 +83,17 @@
public boolean isOpen() throws IllegalStateException {
checkInit();
- return !hasFailed() && state == ConnectionState.ON_LINE;
+ return !hasFailed() && state == VCSConnectionState.OPEN;
}
public boolean isClosed() throws IllegalStateException {
checkInit();
- return !hasFailed() && state != ConnectionState.ON_LINE;
+ return !hasFailed() && state != VCSConnectionState.CLOSE;
}
public boolean hasFailed() throws IllegalStateException {
checkInit();
- return state == ConnectionState.ERROR;
+ return state == VCSConnectionState.ERROR;
}
public void addVCSConnexionEventListener(VCSConnexionEventListener l) {
@@ -246,16 +245,16 @@
}
protected void fireOpen() {
- VCSConnexionEvent e = new VCSConnexionEvent(this, Type.OPEN);
+ VCSConnexionEvent e = new VCSConnexionEvent(this, VCSConnectionState.OPEN);
for (VCSConnexionEventListener l : listeners) {
- l.open(e);
+ l.onConnexionOpened(e);
}
}
protected void fireClose() {
- VCSConnexionEvent e = new VCSConnexionEvent(this, Type.CLOSE);
+ VCSConnexionEvent e = new VCSConnexionEvent(this, VCSConnectionState.CLOSE);
for (VCSConnexionEventListener l : listeners) {
- l.close(e);
+ l.onConnexionClosed(e);
}
}
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 09:49:11 UTC (rev 389)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -110,7 +110,7 @@
return connexions.toArray(new VCSConnexion[connexions.size()]);
}
- public void open(VCSConnexionEvent event) {
+ public void onConnexionOpened(VCSConnexionEvent event) {
// register connexion as active
connexions.add(event.getSource());
if (connexions.size() == 1) {
@@ -119,7 +119,7 @@
}
}
- public void close(VCSConnexionEvent event) {
+ public void onConnexionClosed(VCSConnexionEvent event) {
// remove connexion from active
connexions.remove(event.getSource());
if (connexions.isEmpty()) {
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-06 09:49:11 UTC (rev 389)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -16,7 +16,7 @@
import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
-import org.codelutin.vcs.type.ConnectionState;
+import org.codelutin.vcs.type.VCSConnectionState;
import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
@@ -28,7 +28,7 @@
}
public void init(VCSConnexionConfig config) {
- state = ConnectionState.INIT;
+ state = VCSConnectionState.INIT;
this.config = config;
}
@@ -44,7 +44,7 @@
@Override
public void open() throws IllegalStateException {
checkInit();
- state = ConnectionState.ON_LINE;
+ state = VCSConnectionState.CLOSE;
fireOpen();
}
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java 2008-04-06 09:49:11 UTC (rev 389)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java 2008-04-06 09:57:57 UTC (rev 390)
@@ -18,7 +18,7 @@
import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSRuntimeException;
-import org.codelutin.vcs.type.ConnectionState;
+import org.codelutin.vcs.type.VCSConnectionState;
import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
import org.tmatesoft.svn.core.SVNException;
@@ -48,7 +48,7 @@
}
public void init(VCSConnexionConfig config) {
- state = ConnectionState.UNDEFINED;
+ state = VCSConnectionState.UNDEFINED;
this.config = config;
try {
1
0
r389 - trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 09:49:11 +0000 (Sun, 06 Apr 2008)
New Revision: 389
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java
Log:
javadoc
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java 2008-04-06 09:48:53 UTC (rev 388)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntries.java 2008-04-06 09:49:11 UTC (rev 389)
@@ -21,7 +21,11 @@
import javax.swing.ListSelectionModel;
import java.util.List;
-/** @author chemit */
+/**
+ * Contract of list of VCSEntry
+ *
+ * @author chemit
+ */
public interface VCSEntries {
/**
@@ -64,6 +68,25 @@
void refresh(List<VCSEntry> entries, long timestamp) throws IllegalStateException;
/**
+ * obtain the array of all {@link VCSAction} found in the given entries
+ *
+ * @param entries entries to scan
+ * @return array of {@link VCSAction} found in entires
+ */
+ VCSAction[] getActions(List<VCSEntry> entries);
+
+ /**
+ * obtain the array of all {@link VCSState} found in the given entries
+ *
+ * @param entries entries to scan
+ * @return array of {@link VCSState found in entires
+ */
+ VCSState[] getStates(List<VCSEntry> entries);
+
+ /** clear the internal list of entries. */
+ void clear();
+
+ /**
* obtain the list of all entries.
*
* @return list of all entries
@@ -115,11 +138,4 @@
* @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();
}
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java 2008-04-06 09:48:53 UTC (rev 388)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSEntry.java 2008-04-06 09:49:11 UTC (rev 389)
@@ -21,7 +21,11 @@
import java.io.File;
import java.io.Serializable;
-/** @author chemit */
+/**
+ * Contract of an entry in VCS (a file or a dir)
+ *
+ * @author chemit
+ */
public interface VCSEntry extends Serializable {
/**
1
0
r388 - in trunk/lutinvcs: lutinvcs-api/src/main/java/org/codelutin/vcs lutinvcs-api/src/main/java/org/codelutin/vcs/util lutinvcs-core/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 09:48:53 +0000 (Sun, 06 Apr 2008)
New Revision: 388
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
Log:
improve VCSConnexionConfig (add srttter to contract)
introduc event package to put all event stuff
Modified: 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-06 09:47:33 UTC (rev 387)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexion.java 2008-04-06 09:48:53 UTC (rev 388)
@@ -15,6 +15,7 @@
package org.codelutin.vcs;
import org.codelutin.vcs.type.VCSConnexionMode;
+import org.codelutin.vcs.event.VCSConnexionEventListener;
import java.io.File;
import java.net.URI;
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-06 09:47:33 UTC (rev 387)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-06 09:48:53 UTC (rev 388)
@@ -20,9 +20,9 @@
import org.codelutin.util.ListenerSet;
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.event.VCSConnexionEvent;
+import org.codelutin.vcs.event.VCSConnexionEvent.Type;
+import org.codelutin.vcs.event.VCSConnexionEventListener;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.type.ConnectionState;
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 09:47:33 UTC (rev 387)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 09:48:53 UTC (rev 388)
@@ -24,6 +24,8 @@
import org.codelutin.util.StringUtil;
import org.codelutin.vcs.runner.VCSActionManager;
import org.codelutin.vcs.type.VCSConnexionMode;
+import org.codelutin.vcs.event.VCSConnexionEventListener;
+import org.codelutin.vcs.event.VCSConnexionEvent;
import java.util.ArrayList;
import java.util.List;
1
0
r387 - in trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs: . event
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 09:47:33 +0000 (Sun, 06 Apr 2008)
New Revision: 387
Added:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java
Removed:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java
Log:
improve VCSConnexionConfig (add srttter to contract)
introduc event package to put all event stuff
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java 2008-04-06 09:41:19 UTC (rev 386)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java 2008-04-06 09:47:33 UTC (rev 387)
@@ -1,56 +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 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
Deleted: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java 2008-04-06 09:41:19 UTC (rev 386)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java 2008-04-06 09:47:33 UTC (rev 387)
@@ -1,38 +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;
-
-/**
- * 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
Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java (from rev 371, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEvent.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java 2008-04-06 09:47:33 UTC (rev 387)
@@ -0,0 +1,58 @@
+/**
+ * # #% 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.event;
+
+import org.codelutin.vcs.VCSConnexion;
+
+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/event/VCSConnexionEventListener.java (from rev 371, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionEventListener.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java 2008-04-06 09:47:33 UTC (rev 387)
@@ -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.event;
+
+/**
+ * A listener on {@link org.codelutin.vcs.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
1
0
r386 - in trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs: . util
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 09:41:19 +0000 (Sun, 06 Apr 2008)
New Revision: 386
Added:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/event/
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.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/VCSConnexionConfigImpl.java
Log:
improve VCSConnexionConfig (add srttter to contract)
introduc event package to put all event stuff
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java 2008-04-06 09:34:59 UTC (rev 385)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSConnexionConfig.java 2008-04-06 09:41:19 UTC (rev 386)
@@ -66,5 +66,26 @@
/** @return the type of reposotory used (head,tags,branches,...) */
VCSTypeRepo getTypeRepo();
+
+ void setHostName(String hostName);
+
+ void setKeyFile(File keyFile);
+
+ void setLocalDatabasePath(File localDatabasePath);
+
+ void setNoPassPhrase(boolean noPassPhrase);
+
+ void setPassPhrase(String passPhrase);
+
+ void setRemoteDatabase(String remoteDatabase);
+
+ void setRemotePath(String remotePath);
+
+ void setType(VCSType type);
+
+ void setTypeRepo(VCSTypeRepo typeRepo);
+
+ void setUserName(String userName);
+
void setUseSshConnexion(boolean newValue);
}
\ No newline at end of file
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-06 09:34:59 UTC (rev 385)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-06 09:41:19 UTC (rev 386)
@@ -63,10 +63,6 @@
return handler;
}
- /*public VCSProvider<AbstractVCSConnexion, ?> getProvider() {
- return provider;
- }*/
-
public File getWorkingCopy() throws IllegalStateException {
checkInit();
return localRoot;
@@ -109,7 +105,6 @@
listeners.remove(l);
}
-
public boolean hasWriteAccess() {
return !getConfig().isUseSshConnexion() && getMode() != VCSConnexionMode.ANONYMOUS;
}
@@ -278,5 +273,4 @@
}
}
-
}
Modified: 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 2008-04-06 09:34:59 UTC (rev 385)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java 2008-04-06 09:41:19 UTC (rev 386)
@@ -23,19 +23,18 @@
/** @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;
+ protected VCSType type;
+ protected boolean useSshConnexion;
+ protected String hostName;
+ protected File keyFile;
+ protected String userName;
+ protected boolean noPassPhrase;
+ protected String passPhrase;
+ protected String remotePath;
+ protected String remoteDatabase;
+ protected VCSTypeRepo typeRepo;
+ protected File localDatabasePath;
-
public VCSType getType() {
return type;
}
1
0
r385 - in trunk/lutinvcs: lutinvcs-core/src/main/java/org/codelutin/vcs lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs lutinvcs-provider-mock/src/main/java/org/codelutin/vcs lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock lutinvcs-provider-svn/src/main/java/org/codelutin/vcs lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 09:34:59 +0000 (Sun, 06 Apr 2008)
New Revision: 385
Modified:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java
trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHandler.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockHandler.java
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHandler.java
Log:
improve design :
no more shared handler instance in provider
each connexion has his own handler
handler has a cached connexion
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -83,9 +83,6 @@
// 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);
Modified: trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -14,10 +14,9 @@
*/
package org.codelutin.vcs.impl.cvs;
-import org.codelutin.vcs.CVSProvider;
import org.codelutin.vcs.VCSConnexionConfig;
-import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
import org.netbeans.lib.cvsclient.CVSRoot;
import org.netbeans.lib.cvsclient.Client;
@@ -27,10 +26,10 @@
import org.netbeans.lib.cvsclient.connection.PServerConnection;
/** @author chemit */
-public class CVSConnexion extends AbstractVCSConnexion {
+public class CVSConnexion extends AbstractVCSConnexion<CVSHandler> {
- public CVSConnexion(VCSConnexionMode mode, CVSProvider provider) {
- super(mode, provider);
+ public CVSConnexion(VCSConnexionMode mode, CVSHandler handler) {
+ super(mode, handler);
}
public void init(VCSConnexionConfig config) {
Modified: trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHandler.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHandler.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -29,7 +29,7 @@
super("CVS", "Entries");
}
- public void initWorkingCopy(CVSConnexion connexion) throws VCSException {
+ public void initWorkingCopy() throws VCSException {
VCSConnexionConfig config = connexion.getConfig();
File root = config.getLocalDatabasePath();
@@ -41,7 +41,7 @@
}
- public boolean isOnRemote(CVSConnexion connexion, File file) {
+ public boolean isOnRemote(File file) {
boolean result = false;
if (file.isDirectory()) {
File cvsdir = new File(file, confLocalDirName);
@@ -62,7 +62,7 @@
return result;
}
- public boolean isUpToDate(CVSConnexion connexion, File file) throws VCSException {
+ public boolean isUpToDate(File file) throws VCSException {
CVSCommandResult cvsResult = CVSHelper.cvsStatus(connexion, file);
if (cvsResult.isError()) {
@@ -84,12 +84,12 @@
return result;
}
- public void makeRemoteDir(CVSConnexion connexion, String msg, String... dirNames) throws VCSException {
+ public void makeRemoteDir(String msg, String... dirNames) throws VCSException {
//TODO
throw new RuntimeException(getClass().getName() + "#makeRemoteDir is not actually implemented");
}
- public void deleteRemoteDir(CVSConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
+ public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
throw new RuntimeException(getClass().getName() + "#deleteRemoteDir is not actually implemented");
//TODO
}
@@ -99,16 +99,16 @@
//TODO
}*/
- public VCSState getState(CVSConnexion connexion, File fileState, Collection tmp) throws VCSException {
- return getState(connexion, fileState, tmp, true);
+ public VCSState getState(File fileState, Collection tmp) throws VCSException {
+ return getState(fileState, tmp, true);
}
- public VCSState getState(CVSConnexion connexion, File file, Collection tmp, boolean noremote) throws VCSException {
+ public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getState(File) is not actually implemented");
//TODO
}
- public long add(CVSConnexion connexion, List<File> files, String msg) throws VCSException {
+ public long add(List<File> files, String msg) throws VCSException {
log.debug("files to add: " + files);
CVSCommandResult result = CVSHelper.cvsAdd(connexion, files);
@@ -119,7 +119,7 @@
return -1;
}
- public void delete(CVSConnexion connexion, List<File> files, String msg) throws VCSException {
+ public void delete(List<File> files, String msg) throws VCSException {
CVSCommandResult result = CVSHelper.cvsRemove(connexion, files);
assertCommandResult(result, "Can''t remove files: {0}");
@@ -129,22 +129,22 @@
}
- public long commit(CVSConnexion connexion, List<File> files, String msg) throws VCSException {
- add(connexion, files, msg);
+ public long commit(List<File> files, String msg) throws VCSException {
+ add(files, msg);
return 0;
}
- public void update(CVSConnexion connexion, File file) throws VCSException {
+ public void update(File file) throws VCSException {
CVSCommandResult result = CVSHelper.cvsUpdate(connexion, file);
assertCommandResult(result, "Can''t update files: {0}");
}
- public void checkout(CVSConnexion connexion, File destDir, String module, boolean recurse) throws VCSException {
+ public void checkout(File destDir, String module, boolean recurse) throws VCSException {
CVSCommandResult result = CVSHelper.checkout(connexion, destDir, module);
assertCommandResult(result, "Can''t checkout files: {0}");
}
- public void checkoutFile(CVSConnexion connexion, File destDir, String module) throws VCSException {
+ public void checkoutFile(File destDir, String module) throws VCSException {
/*try {
new File(destDir,module).createNewFile();
} catch (IOException e) {
@@ -154,7 +154,7 @@
}
- public List<String> getRemoteStorageNames(CVSConnexion connexion, File directory) {
+ public List<String> getRemoteStorageNames(File directory) {
List<String> result = new ArrayList<String>();
try {
CVSCommandResult cvsResult = CVSHelper.cvsLog(connexion, directory);
@@ -175,14 +175,13 @@
* Retourne les messages de logs entre la version local et la remote ou null
* si les deux fichiers ont la meme version
*
- * @param connexion connexion to be used
- * @param file TODO
- * @param logInfo TODO
+ * @param file TODO
+ * @param logInfo TODO
* @return le log ou null
* @throws VCSException TODO
*/
@SuppressWarnings("unchecked")
- public String getLogMessage(CVSConnexion connexion, File file, LogInformation logInfo) throws VCSException {
+ public String getLogMessage(File file, LogInformation logInfo) throws VCSException {
CVSCommandResult cvsResult = CVSHelper.cvsStatus(connexion, file);
if (cvsResult.isError()) {
throw new VCSException(_("lutinvcs.error.get.status.files", cvsResult.getTrace().toString()));
@@ -233,27 +232,27 @@
}
}
- public void revert(CVSConnexion connexion, List<File> files) throws VCSException {
+ public void revert(List<File> files) throws VCSException {
throw new RuntimeException(getClass().getName() + "#revert is not actually implemented");
//TODO
}
- public Object getRevision(CVSConnexion connexion, File f) throws VCSException {
+ public Object getRevision(File f) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getRevision is not actually implemented");
//TODO
}
- public void update(CVSConnexion connexion, File file, Object revision) throws VCSException {
+ public void update(File file, Object revision) throws VCSException {
throw new RuntimeException(getClass().getName() + "#update(File,Object) is not actually implemented");
//TODO
}
- public String getDiff(CVSConnexion connexion, File file) throws VCSException {
+ public String getDiff(File file) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getDiff(File,OutputStream) is not actually implemented");
//TODO
}
- public String getDiff(CVSConnexion connexion, File file, Object againstRevision) throws VCSException {
+ public String getDiff(File file, Object againstRevision) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getDiff(File,Object,OutputStream) is not actually implemented");
//TODO
}
@@ -262,30 +261,31 @@
//TODO
}
- public boolean hasProtocoleChanged(CVSConnexion connexion) {
+ public boolean hasProtocoleChanged() {
throw new RuntimeException(getClass().getName() + "#hasProtocoleChanged() is not actually implemented");
}
- public String getChangeLog(CVSConnexion connexion, File file) throws VCSException {
+ public String getChangeLog(File file) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getChangeLog((File) is not actually implemented");
//TODO
}
- public List getLog(CVSConnexion connexion, Object startRevision, Object endRevision, File file) throws VCSException {
+ public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getLog(Object,Object,File) is not actually implemented");
//TODO
}
- public String getFileContent(CVSConnexion connexion, File file, Object revision) throws VCSException {
+ public String getFileContent(File file, Object revision) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getFileContent(File,Object) is not actually implemented");
//TODO
}
- public long checkoutOnlyTheDirectory(CVSConnexion connexion, File root, Object revision) throws VCSException {
- checkoutFile(connexion, root.getParentFile(), root.getName());
+ public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
+ checkoutFile(root.getParentFile(), root.getName());
return -1;
//throw new RuntimeException(getClass().getName() + "#checkoutOnlyTheDirectory(File,Object) is not actually implemented");
//TODO
}
+
}
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -15,14 +15,14 @@
package org.codelutin.vcs;
import org.codelutin.vcs.impl.mock.MockConnexion;
-import org.codelutin.vcs.impl.mock.MockVCSHandler;
+import org.codelutin.vcs.impl.mock.MockHandler;
import org.codelutin.vcs.util.AbstractVCSProvider;
/** @author chemit */
-public class MockProvider extends AbstractVCSProvider<MockConnexion, MockVCSHandler> {
+public class MockProvider extends AbstractVCSProvider<MockConnexion, MockHandler> {
public MockProvider() {
- super("MOCK", MockVCSHandler.class, MockConnexion.class);
+ super("MOCK", MockHandler.class, MockConnexion.class);
}
}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -14,18 +14,17 @@
*/
package org.codelutin.vcs.impl.mock;
-import org.codelutin.vcs.type.ConnectionState;
-import org.codelutin.vcs.type.VCSConnexionMode;
-import org.codelutin.vcs.MockProvider;
import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.type.ConnectionState;
+import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
/** @author chemit */
-public class MockConnexion extends AbstractVCSConnexion {
+public class MockConnexion extends AbstractVCSConnexion<MockHandler> {
- public MockConnexion(VCSConnexionMode mode, MockProvider provider) {
- super(mode, provider);
+ public MockConnexion(VCSConnexionMode mode, MockHandler handler) {
+ super(mode, handler);
}
public void init(VCSConnexionConfig config) {
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockHandler.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockHandler.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -30,90 +30,90 @@
super("", "");
}
- public void initWorkingCopy(MockConnexion connexion) throws VCSException {
+ public void initWorkingCopy() throws VCSException {
}
- public VCSState getState(MockConnexion connexion, File fileState, Collection tmp) throws VCSException {
+ public VCSState getState(File fileState, Collection tmp) throws VCSException {
return null;
}
- public VCSState getState(MockConnexion connexion, File file, Collection tmp, boolean noremote) throws VCSException {
+ public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
return null;
}
- public boolean isOnRemote(MockConnexion connexion, File file) {
+ public boolean isOnRemote(File file) {
return false;
}
- public boolean isUpToDate(MockConnexion connexion, File file) throws VCSException {
+ public boolean isUpToDate(File file) throws VCSException {
return false;
}
- public void makeRemoteDir(MockConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
+ public void makeRemoteDir(String commitMessage, String... dirNames) throws VCSException {
}
- public void deleteRemoteDir(MockConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
+ public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
}
- public long add(MockConnexion connexion, List<File> files, String msg) throws VCSException {
+ public long add(List<File> files, String msg) throws VCSException {
return 0;
}
- public void delete(MockConnexion connexion, List<File> files, String msg) throws VCSException {
+ public void delete(List<File> files, String msg) throws VCSException {
}
- public void revert(MockConnexion connexion, List<File> files) throws VCSException {
+ public void revert(List<File> files) throws VCSException {
}
- public long commit(MockConnexion connexion, List<File> files, String msg) throws VCSException {
+ public long commit(List<File> files, String msg) throws VCSException {
return 0;
}
- public void update(MockConnexion connexion, File file, Object revision) throws VCSException {
+ public void update(File file, Object revision) throws VCSException {
}
- public void update(MockConnexion connexion, File file) throws VCSException {
+ public void update(File file) throws VCSException {
}
- public void checkout(MockConnexion connexion, File destDir, String module, boolean recurse) throws VCSException {
+ public void checkout(File destDir, String module, boolean recurse) throws VCSException {
}
- public void checkoutFile(MockConnexion connexion, File destDir, String module) throws VCSException {
+ public void checkoutFile(File destDir, String module) throws VCSException {
}
- public long checkoutOnlyTheDirectory(MockConnexion connexion, File root, Object revision) throws VCSException {
+ public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
return 0;
}
- public List<String> getRemoteStorageNames(MockConnexion connexion, File directory) throws VCSException {
+ public List<String> getRemoteStorageNames(File directory) throws VCSException {
return null;
}
- public Object getRevision(MockConnexion connexion, File f) throws VCSException {
+ public Object getRevision(File f) throws VCSException {
return null;
}
- public List getLog(MockConnexion connexion, Object startRevision, Object endRevision, File file) throws VCSException {
+ public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
return null;
}
- public String getFileContent(MockConnexion connexion, File file, Object revision) throws VCSException, IOException {
+ public String getFileContent(File file, Object revision) throws VCSException, IOException {
return null;
}
- public String getChangeLog(MockConnexion connexion, File file) throws VCSException {
+ public String getChangeLog(File file) throws VCSException {
return null;
}
- public String getDiff(MockConnexion connexion, File file) throws VCSException, IOException {
+ public String getDiff(File file) throws VCSException, IOException {
return null;
}
- public String getDiff(MockConnexion connexion, File file, Object againstRevision) throws VCSException, IOException {
+ public String getDiff(File file, Object againstRevision) throws VCSException, IOException {
return null;
}
- public boolean hasProtocoleChanged(MockConnexion connexion) throws VCSException {
+ public boolean hasProtocoleChanged() throws VCSException {
return false;
}
}
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -30,11 +30,7 @@
public SVNProvider() {
super("SVN", SVNHandler.class, SVNConnexion.class);
- }
- @Override
- public void init() {
-
// For using over http:// and https://
DAVRepositoryFactory.setup();
@@ -43,8 +39,6 @@
// For using over file:///
FSRepositoryFactory.setup();
-
- super.init();
}
}
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -15,14 +15,12 @@
package org.codelutin.vcs.impl.svn;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.type.ConnectionState;
-import org.codelutin.vcs.type.VCSConnexionMode;
-import org.codelutin.vcs.SVNProvider;
import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSRuntimeException;
+import org.codelutin.vcs.type.ConnectionState;
+import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
-import org.codelutin.vcs.util.AbstractVCSHandler;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.io.SVNRepository;
@@ -35,7 +33,7 @@
import java.util.Arrays;
/** @author chemit */
-public class SVNConnexion extends AbstractVCSConnexion {
+public class SVNConnexion extends AbstractVCSConnexion<SVNHandler> {
protected SVNURL repositoryURL;
@@ -45,8 +43,8 @@
protected SVNWCClient ourWcClient;
- public SVNConnexion(VCSConnexionMode mode, SVNProvider provider) {
- super(mode, provider);
+ public SVNConnexion(VCSConnexionMode mode, SVNHandler handler) {
+ super(mode, handler);
}
public void init(VCSConnexionConfig config) {
@@ -124,17 +122,6 @@
return sb.toString();
}
- public boolean hasProtocoleChanged(SVNHandler handler) throws VCSException {
- File root = config.getLocalDatabasePath();
- if (!root.exists() || !AbstractVCSHandler.isFileInCheckedDir(root, handler)) {
- // local database does not exists, so no switch
- return false;
- }
- String oldProtocol = handler.getSVNStatus(this, root, false).getURL().getProtocol();
- String newProtocol = repositoryURL.getProtocol();
- return !oldProtocol.equals(newProtocol);
- }
-
public void testConnection() throws VCSException {
//TODO This is not the good place for this, this should be done in provider
if (getConfig().isUseSshConnexion()) {
@@ -173,4 +160,5 @@
public SVNURL getRepositoryURL() {
return repositoryURL;
}
+
}
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHandler.java 2008-04-06 09:34:44 UTC (rev 384)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHandler.java 2008-04-06 09:34:59 UTC (rev 385)
@@ -63,7 +63,7 @@
super(".svn", "entries");
}
- public void initWorkingCopy(SVNConnexion connexion) throws VCSException {
+ public void initWorkingCopy() throws VCSException {
try {
// test connection
connexion.getRepository().testConnection();
@@ -80,15 +80,15 @@
if (!root.exists()) {
config.getLocalDatabasePath().mkdirs();
}
- long lastRevision = checkoutOnlyTheDirectory(connexion, root, SVNRevision.HEAD);
+ long lastRevision = checkoutOnlyTheDirectory(root, SVNRevision.HEAD);
log.info(_("lutinvcs.message.copy.revision", null, lastRevision));
}
// TODO Delete VCSStatus and all links, use VCSState
- public VCSStatus getStatus(SVNConnexion connexion, File file) {
+ public VCSStatus getStatus(File file) {
SVNStatusType statusType;
try {
- statusType = getStatusType(connexion, file);
+ statusType = getStatusType(file);
} catch (SVNException e) {
return VCSStatus.NONE;
}
@@ -115,18 +115,18 @@
}
// tmp is used to get back the revision
- public VCSState getState(SVNConnexion connexion, File file, Collection tmp) throws VCSException {
- return getState(connexion, file, tmp, true);
+ public VCSState getState(File file, Collection tmp) throws VCSException {
+ return getState(file, tmp, true);
}
@SuppressWarnings("unchecked")
- public VCSState getState(SVNConnexion connexion, File file, Collection tmp, boolean noremote) throws VCSException {
+ public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
VCSState result = VCSState.UNKNOWN;
boolean exist = file.exists();
- assertFileInWC(file, this, connexion);
+ assertFileInWC(file);
// file is in a working copy
@@ -134,7 +134,7 @@
SVNStatusType statusLocal;
SVNStatusType statRemote;
- if (!exist || !isFileInCheckedDir(file, this)) {
+ if (!exist || !isFileInCheckedDir(file)) {
// file not locally exists or not in a checked dir
// check if present on remote repository
@@ -226,29 +226,29 @@
return prefixPath;
}
- private String getRelativePath(SVNConnexion connexion, File f) {
+ private String getRelativePath(File f) {
final String path = f.getAbsolutePath();
return path.length() <= getPrefixPath(connexion) ? path : path.substring(getPrefixPath(connexion));
}
- public boolean isOnRemote(SVNConnexion connexion, File file) {
- VCSStatus fileStatus = getStatus(connexion, file);
+ public boolean isOnRemote(File file) {
+ VCSStatus fileStatus = getStatus(file);
return !(VCSStatus.UNVERSIONED == fileStatus || VCSStatus.NONE == fileStatus);
}
- public boolean isUpToDate(SVNConnexion connexion, File file) throws VCSException {
- SVNStatus status = getSVNStatus(connexion, file);
+ public boolean isUpToDate(File file) throws VCSException {
+ SVNStatus status = getSVNStatus(file);
return status.getContentsStatus() == STATUS_NORMAL && STATUS_NONE == status.getRemoteContentsStatus();
}
- public long add(SVNConnexion connexion, List<File> files, String msg) throws VCSException {
+ public long add(List<File> files, String msg) throws VCSException {
assertFilesExist(files, msg);
try {
ArrayList<File> filesTmp = new ArrayList<File>(files);
for (Iterator<File> it = filesTmp.iterator(); it.hasNext();) {
File file = it.next();
- VCSStatus status = getStatus(connexion, file);
+ VCSStatus status = getStatus(file);
if (!file.exists() || status == VCSStatus.NORMAL) {
// do not commit this file
it.remove();
@@ -257,14 +257,14 @@
// we must check first if file need really to be added ?
if (status == VCSStatus.UNVERSIONED) {
connexion.getOurWcClient().doAdd(file, false, false, false, false, false);
- log.debug("mark to add '" + getRelativePath(connexion, file) + "'");
+ log.debug("mark to add '" + getRelativePath(file) + "'");
}
}
if (!filesTmp.isEmpty() && msg != null) {
// we do commit
- long rev = commit(connexion, filesTmp, msg);
+ long rev = commit(filesTmp, msg);
for (File file : filesTmp) {
- log.info("'" + getRelativePath(connexion, file) + "' at revison " + rev);
+ log.info("'" + getRelativePath(file) + "' at revison " + rev);
}
return rev;
}
@@ -274,7 +274,7 @@
return -1;
}
- public void delete(SVNConnexion connexion, List<File> files, String msg) throws VCSException {
+ public void delete(List<File> files, String msg) throws VCSException {
assertFilesExist(files, "delete");
files.remove(connexion.getConfig().getLocalDatabasePath());
files.remove(connexion.getConfig().getLocalDatabasePath().getParentFile());
@@ -283,14 +283,14 @@
for (File file : files) {
connexion.getOurWcClient().doDelete(file, true, msg != null, false);
- log.debug("mark to delete '" + getRelativePath(connexion, file) + "'");
+ log.debug("mark to delete '" + getRelativePath(file) + "'");
}
long revision;
if (msg != null) {
// we do commit
- revision = commit(connexion, files, msg);
+ revision = commit(files, msg);
for (File file : files) {
- log.info("'" + getRelativePath(connexion, file) + "' at revison " + revision);
+ log.info("'" + getRelativePath(file) + "' at revison " + revision);
}
}
} catch (SVNException e) {
@@ -298,23 +298,23 @@
}
}
- public void revert(SVNConnexion connexion, List<File> files) throws VCSException {
+ public void revert(List<File> files) throws VCSException {
assertFilesExist(files, "revert");
try {
for (File file : files) {
// we have nothing to do for with a normal status file
- if (getStatus(connexion, file) == VCSStatus.NORMAL) {
+ if (getStatus(file) == VCSStatus.NORMAL) {
continue;
}
connexion.getOurWcClient().doRevert(file, true);
- log.info("'" + getRelativePath(connexion, file) + "' at revison " + "TODO");
+ log.info("'" + getRelativePath(file) + "' at revison " + "TODO");
}
} catch (SVNException e) {
throw new VCSException(e);
}
}
- public long commit(SVNConnexion connexion, List<File> files, String msg) throws VCSException {
+ public long commit(List<File> files, String msg) throws VCSException {
assertFilesExist(files, "commit");
try {
@@ -327,8 +327,8 @@
}
}
- public void update(SVNConnexion connexion, File file) throws VCSException {
- update(connexion, file, SVNRevision.HEAD);
+ public void update(File file) throws VCSException {
+ update(file, SVNRevision.HEAD);
}
/**
@@ -337,21 +337,21 @@
* @throws VCSException if any exception while update operation (like update a
* locally modified file or a unversionned file)
*/
- public void update(SVNConnexion connexion, File file, Object revision) throws VCSException {
+ public void update(File file, Object revision) throws VCSException {
try {
- VCSStatus status = getStatus(connexion, file);
+ VCSStatus status = getStatus(file);
if (status == VCSStatus.MODIFIED)
throw new VCSException("could not update a localy modified file " + file);
if (status == VCSStatus.UNVERSIONED || status == VCSStatus.NONE)
throw new VCSException("could not update a non versionned file " + file);
long newRev = connexion.getOurClientManager().getUpdateClient().doUpdate(file, (SVNRevision) revision, true);
- log.info("'" + getRelativePath(connexion, file) + "' to revision " + newRev);
+ log.info("'" + getRelativePath(file) + "' to revision " + newRev);
} catch (SVNException e) {
throw new VCSException(e);
}
}
- public void checkout(SVNConnexion connexion, File destDir, String module, boolean recurse)
+ public void checkout(File destDir, String module, boolean recurse)
throws VCSException {
try {
final SVNURL urlModule = connexion.getRepositoryURL().appendPath(module, true);
@@ -359,18 +359,18 @@
String sep = File.separator;
// TODO Why this ?
final File modulePath = new File(destDir, module.replaceAll("/", "\\".equals(sep) ? sep + sep : sep));
- log.info(urlModule + " to path '" + getRelativePath(connexion, modulePath) + "' (module:" + module + ")");
+ log.info(urlModule + " to path '" + getRelativePath(modulePath) + "' (module:" + module + ")");
connexion.getOurClientManager().getUpdateClient().doCheckout(urlModule, modulePath, null, SVNRevision.HEAD, recurse);
} catch (SVNException e) {
throw new VCSException(e);
}
}
- public void checkoutFile(SVNConnexion connexion, File destDir, String module) throws VCSException {
- update(connexion, new File(destDir, module));
+ public void checkoutFile(File destDir, String module) throws VCSException {
+ update(new File(destDir, module));
}
- public long checkoutOnlyTheDirectory(SVNConnexion connexion, File root, Object revision)
+ public long checkoutOnlyTheDirectory(File root, Object revision)
throws VCSException {
long lastRevision;
try {
@@ -395,7 +395,7 @@
(SVNRevision) (revision == null ? SVNRevision.HEAD
: revision), false);
- log.info(url + " to path '" + getRelativePath(connexion, root) + "' (module:" + module + ") to revision " + lastRevision);
+ log.info(url + " to path '" + getRelativePath(root) + "' (module:" + module + ") to revision " + lastRevision);
// Suppress all files from root directory of working copy
for (File file : root.listFiles())
if (file.isFile())
@@ -406,7 +406,7 @@
return lastRevision;
}
- public List<String> getRemoteStorageNames(SVNConnexion connexion, File directory)
+ public List<String> getRemoteStorageNames(File directory)
throws VCSException {
final List<String> result = new ArrayList<String>();
@@ -436,7 +436,7 @@
return result;
}
- public SVNRevision getRevision(SVNConnexion connexion, File f) throws VCSException {
+ public SVNRevision getRevision(File f) throws VCSException {
SVNStatus status;
try {
status = connexion.getOurClientManager().getStatusClient().doStatus(f, false);
@@ -453,12 +453,12 @@
* @return la liste des r�visions en tre la startRevision et la endRevision
* @throws VCSException if nay exception while operation
*/
- public List<SVNLogEntry> getLog(SVNConnexion connexion, Object startRevision, Object endRevision,
+ public List<SVNLogEntry> getLog(Object startRevision, Object endRevision,
File file) throws VCSException {
final List<SVNLogEntry> result = new ArrayList<SVNLogEntry>();
- final long workingRevision = getRevision(connexion, file).getNumber();
+ final long workingRevision = getRevision(file).getNumber();
final long startRev = ((SVNRevision) startRevision).getNumber();
ISVNLogEntryHandler handler = new ISVNLogEntryHandler() {
@@ -488,14 +488,13 @@
* @return le log ou null si auncune r�vision n'a �t� fourni
* @throws VCSException if nay exception while operation
*/
- public String getChangeLog(SVNConnexion connexion, File file) throws VCSException {
+ public String getChangeLog(File file) throws VCSException {
SVNRevision startRevision = file.exists() ? SVNRevision.WORKING
: SVNRevision.create(0);
log.debug("file " + file + " init Rev " + startRevision);
- List<SVNLogEntry> logInfo = getLog(connexion, startRevision, SVNRevision.HEAD,
- file);
+ List<SVNLogEntry> logInfo = getLog(startRevision, SVNRevision.HEAD, file);
// List<SVNLogEntry> logInfo = getLog(file.exists()?SVNRevision.WORKING:
// SVNRevision.BASE, SVNRevision.HEAD, file);
@@ -522,20 +521,20 @@
return result.substring(1);
}
- public String getDiff(SVNConnexion connexion, File file) throws VCSException, IOException {
+ public String getDiff(File file) throws VCSException, IOException {
// make diff against Head revision of file
- return getDiff(connexion, file, SVNRevision.HEAD);
+ return getDiff(file, SVNRevision.HEAD);
}
- public String getDiff(SVNConnexion connexion, File file, Object againstRevision)
+ public String getDiff(File file, Object againstRevision)
throws VCSException, IOException {
assertFileExist(file, "getDiff");
SVNRevision remoteRevision = (SVNRevision) againstRevision;
- SVNStatus status = getSVNStatus(connexion, file);
+ SVNStatus status = getSVNStatus(file);
if (status == null) {
throw new VCSException("could not found status for the file " + file);
@@ -573,11 +572,8 @@
}
}
- public boolean hasProtocoleChanged(SVNConnexion connexion) throws VCSException {
- return connexion.hasProtocoleChanged(this);
- }
- public String getFileContent(SVNConnexion connexion, File file, Object revision)
+ public String getFileContent(File file, Object revision)
throws VCSException, IOException {
if (file == null || file.isDirectory()) {
throw new VCSRuntimeException("could not invoke getFileContent for a directory [" + file + "]");
@@ -606,7 +602,7 @@
}
}
- public byte[] getBinaryFileContent(SVNConnexion connexion, File file, Object revision) throws VCSException, IOException {
+ public byte[] getBinaryFileContent(File file, Object revision) throws VCSException, IOException {
if (file == null || file.isDirectory())
throw new VCSRuntimeException("could not invoke getFileContent for a directory [" + file + "]");
String path = file.getAbsolutePath();
@@ -629,11 +625,11 @@
}
}
- public SVNStatus getSVNStatus(SVNConnexion connexion, File file) throws VCSException {
- return getSVNStatus(connexion, file, true);
+ public SVNStatus getSVNStatus(File file) throws VCSException {
+ return getSVNStatus(file, true);
}
- protected SVNStatus getSVNStatus(SVNConnexion connexion, File file, boolean remote) throws VCSException {
+ protected SVNStatus getSVNStatus(File file, boolean remote) throws VCSException {
try {
return connexion.getOurClientManager().getStatusClient().doStatus(file, remote);
} catch (SVNException e) {
@@ -641,7 +637,7 @@
}
}
- protected SVNStatusType getStatusType(SVNConnexion connexion, File file) throws SVNException {
+ protected SVNStatusType getStatusType(File file) throws SVNException {
SVNStatus status = connexion.getOurClientManager().getStatusClient().doStatus(file, false);
return status == null ? UNKNOWN : status.getContentsStatus();
}
@@ -658,7 +654,7 @@
throw new VCSRuntimeException(getClass().getName() + "#" + command + "(File,...) first argument can not be null");
}
- public void makeRemoteDir(SVNConnexion connexion, String commitMessage, String... dirNames)
+ public void makeRemoteDir(String commitMessage, String... dirNames)
throws VCSException {
try {
@@ -681,7 +677,7 @@
}
}
- public void deleteRemoteDir(SVNConnexion connexion, String commitMessage, String... dirNames)
+ public void deleteRemoteDir(String commitMessage, String... dirNames)
throws VCSException {
try {
@@ -703,4 +699,15 @@
}
}
+ public boolean hasProtocoleChanged() throws VCSException {
+ File root = connexion.getConfig().getLocalDatabasePath();
+ if (!root.exists() || !isFileInCheckedDir(root)) {
+ // local database does not exists, so no switch
+ return false;
+ }
+ String oldProtocol = getSVNStatus(root, false).getURL().getProtocol();
+ String newProtocol = connexion.getRepositoryURL().getProtocol();
+ return !oldProtocol.equals(newProtocol);
+ }
+
}
1
0
r384 - in trunk/lutinvcs/lutinvcs-api/src/main: java/org/codelutin/vcs java/org/codelutin/vcs/util resources/i18n
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
by tchemit@users.labs.libre-entreprise.org 06 Apr '08
06 Apr '08
Author: tchemit
Date: 2008-04-06 09:34:44 +0000 (Sun, 06 Apr 2008)
New Revision: 384
Modified:
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
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:
improve design :
no more shared handler instance in provider
each connexion has his own handler
handler has a cached connexion
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-06 09:33:56 UTC (rev 383)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java 2008-04-06 09:34:44 UTC (rev 384)
@@ -30,29 +30,21 @@
/** @return the identifier of the vcs provider (eg SVN, CVS, MOCK) */
String getName();
- /**
- * init the provider. (instanciate handler)
- * <p/>
- * This method MUST be invoked before asking any connexion.
- */
- void init();
+ /** @return the class of implementation of handler to use for this provider */
+ Class<H> getHandlerImpl();
- /**
- * return a new VCSHandler instance for given config.
- *
- * @return the cached instance of handler
- * @throws IllegalStateException if provider was not init via {@link #init()}
- */
- H getHandler() throws IllegalStateException;
+ /** @return the imclass of implementation of connexion to use for this provider */
+ Class<C> getConnexionImpl();
/**
* Instanciate an new connexion for a given config, and init it.
+ * <p/>
+ * Note : <b>After this method connexion is init, but not opened.</b>
*
* @param mode the mode required
* @param config the config to be used
* @return the new connexion initialized <b>but not opened</b>.
- * @throws IllegalStateException if provider was not init via {@link #init()}
*/
- C newConnection(VCSConnexionMode mode, VCSConnexionConfig config) throws IllegalStateException;
+ C newConnection(VCSConnexionMode mode, VCSConnexionConfig config);
}
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-06 09:33:56 UTC (rev 383)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-06 09:34:44 UTC (rev 384)
@@ -16,18 +16,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
import org.codelutin.util.ListenerSet;
-import org.codelutin.vcs.type.ConnectionState;
-import org.codelutin.vcs.type.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.type.VCSConnexionMode;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSProvider;
+import org.codelutin.vcs.type.ConnectionState;
+import org.codelutin.vcs.type.VCSConnexionMode;
import org.codelutin.vcs.type.VCSState;
import java.io.File;
@@ -36,11 +35,10 @@
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
-import java.util.EnumSet;
import java.util.List;
/** @author chemit */
-public abstract class AbstractVCSConnexion implements VCSConnexion {
+public abstract class AbstractVCSConnexion<H extends VCSHandler> implements VCSConnexion<H> {
/** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(AbstractVCSConnexion.class);
@@ -49,26 +47,25 @@
protected URI remoteRoot;
protected VCSConnexionMode mode;
protected ConnectionState state;
-
protected VCSConnexionConfig config;
+ protected H handler;
- protected VCSProvider<AbstractVCSConnexion, ?> provider;
-
protected ListenerSet<VCSConnexionEventListener> listeners = new ListenerSet<VCSConnexionEventListener>();
@SuppressWarnings({"unchecked"})
- protected AbstractVCSConnexion(VCSConnexionMode mode, VCSProvider provider) {
+ protected AbstractVCSConnexion(VCSConnexionMode mode, H handler) {
this.mode = mode;
- this.provider = provider;
+ this.handler = handler;
+ this.handler.setConnexion(this);
}
- public VCSHandler<AbstractVCSConnexion> getHandler() throws IllegalStateException {
- return getProvider().getHandler();
+ public H getHandler() throws IllegalStateException {
+ return handler;
}
- public VCSProvider<AbstractVCSConnexion, ?> getProvider() {
+ /*public VCSProvider<AbstractVCSConnexion, ?> getProvider() {
return provider;
- }
+ }*/
public File getWorkingCopy() throws IllegalStateException {
checkInit();
@@ -112,158 +109,147 @@
listeners.remove(l);
}
+
+ 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);
+ }
+
+ // ---------------------------------------------------------------------
+ // handler delegate methods
+ // ---------------------------------------------------------------------
+
public void initWorkingCopy() throws VCSException {
- getHandler().initWorkingCopy(this);
+ handler.initWorkingCopy();
}
public void deleteWorkingCopy() {
- getHandler().deleteWorkingCopy(this);
+ handler.deleteWorkingCopy();
}
public FilenameFilter getVersionnableFilenameFilter() {
- return getHandler().getVersionnableFilenameFilter();
+ return handler.getVersionnableFilenameFilter();
}
public FileFilter getVersionnableFileFilter() {
- return getHandler().getVersionnableFileFilter();
+ return handler.getVersionnableFileFilter();
}
public String getConfLocalDirname() {
- return getHandler().getConfLocalDirname();
+ return handler.getConfLocalDirname();
}
public String getConfLocalEntriesFilename() {
- return getHandler().getConfLocalEntriesFilename();
+ return handler.getConfLocalEntriesFilename();
}
public VCSState getState(File fileState, Collection tmp) throws VCSException {
- return getHandler().getState(this, fileState, tmp);
+ return handler.getState(fileState, tmp);
}
public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
- return getHandler().getState(this, file, tmp, noremote);
+ return handler.getState(file, tmp, noremote);
}
public boolean isOnRemote(File file) {
- return getHandler().isOnRemote(this, file);
+ return handler.isOnRemote(file);
}
public boolean isUpToDate(File file) throws VCSException {
- return getHandler().isUpToDate(this, file);
+ return handler.isUpToDate(file);
}
public boolean isVersionnableFile(File file) {
- return getHandler().isVersionnableFile(this, file);
+ return handler.isVersionnableFile(file);
}
public void makeRemoteDir(String commitMessage, String... dirNames) throws VCSException {
- getHandler().makeRemoteDir(this, commitMessage, dirNames);
+ handler.makeRemoteDir(commitMessage, dirNames);
}
public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
- getHandler().deleteRemoteDir(this, commitMessage, dirNames);
+ handler.deleteRemoteDir(commitMessage, dirNames);
}
public long add(List<File> files, String msg) throws VCSException {
- return getHandler().add(this, files, msg);
+ return handler.add(files, msg);
}
public void delete(List<File> files, String msg) throws VCSException {
- getHandler().delete(this, files, msg);
+ handler.delete(files, msg);
}
public void revert(List<File> files) throws VCSException {
- getHandler().revert(this, files);
+ handler.revert(files);
}
public long commit(List<File> files, String msg) throws VCSException {
- return getHandler().commit(this, files, msg);
+ return handler.commit(files, msg);
}
public void update(File file, Object revision) throws VCSException {
- getHandler().update(this, file, revision);
+ handler.update(file, revision);
}
public void update(File file) throws VCSException {
- getHandler().update(this, file);
+ handler.update(file);
}
public void checkout(File destDir, String module, boolean recurse) throws VCSException {
- getHandler().checkout(this, destDir, module, recurse);
+ handler.checkout(destDir, module, recurse);
}
public void checkoutFile(File destDir, String module) throws VCSException {
- getHandler().checkoutFile(this, destDir, module);
+ handler.checkoutFile(destDir, module);
}
public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
- return getHandler().checkoutOnlyTheDirectory(this, root, revision);
+ return handler.checkoutOnlyTheDirectory(root, revision);
}
public List<String> getRemoteStorageNames(File directory) throws VCSException {
- return getHandler().getRemoteStorageNames(this, directory);
+ return handler.getRemoteStorageNames(directory);
}
public List<String> getLocalStorageNames(File directory) {
- return getHandler().getLocalStorageNames(this, directory);
+ return handler.getLocalStorageNames(directory);
}
public Object getRevision(File f) throws VCSException {
- return getHandler().getRevision(this, f);
+ return handler.getRevision(f);
}
public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
- return getHandler().getLog(this, startRevision, endRevision, file);
+ return handler.getLog(startRevision, endRevision, file);
}
public String getFileContent(File file, Object revision) throws VCSException, IOException {
- return getHandler().getFileContent(this, file, revision);
+ return handler.getFileContent(file, revision);
}
public String getChangeLog(File file) throws VCSException {
- return getHandler().getChangeLog(this, file);
+ return handler.getChangeLog(file);
}
public String getDiff(File file) throws VCSException, IOException {
- return getHandler().getDiff(this, file);
+ return handler.getDiff(file);
}
public String getDiff(File file, Object againstRevision) throws VCSException, IOException {
- return getHandler().getDiff(this, file, againstRevision);
+ return handler.getDiff(file, againstRevision);
}
public boolean hasProtocoleChanged() throws VCSException {
- return getHandler().hasProtocoleChanged(this);
+ return handler.hasProtocoleChanged();
}
- /**
- * 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) {
@@ -280,14 +266,15 @@
protected void checkInit() throws IllegalStateException {
if (state == null) {
- throw new IllegalStateException("connexion was not init");
+ throw new IllegalStateException(_("lutinvcs.error.connexion.noinit", this));
}
}
protected void checkOpen() throws IllegalStateException {
checkInit();
if (!isOpen()) {
- throw new IllegalStateException("connexion was not init");
+ throw new IllegalStateException(_("lutinvcs.error.connexion.noopen", this));
+
}
}
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-06 09:33:56 UTC (rev 383)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-04-06 09:34:44 UTC (rev 384)
@@ -54,6 +54,7 @@
protected final FileFilter versionnableFileFilter;
protected final String confLocalDirName;
protected final String confLocalEntriesFilename;
+ protected C connexion;
protected AbstractVCSHandler(final String vCSConfLocalDirName, String vCSConfLocalEntriesFilename) {
this.confLocalDirName = vCSConfLocalDirName;
@@ -70,6 +71,10 @@
};
}
+ public void setConnexion(C connexion) {
+ this.connexion = connexion;
+ }
+
public FilenameFilter getVersionnableFilenameFilter() {
return versionnableFilenameFilter;
}
@@ -86,19 +91,19 @@
return confLocalEntriesFilename;
}
- public boolean isVersionnableFile(C connexion, File file) {
+ public boolean isVersionnableFile(File file) {
assertFileExists(file, "file is empty or non existant");
return !confLocalDirName.equalsIgnoreCase(file.getName());
}
- public void deleteWorkingCopy(C connexion) {
+ public void deleteWorkingCopy() {
if (connexion.getConfig().getLocalDatabasePath().exists()) {
FileUtil.deleteRecursively(connexion.getConfig().getLocalDatabasePath());
connexion.getConfig().getLocalDatabasePath().delete();
}
}
- public List<String> getLocalStorageNames(C connexion, File directory) {
+ public List<String> getLocalStorageNames(File directory) {
List<String> result = new ArrayList<String>();
if (directory.exists()) {
getFiles0(directory, result, "");
@@ -107,11 +112,11 @@
return result;
}
- public void doCheckoutDir(C connexion, File... dirs) {
+ public void doCheckoutDir(File... dirs) {
for (File dir : dirs) {
try {
- if (!dir.exists() || !isFileInWorkingCopy(dir, this, connexion, true)) {
- checkoutOnlyTheDirectory(connexion, dir, null);
+ if (!dir.exists() || !isFileInWorkingCopy(dir, true)) {
+ checkoutOnlyTheDirectory(dir, null);
}
} catch (Exception eee) {
log.warn(_("lutinvcs.error.checkout.dir", dir), eee);
@@ -140,40 +145,40 @@
}
}
- public static boolean isFileInWorkingCopy(File parent, String name, VCSHandler handler, VCSConnexion connexion, boolean underVCS) {
+ public boolean isFileInWorkingCopy(File parent, String name, 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);
+ this + "]");
+ return isFileInWorkingCopy(new File(parent, name), 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 + "]");
+ public boolean isFileInWorkingCopy(File file, boolean underVCS) {
+ if (file == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInWorkingCopy can not be invoked with some null parameter but was. [" + file + "," + this + "]");
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);
+ return isFileInCheckedDir(realDir);
}
- 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 + "]");
+ public boolean isFileInCheckedDir(File file) {
+ if (file == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInCheckedDir can not be invoked with some null parameter but was. [" + file + "," + this + "]");
final File realDir = file.isDirectory() ? file : file.getParentFile();
- return (new File(realDir, handler.getConfLocalDirname()).exists());
+ return (new File(realDir, getConfLocalDirname()).exists());
}
- public static void assertFileInWC(File file, VCSHandler handler, VCSConnexion connexion) {
- if (!isFileInWorkingCopy(file, handler, connexion, false))
+ public void assertFileInWC(File file) {
+ if (!isFileInWorkingCopy(file, 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;
+ public String getRemoteRelativePath(File f) {
+ if (!isFileInWorkingCopy(f, false)) return null;
//System.out.println("file on vcs working copy : "+f);
String rootPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath();
String localPath = f.getAbsolutePath();
@@ -182,10 +187,10 @@
return convertToRemoteName(localPath);
}
- public static String getLocalRelativePath(String remoteRelativePath, VCSHandler handler, VCSConnexion connexion) {
+ public String getLocalRelativePath(String remoteRelativePath) {
String localPath = convertToLocalName(remoteRelativePath);
final File file = new File(connexion.getConfig().getLocalDatabasePath(), localPath);
- if (!isFileInWorkingCopy(file, handler, connexion, false)) return null;
+ if (!isFileInWorkingCopy(file, false)) return null;
return localPath;
}
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-06 09:33:56 UTC (rev 383)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java 2008-04-06 09:34:44 UTC (rev 384)
@@ -22,17 +22,11 @@
import org.codelutin.vcs.type.VCSConnexionMode;
/**
- * base implementation of provider with a cached common handler for all connexions.
+ * base implementation of provider.
*
* @author chemit
*/
-public abstract class AbstractVCSProvider<C extends VCSConnexion, H extends VCSHandler<C>> implements VCSProvider<C, H> {
- /**
- * shared cached instance of handler to use for this provider.
- * <p/>
- * The handler can be used by all connexions for this provider
- */
- protected H handler;
+public class AbstractVCSProvider<C extends VCSConnexion, H extends VCSHandler<C>> implements VCSProvider<C, H> {
/** name of ne provider */
protected final String name;
@@ -53,15 +47,26 @@
return name;
}
- public H getHandler() throws IllegalStateException {
- checkHandlerInit();
- return handler;
+ public Class<C> getConnexionImpl() {
+ return connexionImpl;
}
- public C newConnection(VCSConnexionMode mode, VCSConnexionConfig config) throws IllegalStateException {
- checkHandlerInit();
+ public Class<H> getHandlerImpl() {
+ return handlerImpl;
+ }
+
+ public C newConnection(VCSConnexionMode mode, VCSConnexionConfig config) {
+
+ H handler;
+ C connexion;
+
try {
- C connexion = connexionImpl.getConstructor(VCSConnexionMode.class, getClass()).newInstance(mode, this);
+ handler = handlerImpl.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(_("lutinvcs.error.provider.init.handler", handlerImpl, this, e.getCause()));
+ }
+ try {
+ connexion = connexionImpl.getConstructor(VCSConnexionMode.class, handlerImpl).newInstance(mode, handler);
connexion.init(config);
return connexion;
} catch (Exception e) {
@@ -69,20 +74,4 @@
}
}
- public void init() {
- if (handler == null) {
- try {
- handler = handlerImpl.newInstance();
- } catch (Exception e) {
- throw new RuntimeException(_("lutinvcs.error.provider.init.handler", handlerImpl, this, e.getCause()));
- }
- }
- }
-
- protected void checkHandlerInit() throws IllegalStateException {
- if (handler == null) {
- throw new IllegalStateException(_("lutinvcs.error.provider.noinit", handler, this));
- }
- }
-
}
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-06 09:33:56 UTC (rev 383)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties 2008-04-06 09:34:44 UTC (rev 384)
@@ -9,9 +9,10 @@
lutinvcs.action.revert=revert
lutinvcs.action.update=update
lutinvcs.error.checkout.dir=Can''t checkout dir {0}
+lutinvcs.error.connexion.noinit=connexion {0} was not init
+lutinvcs.error.connexion.noopen=connexion {0} was not opened
lutinvcs.error.provider.init.connexion=could not instanciate connexion {0}, for provider {1}, reason\: {2}
lutinvcs.error.provider.init.handler=could not instanciate handler {0}, for provider {1}, reason\: {2}
-lutinvcs.error.provider.noinit=handler {0} was not init for provider {1}
lutinvcs.location.all=All
lutinvcs.location.local=Local
lutinvcs.location.remote=Remote
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-06 09:33:56 UTC (rev 383)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties 2008-04-06 09:34:44 UTC (rev 384)
@@ -9,9 +9,10 @@
lutinvcs.action.revert=Rollback
lutinvcs.action.update=Update
lutinvcs.error.checkout.dir=Ne peut pas uploader le fichier ''{0}''
+lutinvcs.error.connexion.noinit=La connexion {0} n''a pas \u00E9t\u00E9 initialis\u00E9e
+lutinvcs.error.connexion.noopen=La connexion {0} n''a pas \u00E9t\u00E9 ouverte
lutinvcs.error.provider.init.connexion=Erreur lors de l''instanciation de la connexion {0}, provider {1}, cause\: {2}
lutinvcs.error.provider.init.handler=Erreur lors de l''instanciation du handler {0}, provider {1}, cause\: {2}
-lutinvcs.error.provider.noinit=Le handler {0} n''a pas \u00E9t\u00E9 initialis\u00E9 pour le provider {1}
lutinvcs.location.all=All
lutinvcs.location.local=Local
lutinvcs.location.remote=Remote
1
0