Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list locally-modified/unversioned files using svnkit?

Tags:

java

svn

svnkit

I'm writing a piece of code that, once executed anywhere inside an SVN working copy, locates the root:

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

gets the repository url given this root, builds an SVNClientManager given this info and now I'm stuck at how to get a list of anything in the working copy that is not in the repository - this includes locally-modified files, unresolved merges, unversioned files and I'll be happy to hear any anything else I might have missed.

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

clientManager.getLookClient().doGetChanged(...)
like image 410
radai Avatar asked Aug 07 '12 18:08

radai


1 Answers

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;
}
like image 98
Maheshkumar Avatar answered Nov 03 '22 01:11

Maheshkumar