public static void replay( FSFS fsfs, FSRoot root, String basePath, long lowRevision, boolean sendDeltas, ISVNEditor editor) throws SVNException { Map fsChanges = root.getChangedPaths(); basePath = basePath.startsWith("/") ? basePath.substring(1) : basePath; Collection interestingPaths = new LinkedList(); Map changedPaths = new HashMap(); for (Iterator paths = fsChanges.keySet().iterator(); paths.hasNext(); ) { String path = (String) paths.next(); FSPathChange change = (FSPathChange) fsChanges.get(path); path = path.startsWith("/") ? path.substring(1) : path; if ("".equals(basePath) || (path.startsWith(basePath) && (path.charAt(basePath.length()) == '/' || path.length() == basePath.length()))) { path = path.startsWith("/") ? path.substring(1) : path; interestingPaths.add(path); changedPaths.put(path, change); } } if (FSRepository.isInvalidRevision(lowRevision)) { lowRevision = 0; } FSRoot compareRoot = null; if (sendDeltas && root instanceof FSRevisionRoot) { FSRevisionRoot revRoot = (FSRevisionRoot) root; compareRoot = fsfs.createRevisionRoot(revRoot.getRevision() - 1); } if (root instanceof FSRevisionRoot) { FSRevisionRoot revRoot = (FSRevisionRoot) root; editor.targetRevision(revRoot.getRevision()); } ISVNCommitPathHandler handler = new FSReplayPathHandler(fsfs, root, compareRoot, changedPaths, basePath, lowRevision); SVNCommitUtil.driveCommitEditor(handler, interestingPaths, editor, -1); }
public long commitTxn( boolean runPreCommitHook, boolean runPostCommitHook, SVNErrorMessage[] postCommitHookError, StringBuffer conflictPath) throws SVNException { if (myFSFS.isHooksEnabled() && runPreCommitHook) { FSHooks.runPreCommitHook(myFSFS.getRepositoryRoot(), myTxn.getTxnId()); } long newRevision = SVNRepository.INVALID_REVISION; while (true) { long youngishRev = myFSFS.getYoungestRevision(); FSRevisionRoot youngishRoot = myFSFS.createRevisionRoot(youngishRev); FSRevisionNode youngishRootNode = youngishRoot.getRevisionNode("/"); mergeChanges(myFSFS, getTxnRoot(), youngishRootNode, conflictPath); myTxn.setBaseRevision(youngishRev); FSWriteLock writeLock = FSWriteLock.getWriteLockForDB(myFSFS); synchronized (writeLock) { try { writeLock.lock(); newRevision = commit(); } catch (SVNException svne) { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.FS_TXN_OUT_OF_DATE) { long youngestRev = myFSFS.getYoungestRevision(); if (youngishRev == youngestRev) { throw svne; } continue; } throw svne; } finally { writeLock.unlock(); FSWriteLock.release(writeLock); } } break; } if (myFSFS.isHooksEnabled() && runPostCommitHook) { try { FSHooks.runPostCommitHook(myFSFS.getRepositoryRoot(), newRevision); } catch (SVNException svne) { SVNErrorMessage errorMessage = SVNErrorMessage.create( SVNErrorCode.REPOS_POST_COMMIT_HOOK_FAILED, "Commit succeeded, but post-commit hook failed", SVNErrorMessage.TYPE_WARNING); errorMessage.initCause(svne); SVNErrorMessage childErr = svne.getErrorMessage(); childErr.setDontShowErrorCode(true); errorMessage.setChildErrorMessage(childErr); if (postCommitHookError != null && postCommitHookError.length > 0) { postCommitHookError[0] = errorMessage; } else { SVNErrorManager.error(errorMessage, SVNLogType.FSFS); } } } return newRevision; }
public void makeCopy( FSRevisionRoot fromRoot, String fromPath, String toPath, boolean preserveHistory) throws SVNException { FSTransactionRoot txnRoot = getTxnRoot(); String txnId = txnRoot.getTxnID(); FSRevisionNode fromNode = fromRoot.getRevisionNode(fromPath); FSParentPath toParentPath = txnRoot.openPath(toPath, false, true); if ((txnRoot.getTxnFlags() & FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS) != 0) { FSCommitter.allowLockedOperation(myFSFS, toPath, myAuthor, myLockTokens, true, false); } if (toParentPath.getRevNode() != null && toParentPath.getRevNode().getId().equals(fromNode.getId())) { return; } FSPathChangeKind changeKind; long mergeInfoStart = 0; if (toParentPath.getRevNode() != null) { changeKind = FSPathChangeKind.FS_PATH_CHANGE_REPLACE; if (myFSFS.supportsMergeInfo()) { mergeInfoStart = toParentPath.getRevNode().getMergeInfoCount(); } } else { changeKind = FSPathChangeKind.FS_PATH_CHANGE_ADD; } makePathMutable(toParentPath.getParent(), toPath); String fromCanonPath = SVNPathUtil.canonicalizeAbsolutePath(fromPath); copy( toParentPath.getParent().getRevNode(), toParentPath.getEntryName(), fromNode, preserveHistory, fromRoot.getRevision(), fromCanonPath, txnId); if (changeKind == FSPathChangeKind.FS_PATH_CHANGE_REPLACE) { txnRoot.removeRevNodeFromCache(toParentPath.getAbsPath()); } long mergeInfoEnd = 0; if (myFSFS.supportsMergeInfo()) { mergeInfoEnd = fromNode.getMergeInfoCount(); if (mergeInfoStart != mergeInfoEnd) { incrementMergeInfoUpTree(toParentPath.getParent(), mergeInfoEnd - mergeInfoStart); } } FSRevisionNode newNode = txnRoot.getRevisionNode(toPath); addChange( toPath, newNode.getId(), changeKind, false, false, fromRoot.getRevision(), fromCanonPath, fromNode.getType()); }