[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: New JavaHL features

From: Daniel Rall <dlr_at_collab.net>
Date: 2006-11-23 00:46:28 CET

On Wed, 22 Nov 2006, Daniel Rall wrote:

> On Tue, 21 Nov 2006, Mark Phippard wrote:
>
> > Daniel,
> >
> > Since you are doing some stuff with JavaHL lately, one to add to your
> > to-do list would be some kind of support for the svn diff --summarize
> > option. I think this is something we could use in Subclipse to improve
> > performance when comparing two tags of a large project.
>
> Sure Mark. Do you think the summarize option should be a parameter to
> SVNClientInterface.diff(), or a separate API entirely? svn_client.h
> uses two separate APIs to implement 'diff' and 'diff --summarize'.

Mark, please examine the patch below which adds the Java API (but not
the corresponding JNI implementation), and see if it meets your
expectations, and the needs of Subclipse.

One point in particular that I'd like your feedback on is use of a
callback API (which is a more streamy interface) vs. an API which just
returns a list of diff summaries (which is slightly easier to use).
For comparison, see the SVNClientInterface.logMessages() API -- it
returns a LogMessage[] array, where as the underlying svn_ra_get_log()
API uses a svn_log_message_receiver_t callback and baton (the
equivalent of passing in a Java interface, as I do with the new
diffSummarize() API in the patch below).

Index: subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClientInterface.java
===================================================================
--- subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClientInterface.java (revision 22403)
+++ subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClientInterface.java (working copy)
@@ -587,6 +587,32 @@
             throws ClientException;
 
     /**
+ * Produce a diff summary which lists the items changed between
+ * path and revision pairs.
+ *
+ * @param target1 Path or URL.
+ * @param revision1 Revision of <code>target1</code>.
+ * @param target2 Path or URL.
+ * @param revision2 Revision of <code>target2</code>.
+ * @param recurse Whether to recurse.
+ * @param ignoreAncestry Whether to ignore unrelated files during
+ * comparison. False positives may potentially be reported if
+ * this parameter <code>false</code>, since a file might have been
+ * modified between two revisions, but still have the same
+ * contents.
+ * @param receiver As each is difference found, this callback is
+ * invoked with a description of the difference.
+ *
+ * @exception ClientException
+ * @since 1.5
+ */
+ void diffSummarize(String target1, Revision revision1,
+ String target2, Revision revision2,
+ boolean recurse, boolean ignoreAncestry,
+ DiffSummaryReceiver receiver)
+ throws ClientException;
+
+ /**
      * Retrieves the properties of an item
      * @param path the path of the item
      * @return array of property objects
Index: subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClient.java
===================================================================
--- subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClient.java (revision 22408)
+++ subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClient.java (working copy)
@@ -670,6 +670,32 @@
                             boolean force) throws ClientException;
 
     /**
+ * Produce a diff summary which lists the items changed between
+ * path and revision pairs.
+ *
+ * @param target1 Path or URL.
+ * @param revision1 Revision of <code>target1</code>.
+ * @param target2 Path or URL.
+ * @param revision2 Revision of <code>target2</code>.
+ * @param recurse Whether to recurse.
+ * @param ignoreAncestry Whether to ignore unrelated files during
+ * comparison. False positives may potentially be reported if
+ * this parameter <code>false</code>, since a file might have been
+ * modified between two revisions, but still have the same
+ * contents.
+ * @param receiver As each is difference found, this callback is
+ * invoked with a description of the difference.
+ *
+ * @exception ClientException
+ * @since 1.5
+ */
+ public native void diffSummarize(String target1, Revision revision1,
+ String target2, Revision revision2,
+ boolean recurse, boolean ignoreAncestry,
+ DiffSummaryReceiver receiver)
+ throws ClientException;
+
+ /**
      * Retrieves the properties of an item
      * @param path the path of the item
      * @return array of property objects
Index: subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClientSynchronized.java
===================================================================
--- subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClientSynchronized.java (revision 22403)
+++ subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/SVNClientSynchronized.java (working copy)
@@ -873,6 +873,39 @@
     }
 
     /**
+ * Produce a diff summary which lists the items changed between
+ * path and revision pairs.
+ *
+ * @param target1 Path or URL.
+ * @param revision1 Revision of <code>target1</code>.
+ * @param target2 Path or URL.
+ * @param revision2 Revision of <code>target2</code>.
+ * @param recurse Whether to recurse.
+ * @param ignoreAncestry Whether to ignore unrelated files during
+ * comparison. False positives may potentially be reported if
+ * this parameter <code>false</code>, since a file might have been
+ * modified between two revisions, but still have the same
+ * contents.
+ * @param receiver As each is difference found, this callback is
+ * invoked with a description of the difference.
+ *
+ * @exception ClientException
+ * @since 1.5
+ */
+ public void diffSummarize(String target1, Revision revision1,
+ String target2, Revision revision2,
+ boolean recurse, boolean ignoreAncestry,
+ DiffSummaryReceiver receiver)
+ throws ClientException
+ {
+ synchronized (clazz)
+ {
+ diffSummarize(target1, revision1, target2, revision2,
+ recurse, ignoreAncestry, receiver);
+ }
+ }
+
+ /**
      * Retrieves the properties of an item
      * @param path the path of the item
      * @return array of property objects
Index: subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/DiffSummaryReceiver.java
===================================================================
--- subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/DiffSummaryReceiver.java (revision 0)
+++ subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/DiffSummaryReceiver.java (revision 0)
@@ -0,0 +1,34 @@
+/**
+ * @copyright
+ * ====================================================================
+ * Copyright (c) 2006 CollabNet. All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals. For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ * @endcopyright
+ */
+package org.tigris.subversion.javahl;
+
+/**
+ * Subversion diff summarization interface.
+ *
+ * @since 1.5
+ */
+public interface DiffSummaryReceiver
+{
+ /**
+ * Implement this interface to receive diff summaries from the
+ * {@link SVNClientInterface#diffSummarize} API.
+ *
+ * @param descriptor A summary of the diff.
+ */
+ public void onSummary(DiffSummary descriptor);
+}
Index: subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/DiffSummary.java
===================================================================
--- subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/DiffSummary.java (revision 0)
+++ subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/DiffSummary.java (revision 0)
@@ -0,0 +1,125 @@
+/**
+ * @copyright
+ * ====================================================================
+ * Copyright (c) 2006 CollabNet. All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals. For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ * @endcopyright
+ */
+package org.tigris.subversion.javahl;
+
+import java.util.EventObject;
+
+/**
+ * The event passed to the {@link
+ * DiffSummarizer.summarize(DiffSummary)} API in response to path
+ * differences reported by {@link SVNClientInterface#diffSummarize}.
+ *
+ * @since 1.5
+ */
+public class DiffSummary extends EventObject
+{
+ private DiffKind diffKind;
+ private boolean propsChanged;
+ private NodeKind nodeKind;
+
+ /**
+ * This constructor is to be used by the native code.
+ *
+ * @param path The path we have a diff for.
+ * @param diffKind The kind of diff this describes.
+ * @param propChanged Whether any properties have changed.
+ */
+ DiffSummary(String path, int diffKind, boolean propsChanged,
+ NodeKind nodeKind)
+ {
+ super(path);
+ this.diffKind = DiffKind.getInstance(diffKind);
+ this.propsChanged = propsChanged;
+ this.nodeKind = nodeKind;
+ }
+
+ /**
+ * @return The path we have a diff for.
+ */
+ public String getPath()
+ {
+ return (String) super.source;
+ }
+
+ /**
+ * @return The kind of summary this describes.
+ */
+ public DiffKind getDiffKind()
+ {
+ return this.diffKind;
+ }
+
+ /**
+ * @return Whether any properties have changed.
+ */
+ public boolean isPropsChanged()
+ {
+ return this.propsChanged;
+ }
+
+ /**
+ * @return Whether any properties have changed.
+ */
+ public NodeKind getNodeKind()
+ {
+ return this.nodeKind;
+ }
+
+ /**
+ * The type of difference being summarized.
+ */
+ public static class DiffKind
+ {
+ // Corresponds to the svn_client_diff_summarize_kind_t enum.
+ public static DiffKind NORMAL = new DiffKind(0);
+ public static DiffKind ADDED = new DiffKind(1);
+ public static DiffKind MODIFIED = new DiffKind(2);
+ public static DiffKind DELETED = new DiffKind(3);
+
+ private int kind;
+
+ private DiffKind(int kind)
+ {
+ this.kind = kind;
+ }
+
+ /**
+ * @return The appropriate instance.
+ * @exception IllegalArgumentException If the diff kind is not
+ * recognized.
+ */
+ public static DiffKind getInstance(int diffKind)
+ throws IllegalArgumentException
+ {
+ switch (diffKind)
+ {
+ case 0:
+ return NORMAL;
+ case 1:
+ return ADDED;
+ case 2:
+ return MODIFIED;
+ case 3:
+ return DELETED;
+ default:
+ throw new IllegalArgumentException("Diff kind " + diffKind +
+ " not recognized");
+ }
+ }
+ }
+}

  • application/pgp-signature attachment: stored
Received on Thu Nov 23 00:47:56 2006

This is an archived mail posted to the Subversion Dev mailing list.