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 String reserveCopyId(String txnId) throws SVNException { FSTransactionRoot txnRoot = getTxnRoot(); String[] nextIds = txnRoot.readNextIDs(); String copyId = FSRepositoryUtil.generateNextKey(nextIds[1]); myFSFS.writeNextIDs(txnId, nextIds[0], copyId); return "_" + nextIds[1]; }
public void incrementMergeInfoUpTree(FSParentPath parentPath, long increment) throws SVNException { while (parentPath != null) { FSTransactionRoot txnRoot = getTxnRoot(); txnRoot.incrementMergeInfoCount(parentPath.getRevNode(), increment); parentPath = parentPath.getParent(); } }
private FSID createNode(FSRevisionNode revNode, String copyId, String txnId) throws SVNException { FSTransactionRoot txnRoot = getTxnRoot(); String nodeId = txnRoot.getNewTxnNodeId(); FSID id = FSID.createTxnId(nodeId, copyId, txnId); revNode.setId(id); revNode.setIsFreshTxnRoot(false); myFSFS.putTxnRevisionNode(id, revNode); return id; }
public void addChange(String path, FSID id, FSPathChangeKind changeKind, boolean textModified, boolean propsModified, boolean mergeInfoModified, long copyFromRevision, String copyFromPath, SVNNodeKind kind) throws SVNException { path = SVNPathUtil.canonicalizeAbsolutePath(path); OutputStream changesFile = null; try { FSTransactionRoot txnRoot = getTxnRoot(); changesFile = SVNFileUtil.openFileForWriting(txnRoot.getTransactionChangesFile(), true); FSPathChange pathChange = new FSPathChange(path, id, changeKind, textModified, propsModified, mergeInfoModified, copyFromPath, copyFromRevision, kind); txnRoot.writeChangeEntry(changesFile, pathChange, true); } catch (IOException ioe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(changesFile); } }
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();
final OutputStream protoFileOS = null; final FSID newRootId = null; final FSTransactionRoot txnRoot = getTxnRoot(); FSWriteLock txnWriteLock = FSWriteLock.getWriteLockForTxn(myTxn.getTxnId(), myFSFS); synchronized (txnWriteLock) {
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); }
public void makeDir(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, true, false); } makePathMutable(parentPath.getParent(), path); FSRevisionNode subDirNode = makeEntry(parentPath.getParent().getRevNode(), parentPath.getParent().getAbsPath(), parentPath.getEntryName(), true, txnId); txnRoot.putRevNodeToCache(parentPath.getAbsPath(), subDirNode); addChange(path, subDirNode.getId(), FSPathChangeKind.FS_PATH_CHANGE_ADD, false, false, false, SVNRepository.INVALID_REVISION, null, SVNNodeKind.DIR); }
private void copy(FSRevisionNode toNode, String entryName, FSRevisionNode fromNode, boolean preserveHistory, long fromRevision, String fromPath, String txnId) throws SVNException { FSID id = null; FSTransactionRoot txnRoot = getTxnRoot(); if (preserveHistory) { FSID srcId = fromNode.getId(); FSRevisionNode toRevNode = FSRevisionNode.dumpRevisionNode(fromNode); String copyId = reserveCopyId(txnId); toRevNode.setPredecessorId(srcId); if (toRevNode.getCount() != -1) { toRevNode.setCount(toRevNode.getCount() + 1); } String createdPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.append(toNode.getCreatedPath(), entryName)); toRevNode.setCreatedPath(createdPath); toRevNode.setCopyFromPath(fromPath); toRevNode.setCopyFromRevision(fromRevision); toRevNode.setCopyRootPath(null); id = txnRoot.createSuccessor(srcId, toRevNode, copyId); } else { id = fromNode.getId(); } txnRoot.setEntry(toNode, entryName, id, fromNode.getType()); }
mergeChanges(myFSFS, getTxnRoot(), youngishRootNode, conflictPath); myTxn.setBaseRevision(youngishRev);
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); }
public FSRevisionNode makeEntry(FSRevisionNode parent, String parentPath, String entryName, boolean isDir, String txnId) throws SVNException { if (!SVNPathUtil.isSinglePathComponent(entryName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_SINGLE_PATH_COMPONENT, "Attempted to create a node with an illegal name ''{0}''", entryName); SVNErrorManager.error(err, SVNLogType.FSFS); } if (parent.getType() != SVNNodeKind.DIR) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_DIRECTORY, "Attempted to create entry in non-directory parent"); SVNErrorManager.error(err, SVNLogType.FSFS); } if (!parent.getId().isTxn()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_MUTABLE, "Attempted to clone child of non-mutable node"); SVNErrorManager.error(err, SVNLogType.FSFS); } FSRevisionNode newRevNode = new FSRevisionNode(); newRevNode.setType(isDir ? SVNNodeKind.DIR : SVNNodeKind.FILE); String createdPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.append(parentPath, entryName)); newRevNode.setCreatedPath(createdPath); newRevNode.setCopyRootPath(parent.getCopyRootPath()); newRevNode.setCopyRootRevision(parent.getCopyRootRevision()); newRevNode.setCopyFromRevision(SVNRepository.INVALID_REVISION); newRevNode.setCopyFromPath(null); FSID newNodeId = createNode(newRevNode, parent.getId().getCopyID(), txnId); FSRevisionNode childNode = myFSFS.getRevisionNode(newNodeId); FSTransactionRoot txnRoot = getTxnRoot(); txnRoot.setEntry(parent, entryName, childNode.getId(), newRevNode.getType()); return childNode; }
public void makePathMutable(FSParentPath parentPath, String errorPath) throws SVNException { FSTransactionRoot txnRoot = getTxnRoot(); String txnId = txnRoot.getTxnID();
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);