How to list locally modified / unversioned files using svnkit?

I am writing a piece of code that, after executing anywhere in the working copy of SVN, finds the root:

File workingDirectory = new File(".").getCanonicalFile(); File wcRoot = SVNWCUtil.getWorkingCopyRoot(workingDirectory, true); 

gets the repository URL given by this root, builds the SVNClientManager based on this information, and now I am fixated on how to get a list of something in a working copy that is not in the repository - this includes files with local change, unresolved merges , unversioned files, and I will be glad to hear anything else that I could skip.

How can I do it? This snippet seems to require access to the repository itself, and not to the WC:

 clientManager.getLookClient().doGetChanged(...) 
+4
source share
2 answers

This gives you local modifications, i.e. Don't look at things that have been changed in the repository that are not in your working copy.

 static def isModded(SvnConfig svn, File path, SVNRevision rev) { SVNClientManager mgr = newInstance(null, svn.username, svn.password) logger.debug("Searching for modifications beneath $path.path @ $rev") mgr.statusClient.doStatus(path, rev, INFINITY, false, false, false, false, { SVNStatus status -> SVNStatusType statusType = status.contentsStatus if (statusType != STATUS_NONE && statusType != STATUS_NORMAL && statusType != STATUS_IGNORED) { lmodded = true logger.debug("$status.file.path --> lmodded: $statusType") } } as ISVNStatusHandler, null) lmodded } 

The code I have for this is in groovy, but hopefully using svnkit api is pretty obvious to work. SvnConfig is only a local value object containing various information about the repository itself.

+4
source
 public static List<File> listModifiedFiles(File path, SVNRevision revision) throws SVNException { SVNClientManager svnClientManager = SVNClientManager.newInstance(); final List<File> fileList = new ArrayList<File>(); svnClientManager.getStatusClient().doStatus(path, revision, SVNDepth.INFINITY, false, false, false, false, new ISVNStatusHandler() { @Override public void handleStatus(SVNStatus status) throws SVNException { SVNStatusType statusType = status.getContentsStatus(); if (statusType != SVNStatusType.STATUS_NONE && statusType != SVNStatusType.STATUS_NORMAL && statusType != SVNStatusType.STATUS_IGNORED) { fileList.add(status.getFile()); } } }, null); return fileList; } 
+9
source

All Articles