Jaxx-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
[Buix-commits] r373 - trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:50:50 +0000 (Sat, 05 Apr 2008)
New Revision: 373
Modified:
trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx
===================================================================
--- trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx 2008-04-05 20:48:07 UTC (rev 372)
+++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx 2008-04-05 20:50:50 UTC (rev 373)
@@ -23,7 +23,7 @@
@Override
public void setVisible(boolean b) {
- if (getModel().getModel().getLocation() == null) {
+ if (getModel().getModel().getLocation() == VCSEntryLocation.UNKNOW) {
// first launch, no tab model selected,choose one
allTab.doClick();
}
1
0
[Buix-commits] r372 - in trunk/lutinvcs: lutinvcs-api/src/main/resources/i18n lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:48:07 +0000 (Sat, 05 Apr 2008)
New Revision: 372
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties
trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties
trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties 2008-04-05 20:43:39 UTC (rev 371)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties 2008-04-05 20:48:07 UTC (rev 372)
@@ -12,6 +12,7 @@
lutinvcs.location.all=All
lutinvcs.location.local=Local
lutinvcs.location.remote=Remote
+lutinvcs.location.unknown=Unknow
lutinvcs.state.missing=missing
lutinvcs.state.modified=modified
lutinvcs.state.outofdate=out of date
Modified: trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties 2008-04-05 20:43:39 UTC (rev 371)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties 2008-04-05 20:48:07 UTC (rev 372)
@@ -12,6 +12,7 @@
lutinvcs.location.all=All
lutinvcs.location.local=Local
lutinvcs.location.remote=Remote
+lutinvcs.location.unknown=Unknow
lutinvcs.state.missing=non pr\u00E9sent
lutinvcs.state.modified=modifi\u00E9
lutinvcs.state.outofdate=obsol\u00E8te
Modified: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx
===================================================================
--- trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx 2008-04-05 20:43:39 UTC (rev 371)
+++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx 2008-04-05 20:48:07 UTC (rev 372)
@@ -39,7 +39,7 @@
}
protected void selectFile(JTable table) {
- model.setFileModel(model.getModel().getData(table.getSelectionModel())[0]);
+ //model.setFileModel(model.getModel().getData(table.getSelectionModel())[0]);
}
protected void doAction(VCSAction action) {
1
0
[Buix-commits] r371 - trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:43:39 +0000 (Sat, 05 Apr 2008)
New Revision: 371
Modified:
trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx
trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx
===================================================================
--- trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx 2008-04-05 20:43:32 UTC (rev 370)
+++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx 2008-04-05 20:43:39 UTC (rev 371)
@@ -3,6 +3,7 @@
<script>
import org.codelutin.vcs.VCSAction;
+ import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.handler.AbstractDiffUIHandler;
import org.codelutin.vcs.ui.VCSUIConstants;
@@ -14,9 +15,9 @@
@Override
public void setVisible(boolean b) {
- if (getHandler().getModel().getTabModel() == null) {
+ if (getModel().getLocation() == null) {
// first launch, no tab model selected,choose one
- selectTab(VCSUIConstants.DIFF_ALL_MODEL_PROPERTY);
+ allTab.doClick();
}
super.setVisible(b);
}
@@ -33,12 +34,12 @@
this.handler = handler;
}
- protected void selectTab(String tabname) {
- model.setTabModel(model.getModel(tabname));
+ protected void selectTab(VCSEntryLocation location) {
+ getModel().setLocation(location);
}
protected void selectFile(JTable table) {
- model.setFileModel(model.getTabModel().getData(table.getSelectionModel())[0]);
+ model.setFileModel(model.getModel().getData(table.getSelectionModel())[0]);
}
protected void doAction(VCSAction action) {
@@ -77,15 +78,15 @@
<JToggleButton id='allTab' selected='true' buttonGroup='tabs' mnemonic="A"
toolTipText="lutinvcs.tabs.diff.tooltip.all"
icon='{createImageIcon("remote_vs_local.png")}'
- onActionPerformed='selectTab("modelSynchAll")'/>
+ onActionPerformed='selectTab(VCSEntryLocation.ALL)'/>
<JToggleButton id='localTab' selected='false' buttonGroup='tabs' mnemonic="L"
toolTipText="lutinvcs.tabs.diff.tooltip.local"
icon='{createImageIcon("local_vs_local.png")}'
- onActionPerformed='selectTab("modelSynchLocal")'/>
+ onActionPerformed='selectTab(VCSEntryLocation.LOCAL)'/>
<JToggleButton id='remoteTab' selected='false' buttonGroup='tabs' mnemonic="R"
icon='{createImageIcon("remote_vs_remote.png")}'
toolTipText="lutinvcs.tabs.diff.tooltip.remote"
- onActionPerformed='selectTab("modelSynchRemote")'/>
+ onActionPerformed='selectTab(VCSEntryLocation.REMOTE)'/>
<JButton id='nextDiff' toolTipText="lutinvcs.action.tooltip.nextDiff"
@@ -120,16 +121,16 @@
<cell fill='both' weighty='1' weightx='2'>
<JPanel id='preview' layout='{cardLayout}'>
<JScrollPane id='allContent' styleClass='diffScroll' constraints='"modelSynchAll"'>
- <JTable id="modelDiffAllTable" styleClass='diffTable'
- onMouseClicked="selectFile(modelDiffAllTable)"/>
+ <JTable id="allTable" styleClass='diffTable'
+ onMouseClicked="selectFile(allTable)"/>
</JScrollPane>
<JScrollPane id='localContent' styleClass='diffScroll' constraints='"modelSynchLocal"'>
- <JTable id="modelDiffLocalTable" styleClass='diffTable'
- onMouseClicked="selectFile(modelDiffLocalTable)"/>
+ <JTable id="localTable" styleClass='diffTable'
+ onMouseClicked="selectFile(localTable)"/>
</JScrollPane>
<JScrollPane id='remoteContent' styleClass='diffScroll' constraints='"modelSynchRemote"'
- onMouseClicked="selectFile(modelDiffRemoteTable)">
- <JTable id="modelDiffRemoteTable" styleClass='diffTable'/>
+ onMouseClicked="selectFile(remoteTable)">
+ <JTable id="remoteTable" styleClass='diffTable'/>
</JScrollPane>
</JPanel>
</cell>
Modified: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx
===================================================================
--- trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx 2008-04-05 20:43:32 UTC (rev 370)
+++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JSynchUI.jaxx 2008-04-05 20:43:39 UTC (rev 371)
@@ -3,6 +3,7 @@
<script>
import org.codelutin.vcs.VCSAction;
+ import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.handler.AbstractSynchUIHandler;
import org.codelutin.vcs.ui.model.SynchUIModel;
@@ -20,6 +21,14 @@
return (SynchUIModel) super.getModel();
}
+ @Override
+ public void setVisible(boolean b) {
+ if (getModel().getModel().getLocation() == null) {
+ // first launch, no tab model selected,choose one
+ allTab.doClick();
+ }
+ super.setVisible(b);
+ }
public JTable getTable(String modelName) {
return (JTable) get$objectMap().get(modelName+"Table");
}
@@ -28,19 +37,10 @@
return (JVCSPopup) get$objectMap().get(modelName+"Popup");
}
- @Override
- public void setVisible(boolean b) {
- if (getHandler().getModel().getTabModel() == null) {
- // first launch, no tab model selected,choose one
- selectTab(VCSUIConstants.SYNCH_ALL_MODEL_PROPERTY);
+ protected void setLocation(VCSEntryLocation location) {
+ getModel().setLocation(location);
}
- super.setVisible(b);
- }
- protected void selectTab(String tabname) {
- getModel().setTabModel(getModel().getModel(tabname));
- }
-
protected void doAllAction(VCSAction action) {
getModel().doAllAction(action);
}
@@ -52,22 +52,22 @@
<JPopupMenu enabled='false'>
</JPopupMenu>
- <org.codelutin.vcs.ui.JVCSPopup id="modelSynchAllPopup"/>
- <org.codelutin.vcs.ui.JVCSPopup id="modelSynchLocalPopup"/>
- <org.codelutin.vcs.ui.JVCSPopup id="modelSynchRemotePopup"/>
+ <org.codelutin.vcs.ui.JVCSPopup id="allPopup"/>
+ <org.codelutin.vcs.ui.JVCSPopup id="localPopup"/>
+ <org.codelutin.vcs.ui.JVCSPopup id="remotePopup"/>
<Table>
<row fill='both'>
<cell fill='both' weightx='1'>
<JToolBar>
- <JToggleButton id='allTab' selected='true' buttonGroup='tabs' text='lutinvcs.tabs.all' mnemonic="A"
+ <JToggleButton id='allTab' buttonGroup='tabs' text='lutinvcs.tabs.all' mnemonic="A"
toolTipText="lutinvcs.tabs.tooltip.all"
- onActionPerformed='selectTab("modelSynchAll")'/>
+ onActionPerformed='setLocation(VCSEntryLocation.ALL)'/>
<JToggleButton id='localTab' selected='false' buttonGroup='tabs' text='lutinvcs.tabs.local'
mnemonic="L" toolTipText="lutinvcs.tabs.tooltip.local"
- onActionPerformed='selectTab("modelSynchLocal")'/>
+ onActionPerformed='setLocation(VCSEntryLocation.LOCAL)'/>
<JToggleButton id='remoteTab' selected='false' buttonGroup='tabs' text='lutinvcs.tabs.remote'
mnemonic="R" toolTipText="lutinvcs.tabs.tooltip.remote"
- onActionPerformed='selectTab("modelSynchRemote")'/>
+ onActionPerformed='setLocation(VCSEntryLocation.REMOTE)'/>
<JButton id='refreshAll' toolTipText="lutinvcs.action.tooltip.refreshAll"
icon='{createImageIcon("autoRefresh.png")}'
@@ -98,13 +98,13 @@
<cell fill='both' weighty='1' weightx='2'>
<JPanel id='preview' layout='{cardLayout}'>
<JScrollPane id='allContent' styleClass='updateScroll' constraints='"modelSynchAll"'>
- <JTable id="modelSynchAllTable" styleClass='updateTable'/>
+ <JTable id="allTable" styleClass='updateTable'/>
</JScrollPane>
<JScrollPane id='localContent' styleClass='updateScroll' constraints='"modelSynchLocal"'>
- <JTable id="modelSynchLocalTable" styleClass='updateTable'/>
+ <JTable id="localTable" styleClass='updateTable'/>
</JScrollPane>
<JScrollPane id='remoteContent' styleClass='updateScroll' constraints='"modelSynchRemote"'>
- <JTable id="modelSynchRemoteTable" styleClass='updateTable'/>
+ <JTable id="remoteTable" styleClass='updateTable'/>
</JScrollPane>
</JPanel>
</cell>
1
0
[Buix-commits] r370 - in trunk/lutinvcs: lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:43:32 +0000 (Sat, 05 Apr 2008)
New Revision: 370
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/CVSHandler.java
trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHelper.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
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHelper.java
Log:
refactor PRovider, Handler and Connexion
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-05 20:41:33 UTC (rev 369)
+++ trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSConnexion.java 2008-04-05 20:43:32 UTC (rev 370)
@@ -14,23 +14,119 @@
*/
package org.codelutin.vcs.impl.cvs;
+import org.codelutin.vcs.CVSProvider;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSConnexionMode;
+import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.util.AbstractVCSConnexion;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSHandler;
+import org.netbeans.lib.cvsclient.CVSRoot;
+import org.netbeans.lib.cvsclient.Client;
+import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
+import org.netbeans.lib.cvsclient.command.GlobalOptions;
+import org.netbeans.lib.cvsclient.connection.Connection;
+import org.netbeans.lib.cvsclient.connection.PServerConnection;
/** @author chemit */
public class CVSConnexion extends AbstractVCSConnexion {
- public void init(VCSConfig config, VCSHandler handler) {
+ public CVSConnexion(VCSConnexionMode mode, CVSProvider provider) {
+ super(mode, provider);
}
+ public void init(VCSConnexionConfig config) {
+ //TODO
+ this.config = config;
+ }
+
+ public void testConnection() throws VCSException {
+ //TODO
+ }
+
@Override
public void close() throws IllegalStateException {
+ //TODO
checkInit();
}
@Override
public void open() throws IllegalStateException {
+ //TODO
checkInit();
}
+
+ public String getRemoteUrl() {
+ checkInit();
+ return (config.isUseSshConnexion() ? ":ext:" : ":pserver:") + config.getUserName() + "@" + config.getHostName() + config.getRemotePath();
+ }
+
+ protected Client getClient() {
+ checkInit();
+ // WARNING TO DEVELOPERS:
+ // Please be warned that attempting to reuse one open connection for
+ // more commands is not supported by cvs servers very well.
+ // You are advised to open a new Connection each time.
+ // If you still want to proceed, please do:
+ // System.setProperty("javacvs.multiple_commands_warning", "false")
+ // That will disable this message.
+
+ // d'ou l'initialisation syst�matique de la connexion.
+
+ String hostName = getConfig().getHostName();
+
+ // R�pertoire distant du CVS
+ String repository = getConfig().getRemotePath();
+
+ String userName = getConfig().getUserName();
+
+ Connection connection;
+ if (getConfig().isUseSshConnexion()) {
+ throw new RuntimeException(CVSHelper.class + " you can not used a ssh connexion with CVS, use instead SVN configuration");
+ // connexion ssh2
+ //TODO Make this works
+ // Localisation de la clef priv�e (pour la connexion ssh2).
+ //File keyFile = new File(config.getKeyFile());
+ // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2
+ //String host = config.getHost();
+ // Localisation de la clef priv�e (pour la connexion ssh2).
+ //File keyFile = new File(IsisConfig.getProperties().getProperty(
+ // IsisConfig.CVS_KEY_FILE));
+ // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2
+ //String host = IsisConfig.getProperties().getProperty(
+ // IsisConfig.CVS_HOST);
+
+// Ssh2Connexion ssh2Connection = new Ssh2Connexion();
+// ssh2Connection.setUserName(userName);
+// ssh2Connection.setHostName(hostName);
+// ssh2Connection.setKeyFile(keyFile);
+// ssh2Connection.setHost(host);
+// ssh2Connection.setRepository(repository);
+// connection = ssh2Connection;
+ } else {
+ String cvsrootString = ":pserver:" + userName + "@" + hostName + repository;
+ CVSRoot cvsroot = CVSRoot.parse(cvsrootString);
+ // connexion pserver
+ PServerConnection PServerConnection;
+ PServerConnection = new PServerConnection(cvsroot);
+// PServerConnection.setUserName(userName);
+// // PServerConnection.setEncodedPassword(encodedPassword);
+// PServerConnection.setHostName(hostName);
+// PServerConnection.setRepository(repository);
+ connection = PServerConnection;
+ }
+
+ // Le connexion est ouverte automatiquement � l'�x�cution de la
+ // commande CVS si elle n'a pas �t� ouverte pr�c�dement. Je l'ouvre pour
+ // obtenir les messages d'erreurs plus clair.
+ // connection.open();
+
+ return new Client(connection, new StandardAdminHandler());
+ }
+
+ public GlobalOptions getGlobalOptions() {
+ checkInit();
+ GlobalOptions result = new GlobalOptions();
+ String repository = getConfig().getRemotePath();
+ result.setCVSRoot(repository);
+ return result;
+ }
}
\ No newline at end of file
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-05 20:41:33 UTC (rev 369)
+++ trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHandler.java 2008-04-05 20:43:32 UTC (rev 370)
@@ -2,10 +2,10 @@
import static org.codelutin.i18n.I18n._;
import org.codelutin.util.FileUtil;
-import org.codelutin.vcs.util.AbstractVCSHandler;
-import org.codelutin.vcs.VCSConfig;
+import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.util.AbstractVCSHandler;
import org.netbeans.lib.cvsclient.command.FileInfoContainer;
import org.netbeans.lib.cvsclient.command.log.LogInformation;
import org.netbeans.lib.cvsclient.command.status.StatusInformation;
@@ -23,27 +23,25 @@
* @author chemit
*/
-public class CVSHandler extends AbstractVCSHandler {
+public class CVSHandler extends AbstractVCSHandler<CVSConnexion> {
- public CVSHandler(VCSConfig config) {
- super(config, "CVS", "Entries");
+ public CVSHandler() {
+ super("CVS", "Entries");
}
- public void initWorkingCopy() throws VCSException {
+ public void initWorkingCopy(CVSConnexion connexion) throws VCSException {
+ VCSConnexionConfig config = connexion.getConfig();
File root = config.getLocalDatabasePath();
- if (!root.exists()) getLocalDatabasePath().mkdirs();
+ if (!root.exists()) config.getLocalDatabasePath().mkdirs();
//TODO Should checkout root remote directory unrecurse ?
//TODO to have vcs configuration file present in local database directory
//CVSHelper.checkout(root,"");
}
- public String getRemoteUrl() {
- return (config.isUseSshConnexion() ? ":ext:" : ":pserver:") + config.getUserName() + "@" + config.getHostName() + config.getRemotePath();
- }
- public boolean isOnRemote(File file) {
+ public boolean isOnRemote(CVSConnexion connexion, File file) {
boolean result = false;
if (file.isDirectory()) {
File cvsdir = new File(file, confLocalDirName);
@@ -64,9 +62,9 @@
return result;
}
- public boolean isUpToDate(File file) throws VCSException {
+ public boolean isUpToDate(CVSConnexion connexion, File file) throws VCSException {
- CVSCommandResult cvsResult = CVSHelper.cvsStatus(file);
+ CVSCommandResult cvsResult = CVSHelper.cvsStatus(connexion, file);
if (cvsResult.isError()) {
throw new VCSException(_("lutinvcs.error.status.files", cvsResult.getTrace().toString()));
}
@@ -86,12 +84,12 @@
return result;
}
- public void makeRemoteDir(String msg, String... dirNames) throws VCSException {
+ public void makeRemoteDir(CVSConnexion connexion, String msg, String... dirNames) throws VCSException {
//TODO
throw new RuntimeException(getClass().getName() + "#makeRemoteDir is not actually implemented");
}
- public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ public void deleteRemoteDir(CVSConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
throw new RuntimeException(getClass().getName() + "#deleteRemoteDir is not actually implemented");
//TODO
}
@@ -101,52 +99,52 @@
//TODO
}*/
- public VCSState getState(File fileState, Collection tmp) throws VCSException {
- return getState(fileState, tmp, true);
+ public VCSState getState(CVSConnexion connexion, File fileState, Collection tmp) throws VCSException {
+ return getState(connexion, fileState, tmp, true);
}
- public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
+ public VCSState getState(CVSConnexion connexion, File file, Collection tmp, boolean noremote) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getState(File) is not actually implemented");
//TODO
}
- public long add(List<File> files, String msg) throws VCSException {
+ public long add(CVSConnexion connexion, List<File> files, String msg) throws VCSException {
log.debug("files to add: " + files);
- CVSCommandResult result = CVSHelper.cvsAdd(files);
+ CVSCommandResult result = CVSHelper.cvsAdd(connexion, files);
assertCommandResult(result, "Can''t add files: {0}");
- result = CVSHelper.cvsCommit(files, msg);
+ result = CVSHelper.cvsCommit(connexion, files, msg);
assertCommandResult(result, "Can''t commit files: {0}");
return -1;
}
- public void delete(List<File> files, String msg) throws VCSException {
+ public void delete(CVSConnexion connexion, List<File> files, String msg) throws VCSException {
- CVSCommandResult result = CVSHelper.cvsRemove(files);
+ CVSCommandResult result = CVSHelper.cvsRemove(connexion, files);
assertCommandResult(result, "Can''t remove files: {0}");
- result = CVSHelper.cvsCommit(files, msg);
+ result = CVSHelper.cvsCommit(connexion, files, msg);
assertCommandResult(result, "Can''t commit deleted files: {0}");
}
- public long commit(List<File> files, String msg) throws VCSException {
- add(files, msg);
+ public long commit(CVSConnexion connexion, List<File> files, String msg) throws VCSException {
+ add(connexion, files, msg);
return 0;
}
- public void update(File file) throws VCSException {
- CVSCommandResult result = CVSHelper.cvsUpdate(file);
+ public void update(CVSConnexion connexion, File file) throws VCSException {
+ CVSCommandResult result = CVSHelper.cvsUpdate(connexion, file);
assertCommandResult(result, "Can''t update files: {0}");
}
- public void checkout(File destDir, String module, boolean recurse) throws VCSException {
- CVSCommandResult result = CVSHelper.checkout(destDir, module);
+ public void checkout(CVSConnexion connexion, 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(File destDir, String module) throws VCSException {
+ public void checkoutFile(CVSConnexion connexion, File destDir, String module) throws VCSException {
/*try {
new File(destDir,module).createNewFile();
} catch (IOException e) {
@@ -156,10 +154,10 @@
}
- public List<String> getRemoteStorageNames(File directory) {
+ public List<String> getRemoteStorageNames(CVSConnexion connexion, File directory) {
List<String> result = new ArrayList<String>();
try {
- CVSCommandResult cvsResult = CVSHelper.cvsLog(directory);
+ CVSCommandResult cvsResult = CVSHelper.cvsLog(connexion, directory);
for (FileInfoContainer info : cvsResult.getFileInfo()) {
if (info instanceof LogInformation) {
LogInformation status = (LogInformation) info;
@@ -177,14 +175,15 @@
* Retourne les messages de logs entre la version local et la remote ou null
* si les deux fichiers ont la meme version
*
- * @param file TODO
- * @param logInfo TODO
+ * @param connexion connexion to be used
+ * @param file TODO
+ * @param logInfo TODO
* @return le log ou null
* @throws VCSException TODO
*/
@SuppressWarnings("unchecked")
- public String getLogMessage(File file, LogInformation logInfo) throws VCSException {
- CVSCommandResult cvsResult = CVSHelper.cvsStatus(file);
+ public String getLogMessage(CVSConnexion connexion, 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()));
}
@@ -234,27 +233,27 @@
}
}
- public void revert(List<File> files) throws VCSException {
+ public void revert(CVSConnexion connexion, List<File> files) throws VCSException {
throw new RuntimeException(getClass().getName() + "#revert is not actually implemented");
//TODO
}
- public Object getRevision(File f) throws VCSException {
+ public Object getRevision(CVSConnexion connexion, File f) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getRevision is not actually implemented");
//TODO
}
- public void update(File file, Object revision) throws VCSException {
+ public void update(CVSConnexion connexion, File file, Object revision) throws VCSException {
throw new RuntimeException(getClass().getName() + "#update(File,Object) is not actually implemented");
//TODO
}
- public String getDiff(File file) throws VCSException {
+ public String getDiff(CVSConnexion connexion, File file) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getDiff(File,OutputStream) is not actually implemented");
//TODO
}
- public String getDiff(File file, Object againstRevision) throws VCSException {
+ public String getDiff(CVSConnexion connexion, File file, Object againstRevision) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getDiff(File,Object,OutputStream) is not actually implemented");
//TODO
}
@@ -263,27 +262,27 @@
//TODO
}
- public boolean hasProtocoleChanged() {
+ public boolean hasProtocoleChanged(CVSConnexion connexion) {
throw new RuntimeException(getClass().getName() + "#hasProtocoleChanged() is not actually implemented");
}
- public String getChangeLog(File file) throws VCSException {
+ public String getChangeLog(CVSConnexion connexion, File file) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getChangeLog((File) is not actually implemented");
//TODO
}
- public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
+ public List getLog(CVSConnexion connexion, 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(File file, Object revision) throws VCSException {
+ public String getFileContent(CVSConnexion connexion, File file, Object revision) throws VCSException {
throw new RuntimeException(getClass().getName() + "#getFileContent(File,Object) is not actually implemented");
//TODO
}
- public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
- checkoutFile(root.getParentFile(), root.getName());
+ public long checkoutOnlyTheDirectory(CVSConnexion connexion, File root, Object revision) throws VCSException {
+ checkoutFile(connexion, root.getParentFile(), root.getName());
return -1;
//throw new RuntimeException(getClass().getName() + "#checkoutOnlyTheDirectory(File,Object) is not actually implemented");
//TODO
Modified: trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHelper.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHelper.java 2008-04-05 20:41:33 UTC (rev 369)
+++ trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/impl/cvs/CVSHelper.java 2008-04-05 20:43:32 UTC (rev 370)
@@ -34,11 +34,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.VCSConfig;
import org.codelutin.vcs.VCSException;
-import org.codelutin.vcs.VCSRuntimeException;
-import org.codelutin.vcs.VCSType;
-import org.netbeans.lib.cvsclient.CVSRoot;
import org.netbeans.lib.cvsclient.Client;
import org.netbeans.lib.cvsclient.admin.Entry;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
@@ -53,8 +49,6 @@
import org.netbeans.lib.cvsclient.command.status.StatusCommand;
import org.netbeans.lib.cvsclient.command.update.UpdateCommand;
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
-import org.netbeans.lib.cvsclient.connection.Connection;
-import org.netbeans.lib.cvsclient.connection.PServerConnection;
import org.netbeans.lib.cvsclient.event.BinaryMessageEvent;
import org.netbeans.lib.cvsclient.event.CVSListener;
import org.netbeans.lib.cvsclient.event.FileAddedEvent;
@@ -71,108 +65,31 @@
import java.util.ArrayList;
import java.util.List;
-/** @author poussin */
+/**
+ * @author poussin
+ * @author tchemit
+ */
public class CVSHelper {
- private static VCSConfig config;
/** Logger for this class */
private static final Log log = LogFactory.getLog(CVSHelper.class);
- static protected Client getClient() {
- // WARNING TO DEVELOPERS:
- // Please be warned that attempting to reuse one open connection for
- // more commands is not supported by cvs servers very well.
- // You are advised to open a new Connection each time.
- // If you still want to proceed, please do:
- // System.setProperty("javacvs.multiple_commands_warning", "false")
- // That will disable this message.
- // d'ou l'initialisation syst�matique de la connexion.
-
- String hostName = getConfig().getHostName();
-
- // R�pertoire distant du CVS
- String repository = getConfig().getRemotePath();
-
- String userName = getConfig().getUserName();
-
- Connection connection;
- if (getConfig().isUseSshConnexion()) {
- throw new RuntimeException(CVSHelper.class + " you can not used a ssh connexion with CVS, use instead SVN configuration");
- // connexion ssh2
- // Localisation de la clef priv�e (pour la connexion ssh2).
- //File keyFile = new File(config.getKeyFile());
- // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2
- //String host = config.etHost();
- // Localisation de la clef priv�e (pour la connexion ssh2).
- //File keyFile = new File(IsisConfig.getProperties().getProperty(
- // IsisConfig.CVS_KEY_FILE));
- // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2
- //String host = IsisConfig.getProperties().getProperty(
- // IsisConfig.CVS_HOST);
-
-// Ssh2Connexion ssh2Connection = new Ssh2Connexion();
-// ssh2Connection.setUserName(userName);
-// ssh2Connection.setHostName(hostName);
-// ssh2Connection.setKeyFile(keyFile);
-// ssh2Connection.setHost(host);
-// ssh2Connection.setRepository(repository);
-// connection = ssh2Connection;
- } else {
- String cvsrootString = ":pserver:" + userName + "@" + hostName + repository;
- CVSRoot cvsroot = CVSRoot.parse(cvsrootString);
- // connexion pserver
- PServerConnection PServerConnection;
- PServerConnection = new PServerConnection(cvsroot);
-// PServerConnection.setUserName(userName);
-// // PServerConnection.setEncodedPassword(encodedPassword);
-// PServerConnection.setHostName(hostName);
-// PServerConnection.setRepository(repository);
- connection = PServerConnection;
- }
-
- // Le connexion est ouverte automatiquement � l'�x�cution de la
- // commande CVS si elle n'a pas �t� ouverte pr�c�dement. Je l'ouvre pour
- // obtenir les messages d'erreurs plus clair.
- // connection.open();
-
- return new Client(connection, new StandardAdminHandler());
- }
-
- private static VCSConfig getConfig() {
- if (config == null) {
- throw new IllegalStateException("config is null, should use provider to init config, or setConfig method");
- }
- if (config.getType() != VCSType.CVS) {
- throw new VCSRuntimeException("can not execute CVS command with " +
- "a [" + config.getType() + "] handler");
- }
- return config;
- }
-
- static public GlobalOptions getGlobalOptions() {
- GlobalOptions result = new GlobalOptions();
- //String repository = IsisConfig.getProperties().getProperty(
- // IsisConfig.CVS_REPOSITORY);
- String repository = getConfig().getRemotePath();
- result.setCVSRoot(repository);
- return result;
- }
-
/**
* Permet de r�cuperer un nouveau module depuis le serveur
* Les donn�es sur le serveur sont dans /cvsroot/isis-fish/data/...
* on ne souhaite pas voir apparaitre data en local, on utilise donc
* le renomage du module a l'arrive pour retirer data
*
- * @param destdir le repertoire local ou il faut mettre le module
- * @param module le nom du module a recuperer
+ * @param connexion connexion to be used
+ * @param destdir le repertoire local ou il faut mettre le module
+ * @param module le nom du module a recuperer
* @return result of command
- * @throws org.codelutin.vcs.VCSException TODO
+ * @throws VCSException TODO
*/
- static public CVSCommandResult checkout(File destdir, String module) throws VCSException {
- String data = getConfig().getRemoteDatabase();
+ static public CVSCommandResult checkout(CVSConnexion connexion, File destdir, String module) throws VCSException {
+ String data = connexion.getConfig().getRemoteDatabase();
//TODO Fix bug when module is a multi path one, check there is no
//TODO File.separator
String sep = File.separator;
@@ -183,8 +100,8 @@
// connexion ssh ou pserver, globalOption et initialisation client
// Intitialistion des options globals
- GlobalOptions globalOptions = getGlobalOptions();
- Client client = getClient();
+ GlobalOptions globalOptions = connexion.getGlobalOptions();
+ Client client = connexion.getClient();
client.setLocalPath(destdir.getPath());
@@ -215,13 +132,14 @@
/**
* Permet de recuperer les mises a jours faite depuis le serveur
*
- * @param file le fichier ou repertoire a mettre a jour recursivement
+ * @param connexion connexion to be used
+ * @param file le fichier ou repertoire a mettre a jour recursivement
* @return the result of the command
* @throws VCSException if any problem while updating
*/
- static public CVSCommandResult cvsUpdate(File file) throws VCSException {
- GlobalOptions globalOptions = getGlobalOptions();
- Client client = getClient();
+ static public CVSCommandResult cvsUpdate(CVSConnexion connexion, File file) throws VCSException {
+ GlobalOptions globalOptions = connexion.getGlobalOptions();
+ Client client = connexion.getClient();
if (!file.exists() || file.isFile()) {
client.setLocalPath(file.getParent());
@@ -254,13 +172,14 @@
/**
* Permet de recuperer les statuts depuis le serveur
*
- * @param file le fichier ou repertoire dont on souhaite le statut recursivement
+ * @param connexion connexion to be used
+ * @param file le fichier ou repertoire dont on souhaite le statut recursivement
* @return the result of the command
* @throws VCSException if any problem while updating
*/
- static public CVSCommandResult cvsStatus(File file) throws VCSException {
- GlobalOptions globalOptions = getGlobalOptions();
- Client client = getClient();
+ static public CVSCommandResult cvsStatus(CVSConnexion connexion, File file) throws VCSException {
+ GlobalOptions globalOptions = connexion.getGlobalOptions();
+ Client client = connexion.getClient();
if (file.isFile()) {
client.setLocalPath(file.getParent());
@@ -298,13 +217,14 @@
/**
* Permet de recuperer les logs depuis le serveur
*
- * @param file le fichier ou repertoire dont on souhaite le log recursivement
+ * @param connexion connexion to be used
+ * @param file le fichier ou repertoire dont on souhaite le log recursivement
* @return the result of the command
* @throws VCSException if any problem while updating
*/
- static public CVSCommandResult cvsLog(File file) throws VCSException {
- GlobalOptions globalOptions = getGlobalOptions();
- Client client = getClient();
+ static public CVSCommandResult cvsLog(CVSConnexion connexion, File file) throws VCSException {
+ GlobalOptions globalOptions = connexion.getGlobalOptions();
+ Client client = connexion.getClient();
if (file.isFile()) {
client.setLocalPath(file.getParent());
@@ -345,12 +265,13 @@
* Tous les r�pertoires contenant des fichiers a ajouter doivent aussi
* etre ajout� s'il ne sont pas deja dans le CVS.
*
- * @param files la listes des fichiers a ajouter, si les fichiers sont
- * deja ajout�s cela ne produit pas d'erreur
+ * @param connexion connexion to be used
+ * @param files la listes des fichiers a ajouter, si les fichiers sont
+ * deja ajout�s cela ne produit pas d'erreur
* @return the result of the command
* @throws VCSException if any problem while updating
*/
- static public CVSCommandResult cvsAdd(List<File> files) throws VCSException {
+ static public CVSCommandResult cvsAdd(CVSConnexion connexion, List<File> files) throws VCSException {
StandardAdminHandler adminHandler = new StandardAdminHandler();
File root = null;
@@ -383,8 +304,8 @@
return new CVSCommandResult();
} else {
log.debug(_("lutinvcs.message.add.cvs", root, fileToAdd));
- GlobalOptions globalOptions = getGlobalOptions();
- Client client = getClient();
+ GlobalOptions globalOptions = connexion.getGlobalOptions();
+ Client client = connexion.getClient();
client.setLocalPath(root.getPath());
@@ -415,12 +336,13 @@
/**
* Permet de marquer des fichier a supprimer du CVS
*
- * @param files la listes des fichiers a supprimer, si les fichiers sont
- * deja supprim�s cela ne produit pas d'erreur
+ * @param connexion connexion to be used
+ * @param files la listes des fichiers a supprimer, si les fichiers sont
+ * deja supprim�s cela ne produit pas d'erreur
* @return the result of the command
* @throws VCSException if any problem while updating
*/
- static public CVSCommandResult cvsRemove(List<File> files) throws VCSException {
+ static public CVSCommandResult cvsRemove(CVSConnexion connexion, List<File> files) throws VCSException {
File root = null;
File tmpRoot = null;
List<File> fileToRemove = new ArrayList<File>();
@@ -442,8 +364,8 @@
return new CVSCommandResult();
} else {
log.debug(_("lutinvcs.message.remove.files", fileToRemove));
- GlobalOptions globalOptions = getGlobalOptions();
- Client client = getClient();
+ GlobalOptions globalOptions = connexion.getGlobalOptions();
+ Client client = connexion.getClient();
client.setLocalPath(root.getPath());
@@ -476,13 +398,14 @@
/**
* Permet d'envoyer des modifications au CVS
*
- * @param files le fichier ou repertoire a envoyer, si file represente un
- * repertoire alors un commit recursif est fait
- * @param msg message of the commit
+ * @param connexion connexion to be used
+ * @param files le fichier ou repertoire a envoyer, si file represente un
+ * repertoire alors un commit recursif est fait
+ * @param msg message of the commit
* @return the result of the command
* @throws VCSException if any problem while updating
*/
- static public CVSCommandResult cvsCommit(List<File> files, String msg) throws VCSException {
+ static public CVSCommandResult cvsCommit(CVSConnexion connexion, List<File> files, String msg) throws VCSException {
File root = null;
File tmpRoot = null;
for (File file : files) {
@@ -495,8 +418,8 @@
}
}
- GlobalOptions globalOptions = getGlobalOptions();
- Client client = getClient();
+ GlobalOptions globalOptions = connexion.getGlobalOptions();
+ Client client = connexion.getClient();
client.setLocalPath(root.getPath());
@@ -524,9 +447,6 @@
return listener.getResult();
}
- public static void setConfig(VCSConfig config) {
- CVSHelper.config = config;
- }
static protected class LogCVSListener implements CVSListener {
protected CVSCommandResult result = new CVSCommandResult();
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-05 20:41:33 UTC (rev 369)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNConnexion.java 2008-04-05 20:43:32 UTC (rev 370)
@@ -14,27 +14,163 @@
*/
package org.codelutin.vcs.impl.svn;
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.vcs.ConnectionState;
+import org.codelutin.vcs.SVNProvider;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSConnexionMode;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSRuntimeException;
import org.codelutin.vcs.util.AbstractVCSConnexion;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSHandler;
+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;
+import org.tmatesoft.svn.core.wc.ISVNOptions;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCClient;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+import java.io.File;
+import java.util.Arrays;
+
/** @author chemit */
public class SVNConnexion extends AbstractVCSConnexion {
- public void init(VCSConfig config, VCSHandler handler) {
- state = null;
+ protected SVNURL repositoryURL;
+
+ protected SVNRepository repository;
+
+ protected SVNClientManager ourClientManager;
+
+ protected SVNWCClient ourWcClient;
+
+ public SVNConnexion(VCSConnexionMode mode, SVNProvider provider) {
+ super(mode, provider);
}
+ public void init(VCSConnexionConfig config) {
+ state = ConnectionState.UNDEFINED;
+ this.config = config;
+
+ try {
+
+ // construct remote repository SVNURL
+
+ repositoryURL = SVNURL.parseURIEncoded(getRemoteUrl());
+ log.info("repositoryURL " + repositoryURL);
+
+ // instanciate runtime default options
+ ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
+
+ // TODO Deal with authentication
+
+ if (config.isUseSshConnexion()) {
+ // we use a ssh2 authentication mecanism (username /keyFile)
+ // just push in System properties that's we need for this...
+ System.setProperty("svnkit.ssh2.key", config.getKeyFile().getAbsolutePath());
+ System.setProperty("svnkit.ssh2.username", config.getUserName());
+ if (!config.isNoPassPhrase()) {
+ char[] pass = getConfig().getPassphrase().toCharArray();
+ if (pass != null) {
+ System.setProperty("svnkit.ssh2.passphrase", Arrays.toString(pass));
+ Arrays.fill(pass, '0');
+ }
+ }
+ //System.setProperty("svnkit.ssh2.password", "");
+ //System.setProperty("svnkit.ssh2.port", "22");
+
+ // instanciate svn client manager
+ ourClientManager = SVNClientManager.newInstance(options);
+
+ } else {
+ // we use a simple authentication mecanism (username/password)
+ ourClientManager = SVNClientManager.newInstance(options, config.getUserName(), config.getUserName());
+ }
+ // instanciate repo
+ repository = ourClientManager.createRepository(repositoryURL, true);
+
+ // add our svn event logger TODO Remake this logger or use the
+ // DebugLog from svnkit ?
+ ourClientManager.setEventHandler(new SVNHelper.SVNEventLoggerHandler());
+ } catch (SVNException e) {
+ // TODO I18N
+ throw new VCSRuntimeException("could not compute repository url ", e);
+ }
+ }
+
@Override
public void close() throws IllegalStateException {
checkInit();
if (!isOpen()) {
return;
}
+ //TODO to be done
+ log.info(this);
}
@Override
public void open() throws IllegalStateException {
checkInit();
+ //TODO testConnexion ?
}
+
+ public String getRemoteUrl() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(config.isUseSshConnexion() ? "svn+ssh://" : "svn://");
+ sb.append(config.getHostName()).append("/");
+ sb.append(config.getRemotePath()).append("/");
+ sb.append(config.getRemoteDatabase());
+ 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()) {
+ // try to test the ssh connection
+
+ 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());
+ return;
+ } catch (VCSException e) {
+ log.warn(_("lutinvcs.error.vcs.no.ssh.connection", getConfig().getUserName(), path));
+ }
+ }
+ // do not use ssh connection
+ getConfig().setUseSshConnexion(false);
+ // try to test with a anonymous connection
+ SVNHelper.testAnonymousConnection(repositoryURL.toString());
+ }
+
+
+ public SVNWCClient getOurWcClient() {
+ if (ourWcClient == null)
+ ourWcClient = ourClientManager.getWCClient();
+ return ourWcClient;
+ }
+
+ public SVNClientManager getOurClientManager() {
+ return ourClientManager;
+ }
+
+ public SVNRepository getRepository() {
+ return repository;
+ }
+
+ 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-05 20:41:33 UTC (rev 369)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHandler.java 2008-04-05 20:43:32 UTC (rev 370)
@@ -20,17 +20,15 @@
package org.codelutin.vcs.impl.svn;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.util.AbstractVCSHandler;
-import org.codelutin.vcs.VCSConfig;
+import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSException;
-import org.codelutin.vcs.util.VCSHelper;
-import static org.codelutin.vcs.util.VCSHelper.isFileInCheckedDir;
import org.codelutin.vcs.VCSRuntimeException;
import org.codelutin.vcs.VCSState;
import static org.codelutin.vcs.VCSState.OUT_OF_DATE;
import static org.codelutin.vcs.VCSState.OUT_OF_DATE_AND_MODIFIED;
import static org.codelutin.vcs.VCSState.UP_TO_DATE;
import org.codelutin.vcs.VCSStatus;
+import org.codelutin.vcs.util.AbstractVCSHandler;
import org.tmatesoft.svn.core.ISVNDirEntryHandler;
import org.tmatesoft.svn.core.ISVNLogEntryHandler;
import org.tmatesoft.svn.core.SVNCommitInfo;
@@ -39,21 +37,15 @@
import org.tmatesoft.svn.core.SVNLogEntry;
import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.SVNURL;
-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.SVNStatus;
import org.tmatesoft.svn.core.wc.SVNStatusType;
import static org.tmatesoft.svn.core.wc.SVNStatusType.*;
-import org.tmatesoft.svn.core.wc.SVNWCClient;
-import org.tmatesoft.svn.core.wc.SVNWCUtil;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -65,83 +57,16 @@
* @author chemit
*/
-public final class SVNHandler extends AbstractVCSHandler {
+public final class SVNHandler extends AbstractVCSHandler<SVNConnexion> {
- protected SVNURL repositoryURL;
-
- protected SVNRepository repository;
-
- protected SVNClientManager ourClientManager;
-
- protected SVNWCClient ourWcClient;
-
- public SVNHandler(VCSConfig config) {
-
- super(config, ".svn", "entries");
-
- SVNHelper.setupLibrary();
-
- try {
-
- // construct remote repository SVNURL
-
- repositoryURL = SVNURL.parseURIEncoded(getRemoteUrl());
- log.info("repositoryURL " + repositoryURL);
-
- // instanciate runtime default options
- ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
-
- // TODO Deal with authentication
-
- if (config.isUseSshConnexion()) {
- // we use a ssh2 authentication mecanism (username /keyFile)
- // just push in System properties that's we need for this...
- System.setProperty("svnkit.ssh2.key", config.getKeyFile().getAbsolutePath());
- System.setProperty("svnkit.ssh2.username", config.getUserName());
- if (!config.isNoPassPhrase()) {
- char[] pass = getConfig().getPassphrase().toCharArray();
- if (pass != null) {
- System.setProperty("svnkit.ssh2.passphrase", Arrays.toString(pass));
- Arrays.fill(pass, '0');
- }
- }
- //System.setProperty("svnkit.ssh2.password", "");
- //System.setProperty("svnkit.ssh2.port", "22");
-
- // instanciate svn client manager
- ourClientManager = SVNClientManager.newInstance(options);
-
- } else {
- // we use a simple authentication mecanism (username/password)
- ourClientManager = SVNClientManager.newInstance(options, config.getUserName(), config.getUserName());
- }
- // instanciate repo
- repository = ourClientManager.createRepository(repositoryURL, true);
-
- // add our svn event logger TODO Remake this logger or use the
- // DebugLog from svnkit ?
- ourClientManager.setEventHandler(new SVNHelper.SVNEventLoggerHandler());
- } catch (SVNException e) {
- // TODO I18N
- throw new VCSRuntimeException("could not compute repository url ", e);
- }
+ public SVNHandler() {
+ super(".svn", "entries");
}
- public boolean hasProtocoleChanged() throws VCSException {
- File root = config.getLocalDatabasePath();
- if (!root.exists() || !isFileInCheckedDir(root, this)) {
- // local database does not exists, so no switch
- return false;
- }
- String oldProtocol = getSVNStatus(root, false).getURL().getProtocol();
- String newProtocol = repositoryURL.getProtocol();
- return !oldProtocol.equals(newProtocol);
- }
-
- public void initWorkingCopy() throws VCSException {
+ public void initWorkingCopy(SVNConnexion connexion) throws VCSException {
try {
// test connection
- repository.testConnection();
+ connexion.getRepository().testConnection();
} catch (SVNException e1) {
// connexion failed, what do we want to do ? display vcs
@@ -150,47 +75,20 @@
throw new VCSException(e1);
}
+ VCSConnexionConfig config = connexion.getConfig();
File root = config.getLocalDatabasePath();
if (!root.exists()) {
- getLocalDatabasePath().mkdirs();
+ config.getLocalDatabasePath().mkdirs();
}
- long lastRevision = checkoutOnlyTheDirectory(root, SVNRevision.HEAD);
+ long lastRevision = checkoutOnlyTheDirectory(connexion, root, SVNRevision.HEAD);
log.info(_("lutinvcs.message.copy.revision", null, lastRevision));
}
- public void testConnection() throws VCSException {
- if (getConfig().isUseSshConnexion()) {
- // try to test the ssh connection
-
- 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());
- return;
- } catch (VCSException e) {
- log.warn(_("lutinvcs.error.vcs.no.ssh.connection", getConfig().getUserName(), path));
- }
- }
- // do not use ssh connection
- getConfig().setUseSshConnexion(false);
- // try to test with a anonymous connection
- SVNHelper.testAnonymousConnection(repositoryURL.toString());
- }
-
- public String getRemoteUrl() {
- StringBuilder sb = new StringBuilder();
- sb.append(config.isUseSshConnexion() ? "svn+ssh://" : "svn://");
- sb.append(config.getHostName()).append("/");
- sb.append(config.getRemotePath()).append("/");
- sb.append(config.getRemoteDatabase());
- return sb.toString();
- }
-
// TODO Delete VCSStatus and all links, use VCSState
- public VCSStatus getStatus(File file) {
+ public VCSStatus getStatus(SVNConnexion connexion, File file) {
SVNStatusType statusType;
try {
- statusType = getStatusType(file);
+ statusType = getStatusType(connexion, file);
} catch (SVNException e) {
return VCSStatus.NONE;
}
@@ -217,18 +115,18 @@
}
// tmp is used to get back the revision
- public VCSState getState(File file, Collection tmp) throws VCSException {
- return getState(file, tmp, true);
+ public VCSState getState(SVNConnexion connexion, File file, Collection tmp) throws VCSException {
+ return getState(connexion, file, tmp, true);
}
@SuppressWarnings("unchecked")
- public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
+ public VCSState getState(SVNConnexion connexion, File file, Collection tmp, boolean noremote) throws VCSException {
VCSState result = VCSState.UNKNOWN;
boolean exist = file.exists();
- VCSHelper.assertFileInWC(file, this);
+ assertFileInWC(file, this, connexion);
// file is in a working copy
@@ -242,7 +140,7 @@
// check if present on remote repository
try {
- stat = ourClientManager.getStatusClient().doStatus(file, true);
+ stat = connexion.getOurClientManager().getStatusClient().doStatus(file, true);
if (stat != null) {
@@ -272,7 +170,7 @@
// file is under VCS and exists
try {
- stat = ourClientManager.getStatusClient().doStatus(file, true);
+ stat = connexion.getOurClientManager().getStatusClient().doStatus(file, true);
} catch (SVNException e) {
log.warn(_("lutinvcs.error.not.find.status", file, e.getErrorMessage()));
@@ -322,35 +220,35 @@
private int prefixPath = -1;
- private int getPrefixPath() {
+ private int getPrefixPath(SVNConnexion connexion) {
if (prefixPath == -1)
- prefixPath = getLocalDatabasePath().getAbsolutePath().length() + 1;
+ prefixPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath().length() + 1;
return prefixPath;
}
- private String getRelativePath(File f) {
+ private String getRelativePath(SVNConnexion connexion, File f) {
final String path = f.getAbsolutePath();
- return path.length() <= getPrefixPath() ? path : path.substring(getPrefixPath());
+ return path.length() <= getPrefixPath(connexion) ? path : path.substring(getPrefixPath(connexion));
}
- public boolean isOnRemote(File file) {
- VCSStatus fileStatus = getStatus(file);
+ public boolean isOnRemote(SVNConnexion connexion, File file) {
+ VCSStatus fileStatus = getStatus(connexion, file);
return !(VCSStatus.UNVERSIONED == fileStatus || VCSStatus.NONE == fileStatus);
}
- public boolean isUpToDate(File file) throws VCSException {
- SVNStatus status = getSVNStatus(file);
+ public boolean isUpToDate(SVNConnexion connexion, File file) throws VCSException {
+ SVNStatus status = getSVNStatus(connexion, file);
return status.getContentsStatus() == STATUS_NORMAL && STATUS_NONE == status.getRemoteContentsStatus();
}
- public long add(List<File> files, String msg) throws VCSException {
+ public long add(SVNConnexion connexion, 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(file);
+ VCSStatus status = getStatus(connexion, file);
if (!file.exists() || status == VCSStatus.NORMAL) {
// do not commit this file
it.remove();
@@ -358,15 +256,15 @@
}
// we must check first if file need really to be added ?
if (status == VCSStatus.UNVERSIONED) {
- getOurWcClient().doAdd(file, false, false, false, false, false);
- log.debug("mark to add '" + getRelativePath(file) + "'");
+ connexion.getOurWcClient().doAdd(file, false, false, false, false, false);
+ log.debug("mark to add '" + getRelativePath(connexion, file) + "'");
}
}
if (!filesTmp.isEmpty() && msg != null) {
// we do commit
- long rev = commit(filesTmp, msg);
+ long rev = commit(connexion, filesTmp, msg);
for (File file : filesTmp) {
- log.info("'" + getRelativePath(file) + "' at revison " + rev);
+ log.info("'" + getRelativePath(connexion, file) + "' at revison " + rev);
}
return rev;
}
@@ -376,23 +274,23 @@
return -1;
}
- public void delete(List<File> files, String msg) throws VCSException {
+ public void delete(SVNConnexion connexion, List<File> files, String msg) throws VCSException {
assertFilesExist(files, "delete");
- files.remove(getLocalDatabasePath());
- files.remove(getLocalDatabasePath().getParentFile());
+ files.remove(connexion.getConfig().getLocalDatabasePath());
+ files.remove(connexion.getConfig().getLocalDatabasePath().getParentFile());
try {
// when delete is true, after commit we have a none status
for (File file : files) {
- getOurWcClient().doDelete(file, true, msg != null, false);
- log.debug("mark to delete '" + getRelativePath(file) + "'");
+ connexion.getOurWcClient().doDelete(file, true, msg != null, false);
+ log.debug("mark to delete '" + getRelativePath(connexion, file) + "'");
}
long revision;
if (msg != null) {
// we do commit
- revision = commit(files, msg);
+ revision = commit(connexion, files, msg);
for (File file : files) {
- log.info("'" + getRelativePath(file) + "' at revison " + revision);
+ log.info("'" + getRelativePath(connexion, file) + "' at revison " + revision);
}
}
} catch (SVNException e) {
@@ -400,27 +298,27 @@
}
}
- public void revert(List<File> files) throws VCSException {
+ public void revert(SVNConnexion connexion, 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(file) == VCSStatus.NORMAL) {
+ if (getStatus(connexion, file) == VCSStatus.NORMAL) {
continue;
}
- getOurWcClient().doRevert(file, true);
- log.info("'" + getRelativePath(file) + "' at revison " + "TODO");
+ connexion.getOurWcClient().doRevert(file, true);
+ log.info("'" + getRelativePath(connexion, file) + "' at revison " + "TODO");
}
} catch (SVNException e) {
throw new VCSException(e);
}
}
- public long commit(List<File> files, String msg) throws VCSException {
+ public long commit(SVNConnexion connexion, List<File> files, String msg) throws VCSException {
assertFilesExist(files, "commit");
try {
- SVNCommitInfo commitInfo = ourClientManager.getCommitClient()
+ SVNCommitInfo commitInfo = connexion.getOurClientManager().getCommitClient()
.doCommit(files.toArray(new File[files.size()]), false, msg, false, true);
log.debug("to revision " + commitInfo.getNewRevision());
return commitInfo.getNewRevision();
@@ -429,8 +327,8 @@
}
}
- public void update(File file) throws VCSException {
- update(file, SVNRevision.HEAD);
+ public void update(SVNConnexion connexion, File file) throws VCSException {
+ update(connexion, file, SVNRevision.HEAD);
}
/**
@@ -439,45 +337,45 @@
* @throws VCSException if any exception while update operation (like update a
* locally modified file or a unversionned file)
*/
- public void update(File file, Object revision) throws VCSException {
+ public void update(SVNConnexion connexion, File file, Object revision) throws VCSException {
try {
- VCSStatus status = getStatus(file);
+ VCSStatus status = getStatus(connexion, 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 = ourClientManager.getUpdateClient().doUpdate(file, (SVNRevision) revision, true);
- log.info("'" + getRelativePath(file) + "' to revision " + newRev);
+ long newRev = connexion.getOurClientManager().getUpdateClient().doUpdate(file, (SVNRevision) revision, true);
+ log.info("'" + getRelativePath(connexion, file) + "' to revision " + newRev);
} catch (SVNException e) {
throw new VCSException(e);
}
}
- public void checkout(File destDir, String module, boolean recurse)
+ public void checkout(SVNConnexion connexion, File destDir, String module, boolean recurse)
throws VCSException {
try {
- final SVNURL urlModule = repositoryURL.appendPath(module, true);
+ final SVNURL urlModule = connexion.getRepositoryURL().appendPath(module, true);
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(modulePath) + "' (module:" + module + ")");
- ourClientManager.getUpdateClient().doCheckout(urlModule, modulePath, null, SVNRevision.HEAD, recurse);
+ log.info(urlModule + " to path '" + getRelativePath(connexion, modulePath) + "' (module:" + module + ")");
+ connexion.getOurClientManager().getUpdateClient().doCheckout(urlModule, modulePath, null, SVNRevision.HEAD, recurse);
} catch (SVNException e) {
throw new VCSException(e);
}
}
- public void checkoutFile(File destDir, String module) throws VCSException {
- update(new File(destDir, module));
+ public void checkoutFile(SVNConnexion connexion, File destDir, String module) throws VCSException {
+ update(connexion, new File(destDir, module));
}
- public long checkoutOnlyTheDirectory(File root, Object revision)
+ public long checkoutOnlyTheDirectory(SVNConnexion connexion, File root, Object revision)
throws VCSException {
long lastRevision;
try {
// obtain module
- File repoRoot = getLocalDatabasePath();
+ File repoRoot = connexion.getConfig().getLocalDatabasePath();
File tmp = root;
StringBuilder sb = new StringBuilder();
while (!tmp.equals(repoRoot)) {
@@ -488,16 +386,16 @@
if (module.length() > 0)
module = module.substring(1);
- SVNURL url = repositoryURL.appendPath(module, true);
+ SVNURL url = connexion.getRepositoryURL().appendPath(module, true);
- lastRevision = ourClientManager.getUpdateClient().doCheckout(
+ lastRevision = connexion.getOurClientManager().getUpdateClient().doCheckout(
url,
root,
null,
(SVNRevision) (revision == null ? SVNRevision.HEAD
: revision), false);
- log.info(url + " to path '" + getRelativePath(root) + "' (module:" + module + ") to revision " + lastRevision);
+ log.info(url + " to path '" + getRelativePath(connexion, root) + "' (module:" + module + ") to revision " + lastRevision);
// Suppress all files from root directory of working copy
for (File file : root.listFiles())
if (file.isFile())
@@ -508,7 +406,7 @@
return lastRevision;
}
- public List<String> getRemoteStorageNames(File directory)
+ public List<String> getRemoteStorageNames(SVNConnexion connexion, File directory)
throws VCSException {
final List<String> result = new ArrayList<String>();
@@ -522,7 +420,7 @@
if (dirEntry.getKind() == SVNNodeKind.FILE) {
String s = dirEntry.getRelativePath();
- // TODO Prefer use VCSHelper.XXX method to convert names
+ // TODO Prefer use XXX method to convert names
if (s.indexOf("/") > -1) {
s = s.replaceAll("/", sep.equals("\\") ? sep + sep : sep);
}
@@ -530,8 +428,7 @@
}
}
};
- ourClientManager.getLogClient().doList(directory, SVNRevision.BASE,
- SVNRevision.HEAD, true, handler);
+ connexion.getOurClientManager().getLogClient().doList(directory, SVNRevision.BASE, SVNRevision.HEAD, true, handler);
} catch (SVNException e) {
throw new VCSException(e);
}
@@ -539,10 +436,10 @@
return result;
}
- public SVNRevision getRevision(File f) throws VCSException {
+ public SVNRevision getRevision(SVNConnexion connexion, File f) throws VCSException {
SVNStatus status;
try {
- status = ourClientManager.getStatusClient().doStatus(f, false);
+ status = connexion.getOurClientManager().getStatusClient().doStatus(f, false);
return status.getRevision();
} catch (SVNException e) {
throw new VCSException(e);
@@ -556,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(Object startRevision, Object endRevision,
+ public List<SVNLogEntry> getLog(SVNConnexion connexion, Object startRevision, Object endRevision,
File file) throws VCSException {
final List<SVNLogEntry> result = new ArrayList<SVNLogEntry>();
- final long workingRevision = getRevision(file).getNumber();
+ final long workingRevision = getRevision(connexion, file).getNumber();
final long startRev = ((SVNRevision) startRevision).getNumber();
ISVNLogEntryHandler handler = new ISVNLogEntryHandler() {
@@ -573,7 +470,7 @@
};
try {
- ourClientManager.getLogClient().doLog(new File[]{file},
+ connexion.getOurClientManager().getLogClient().doLog(new File[]{file},
(SVNRevision) startRevision, (SVNRevision) endRevision,
false, false, 1024, handler);
} catch (SVNException e) {
@@ -591,13 +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(File file) throws VCSException {
+ public String getChangeLog(SVNConnexion connexion, File file) throws VCSException {
SVNRevision startRevision = file.exists() ? SVNRevision.WORKING
: SVNRevision.create(0);
log.debug("file " + file + " init Rev " + startRevision);
- List<SVNLogEntry> logInfo = getLog(startRevision, SVNRevision.HEAD,
+ List<SVNLogEntry> logInfo = getLog(connexion, startRevision, SVNRevision.HEAD,
file);
// List<SVNLogEntry> logInfo = getLog(file.exists()?SVNRevision.WORKING:
// SVNRevision.BASE, SVNRevision.HEAD, file);
@@ -625,20 +522,20 @@
return result.substring(1);
}
- public String getDiff(File file) throws VCSException, IOException {
+ public String getDiff(SVNConnexion connexion, File file) throws VCSException, IOException {
// make diff against Head revision of file
- return getDiff(file, SVNRevision.HEAD);
+ return getDiff(connexion, file, SVNRevision.HEAD);
}
- public String getDiff(File file, Object againstRevision)
+ public String getDiff(SVNConnexion connexion, File file, Object againstRevision)
throws VCSException, IOException {
assertFileExist(file, "getDiff");
SVNRevision remoteRevision = (SVNRevision) againstRevision;
- SVNStatus status = getSVNStatus(file);
+ SVNStatus status = getSVNStatus(connexion, file);
if (status == null) {
throw new VCSException("could not found status for the file " + file);
@@ -667,7 +564,7 @@
// we know there is something to diff
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
- ourClientManager.getDiffClient().doDiff(file, localRevision, file, remoteRevision, true, false, baos);
+ connexion.getOurClientManager().getDiffClient().doDiff(file, localRevision, file, remoteRevision, true, false, baos);
return baos.toString();
} catch (Exception e) {
throw new VCSException(e);
@@ -676,16 +573,20 @@
}
}
- public String getFileContent(File file, Object revision)
+ public boolean hasProtocoleChanged(SVNConnexion connexion) throws VCSException {
+ return connexion.hasProtocoleChanged(this);
+ }
+
+ public String getFileContent(SVNConnexion connexion, 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();
- int prefixRoot = getLocalDatabasePath().getAbsolutePath().length();
+ int prefixRoot = connexion.getConfig().getLocalDatabasePath().getAbsolutePath().length();
if (path.length() < prefixRoot) {
- throw new VCSException("can't get the content file for file " + file + " since it is not under the root working copy (" + getLocalDatabasePath() + ")");
+ throw new VCSException("can't get the content file for file " + file + " since it is not under the root working copy (" + connexion.getConfig().getLocalDatabasePath() + ")");
}
String sep = File.separator;
path = path.substring(prefixRoot).replaceAll("\\".equals(sep) ? "\\\\" : sep, "/");
@@ -693,9 +594,9 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
- repository.setLocation(repositoryURL, false);
+ connexion.getRepository().setLocation(connexion.getRepositoryURL(), false);
- repository.getFile(path.substring(1), ((SVNRevision) revision).getNumber(), null, baos);
+ connexion.getRepository().getFile(path.substring(1), ((SVNRevision) revision).getNumber(), null, baos);
return baos.toString();
} catch (SVNException e) {
@@ -705,21 +606,21 @@
}
}
- public byte[] getBinaryFileContent(File file, Object revision) throws VCSException, IOException {
+ public byte[] getBinaryFileContent(SVNConnexion connexion, 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();
- int prefixRoot = getLocalDatabasePath().getAbsolutePath().length();
+ int prefixRoot = connexion.getConfig().getLocalDatabasePath().getAbsolutePath().length();
if (path.length() < prefixRoot)
- throw new VCSException("can't get the content file for file " + file + " since it is not under the root working copy (" + getLocalDatabasePath() + ")");
+ throw new VCSException("can't get the content file for file " + file + " since it is not under the root working copy (" + connexion.getConfig().getLocalDatabasePath() + ")");
String sep = File.separator;
path = path.substring(prefixRoot).replaceAll("\\".equals(sep) ? "\\\\" : sep, "/");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
- repository.setLocation(repositoryURL, false);
- repository.getFile(path.substring(1), ((SVNRevision) revision).getNumber(), null, baos);
+ connexion.getRepository().setLocation(connexion.getRepositoryURL(), false);
+ connexion.getRepository().getFile(path.substring(1), ((SVNRevision) revision).getNumber(), null, baos);
return baos.toByteArray();
} catch (SVNException e) {
throw new VCSException(e);
@@ -728,32 +629,23 @@
}
}
- public SVNURL getRepositoryURL() {
- return repositoryURL;
+ 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(File file, boolean remote) throws VCSException {
+ protected SVNStatus getSVNStatus(SVNConnexion connexion, File file, boolean remote) throws VCSException {
try {
- return ourClientManager.getStatusClient().doStatus(file, remote);
+ return connexion.getOurClientManager().getStatusClient().doStatus(file, remote);
} catch (SVNException e) {
throw new VCSException(e);
}
}
- protected SVNStatusType getStatusType(File file) throws SVNException {
- SVNStatus status = ourClientManager.getStatusClient().doStatus(file, false);
+ protected SVNStatusType getStatusType(SVNConnexion connexion, File file) throws SVNException {
+ SVNStatus status = connexion.getOurClientManager().getStatusClient().doStatus(file, false);
return status == null ? UNKNOWN : status.getContentsStatus();
}
- private SVNWCClient getOurWcClient() {
- if (ourWcClient == null)
- ourWcClient = ourClientManager.getWCClient();
- return ourWcClient;
- }
private void assertFilesExist(List<File> files, String command)
throws VCSException {
@@ -766,19 +658,19 @@
throw new VCSRuntimeException(getClass().getName() + "#" + command + "(File,...) first argument can not be null");
}
- public void makeRemoteDir(String commitMessage, String... dirNames)
+ public void makeRemoteDir(SVNConnexion connexion, String commitMessage, String... dirNames)
throws VCSException {
try {
SVNURL[] urls = new SVNURL[dirNames.length];
for (int i = 0; i < dirNames.length; i++) {
- SVNURL url = repositoryURL;
+ SVNURL url = connexion.getRepositoryURL();
for (String path : dirNames[i].split("/"))
url = url.appendPath(path, false);
urls[i] = url;
}
- SVNCommitInfo commit = ourClientManager.getCommitClient().doMkDir(
+ SVNCommitInfo commit = connexion.getOurClientManager().getCommitClient().doMkDir(
urls, commitMessage);
long rev = commit.getNewRevision();
for (String dirName : dirNames) {
@@ -789,18 +681,18 @@
}
}
- public void deleteRemoteDir(String commitMessage, String... dirNames)
+ public void deleteRemoteDir(SVNConnexion connexion, String commitMessage, String... dirNames)
throws VCSException {
try {
SVNURL[] urls = new SVNURL[dirNames.length];
for (int i = 0; i < dirNames.length; i++) {
- SVNURL url = repositoryURL;
+ SVNURL url = connexion.getRepositoryURL();
for (String path : dirNames[i].split("/"))
url = url.appendPath(path, false);
urls[i] = url;
}
- SVNCommitInfo commit = ourClientManager.getCommitClient().doDelete(
+ SVNCommitInfo commit = connexion.getOurClientManager().getCommitClient().doDelete(
urls, commitMessage);
long rev = commit.getNewRevision();
for (String dirName : dirNames) {
Modified: 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-05 20:41:33 UTC (rev 369)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/SVNHelper.java 2008-04-05 20:43:32 UTC (rev 370)
@@ -22,7 +22,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.vcs.VCSException;
-import org.codelutin.vcs.util.VCSHelper;
+import org.codelutin.vcs.util.AbstractVCSHandler;
import org.codelutin.vcs.VCSRuntimeException;
import org.codelutin.vcs.VCSTypeRepo;
import org.tmatesoft.svn.core.SVNCancelException;
@@ -183,8 +183,8 @@
VCSTypeRepo result;
- String remotePath = VCSHelper.getRemotePath(typeRepo, uncleanRemotePath);
- String remoteDatabase = VCSHelper.getRemoteDatabase(typeRepo, databaseVersion);
+ 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();
1
0
[Buix-commits] r369 - in trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs: . impl/svn
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:41:33 +0000 (Sat, 05 Apr 2008)
New Revision: 369
Added:
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/VCSRevisionImpl.java
Removed:
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/VCSRevisionImpl.java
Log:
move
Deleted: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/VCSRevisionImpl.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/VCSRevisionImpl.java 2008-04-05 20:41:21 UTC (rev 368)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/VCSRevisionImpl.java 2008-04-05 20:41:33 UTC (rev 369)
@@ -1,31 +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 org.tmatesoft.svn.core.wc.SVNRevision;
-
-/** @author chemit */
-public class VCSRevisionImpl implements VCSRevision {
-
- SVNRevision rev;
-
- public String getValue() {
- return rev == null ? null : rev.toString();
- }
-
- public void setRev(SVNRevision rev) {
- this.rev = rev;
- }
-}
Copied: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/VCSRevisionImpl.java (from rev 345, trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/VCSRevisionImpl.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/VCSRevisionImpl.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/impl/svn/VCSRevisionImpl.java 2008-04-05 20:41:33 UTC (rev 369)
@@ -0,0 +1,32 @@
+/**
+ * # #% 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.tmatesoft.svn.core.wc.SVNRevision;
+import org.codelutin.vcs.VCSRevision;
+
+/** @author chemit */
+public class VCSRevisionImpl implements VCSRevision {
+
+ SVNRevision rev;
+
+ public String getValue() {
+ return rev == null ? null : rev.toString();
+ }
+
+ public void setRev(SVNRevision rev) {
+ this.rev = rev;
+ }
+}
1
0
[Buix-commits] r368 - trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:41:21 +0000 (Sat, 05 Apr 2008)
New Revision: 368
Modified:
trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/CVSProvider.java
Log:
refactor providers
Modified: trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/CVSProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/CVSProvider.java 2008-04-05 20:40:44 UTC (rev 367)
+++ trunk/lutinvcs/lutinvcs-provider-cvs/src/main/java/org/codelutin/vcs/CVSProvider.java 2008-04-05 20:41:21 UTC (rev 368)
@@ -16,24 +16,13 @@
import org.codelutin.vcs.impl.cvs.CVSConnexion;
import org.codelutin.vcs.impl.cvs.CVSHandler;
-import org.codelutin.vcs.impl.cvs.CVSHelper;
import org.codelutin.vcs.util.AbstractVCSProvider;
/** @author chemit */
-public class CVSProvider extends AbstractVCSProvider<CVSHandler, CVSConnexion> {
+public class CVSProvider extends AbstractVCSProvider<CVSConnexion, CVSHandler> {
public CVSProvider() {
- super("CVS", CVSHandler.class);
+ super("CVS", CVSHandler.class, CVSConnexion.class);
}
- @Override
- public CVSHandler newInstance(VCSConfig config) {
- CVSHelper.setConfig(config);
- return super.newInstance(config);
- }
-
- public CVSConnexion newConnection(VCSConnexionMode mode, VCSConfig config) {
- checkHandlerInit();
- return null;
- }
}
\ No newline at end of file
1
0
[Buix-commits] r367 - trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:40:44 +0000 (Sat, 05 Apr 2008)
New Revision: 367
Modified:
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
Log:
refactor providers
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-05 20:40:27 UTC (rev 366)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-05 20:40:44 UTC (rev 367)
@@ -14,19 +14,37 @@
*/
package org.codelutin.vcs;
+import org.codelutin.vcs.impl.svn.SVNConnexion;
import org.codelutin.vcs.impl.svn.SVNHandler;
-import org.codelutin.vcs.util.AbstractVCSConnexion;
import org.codelutin.vcs.util.AbstractVCSProvider;
+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;
-/** @author chemit */
-public class SVNProvider extends AbstractVCSProvider<SVNHandler, AbstractVCSConnexion> {
+/**
+ * SVN Provider
+ *
+ * @author chemit
+ */
+public class SVNProvider extends AbstractVCSProvider<SVNConnexion, SVNHandler> {
public SVNProvider() {
- super("SVN", SVNHandler.class);
+ super("SVN", SVNHandler.class, SVNConnexion.class);
}
- public AbstractVCSConnexion newConnection(VCSConnexionMode mode, VCSConfig config) {
- checkHandlerInit();
- return null;
+ @Override
+ public void init() {
+
+ // For using over http:// and https://
+ DAVRepositoryFactory.setup();
+
+ // For using over svn:// and svn+xxx://
+ SVNRepositoryFactoryImpl.setup();
+
+ // For using over file:///
+ FSRepositoryFactory.setup();
+
+ super.init();
}
+
}
1
0
[Buix-commits] r366 - in trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs: . impl/mock
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:40:27 +0000 (Sat, 05 Apr 2008)
New Revision: 366
Removed:
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java
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/impl/mock/MockConnexion.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java
Log:
refactor providers
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-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -19,14 +19,10 @@
import org.codelutin.vcs.util.AbstractVCSProvider;
/** @author chemit */
-public class MockProvider extends AbstractVCSProvider<MockVCSHandler, MockConnexion> {
+public class MockProvider extends AbstractVCSProvider<MockConnexion, MockVCSHandler> {
public MockProvider() {
- super("MOCK", MockVCSHandler.class);
+ super("MOCK", MockVCSHandler.class, MockConnexion.class);
}
- public MockConnexion newConnection(VCSConnexionMode mode, VCSConfig config) {
- checkHandlerInit();
- return null;
- }
}
\ 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-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -14,27 +14,39 @@
*/
package org.codelutin.vcs.impl.mock;
+import org.codelutin.vcs.ConnectionState;
+import org.codelutin.vcs.MockProvider;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.ConnectionState;
/** @author chemit */
public class MockConnexion extends AbstractVCSConnexion {
- public void init(VCSConfig config, VCSHandler handler) {
+ public MockConnexion(VCSConnexionMode mode, MockProvider provider) {
+ super(mode, provider);
+ }
+
+ public void init(VCSConnexionConfig config) {
state = ConnectionState.INIT;
+ this.config = config;
}
+ public void testConnection() throws VCSException {
+ }
+
@Override
public void close() throws IllegalStateException {
checkInit();
+ fireClose();
}
@Override
public void open() throws IllegalStateException {
checkInit();
- state = ConnectionState.INIT;
+ state = ConnectionState.ON_LINE;
+ fireOpen();
}
}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java 2008-04-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -1,126 +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.impl.mock;
-
-import org.codelutin.vcs.ConnectionState;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSType;
-import org.codelutin.vcs.VCSTypeRepo;
-
-import java.io.File;
-import java.net.URL;
-
-/** @author chemit */
-public class MockVCSConfig implements VCSConfig {
-
- File localRoot;
- URL remoteRoot;
-
- boolean init;
-
- public boolean canConnect() {
- return false;
- }
-
- public boolean isConnected() {
- return false;
- }
-
- public ConnectionState getConnectionState() {
- return null;
- }
-
- public VCSType getType() {
- return VCSType.MOCK;
- }
-
- public boolean isUseSshConnexion() {
- return false;
- }
-
- public String getHostName() {
- return null;
- }
-
- public File getKeyFile() {
- return null;
- }
-
- public String getUserName() {
- return null;
- }
-
- public boolean isNoPassPhrase() {
- return false;
- }
-
- public String getPassphrase() {
- return null;
- }
-
- public String getRemotePath() {
- return null;
- }
-
- public String getRemoteDatabase() {
- return remoteRoot.toString();
- }
-
- public String getRemoteDatabasePath() {
- return remoteRoot.toString();
- }
-
- public File getLocalDatabasePath() {
- return localRoot;
- }
-
- public VCSTypeRepo getTypeRepo() {
- return null;
- }
-
- public boolean isOffline() {
- return false;
- }
-
- public boolean isReadOnly() {
- return false;
- }
-
- public boolean isInit() {
- return init;
- }
-
- public void validate() {
- }
-
- public void setUseSshConnexion(boolean useSshConnexion) {
- }
-
- public File getSource() {
- return null;
- }
-
- public void setLocalRoot(File localRoot) {
- this.localRoot = localRoot;
- }
-
- public void setRemoteRoot(URL remoteRoot) {
- this.remoteRoot = remoteRoot;
- }
-
- public void setInit(boolean init) {
- this.init = init;
- }
-}
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java 2008-04-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -14,10 +14,9 @@
*/
package org.codelutin.vcs.impl.mock;
-import org.codelutin.vcs.util.AbstractVCSHandler;
-import org.codelutin.vcs.VCSConfig;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.util.AbstractVCSHandler;
import java.io.File;
import java.io.IOException;
@@ -25,103 +24,96 @@
import java.util.List;
/** @author chemit */
-public class MockVCSHandler extends AbstractVCSHandler {
+public class MockVCSHandler extends AbstractVCSHandler<MockConnexion> {
- public MockVCSHandler(VCSConfig config) {
- super(config, "", "");
+ public MockVCSHandler() {
+ super("", "");
}
- public void initWorkingCopy() throws VCSException {
+ public void initWorkingCopy(MockConnexion connexion) throws VCSException {
}
- public String getRemoteUrl() {
+ public VCSState getState(MockConnexion connexion, File fileState, Collection tmp) throws VCSException {
return null;
}
- public VCSState getState(File fileState, Collection tmp) throws VCSException {
+ public VCSState getState(MockConnexion connexion, File file, Collection tmp, boolean noremote) throws VCSException {
return null;
}
- public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
- return null;
- }
-
- public boolean isOnRemote(File file) {
+ public boolean isOnRemote(MockConnexion connexion, File file) {
return false;
}
- public boolean isUpToDate(File file) throws VCSException {
+ public boolean isUpToDate(MockConnexion connexion, File file) throws VCSException {
return false;
}
- public void makeRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ public void makeRemoteDir(MockConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
}
- public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ public void deleteRemoteDir(MockConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
}
- public long add(List<File> files, String msg) throws VCSException {
+ public long add(MockConnexion connexion, List<File> files, String msg) throws VCSException {
return 0;
}
- public void delete(List<File> files, String msg) throws VCSException {
+ public void delete(MockConnexion connexion, List<File> files, String msg) throws VCSException {
}
- public void revert(List<File> files) throws VCSException {
+ public void revert(MockConnexion connexion, List<File> files) throws VCSException {
}
- public long commit(List<File> files, String msg) throws VCSException {
+ public long commit(MockConnexion connexion, List<File> files, String msg) throws VCSException {
return 0;
}
- public void update(File file, Object revision) throws VCSException {
+ public void update(MockConnexion connexion, File file, Object revision) throws VCSException {
}
- public void update(File file) throws VCSException {
+ public void update(MockConnexion connexion, File file) throws VCSException {
}
- public void checkout(File destDir, String module, boolean recurse) throws VCSException {
+ public void checkout(MockConnexion connexion, File destDir, String module, boolean recurse) throws VCSException {
}
- public void checkoutFile(File destDir, String module) throws VCSException {
+ public void checkoutFile(MockConnexion connexion, File destDir, String module) throws VCSException {
}
- public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
+ public long checkoutOnlyTheDirectory(MockConnexion connexion, File root, Object revision) throws VCSException {
return 0;
}
- public List<String> getRemoteStorageNames(File directory) throws VCSException {
+ public List<String> getRemoteStorageNames(MockConnexion connexion, File directory) throws VCSException {
return null;
}
- public Object getRevision(File f) throws VCSException {
+ public Object getRevision(MockConnexion connexion, File f) throws VCSException {
return null;
}
- public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
+ public List getLog(MockConnexion connexion, Object startRevision, Object endRevision, File file) throws VCSException {
return null;
}
- public String getFileContent(File file, Object revision) throws VCSException, IOException {
+ public String getFileContent(MockConnexion connexion, File file, Object revision) throws VCSException, IOException {
return null;
}
- public String getChangeLog(File file) throws VCSException {
+ public String getChangeLog(MockConnexion connexion, File file) throws VCSException {
return null;
}
- public String getDiff(File file) throws VCSException, IOException {
+ public String getDiff(MockConnexion connexion, File file) throws VCSException, IOException {
return null;
}
- public String getDiff(File file, Object againstRevision) throws VCSException, IOException {
+ public String getDiff(MockConnexion connexion, File file, Object againstRevision) throws VCSException, IOException {
return null;
}
- public void testConnection() throws VCSException {
- }
-
- public boolean hasProtocoleChanged() throws VCSException {
+ public boolean hasProtocoleChanged(MockConnexion connexion) throws VCSException {
return false;
}
}
1
0
[Buix-commits] r365 - in trunk/lutinvcs/lutinvcs-ui/src: main/java/org/codelutin/vcs/ui test/java/org/codelutin/vcs/ui
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:40:12 +0000 (Sat, 05 Apr 2008)
New Revision: 365
Modified:
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java
trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -15,7 +15,6 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.ui.handler.AbstractConfirmUIHandler;
import org.codelutin.vcs.ui.model.ConfirmUIModel;
@@ -26,8 +25,7 @@
protected final JConfirmUI ui;
- public ConfirmUIHandler(VCSHandler handler) {
- super(handler);
+ public ConfirmUIHandler() {
this.ui = new JConfirmUI(this);
}
@@ -47,7 +45,7 @@
VCSAction action = ui.getModel().getAction();
ui.getAccept().setText(action.getLibelle());
ui.getToolbar().setVisible(action.isCommit());
- ui.getHandler().getSelectionModel().setSelectionInterval(0, getModel().getModel().size() - 1);
+ ui.getHandler().getSelectionModel().setSelectionInterval(0, getModel().getModel().getRowCount() - 1);
}
protected void updateMessageUI() {
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -15,12 +15,10 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.ui.handler.AbstractDiffUIHandler;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.model.DiffUIModel;
-import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel;
import javax.swing.ListSelectionModel;
@@ -29,8 +27,7 @@
protected final JDiffUI ui;
- public DiffUIHandler(VCSHandler handler) {
- super(handler);
+ public DiffUIHandler() {
this.ui = new JDiffUI(this);
}
@@ -43,17 +40,17 @@
}
public ListSelectionModel getSelectionModel() {
- AbstractVCSFileStatesModel tabModel = getModel().getTabModel();
- return tabModel == null ? null : ui.getTable(tabModel.getName()).getSelectionModel();
+ AbstractVCSEntriesTableModel tabModel = getModel().getModel();
+ return tabModel == null ? null : ui.getTable(tabModel.getLocation().name().toLowerCase()).getSelectionModel();
}
- public void doSelectTab(SimpleVCSFileStatesModel action) {
+ public void doSelectTab(AbstractVCSEntriesTableModel action) {
}
- public void doSelectFile(VCSFileState model) {
+ public void doSelectFile(VCSEntry model) {
}
- public void doAction(VCSAction action, VCSFileState model) {
+ public void doAction(VCSAction action, VCSEntry model) {
}
public void gotoNextDiff() {
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -1,30 +1,25 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.handler.AbstractSynchUIHandler;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
-import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.model.SynchUIModel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
/** @author chemit */
-public class SynchUIHandler extends AbstractSynchUIHandler implements ListSelectionListener {
+public class SynchUIHandler extends AbstractSynchUIHandler {
protected final JSynchUI ui;
- public SynchUIHandler(VCSHandler handler) {
- super(handler);
+ public SynchUIHandler() {
this.ui = new JSynchUI(this);
}
@@ -35,9 +30,9 @@
@Override
public void init() {
super.init();
- initTab(VCSUIConstants.SYNCH_ALL_MODEL_PROPERTY);
- initTab(VCSUIConstants.SYNCH_LOCAL_MODEL_PROPERTY);
- initTab(VCSUIConstants.SYNCH_REMOTE_MODEL_PROPERTY);
+ initTab(VCSEntryLocation.ALL);
+ initTab(VCSEntryLocation.LOCAL);
+ initTab(VCSEntryLocation.REMOTE);
}
public SynchUIModel getModel() {
@@ -45,53 +40,45 @@
}
public ListSelectionModel getSelectionModel() {
- AbstractVCSFileStatesModel tabModel = getModel().getTabModel();
- return tabModel == null ? null : ui.getTable(tabModel.getName()).getSelectionModel();
+ return ui.getTable(getModel().getModel().getLocation().name().toLowerCase()).getSelectionModel();
}
- public void doAllAction(VCSAction action, SimpleVCSFileStatesModel model) {
+ public void doAllAction(VCSAction action) {
+ AbstractVCSEntriesTableModel model = getModel().getModel();
log.info(action + " : " + model);
- JTable table = ui.getTable(model.getName());
- ListSelectionModel selectionModel = table.getSelectionModel();
+ ListSelectionModel selectionModel = getSelectionModel();
if (action == VCSAction.REFRESH) {
selectionModel.clearSelection();
// do refresh of all states
- log.info("refresh :" + model.size());
- model.refresh(model.getStates());
+ log.info("refresh :" + model.getRowCount());
+ model.refresh(model.getEntries(), System.nanoTime());
} else {
- model.select(action, selectionModel, true);
- // do action on selected items
- doSelectAction(action, model);
- }
- }
+ List<VCSEntry> entries = model.filter(action, model.getDisplayedEntries(null));
+ if (entries.isEmpty()) {
+ // nothing to do
+ return;
+ }
+ if (action == VCSAction.DIFF) {
+ // show diff ui
+ return;
+ }
+ log.info("files to treate :" + entries.size());
+ JConfirmUI confirmUI = VCSUIFactory.newConfirmUI();
- public void doSelectAction(VCSAction action, SimpleVCSFileStatesModel model) {
- log.info(action + " : " + model);
- JTable table = ui.getTable(model.getName());
- ListSelectionModel selectionModel = table.getSelectionModel();
- if (selectionModel.isSelectionEmpty()) {
- // nothing to do
- return;
+ confirmUI.getModel().init(action, model.getLocation(), entries.toArray(new VCSEntry[entries.size()]));
+
+ confirmUI.setVisible(true);
+ //TODO SynchModel should listener for modification on ActionManagerQueue thread
+ log.info("TODO refresh states for files...");
}
- if (action == VCSAction.DIFF) {
- // show diff ui
- return;
- }
- VCSFileState[] states = model.getData(selectionModel);
- log.info("files to treate :" + states.length);
- JConfirmUI confirmUI = VCSUIFactory.newConfirmUI(getHandler(), Arrays.asList(states));
- confirmUI.getModel().setAction(action);
- confirmUI.setVisible(true);
- //TODO SynchModel should listener for modification on ActionManagerQueue thread
- log.info("TODO refresh states for files...");
}
- public void doSelectTabAction(SimpleVCSFileStatesModel model) {
- log.info(model);
- String tabModelName = model.getName();
- ui.cardLayout.show(ui.preview, tabModelName);
- VCSAction[] actions = model.getActions();
+ public void doSelectLocation(VCSEntryLocation location) {
+ log.info(location);
+
+ ui.cardLayout.show(ui.preview, location.name().toLowerCase() + "Content");
+ VCSAction[] actions = getModel().getModel().getActions((ListSelectionModel) null);
List<String> acts = new ArrayList<String>();
for (VCSAction action : actions) {
acts.add(action.name().toLowerCase());
@@ -105,42 +92,31 @@
ui.getRefreshAll().setEnabled(hasActions);
}
- public void valueChanged(ListSelectionEvent e) {
- ListSelectionModel list = (ListSelectionModel) e.getSource();
- if (!list.getValueIsAdjusting() && log.isDebugEnabled()) {
- log.debug(list);
- }
- }
-
- private void initTab(String modelName) {
- JTable table = ui.getTable(modelName);
- SimpleVCSFileStatesModel fileStatesModel = getModel().getModel(modelName);
+ private void initTab(VCSEntryLocation location) {
+ String s = location.name().toLowerCase();
+ JTable table = ui.getTable(s);
+ AbstractVCSEntriesTableModel fileStatesModel = getModel().getModel();
table.setModel(fileStatesModel);
- table.getSelectionModel().addListSelectionListener(this);
- table.addMouseListener(new ListMouseListener(ui, fileStatesModel));
- JVCSPopup jvcsPopup = ui.getPopup(modelName);
- jvcsPopup.setDispatchAction(new VCSPopupAction(ui, modelName));
+ table.addMouseListener(new ListMouseListener(ui, fileStatesModel, s));
+ JVCSPopup jvcsPopup = ui.getPopup(s);
+ jvcsPopup.setDispatchAction(new VCSPopupAction(ui, location));
}
private class ListMouseListener extends MouseAdapter {
- private final AbstractVCSFileStatesModel model;
+ private final AbstractVCSEntriesTableModel model;
private final ListSelectionModel selectionModel;
private final JTable jTable;
private final JVCSPopup jPopupMenu;
- public ListMouseListener(JSynchUI ui, AbstractVCSFileStatesModel model) {
+ public ListMouseListener(JSynchUI ui, AbstractVCSEntriesTableModel model, String modelName) {
this.model = model;
- String modelName = model.getName();
-
jPopupMenu = ui.getPopup(modelName);
jTable = ui.getTable(modelName);
selectionModel = jTable.getSelectionModel();
- // init actions
-
}
@Override
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -15,13 +15,14 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.handler.VCSAbsractAction;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import javax.swing.ListSelectionModel;
import java.awt.event.ActionEvent;
-import java.util.Arrays;
+import java.util.List;
/**
* Action of a clik inside the popup menu
@@ -31,30 +32,38 @@
public class VCSPopupAction extends VCSAbsractAction {
private static final long serialVersionUID = -1983061535956510913L;
- protected AbstractVCSFileStatesModel model;
+ protected VCSEntryLocation location;
protected transient ListSelectionModel selectionModel;
- public VCSPopupAction(JSynchUI ui, String modelName) {
- super(ui.getHandler().getHandler());
- this.model = ui.getModel().getModel(modelName);
- this.selectionModel = ui.getTable(modelName).getSelectionModel();
+ protected transient JSynchUI ui;
+
+ protected AbstractVCSEntriesTableModel tableModel;
+
+ public VCSPopupAction(JSynchUI ui, VCSEntryLocation location) {
+ super();
+ this.ui = ui;
+ this.location = location;
+ //this.selectionModel = ui.getHandler().getSelectionModel();
+ this.selectionModel = ui.getTable(location.name().toLowerCase()).getSelectionModel();
+ tableModel = ui.getModel().getModel();
}
public void actionPerformed(ActionEvent e) {
// select only lines for this action inside already selected lines
- model.select(action, selectionModel, false);
- // obtain thoses lines
- VCSFileState[] states = model.getData(selectionModel);
- log.info("action: " + action + ", files to treate :" + states.length);
+ List<VCSEntry> entries = tableModel.filter(action, tableModel.getDisplayedEntries(selectionModel));
+ log.info("action: " + action + ", files to treate :" + entries.size() + " " + selectionModel);
if (action == VCSAction.DIFF) {
// show diff ui
+ ui.getModel().refresh(entries);
+
} else if (action == VCSAction.REFRESH) {
// refresh ui, and update list if needed
+
} else {
// show confirm action ui
- JConfirmUI confirmUI = VCSUIFactory.newConfirmUI(getHandler(), Arrays.asList(states));
- confirmUI.getModel().setAction(action);
- confirmUI.getHandler().getSelectionModel().setSelectionInterval(0, states.length - 1);
+ JConfirmUI confirmUI = VCSUIFactory.newConfirmUI();
+ confirmUI.getModel().init(action, tableModel.getLocation(), entries.toArray(new VCSEntry[entries.size()]));
+ confirmUI.getHandler().getSelectionModel().setSelectionInterval(0, entries.size() - 1);
confirmUI.setVisible(true);
}
}
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -14,43 +14,36 @@
*/
package org.codelutin.vcs.ui;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.ui.handler.AbstractUIHandler;
-import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-/** @author chemit */
+/**
+ * Factory if VCS UI, using a cache.
+ *
+ * @author chemit
+ */
public class VCSUIFactory {
protected static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> cache;
- public static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> getCache() {
- if (cache == null) {
- cache = new HashMap<Class<? extends AbstractUIHandler>, AbstractUIHandler>();
- }
- return cache;
- }
-
protected static JSynchUI synchUI;
protected static JDiffUI diffUI;
protected static JConfirmUI confirmUI;
- public static JSynchUI newSynchUI(VCSHandler handler, List<VCSFileState> states) {
- SynchUIHandler result = newHandler(handler, SynchUIHandler.class, states);
+ public static JSynchUI newSynchUI() {
+ SynchUIHandler result = newHandler(SynchUIHandler.class);
return result.getUi();
}
- public static JDiffUI newDiffUI(VCSHandler handler, List<VCSFileState> states) {
- DiffUIHandler result = newHandler(handler, DiffUIHandler.class, states);
+ public static JDiffUI newDiffUI() {
+ DiffUIHandler result = newHandler(DiffUIHandler.class);
return result.getUi();
}
- public static JConfirmUI newConfirmUI(VCSHandler handler, List<VCSFileState> states) {
- ConfirmUIHandler result = newHandler(handler, ConfirmUIHandler.class, states);
+ public static JConfirmUI newConfirmUI() {
+ ConfirmUIHandler result = newHandler(ConfirmUIHandler.class);
return result.getUi();
}
@@ -61,26 +54,28 @@
cache = null;
}
+ protected static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> getCache() {
+ if (cache == null) {
+ cache = new HashMap<Class<? extends AbstractUIHandler>, AbstractUIHandler>();
+ }
+ return cache;
+ }
+
@SuppressWarnings({"unchecked"})
- protected static <H extends AbstractUIHandler> H newHandler(VCSHandler handler, Class<H> klass, List<VCSFileState> states) {
+ protected static <H extends AbstractUIHandler> H newHandler(Class<H> klass) {
H result;
result = (H) getCache().get(klass);
if (result == null) {
try {
- result = klass.getConstructor(VCSHandler.class).newInstance(handler);
+ result = klass.newInstance();
result.init();
getCache().put(klass, result);
} catch (InstantiationException e) {
throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
} catch (IllegalAccessException e) {
throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
- } catch (InvocationTargetException e) {
- throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
- } catch (NoSuchMethodException e) {
- throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
}
}
- result.getModel().setData(states);
return result;
}
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-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -14,13 +14,17 @@
*/
package org.codelutin.vcs.ui;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSFileStateImpl;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSHandlerFactory;
+import org.codelutin.i18n.I18n;
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSConnexionMode;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSFactory;
import org.codelutin.vcs.VCSState;
-import org.codelutin.vcs.impl.mock.MockVCSConfig;
+import org.codelutin.vcs.VCSType;
import org.codelutin.vcs.ui.model.SynchUIModel;
+import org.codelutin.vcs.util.VCSConnexionConfigImpl;
+import org.codelutin.vcs.util.VCSEntryImpl;
import java.io.File;
import java.util.ArrayList;
@@ -33,52 +37,57 @@
static java.util.Random r = new java.util.Random();
public static void main(String[] args) {
- org.codelutin.i18n.I18n.init();
- File root = new File(new File("").getAbsolutePath());
+ I18n.init();
- VCSHandler handler = initVCS(root);
+ VCSConnexion connexion = initVCS(new File(new File("").getAbsolutePath()));
- List<VCSFileState> datas = generateListFileStates(handler, 50, "trunk", "local/", "remote/");
+ try {
+ connexion.open();
- JSynchUI synchUI = VCSUIFactory.newSynchUI(handler, datas);
+ JSynchUI ui = VCSUIFactory.newSynchUI();
- synchUI.setVisible(true);
+ fillSynchModel(connexion, ui.getModel(), 20, "trunk", "local/", "remote/");
- handler.close();
+ ui.setVisible(true);
+
+ } finally {
+ connexion.close();
+ }
}
- public static VCSHandler initVCS(File root) {
- MockVCSConfig config = new MockVCSConfig();
- config.setLocalRoot(root);
- config.setInit(true);
- VCSHandlerFactory.setConfig(config);
- return VCSHandlerFactory.getHandler();
+ public static VCSConnexion initVCS(File root) {
+ VCSConnexionConfigImpl config = new VCSConnexionConfigImpl();
+ config.setType(VCSType.MOCK);
+ config.setLocalDatabasePath(root);
+ VCSConnexion connexion = VCSFactory.newConnexion(VCSConnexionMode.ANONYMOUS, config);
+ connexion.init(config);
+ return connexion;
}
- protected static void fillSynchModel(VCSHandler handler, SynchUIModel model, int max, String prefix, String localPRefix, String remotePrefix) {
- List<VCSFileState> datas = generateListFileStates(handler, max, prefix, localPRefix, remotePrefix);
- model.setData(datas);
+ protected static void fillSynchModel(VCSConnexion handler, SynchUIModel model, int max, String prefix, String localPRefix, String remotePrefix) {
+ List<VCSEntry> datas = generateListFileStates(handler, max, prefix, localPRefix, remotePrefix);
+ model.populate(VCSEntryLocation.UNKNOW, datas.toArray(new VCSEntry[datas.size()]));
}
- private static List<VCSFileState> generateListFileStates(VCSHandler handler, int max, String prefix, String localPRefix, String remotePrefix) {
- List<VCSFileState> datas = generateLocalFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), localPRefix);
+ protected static List<VCSEntry> generateListFileStates(VCSConnexion handler, int max, String prefix, String localPRefix, String remotePrefix) {
+ List<VCSEntry> datas = generateLocalFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), localPRefix);
datas.addAll(generateRemoteFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), remotePrefix));
return datas;
}
- protected static List<VCSFileState> generateLocalFileStates(VCSHandler handler, int max, File root, String localPRefix) {
+ protected static List<VCSEntry> generateLocalFileStates(VCSConnexion handler, int max, File root, String localPRefix) {
return generateFileStates(handler, root, max, localPRefix, VCSState.MODIFIED, VCSState.UNVERSIONNED, VCSState.OUT_OF_DATE_AND_MODIFIED, VCSState.REMOVED);
}
- protected static List<VCSFileState> generateRemoteFileStates(VCSHandler handler, int max, File root, String remotePRefix) {
+ protected static List<VCSEntry> generateRemoteFileStates(VCSConnexion handler, int max, File root, String remotePRefix) {
return generateFileStates(handler, root, max, remotePRefix, VCSState.MISSING, VCSState.OUT_OF_DATE, VCSState.OUT_OF_DATE_AND_MODIFIED);
}
- protected static List<VCSFileState> generateFileStates(VCSHandler handler, File root, int max, String prefix, VCSState... states) {
- List<VCSFileState> datas = new ArrayList<VCSFileState>();
+ protected static List<VCSEntry> generateFileStates(VCSConnexion handler, File root, int max, String prefix, VCSState... states) {
+ List<VCSEntry> datas = new ArrayList<VCSEntry>();
for (int i = 0, nbFiles = 1 + r.nextInt(max), size = states.length; i < nbFiles; i++) {
- VCSFileStateImpl state = new VCSFileStateImpl(handler, new File(root, prefix + "file" + i));
+ VCSEntry state = new VCSEntryImpl(handler, root.getName() + File.separator + prefix + "file" + i);
state.setState(states[r.nextInt(size)]);
datas.add(state);
}
1
0
[Buix-commits] r364 - trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:48 +0000 (Sat, 05 Apr 2008)
New Revision: 364
Modified:
trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties
trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties 2008-04-05 20:37:32 UTC (rev 363)
+++ trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties 2008-04-05 20:37:48 UTC (rev 364)
@@ -1,5 +1,3 @@
-lutinvcs.error.init.config=config is not init, you should invoke on the config validate(true) method to validate it and finish his init {0}
-lutinvcs.error.init.no.config=should invoke {0}\#init(VCSType,Properties) before required instance.
lutinvcs.error.thread.action=
lutinvcs.file=File
lutinvcs.module=Module
Modified: trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties 2008-04-05 20:37:32 UTC (rev 363)
+++ trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties 2008-04-05 20:37:48 UTC (rev 364)
@@ -1,5 +1,3 @@
-lutinvcs.error.init.config=config is not init, you should invoke on the config validate(true) method to validate it and finish his init {0}
-lutinvcs.error.init.no.config=should invoke {0}\#init(VCSType,Properties) before required instance.
lutinvcs.error.thread.action=
lutinvcs.file=Fichier
lutinvcs.module=Module
1
0