Eugene Kuleshov <eu@md.pp.ru> wrote on 08/21/2005 10:10:52 PM:
> I've put together some prototype for the approach we have discussed
> for AbstractJhlClientAdapter. Basically it is what user would do
> manually. See patch attached.
>
> Current limitations are all your edge cases, some logging in DirUtils
> and progress indication for DirUtils functions.
> Present code also always using copy + delete in place of rename().
>
> If you ok with doing something like this I can pull up methods to
> handle temp location to common adapter class (to make it work for
> cmdAdapter) and check what should be done in the UI.
I took your prototype and made my own that I have attached. It
demonstrates the idea that I had about putting the code in the Abstract
class and conditioning it. This would just make it easy for different
adapters to use or not use this code.
In general I am fine with this as long as it works.
As for the edge cases, I wouldn't code for them initially, I would just
test them. I think that Subversion itself can handle most of them. The
EOL chars is probably the only one it can't and that seems like an extreme
edge case. The problem would only be if the files you already had did not
have the same EOL chars that Subversion was going to make the file in the
WC.
Does the Java code you are proposing work consistently across platforms?
For example, on Windows if you copy a folder structure on top of an
existing one, Windows "merges" the results. On Linux and OS X, the
existing structure is replaced. So if you copy a folder with 1 file on
top of a folder with 5 files you get a folder with 1 file. On Windows,
you either have a folder with 5 or 6 files. The Windows behavior is what
we would need here.
If you want to just get the adapter code worked out, I can probably do the
UI. Although I imagine you need it in order to test.
Thanks
Mark
Index:
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/AbstractClientAdapter.java
===================================================================
---
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/AbstractClientAdapter.java
(revision 1564)
+++
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/AbstractClientAdapter.java
(working copy)
@@ -16,6 +16,7 @@
package org.tigris.subversion.svnclientadapter;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -168,4 +169,44 @@
public boolean statusReturnsRemoteInfo() {
return false;
}
+
+ public abstract SVNNotificationHandler getNotificationHandler();
+
+ public abstract boolean checkoutSupportsOverwrite();
+
+ protected abstract void checkoutImpl(SVNUrl moduleName, File
destPath,
+ SVNRevision revision, boolean recurse) throws
SVNClientException;
+
+ public void checkout(SVNUrl moduleName, File destPath,
+ SVNRevision revision, boolean recurse) throws
SVNClientException {
+ File tempDir = null;
+ if (!checkoutSupportsOverwrite()){
+ try {
+ if(!DirUtils.isDirEmpty(destPath)) {
+ tempDir = DirUtils.createTempDir();
+ DirUtils.copyDir(destPath, tempDir);
+ DirUtils.delete(destPath);
+ }
+ } catch( IOException e) {
+ getNotificationHandler().logException(e);
+ throw new SVNClientException(e);
+ }
+
+ }
+
+ checkoutImpl(moduleName, destPath, revision, recurse);
+
+ if (!checkoutSupportsOverwrite()){
+ try {
+ if(tempDir!=null) {
+ DirUtils.copyDir(tempDir, destPath);
+ cleanup(destPath);
+ DirUtils.delete(tempDir);
+ }
+ } catch( IOException e) {
+ getNotificationHandler().logException(e);
+ throw new SVNClientException(e);
+ }
+ }
+ }
}
Index:
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/commandline/CmdLineClientAdapter.java
===================================================================
---
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/commandline/CmdLineClientAdapter.java
(revision 1564)
+++
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/commandline/CmdLineClientAdapter.java
(working copy)
@@ -38,6 +38,7 @@
import org.tigris.subversion.svnclientadapter.SVNBaseDir;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNConstants;
+import org.tigris.subversion.svnclientadapter.SVNNotificationHandler;
import org.tigris.subversion.svnclientadapter.SVNRevision;
import org.tigris.subversion.svnclientadapter.SVNStatusUnversioned;
import org.tigris.subversion.svnclientadapter.SVNUrl;
@@ -544,7 +545,7 @@
/* (non-Javadoc)
* @see
org.tigris.subversion.subclipse.client.ISVNClientAdapter#checkout(java.net.URL,
java.io.File, org.tigris.subversion.subclipse.client.ISVNRevision,
boolean)
*/
- public void checkout(SVNUrl url, File destPath, SVNRevision
revision, boolean b)
+ public void checkoutImpl(SVNUrl url, File destPath, SVNRevision
revision, boolean b)
throws SVNClientException {
try {
notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(destPath));
@@ -1210,4 +1211,10 @@
}
}
}
+ public boolean checkoutSupportsOverwrite() {
+ return false;
+ }
+ public SVNNotificationHandler getNotificationHandler() {
+ return notificationHandler;
+ }
}
Index:
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/javahl/AbstractJhlClientAdapter.java
===================================================================
---
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/javahl/AbstractJhlClientAdapter.java
(revision 1564)
+++
C:/tsvn/Subclipse/repos/trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/javahl/AbstractJhlClientAdapter.java
(working copy)
@@ -41,6 +41,7 @@
import org.tigris.subversion.svnclientadapter.SVNBaseDir;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNInfoUnversioned;
+import org.tigris.subversion.svnclientadapter.SVNNotificationHandler;
import org.tigris.subversion.svnclientadapter.SVNRevision;
import org.tigris.subversion.svnclientadapter.SVNStatusKind;
import org.tigris.subversion.svnclientadapter.SVNStatusUnversioned;
@@ -193,7 +194,7 @@
* @param recurse whether you want it to checkout files recursively.
* @exception ClientException
*/
- public void checkout(
+ public void checkoutImpl(
SVNUrl moduleName,
File destPath,
SVNRevision revision,
@@ -1649,4 +1650,11 @@
throw new SVNClientException(e);
}
}
+
+ public boolean checkoutSupportsOverwrite() {
+ return false;
+ }
+ public SVNNotificationHandler getNotificationHandler() {
+ return notificationHandler;
+ }
}
_____________________________________________________________________________
Scanned for SoftLanding Systems, Inc. by IBM Email Security Management Services powered by MessageLabs.
_____________________________________________________________________________
Received on Tue Aug 23 01:25:29 2005