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

Re: [Subclipse-users] Need svn info from WC

From: Mike Mikhailov <ekimka_at_gmail.com>
Date: Wed, 23 Dec 2009 09:32:10 +0500

Sorry, my first post was not clear. I need an ability to get the 'svn info'
from the working copy using svnant. Currently svnant uses only the remote
repository to fetch the required info. And what I've found in the source code
(from svnant repository):

$ grep 'private ISVNInfo acquireInfo' -B 10 -A 5
src/main/org/tigris/subversion/svnant/commands/Info.java

    /**
     * Always contacts the repository. In the future, might want to
     * allow for use of
     * <code>ISVNInfo.getInfoFromWorkingCopy()</code>, which uses only
     * the meta data from the WC.
     *
     * @exception SVNClientException If ISVNInfo.getInfo(target)
     * fails.
     */
    private ISVNInfo acquireInfo()
        throws SVNClientException {
        File targetAsFile = new File(Project.translatePath(this.target));
        if (targetAsFile.exists()) {
            // Since the target exists locally, assume it's not a URL.
            return svnClient.getInfo(targetAsFile);

It always contacts the remote repository to query the info. As
mentioned in method's javadoc
the method can be used to retrieve info from the WC, but in the
future. I would like to
move that future near to me and patch below (with little documentation
enhancements)
I would like to offer the community.

--- src/main/org/tigris/subversion/svnant/commands/Info.java
2009-12-20 17:24:05.000000000 +0500
+++ src/main/org/tigris/subversion/svnant/commands/Info.java.new
 2009-12-23 09:02:35.000000000 +0500
@@ -28,6 +28,9 @@
     /** Whether or not to print the properties. */
     private boolean verbose = false;

+ /** Whether or not to use the local info instead of remote */
+ private boolean local = false;
+
     /** String prepended to new property names. */
     private String propPrefix = "svn.info.";

@@ -98,10 +101,8 @@
     }

     /**
- * Always contacts the repository. In the future, might want to
- * allow for use of
- * <code>ISVNInfo.getInfoFromWorkingCopy()</code>, which uses only
- * the meta data from the WC.
+ * Returns the information about working copy if local flag was set to
+ * true or remote one if set to false (default).
      *
      * @exception SVNClientException If ISVNInfo.getInfo(target)
      * fails.
@@ -109,6 +110,9 @@
     private ISVNInfo acquireInfo()
         throws SVNClientException {
         File targetAsFile = new File(Project.translatePath(this.target));
+
+ if (isLocal()) return svnClient.getInfoFromWorkingCopy(targetAsFile);
+
         if (targetAsFile.exists()) {
             // Since the target exists locally, assume it's not a URL.
             return svnClient.getInfo(targetAsFile);
@@ -221,6 +225,22 @@
     }

     /**
+ * Returns where the returned by task is for working copy
+ * instead of remote one.
+ */
+ public boolean isLocal() {
+ return local;
+ }
+
+ /**
+ * Sets whether use the local working copy
+ * information insted of remote.
+ */
+ public void setLocal(boolean local) {
+ this.local = local;
+ }
+
+ /**
      * Sets the Ant property prefix. The default is
      * <code>svn.info.</code>.
      *

Thanks.

------------------------------------------------------
http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=2432501

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subclipse.tigris.org].
Received on 2009-12-23 05:32:20 CET

This is an archived mail posted to the Subclipse Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.