public FSCommitter getCommitter() { if (myCommitter == null) { myCommitter = new FSCommitter(myFSFS, myTxnRoot, myTxn, null, null); } return myCommitter; } }
public void abortEdit() throws SVNException { if (myDeltaConsumer != null) { myDeltaConsumer.abort(); } try { if (myTxn == null || !isTxnOwner) { return; } FSCommitter.abortTransaction(myFSFS, myTxn.getTxnId()); } finally { myRepository.closeRepository(); myTxn = null; myTxnRoot = null; } }
private long finalizeCommit() throws SVNException { FSHooks.runPreCommitHook(myFSFS.getRepositoryRoot(), myTxn.getTxnId()); return myCommitter.commitTxn(); }
private void verifyLocks() throws SVNException { FSTransactionRoot txnRoot = getTxnRoot(); Map changes = txnRoot.getChangedPaths(); Object[] changedPaths = changes.keySet().toArray(); Arrays.sort(changedPaths); String lastRecursedPath = null; for (int i = 0; i < changedPaths.length; i++) { String changedPath = (String) changedPaths[i]; boolean recurse = true; if (lastRecursedPath != null && SVNPathUtil.getPathAsChild(lastRecursedPath, changedPath) != null) { continue; } FSPathChange change = (FSPathChange) changes.get(changedPath); if (change.getChangeKind() == FSPathChangeKind.FS_PATH_CHANGE_MODIFY) { recurse = false; } allowLockedOperation(myFSFS, changedPath, myAuthor, myLockTokens, recurse, true); if (recurse) { lastRecursedPath = changedPath; } } }
public void makeFile(String path) throws SVNException { SVNPathUtil.checkPathIsValid(path); FSTransactionRoot txnRoot = getTxnRoot(); String txnId = txnRoot.getTxnID(); FSParentPath parentPath = txnRoot.openPath(path, false, true); if (parentPath.getRevNode() != null) { SVNErrorManager.error(FSErrors.errorAlreadyExists(txnRoot, path, myFSFS), SVNLogType.FSFS); } if ((txnRoot.getTxnFlags() & FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS) != 0) { allowLockedOperation(myFSFS, path, myAuthor, myLockTokens, false, false); } makePathMutable(parentPath.getParent(), path); FSRevisionNode childNode = makeEntry(parentPath.getParent().getRevNode(), parentPath.getParent().getAbsPath(), parentPath.getEntryName(), false, txnId); txnRoot.putRevNodeToCache(parentPath.getAbsPath(), childNode); addChange(path, childNode.getId(), FSPathChangeKind.FS_PATH_CHANGE_ADD, true, false, false, SVNRepository.INVALID_REVISION, null, SVNNodeKind.FILE); }
private boolean maybeAddWithHistory(NodeBaton nodeBaton) throws SVNException { if (nodeBaton.myCopyFromPath == null) { if (nodeBaton.myKind == SVNNodeKind.FILE) { myCurrentRevisionBaton.getCommitter().makeFile(nodeBaton.myPath); } else if (nodeBaton.myKind == SVNNodeKind.DIR) { myCurrentRevisionBaton.getCommitter().makeDir(nodeBaton.myPath); myCurrentRevisionBaton.getCommitter().makeCopy(copyRoot, nodeBaton.myCopyFromPath, nodeBaton.myPath, true);
public void changeNodeProperty(String path, String name, SVNPropertyValue propValue) throws SVNException { FSRepositoryUtil.validateProperty(name, propValue); FSTransactionRoot txnRoot = getTxnRoot(); FSParentPath parentPath = txnRoot.openPath(path, true, true); SVNNodeKind kind = parentPath.getRevNode().getType(); allowLockedOperation(myFSFS, path, myAuthor, myLockTokens, false, false); makePathMutable(parentPath, path); SVNProperties properties = parentPath.getRevNode().getProperties(myFSFS); incrementMergeInfoUpTree(parentPath, increment); addChange(path, parentPath.getRevNode().getId(), FSPathChangeKind.FS_PATH_CHANGE_MODIFY, false, true, mergeInfoModified, SVNRepository.INVALID_REVISION, null, kind);
private void changeNodeProperty(String path, String propName, String propValue) throws SVNException { if (!SVNProperty.isRegularProperty(propName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_BAD_ARGS, "Storage of non-regular property ''{0}'' is disallowed through the repository interface, and could indicate a bug in your client", propName); SVNErrorManager.error(err); } FSParentPath parentPath = myTxnRoot.openPath(path, true, true); if ((myTxnRoot.getTxnFlags() & FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS) != 0) { FSCommitter.allowLockedOperation(myFSFS, path, myAuthor, myLockTokens, false, false); } myCommitter.makePathMutable(parentPath, path); Map properties = parentPath.getRevNode().getProperties(myFSFS); if (properties.isEmpty() && propValue == null) { return; } if (propValue == null) { properties.remove(propName); } else { properties.put(propName, propValue); } myTxnRoot.setProplist(parentPath.getRevNode(), properties); myCommitter.addChange(path, parentPath.getRevNode().getId(), FSPathChangeKind.FS_PATH_CHANGE_MODIFY, false, true, FSRepository.SVN_INVALID_REVNUM, null); }
long newRevision = -1; try { newRevision = baton.getCommitter().commitTxn(myIsUsePreCommitHook, myIsUsePostCommitHook, null, null); } catch (SVNException svne) { try { FSCommitter.abortTransaction(myFSFS, baton.myTxn.getTxnId()); } catch (SVNException svne2) {
public void addFile(String path, String copyFromPath, long copyFromRevision) throws SVNException { DirBaton parentBaton = (DirBaton) myDirsStack.peek(); String fullPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.append(myBasePath, path)); if (copyFromPath != null && FSRepository.isInvalidRevision(copyFromRevision)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "Got source path but no source revision for ''{0}''", fullPath); SVNErrorManager.error(err, SVNLogType.FSFS); } else if (copyFromPath != null) { SVNNodeKind kind = myTxnRoot.checkNodeKind(fullPath); if (kind != SVNNodeKind.NONE && !parentBaton.isCopied()) { SVNErrorManager.error(FSErrors.errorOutOfDate(fullPath, kind), SVNLogType.FSFS); } copyFromPath = myRepository.getRepositoryPath(copyFromPath); FSRevisionRoot copyRoot = myFSFS.createRevisionRoot(copyFromRevision); myCommitter.makeCopy(copyRoot, copyFromPath, fullPath, true); } else { myCommitter.makeFile(fullPath); } }
public void addDir(String path, String copyFromPath, long copyFromRevision) throws SVNException { DirBaton parentBaton = (DirBaton) myDirsStack.peek(); String fullPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.append(myBasePath, path)); boolean isCopied = false; if (copyFromPath != null && FSRepository.isInvalidRevision(copyFromRevision)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "Got source path but no source revision for ''{0}''", fullPath); SVNErrorManager.error(err, SVNLogType.FSFS); } else if (copyFromPath != null) { SVNNodeKind kind = myTxnRoot.checkNodeKind(fullPath); if (kind != SVNNodeKind.NONE && !parentBaton.isCopied()) { SVNErrorManager.error(FSErrors.errorOutOfDate(fullPath, kind), SVNLogType.FSFS); } copyFromPath = myRepository.getRepositoryPath(copyFromPath); FSRevisionRoot copyRoot = myFSFS.createRevisionRoot(copyFromRevision); myCommitter.makeCopy(copyRoot, copyFromPath, fullPath, true); isCopied = true; } else { myCommitter.makeDir(fullPath); } DirBaton dirBaton = new DirBaton(SVNRepository.INVALID_REVISION, fullPath, isCopied); myDirsStack.push(dirBaton); }
FSCommitter committer = new FSCommitter(fsfs, root, txnInfo, resource.getLockTokens(), resource.getUserName()); try { committer.makeFile(path); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, committer.commitTxn(true, true, null, conflictPath); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_CONFLICT, "Conflict when committing ''{0}''.",
public void deleteNodeProperty(String propertyName) throws SVNException { myCurrentRevisionBaton.getCommitter().changeNodeProperty(myCurrentNodeBaton.myPath, propertyName, null); }
public void deleteEntry(String path, long revision) throws SVNException { String fullPath = SVNPathUtil.concatToAbs(myBasePath, path); SVNNodeKind kind = myTxnRoot.checkNodeKind(fullPath); if (kind == SVNNodeKind.NONE) { return; } FSRevisionNode existingNode = myTxnRoot.getRevisionNode(fullPath); long createdRev = existingNode.getId().getRevision(); if (FSRepository.isValidRevision(revision) && revision < createdRev) { SVNErrorManager.error(FSErrors.errorOutOfDate(fullPath, myTxnRoot.getTxnID())); } myCommitter.deleteNode(fullPath); }
protected void moveResource(DAVResource srcResource, DAVResource dstResource) throws DAVException { if (srcResource.getType() != DAVResourceType.REGULAR || dstResource.getType() != DAVResourceType.REGULAR || !getConfig().isAutoVersioning()) { throw new DAVException("MOVE only allowed on two public URIs, and autoversioning must be active.", HttpServletResponse.SC_METHOD_NOT_ALLOWED, 0); } checkOut(dstResource, true, false, false, null); FSCommitter committer = getCommitter(dstResource.getFSFS(), dstResource.getRoot(), dstResource.getTxnInfo(), dstResource.getLockTokens(), dstResource.getUserName()); String srcPath = srcResource.getResourceURI().getPath(); String dstPath = dstResource.getResourceURI().getPath(); try { committer.makeCopy((FSRevisionRoot) srcResource.getRoot(), srcPath, dstPath, true); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to make a filesystem copy.", null); } try { committer.deleteNode(srcPath); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not delete the src resource.", null); } checkIn(dstResource, false, false); }
if (kind == SVNNodeKind.NONE) { try { committer.makeFile(path); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, if (mimeType == null) { try { committer.changeNodeProperty(path, SVNProperty.MIME_TYPE, SVNPropertyValue.create(myRequest.getContentType())); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
private void verifyLocks() throws SVNException { Map changes = myTxnRoot.getChangedPaths(); Object[] changedPaths = changes.keySet().toArray(); Arrays.sort(changedPaths); String lastRecursedPath = null; for (int i = 0; i < changedPaths.length; i++) { String changedPath = (String) changedPaths[i]; boolean recurse = true; if (lastRecursedPath != null && SVNPathUtil.getPathAsChild(lastRecursedPath, changedPath) != null) { continue; } FSPathChange change = (FSPathChange) changes.get(changedPath); if (change.getChangeKind() == FSPathChangeKind.FS_PATH_CHANGE_MODIFY) { recurse = false; } allowLockedOperation(myFSFS, changedPath, myAuthor, myLockTokens, recurse, true); if (recurse) { lastRecursedPath = changedPath; } } }
String dstPath = dstResource.getResourceURI().getPath(); try { committer.makeCopy((FSRevisionRoot) srcResource.getRoot(), srcPath, dstPath, true); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
protected void createdCollection(DAVResource resource) throws DAVException { if (resource.getType() != DAVResourceType.WORKING && resource.getType() != DAVResourceType.REGULAR) { throw new DAVException("Collections can only be created within a working or regular collection [at this time].", HttpServletResponse.SC_METHOD_NOT_ALLOWED, 0); } if (resource.getType() == DAVResourceType.REGULAR && !getConfig().isAutoVersioning()) { throw new DAVException("MKCOL called on regular resource, but autoversioning is not active.", HttpServletResponse.SC_METHOD_NOT_ALLOWED, 0); } if (resource.getType() == DAVResourceType.REGULAR) { checkOut(resource, true, false, false, null); } FSCommitter committer = getCommitter(resource.getFSFS(), resource.getRoot(), resource.getTxnInfo(), resource.getLockTokens(), resource.getUserName()); try { committer.makeDir(resource.getResourceURI().getPath()); } catch (SVNException svne) { throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not create the collection.", null); } if (resource.isAutoCheckedOut()) { checkIn(resource, false, false); } }
public void deleteNode(String path) throws SVNException { FSTransactionRoot txnRoot = getTxnRoot(); FSParentPath parentPath = txnRoot.openPath(path, true, true); SVNNodeKind kind = parentPath.getRevNode().getType(); if (parentPath.getParent() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_ROOT_DIR, "The root directory cannot be deleted"); SVNErrorManager.error(err, SVNLogType.FSFS); } if ((txnRoot.getTxnFlags() & FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS) != 0) { allowLockedOperation(myFSFS, path, myAuthor, myLockTokens, true, false); } makePathMutable(parentPath.getParent(), path); txnRoot.deleteEntry(parentPath.getParent().getRevNode(), parentPath.getEntryName()); txnRoot.removeRevNodeFromCache(parentPath.getAbsPath()); if (myFSFS.supportsMergeInfo()) { long mergeInfoCount = parentPath.getRevNode().getMergeInfoCount(); if (mergeInfoCount > 0) { incrementMergeInfoUpTree(parentPath.getParent(), -mergeInfoCount); } } addChange(path, parentPath.getRevNode().getId(), FSPathChangeKind.FS_PATH_CHANGE_DELETE, false, false, false, SVNRepository.INVALID_REVISION, null, kind); }