0

I need to get log from SVNRepository from specific folder.

For example - I have

SVNURL url = SVNURL.parseURIEncoded("https://subversion.assembla.com/svn/jscrum");
SVNRepository svnRepository = DAVRepositoryFactory.create(url);

and I'm getting log from repository:

Collection logEntries = svnRepository.log(new String[] { "" }, null, startRevision, endRevision, true, true);

And it's working correct, but shows me log from whole repo. I need changes from folder on repo: "/trunk/js/web/src/main/webapp".

I've tried some 'tricks', but none of them are working :<

SVNURL url = SVNURL.parseURIEncoded("https://subversion.assembla.com/svn/jscrum/trunk/js/web/src/main/webapp");

or

Collection logEntries = svnRepository.log(new String[] { "/trunk/js/web/src/main/webapp" }, null, startRevision, endRevision, true, true);

One option is to check if returned path from whole repo contains my directory path, but it seems not so proffesional ; p

Thanks for any advices.

Krystian
  • 2,221
  • 1
  • 26
  • 41
  • 1
    IMO, both solutions will work in the sense that you will only get `SVNLogEntry` objects for which the specific path has been changed. However, `SVNLogEntry.myChangedPaths` will always contain *all* changes paths of that revision, so you have to filter them manually. – mstrap Aug 30 '13 at 09:30

1 Answers1

2

Ok, so solution looks like this (for next generation of searchers :P):

for (Iterator entries = logEntries.iterator(); entries.hasNext();) {
                SVNLogEntry logEntry = (SVNLogEntry) entries.next();

                if (logEntry.getChangedPaths().size() > 0) {
                    Set<String> changedPathsSet = logEntry.getChangedPaths().keySet();

                    for (Iterator<String> changedPaths = changedPathsSet.iterator(); changedPaths
                            .hasNext();) {
                        SVNLogEntryPath entryPath = (SVNLogEntryPath) logEntry
                                .getChangedPaths().get(changedPaths.next());
                        String path = entryPath.getPath();
                        if (!path.startsWith(updatePath)) {
                            continue;
                        }

+ end of for(s) and if(s)

Krystian
  • 2,221
  • 1
  • 26
  • 41