Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [subversive-dev] Weird behavior of the "Compare with branch" feature

Le 29/11/2015 09:31, Alexander Gurov a écrit :
>> OK, I finally found out that your patch works as expected when using
>> the JavaHL connector. With the SVNKit connector it only works as
>> expected when the user selects the project's root directory for
>> comparison. Otherwise, selecting any subfolder for comparison is still
>> buggy. Do you have any hint on how to fix this? 
>
> After checking the issue it do seems that:
> 1) SVN Kit 1.8.11 implements the functionality differently than JavaHL
> in regards to the paths reported. And it seems to be the SVN Kit's bug,
> since both libraries should implement SVN API the same way.

I was able to fix paths with a hack (see attached patch).
I haven't dug deeper yet because I'm still a noob with eclipse
development. I hope you can do better.


> 2) SVN Kit 1.7.14 does not provide support for working copy-to-URL
> comparison. So, the patch would not work with SVN Kit 1.7.14 at all. I
> can't check with JavaHL 1.7.x now since it's troublesome in my
> configuration, but I guess it'll be the same anyway, because the error
> message I've got said something like "diff summarize could be performed
> only on the URL-to-URL basis".
> 
> So, I guess there is no choice but to make the code compatible with the
> SVN 1.8 only, since providing a wrong compare result is worse than
> providing nothing at all (on the other hand the functionality will
> completely stop working with SVN 1.7)?

What I understand here is that trying to fix SVN connectors v1.7 would
be tedious and probably risky. So I agree that we should only fix
connectors v1.8.
If possible, it would be a nice workaround to make subversive's "compare
with..." popup print a warning when used with a connector v1.7 and point
the user to a bug report and suggest to upgrade to v1.8.


> Also I suppose, the behaviour of
> SVN Kit connector could be adapted to its incorrect implementation, so
> that it won't seem different with JavaHL (though it does not mean the
> issue won't be reported to SVN Kit team).

I'm not sure to understand what you mean here.
Do you suggest to temporarily implement a workaround in SVNKit
connector's code until the bug in SVNKit you mentionned above is fixed?
If it is feasible then I think this is the best choice we have.

As said above, I managed to fix paths but there are still some glitches:
- some unmodified resources are still listed in the compare window (I'm
  still investigating on this)
- resource decorations seem inappropriate: modified resources appear as
  incoming changes which is an arbitrary choice I guess. Maybe a
  bidirectional arrow would be more meaningful in this case.

-- 
Florent Angebault
Linagora - Support OSSA
https://www.08000linux.com/
Index: org.polarion.eclipse.team.svn.connector.svnkit18/src/org/polarion/team/svn/connector/svnkit/SVNKitConnector.java
===================================================================
--- org.polarion.eclipse.team.svn.connector.svnkit18/src/org/polarion/team/svn/connector/svnkit/SVNKitConnector.java	(révision 50252)
+++ org.polarion.eclipse.team.svn.connector.svnkit18/src/org/polarion/team/svn/connector/svnkit/SVNKitConnector.java	(copie de travail)
@@ -2449,8 +2449,9 @@
 					tPath2 = this.next;
 				}
 				else {
-					tPath1 = this.prev + "/" + tPath1;
-					tPath2 = this.next + "/" + tPath2;
+					// XXX LINA quick-n-dirty hack
+					tPath1 = collapsePaths(this.prev, tPath1);
+					tPath2 = collapsePaths(this.next, tPath2);
 				}
 				SVNDiffStatus status = new SVNDiffStatus(SVNUtility.encodeURL(tPath1), SVNUtility.encodeURL(tPath2), ConversionUtility.convert(descriptor.getNodeKind()), changeType, propChangeType);
 				if (this.savedDiff != null) {
@@ -2472,6 +2473,47 @@
 			}
 		}
 	}
+	
+	/*
+	 *  XXX LINA quick-n-dirty hack
+	 */
+	private static String collapsePaths(String lPath, String rPath) {
+		String res = "";
+		if (basename(lPath).equals(rootdirname(rPath))) {
+			res = dirname(lPath) + "/" + rPath;
+		} else {
+			res = lPath + "/" + rPath;
+		}
+		System.out.format("'%s' + '%s' = '%s' %n", lPath, rPath, res);
+		return res;
+	}
+	
+	private static String basename(String path) {
+		int lastSepIndex = path.lastIndexOf('/');
+		if (lastSepIndex != -1) {
+			return path.substring(lastSepIndex + 1);
+		} else {
+			return path;
+		}
+	}
+	
+	private static String dirname(String path) {
+		int lastSepIndex = path.lastIndexOf('/');
+		if (lastSepIndex != -1) {
+			return path.substring(0, lastSepIndex);
+		} else {
+			return path;
+		}
+	}
+	
+	private static String rootdirname(String path) {
+		int firstSepIndex = path.indexOf('/');
+		if (firstSepIndex != -1) {
+			return path.substring(0, firstSepIndex);
+		} else {
+			return path;
+		}
+	}
 
 	protected class CommitMessage implements org.apache.subversion.javahl.callback.CommitMessageCallback {
 		private String message;

Back to the top