Create SVNLogEntryPath from SVNLogEntry

View: New views
3 Messages — Rating Filter:   Alert me  

Create SVNLogEntryPath from SVNLogEntry

by Sandro F :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

a try to access the history from a svn repository directory like this:

                Iterator it = invalidEntrys.iterator();
                while(it.hasNext()) {
                    SVNURL url = repos.getLocation();
                    String entry      = (String) it.next();
                    String dir        = entry.substring(0, entry.lastIndexOf("/"));
                    url = url.appendPath(dir, false);
                    logClient.doLog(url, null, SVNRevision.HEAD, SVNRevision.parse("1"), SVNRevision.HEAD, false, true, 0, new ISVNLogEntryHandler() {
                        public void handleLogEntry(SVNLogEntry arg0) throws SVNException {
                           System.out.println(arg0.getChangedPaths().values());
                           SVNLogEntryPath entryPath = (SVNLogEntryPath) arg0.getChangedPaths().values();
                        }
                    });
                }

This line:

SVNLogEntryPath entryPath = (SVNLogEntryPath) arg0.getChangedPaths().values();

does not work:

org.tmatesoft.svn.core.internal.util.SVNHashMap$ValueCollection cannot be cast to org.tmatesoft.svn.core.SVNLogEntryPath
java.lang.ClassCastException: org.tmatesoft.svn.core.internal.util.SVNHashMap$ValueCollection cannot be cast to org.tmatesoft.svn.core.SVNLogEntryPath
        at org.technisat.checkurl.CheckURL$1.handleLogEntry(CheckURL.java:124)
        at org.tmatesoft.svn.core.wc.SVNLogClient$2.handleLogEntry(SVNLogClient.java:783)
        at org.tmatesoft.svn.core.internal.io.dav.DAVRepository$1.handleLogEntry(DAVRepository.java:597)



How can I create a SVNLogEntryPath object from SVNLogEntry?


Many thanks and best regards,
Sandro Frenzel


Re: Create SVNLogEntryPath from SVNLogEntry

by Alexander Sinyushkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Sandro,

Your casting is invalid and it is what the stack trace reports about.

You should iterate over a Map object, like this:

for (Iterator pathsIter = arg0.getChangedPaths().keySet().iterator();
pathsIter.hasNext();) {
    String path = (String) pathsIter.next();
    SVNLogEntryPath logEntryPath  = (SVNLogEntryPath)
arg0.getChangedPaths.get(path);
}

----
Alexander Sinyushkin,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!



Sandro F wrote:

> Hello all,
>
> a try to access the history from a svn repository directory like this:
>
>                 Iterator it = invalidEntrys.iterator();
>                 while(it.hasNext()) {
>                     SVNURL url = repos.getLocation();
>                     String entry      = (String) it.next();
>                     String dir        = entry.substring(0,
> entry.lastIndexOf("/"));
>                     url = url.appendPath(dir, false);
>                     logClient.doLog(url, null, SVNRevision.HEAD,
> SVNRevision.parse("1"), SVNRevision.HEAD, false, true, 0, new
> ISVNLogEntryHandler() {
>                         public void handleLogEntry(SVNLogEntry arg0) throws
> SVNException {
>                          
> System.out.println(arg0.getChangedPaths().values());
>                            SVNLogEntryPath entryPath = (SVNLogEntryPath)
> arg0.getChangedPaths().values();
>                         }
>                     });
>                 }
>
> This line:
>
> SVNLogEntryPath entryPath = (SVNLogEntryPath)
> arg0.getChangedPaths().values();
>
> does not work:
>
> org.tmatesoft.svn.core.internal.util.SVNHashMap$ValueCollection cannot be
> cast to org.tmatesoft.svn.core.SVNLogEntryPath
> java.lang.ClassCastException:
> org.tmatesoft.svn.core.internal.util.SVNHashMap$ValueCollection cannot be
> cast to org.tmatesoft.svn.core.SVNLogEntryPath
>         at
> org.technisat.checkurl.CheckURL$1.handleLogEntry(CheckURL.java:124)
>         at
> org.tmatesoft.svn.core.wc.SVNLogClient$2.handleLogEntry(SVNLogClient.java:783)
>         at
> org.tmatesoft.svn.core.internal.io.dav.DAVRepository$1.handleLogEntry(DAVRepository.java:597)
>
>
>
> How can I create a SVNLogEntryPath object from SVNLogEntry?
>
>
> Many thanks and best regards,
> Sandro Frenzel
>
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: svnkit-users-unsubscribe@...
For additional commands, e-mail: svnkit-users-help@...


Re: Create SVNLogEntryPath from SVNLogEntry

by David Honey-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Or better still, use: Map.Entry<String,SVNLogEntryPath>.
It's more efficient to iterate over a map using a Map.Entry because it provides both the key and the value together without having to look up the map value by key later.


From: Alexander Sinyushkin <Alexander.Sinyushkin@...>
To: svnkit-users@...
Date: 11/08/2009 14:26
Subject: Re: Create SVNLogEntryPath from SVNLogEntry





Hello Sandro,

Your casting is invalid and it is what the stack trace reports about.

You should iterate over a Map object, like this:

for (Iterator pathsIter = arg0.getChangedPaths().keySet().iterator();
pathsIter.hasNext();) {
   String path = (String) pathsIter.next();
   SVNLogEntryPath logEntryPath  = (SVNLogEntryPath)
arg0.getChangedPaths.get(path);
}

----
Alexander Sinyushkin,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!



Sandro F wrote:
> Hello all,
>
> a try to access the history from a svn repository directory like this:
>
>                 Iterator it = invalidEntrys.iterator();
>                 while(it.hasNext()) {
>                     SVNURL url = repos.getLocation();
>                     String entry      = (String) it.next();
>                     String dir        = entry.substring(0,
> entry.lastIndexOf("/"));
>                     url = url.appendPath(dir, false);
>                     logClient.doLog(url, null, SVNRevision.HEAD,
> SVNRevision.parse("1"), SVNRevision.HEAD, false, true, 0, new
> ISVNLogEntryHandler() {
>                         public void handleLogEntry(SVNLogEntry arg0) throws
> SVNException {
>                          
> System.out.println(arg0.getChangedPaths().values());
>                            SVNLogEntryPath entryPath = (SVNLogEntryPath)
> arg0.getChangedPaths().values();
>                         }
>                     });
>                 }
>
> This line:
>
> SVNLogEntryPath entryPath = (SVNLogEntryPath)
> arg0.getChangedPaths().values();
>
> does not work:
>
> org.tmatesoft.svn.core.internal.util.SVNHashMap$ValueCollection cannot be
> cast to org.tmatesoft.svn.core.SVNLogEntryPath
> java.lang.ClassCastException:
> org.tmatesoft.svn.core.internal.util.SVNHashMap$ValueCollection cannot be
> cast to org.tmatesoft.svn.core.SVNLogEntryPath
>         at
> org.technisat.checkurl.CheckURL$1.handleLogEntry(CheckURL.java:124)
>         at
> org.tmatesoft.svn.core.wc.SVNLogClient$2.handleLogEntry(SVNLogClient.java:783)
>         at
> org.tmatesoft.svn.core.internal.io.dav.DAVRepository$1.handleLogEntry(DAVRepository.java:597)
>
>
>
> How can I create a SVNLogEntryPath object from SVNLogEntry?
>
>
> Many thanks and best regards,
> Sandro Frenzel
>
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: svnkit-users-unsubscribe@...
For additional commands, e-mail: svnkit-users-help@...









Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU