}
}
}
}
SVNWCAccess baseAccess = SVNWCAccess.newInstance(new ISVNEventHandler() {
public void handleEvent(SVNEvent event, double progress) throws SVNException {
}
public void checkCancelled() throws SVNCancelException {
statusClient.checkCancelled();
}
});
baseAccess.setOptions(statusClient.getOptions());
try {
baseAccess.open(baseDir, true, lockAll ? SVNWCAccess.INFINITE_DEPTH : 0);
statusClient.checkCancelled();
dirsToLock = new ArrayList(dirsToLock);
dirsToLockRecursively = new ArrayList(dirsToLockRecursively);
Collections.sort((List) dirsToLock, SVNPathUtil.PATH_COMPARATOR);
Collections.sort((List) dirsToLockRecursively, SVNPathUtil.PATH_COMPARATOR);
if (!lockAll) {
List uniqueDirsToLockRecursively = new ArrayList();
uniqueDirsToLockRecursively.addAll(dirsToLockRecursively);
Map processedPaths = new SVNHashMap();
for(Iterator ps = uniqueDirsToLockRecursively.iterator(); ps.hasNext();) {
String pathToLock = (String) ps.next();
if (processedPaths.containsKey(pathToLock)) {
//remove any duplicates
ps.remove();
continue;
}
processedPaths.put(pathToLock, pathToLock);
for(Iterator existing = dirsToLockRecursively.iterator(); existing.hasNext();) {
String existingPath = (String) existing.next();
if (pathToLock.startsWith(existingPath + "/")) {
// child of other path
ps.remove();
break;
}
}
}
Collections.sort(uniqueDirsToLockRecursively, SVNPathUtil.PATH_COMPARATOR);
dirsToLockRecursively = uniqueDirsToLockRecursively;
removeRedundantPaths(dirsToLockRecursively, dirsToLock);
for (Iterator nonRecusivePaths = dirsToLock.iterator(); nonRecusivePaths.hasNext();) {
statusClient.checkCancelled();
String path = (String) nonRecusivePaths.next();
File pathFile = new File(baseDir, path);
baseAccess.open(pathFile, true, 0);
}
for (Iterator recusivePaths = dirsToLockRecursively.iterator(); recusivePaths.hasNext();) {
statusClient.checkCancelled();
String path = (String) recusivePaths.next();
File pathFile = new File(baseDir, path);
baseAccess.open(pathFile, true, SVNWCAccess.INFINITE_DEPTH);
}
}
for(int i = 0; i < paths.length; i++) {
statusClient.checkCancelled();
File path = paths[i].getAbsoluteFile();
path = path.getAbsoluteFile();
try {
baseAccess.probeRetrieve(path);
} catch (SVNException e) {
SVNErrorMessage err = e.getErrorMessage().wrap("Are all the targets part of the same working copy?");
SVNErrorManager.error(err, SVNLogType.WC);
}
if (depth != SVNDepth.INFINITY && !force) {
if (SVNFileType.getType(path) == SVNFileType.DIRECTORY) {
// TODO replace with direct SVNStatusEditor call.
SVNStatus status = statusClient.doStatus(path, false);
if (status != null && (status.getContentsStatus() == SVNStatusType.STATUS_DELETED || status.getContentsStatus() == SVNStatusType.STATUS_REPLACED)) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Cannot non-recursively commit a directory deletion");
SVNErrorManager.error(err, SVNLogType.WC);
}
}
}
}
// if commit is non-recursive and forced, remove those child dirs
// that were not explicitly added but are explicitly copied. ufff.
if (depth != SVNDepth.INFINITY && force) {
SVNAdminArea[] lockedDirs = baseAccess.getAdminAreas();
for (int i = 0; i < lockedDirs.length; i++) {
statusClient.checkCancelled();
SVNAdminArea dir = lockedDirs[i];
if (dir == null) {
// could be null for missing, but known dir.
continue;
}
SVNEntry rootEntry = baseAccess.getEntry(dir.getRoot(), true);
if (rootEntry.getCopyFromURL() != null) {
File dirRoot = dir.getRoot();
boolean keep = false;
for (int j = 0; j < paths.length; j++) {
if (dirRoot.equals(paths[j])) {
keep = true;
break;
}
}
if (!keep) {
baseAccess.closeAdminArea(dir.getRoot());
}
}
}
}
} catch (SVNException e) {
baseAccess.close();
throw e;
}
baseAccess.setAnchor(baseDir);
return baseAccess;
}