0

I am committing the files to SVN using the API available in SVNKit.

ourClientManager.getCommitClient().doCommit(mypaths, kpLocks, "", force-yes, recursive-true);

I want to find out if the directory of the file, is part of working copy or not, before checking in the file. Can you please suggest what API i can use to get this information.

mstrap
  • 16,808
  • 10
  • 56
  • 86
Krishnaveni
  • 799
  • 2
  • 11
  • 32

3 Answers3

2

You want to use status to figure this out:

ourClientManager.getStatusClient().doStatus(path, false).isVersioned()

If you want to figure out if more than one file is versioned you'll probably want to write an ISVNStatusHandler.

Link to the SVNKit Documentation: http://svnkit.com/javadoc/org/tmatesoft/svn/core/wc/SVNStatusClient.html

Ben Reser
  • 5,695
  • 1
  • 21
  • 29
  • I tried to use this info = ourClientManager.getStatusClient().doStatus(file, false); -- but this line gives SVN Exception -- file not working copy -- file here is the new package.. – Krishnaveni Mar 23 '13 at 10:05
  • That means the file isn't in a working copy. If you want to check if arbitrary files are versioned and in a working copy you probably just watch to catch that exception. The other possibility is that the working copy is not compatible with the libraries you're using, however I believe SVNKit will deal with 1.6 and 1.7 working copy formats, so that's probably not the problem here. – Ben Reser Mar 23 '13 at 19:30
2

As SVNKit developer I would recommend you to use SVNWCUtil#isVersionedDirectory or SvnOperationFactory#isVersionedDirectory.

SvnOperationFactory#isVersionedDirectory can accept "isAdditionMode" parameter that is used to distinguish a very special case: in your working copy you have a unversioned symlink that points to a nested working copy. For all operations except "svn add" this symlink should be considered as versioned, because it points to a working copy (in particular "svn info this_symlink" shows info for that nested working copy), but for "svn add" is should be considered as unversioned to let the user add it to the repository as a file with svn:special property (instead of showing an error that the working copy is already versioned).

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
1

Hi you can use following method to get the list of modified and unversioned files

public List<SVNStatus> getCommitableFiles(File path, String revision) throws SVNException {
    SVNClientManager svnClientManager = SVNClientManager.newInstance();
    final List<SVNStatus> allSVNStatus = new ArrayList<SVNStatus>();
    svnClientManager.getStatusClient().doStatus(path, SVNRevision.parse(revision), SVNDepth.INFINITY, false, false, false, false, new ISVNStatusHandler() {
        public void handleStatus(SVNStatus status) throws SVNException {
            SVNStatusType statusType = status.getContentsStatus();
            if (statusType != SVNStatusType.STATUS_NONE && statusType != SVNStatusType.STATUS_NORMAL
                    && statusType != SVNStatusType.STATUS_IGNORED) {
                allSVNStatus.add(status);
            }
        }
    }, null);

    return allSVNStatus;
}
Zyber
  • 428
  • 4
  • 21