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
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); + } + }
participants (1)
-
tchemit@users.labs.libre-entreprise.org