简体   繁体   中英

Get history of a Deleted File from SVN using SVNKit

I am trying to access Revision History of a file that has been deleted using SVNKit.

Following is what I am doing to achieve that.

SVNClientManager manager = SVNClientManager.newInstance(); 
SVNLogClient logClient = manager.getLogClient(); 
logClient.doLog(svnURL, new String[] { fileName }, SVNRevision.create(deletedRevision),
                                            SVNRevision.UNDEFINED, SVNRevision.UNDEFINED, false, false, true, -1, null,
                                            new ISVNLogEntryHandler() {
                                                public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
                                                    log.debug(" ==== " + logEntry.getChangedPaths() + " === "
                                                            + logEntry.getRevision());
                                            }
                                        });

Here, deletedRevision => The SVN revision in which File was deleted.

When this code is executed I keep on getting following exceptions:

org.tmatesoft.svn.core.SVNException: svn: '<FilePath>' path not found: 404 Not Found (https://<RepositoryURL>
        at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
        at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
        at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.logImpl(DAVRepository.java:976)
        at org.tmatesoft.svn.core.io.SVNRepository.log(SVNRepository.java:1034)
        at org.tmatesoft.svn.core.wc.SVNLogClient.doLog(SVNLogClient.java:1024)
        at org.tmatesoft.svn.core.wc.SVNLogClient.doLog(SVNLogClient.java:891)
        at com.blueoptima.connectors.scr.SVN.getWorkingFileList(SVN.java:711)
        ... 4 more

Is it something that I am doing wrong here? Is there any other way to get the History of a deleted file using SVNKit

Though this question has been asked more than a year back but still thought of answering it if it could be other's help.

I didnt try for retrieving history of a deleted file but i could retrieve the history of a deleted branch using -

SVNLogClient.doLog(SVNURL.parseURIEncoded(path), new String[] { "" }, pegRevision, SVNRevision.create(0),pegRevision, stopOnCopy, discoverChangedPaths, logsLimit, logHandler);

This is similar to the call you are making but you need to supply proper values for pegRevision , startRevision and endRevision . Use of UNDEFINED may not give correct result, instead use the revision at which file was deleted as pegRevision and startRevision as 0 and it should work.

You should specify a revision where the file existed as a peg revision. Obviously it is deletedRevision-1. And maybe (I'm not sure here, just try) the file should exist in both start and end revisions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM