if (depth == SVNDepth.UNKNOWN) {
depthIsSticky = false;
}
path = path.getAbsoluteFile();
SVNWCAccess wcAccess = createWCAccess();
SVNAdminAreaInfo adminInfo = null;
int admOpenDepth = depthIsSticky ? -1 : getLevelsToLockFromDepth(depth);
try {
if (isUpdateLocksOnDemand()) {
wcAccess.openAnchor(path, true, 0);
wcAccess.close();
}
adminInfo = wcAccess.openAnchor(path, !isUpdateLocksOnDemand(), admOpenDepth);
SVNAdminArea anchorArea = adminInfo.getAnchor();
SVNEntry entry = anchorArea.getEntry(anchorArea.getThisDirName(), false);
SVNURL url = entry.getSVNURL();
if (url == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_MISSING_URL,
"Entry ''{0}'' has no URL", anchorArea.getRoot());
SVNErrorManager.error(err, SVNLogType.WC);
}
if (depthIsSticky && depth.compareTo(SVNDepth.INFINITY) < 0) {
SVNEntry targetEntry = anchorArea.getEntry(adminInfo.getTargetName(), true);
if (targetEntry != null && targetEntry.isDirectory()) {
SVNWCManager.crop(adminInfo, depth);
if (depth == SVNDepth.EXCLUDE) {
return -1;
}
}
}
String[] preservedExts = getOptions().getPreservedConflictFileExtensions();
SVNRepository repos = createRepository(url, anchorArea.getRoot(), wcAccess, true);
boolean serverSupportsDepth = repos.hasCapability(SVNCapability.DEPTH);
final SVNReporter reporter = new SVNReporter(adminInfo, path, true, !serverSupportsDepth,
depth, isUpdateLocksOnDemand(), false, !depthIsSticky, getDebugLog());
String target = "".equals(adminInfo.getTargetName()) ? null : adminInfo.getTargetName();
long revNumber = getRevisionNumber(revision, repos, path);
SVNURL reposRoot = repos.getRepositoryRoot(true);
wcAccess.setRepositoryRoot(path, reposRoot);
final SVNRepository repos2 = createRepository(reposRoot, null, null, false);
ISVNFileFetcher fileFetcher = new ISVNFileFetcher() {
public long fetchFile(String path, long revision, OutputStream os, SVNProperties properties) throws SVNException {
return repos2.getFile(path, revision, properties, os);
}
};
ISVNUpdateEditor editor = wcAccess.createUpdateEditor(adminInfo, null, allowUnversionedObstructions,
depthIsSticky, depth, preservedExts, fileFetcher, isUpdateLocksOnDemand());
ISVNEditor filterEditor = SVNAmbientDepthFilterEditor.wrap(editor, adminInfo, depthIsSticky);
try {
repos.update(revNumber, target, depth, sendCopyFrom, reporter, SVNCancellableEditor.newInstance(filterEditor, this, getDebugLog()));
} finally {
repos2.closeSession();
}
long targetRevision = editor.getTargetRevision();
if (targetRevision >= 0) {
if ((depth == SVNDepth.INFINITY || depth == SVNDepth.UNKNOWN) && !isIgnoreExternals()) {
handleExternals(wcAccess, adminInfo.getAnchor().getRoot(),
adminInfo.getOldExternals(), adminInfo.getNewExternals(), adminInfo.getDepths(), url, reposRoot, depth, false, true);
}
dispatchEvent(SVNEventFactory.createSVNEvent(adminInfo.getTarget().getRoot(),
SVNNodeKind.NONE, null, targetRevision, SVNEventAction.UPDATE_COMPLETED, null, null,
null, reporter.getReportedFilesCount(), reporter.getTotalFilesCount()));
}
return targetRevision;
} finally {
wcAccess.close();
sleepForTimeStamp();
}
}