public String getNewTxnNodeId() throws SVNException { String[] curIds = readNextIDs(); String curNodeId = curIds[0]; String curCopyId = curIds[1]; String nextNodeId = FSRepositoryUtil.generateNextKey(curNodeId); getOwner().writeNextIDs(getTxnID(), nextNodeId, curCopyId); return "_" + curNodeId; }
public void removeNodeProperties() throws SVNException { FSTransactionRoot txnRoot = myCurrentRevisionBaton.myTxnRoot; FSRevisionNode node = txnRoot.getRevisionNode(myCurrentNodeBaton.myPath); SVNProperties props = node.getProperties(myFSFS); for (Iterator propNames = props.nameSet().iterator(); propNames.hasNext();) { String propName = (String) propNames.next(); myCurrentRevisionBaton.getCommitter().changeNodeProperty(myCurrentNodeBaton.myPath, propName, null); } }
public FSTransactionInfo openTxn(String txnName) throws SVNException { SVNFileType kind = SVNFileType.getType(getTransactionDir(txnName)); if (kind != SVNFileType.DIRECTORY) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NO_SUCH_TRANSACTION, "No such transaction"); SVNErrorManager.error(err, SVNLogType.FSFS); } FSTransactionRoot txnRoot = new FSTransactionRoot(this, txnName, -1, 0); FSTransactionInfo localTxn = txnRoot.getTxn(); return new FSTransactionInfo(localTxn.getBaseRevision(), txnName); }
private String getNewTxnNodeId() throws SVNException { String[] curIds = myTxnRoot.readNextIDs(); String curNodeId = curIds[0]; String curCopyId = curIds[1]; String nextNodeId = FSTransactionRoot.generateNextKey(curNodeId); myFSFS.writeNextIDs(myTxnRoot.getTxnID(), nextNodeId, curCopyId); return "_" + nextNodeId; }
public void writeFinalCurrentFile(long newRevision, String startNodeId, String startCopyId) throws SVNException, IOException { if (getOwner().getDBFormat() >= FSFS.MIN_NO_GLOBAL_IDS_FORMAT) { getOwner().writeCurrentFile(newRevision, null, null); return; } String[] txnIds = readNextIDs(); String txnNodeId = txnIds[0]; String txnCopyId = txnIds[1]; String newNodeId = FSTransactionRoot.addKeys(startNodeId, txnNodeId); String newCopyId = FSTransactionRoot.addKeys(startCopyId, txnCopyId); getOwner().writeCurrentFile(newRevision, newNodeId, newCopyId); }
public void makeFile(String path) throws SVNException { SVNPathUtil.checkPathIsValid(path); String txnId = myTxnRoot.getTxnID(); FSParentPath parentPath = myTxnRoot.openPath(path, false, true); if (parentPath.getRevNode() != null) { SVNErrorManager.error(FSErrors.errorAlreadyExists(myTxnRoot, path, myFSFS), SVNLogType.FSFS); } if ((myTxnRoot.getTxnFlags() & FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS) != 0) { FSCommitter.allowLockedOperation(myFSFS, path, myAuthor, myLockTokens, false, false); } makePathMutable(parentPath.getParent(), path); FSRevisionNode childNode = makeEntry(parentPath.getParent().getRevNode(), parentPath.getParent().getAbsPath(), parentPath.getEntryName(), false, txnId); myTxnRoot.putRevNodeToCache(parentPath.getAbsPath(), childNode); addChange(path, childNode.getId(), FSPathChangeKind.FS_PATH_CHANGE_ADD, false, false, SVNRepository.INVALID_REVISION, null, SVNNodeKind.FILE); }
public void makeCopy(FSRevisionRoot fromRoot, String fromPath, String toPath, boolean preserveHistory) throws SVNException { String txnId = myTxnRoot.getTxnID(); FSRevisionNode fromNode = fromRoot.getRevisionNode(fromPath); FSParentPath toParentPath = myTxnRoot.openPath(toPath, false, true); if ((myTxnRoot.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; if (toParentPath.getRevNode() != null) { changeKind = FSPathChangeKind.FS_PATH_CHANGE_REPLACE; } else { changeKind = FSPathChangeKind.FS_PATH_CHANGE_ADD; } makePathMutable(toParentPath.getParent(), toPath); String fromCanonPath = fromPath; copy(toParentPath.getParent().getRevNode(), toParentPath.getNameEntry(), fromNode, preserveHistory, fromRoot.getRevision(), fromCanonPath, txnId); if (changeKind == FSPathChangeKind.FS_PATH_CHANGE_REPLACE) { myTxnRoot.removeRevNodeFromCache(toParentPath.getAbsPath()); } FSRevisionNode newNode = myTxnRoot.getRevisionNode(toPath); addChange(toPath, newNode.getId(), changeKind, false, false, fromRoot.getRevision(), fromCanonPath); }
public void makePathMutable(FSParentPath parentPath, String errorPath) throws SVNException { String txnId = myTxnRoot.getTxnID(); clone = myTxnRoot.cloneChild(parentPath.getParent().getRevNode(), clonePath, parentPath.getEntryName(), copyId, isParentCopyRoot); myTxnRoot.putRevNodeToCache(parentPath.getAbsPath(), clone); } else { FSTransactionInfo txn = myTxnRoot.getTxn();
FSFS owner = getOwner(); FSRevisionNode revNode = owner.getRevisionNode(id); if (revNode.getType() == SVNNodeKind.DIR) { for (Iterator entries = namesToEntries.values().iterator(); entries.hasNext();) { FSEntry dirEntry = (FSEntry) entries.next(); newId = writeFinalRevision(newId, protoFile, revision, dirEntry.getId(), startNodeId, startCopyId); if (newId != null && newId.getRevision() == revision) { SVNProperties unparsedEntries = unparseDirEntries(namesToEntries); FSRepresentation textRep = revNode.getTextRepresentation(); textRep.setTxnId(null); textRep.setOffset(protoFile.getPosition()); final MessageDigest checksum = MessageDigest.getInstance("MD5"); long size = writeHashRepresentation(unparsedEntries, protoFile, checksum); String hexDigest = SVNFileUtil.toHexDigest(checksum); textRep.setSize(size); propsRep.setOffset(protoFile.getPosition()); final MessageDigest checksum = MessageDigest.getInstance("MD5"); long size = writeHashRepresentation(props, protoFile, checksum); String hexDigest = SVNFileUtil.toHexDigest(checksum); propsRep.setSize(size); if (getOwner().getDBFormat() >= FSFS.MIN_NO_GLOBAL_IDS_FORMAT) { myNodeId = nodeId.substring(1) + "-" + revision; } else {
FSFS owner = getOwner(); FSRevisionNode revNode = owner.getRevisionNode(id); if (revNode.getType() == SVNNodeKind.DIR) { for (Iterator entries = namesToEntries.values().iterator(); entries.hasNext();) { FSEntry dirEntry = (FSEntry) entries.next(); newId = writeFinalRevision(newId, protoFile, revision, dirEntry.getId(), startNodeId, startCopyId, representations, false); if (newId != null && newId.getRevision() == revision) { SVNProperties unparsedEntries = unparseDirEntries(namesToEntries); FSRepresentation textRep = revNode.getTextRepresentation(); textRep.setTxnId(null); textRep.setItemIndex(protoFile.getPosition()); final MessageDigest checksum = MessageDigest.getInstance("MD5"); long size = writeHashRepresentation(textRep, unparsedEntries, protoFile, checksum, FSP2LProtoIndex.ItemType.DIR_REP); String hexDigest = SVNFileUtil.toHexDigest(checksum); textRep.setSize(size); propsRep.setItemIndex(protoFile.getPosition()); final MessageDigest checksum = MessageDigest.getInstance("MD5"); long size = writeHashRepresentation(propsRep, props, protoFile, checksum, itemType); String hexDigest = SVNFileUtil.toHexDigest(checksum); propsRep.setSize(size); if (getOwner().getDBFormat() >= FSFS.MIN_NO_GLOBAL_IDS_FORMAT) { myNodeId = nodeId.substring(1) + "-" + revision; } else {
public FSRevisionNode cloneChild(FSRevisionNode parent, String parentPath, String childName, String copyId, boolean isParentCopyRoot) throws SVNException { if (!parent.getId().isTxn()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_MUTABLE, "Attempted to clone child of non-mutable node"); SVNErrorManager.error(err); } if (!SVNPathUtil.isSinglePathComponent(childName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_SINGLE_PATH_COMPONENT, "Attempted to make a child clone with an illegal name ''{0}''", childName); SVNErrorManager.error(err); } FSRevisionNode childNode = parent.getChildDirNode(childName, getOwner()); FSID newNodeId = null; if (childNode.getId().isTxn()) { newNodeId = childNode.getId(); } else { if (isParentCopyRoot) { childNode.setCopyRootPath(parent.getCopyRootPath()); childNode.setCopyRootRevision(parent.getCopyRootRevision()); } childNode.setCopyFromPath(null); childNode.setCopyFromRevision(FSRepository.SVN_INVALID_REVNUM); childNode.setPredecessorId(childNode.getId()); if (childNode.getCount() != -1) { childNode.setCount(childNode.getCount() + 1); } childNode.setCreatedPath(SVNPathUtil.concatToAbs(parentPath, childName)); newNodeId = createSuccessor(childNode.getId(), childNode, copyId); setEntry(parent, childName, newNodeId, childNode.getType()); } return getOwner().getRevisionNode(newNodeId); }
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); }
private void copy(FSRevisionNode toNode, String entryName, FSRevisionNode fromNode, boolean preserveHistory, long fromRevision, String fromPath, String txnId) throws SVNException { FSID id = null; 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); } toRevNode.setCreatedPath(SVNPathUtil.concatToAbs(toNode.getCreatedPath(), entryName)); toRevNode.setCopyFromPath(fromPath); toRevNode.setCopyFromRevision(fromRevision); toRevNode.setCopyRootPath(null); id = myTxnRoot.createSuccessor(srcId, toRevNode, copyId); } else { id = fromNode.getId(); } myTxnRoot.setEntry(toNode, entryName, id, fromNode.getType()); }
public static SVNErrorMessage errorNotFound(FSRoot root, String path) { SVNErrorMessage err; if (root instanceof FSTransactionRoot) { FSTransactionRoot txnRoot = (FSTransactionRoot) root; err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND, "File not found: transaction ''{0}'', path ''{1}''", new Object[] { txnRoot.getTxnID(), path }); } else { FSRevisionRoot revRoot = (FSRevisionRoot) root; err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND, "File not found: revision {0}, path ''{1}''", new Object[] { new Long(revRoot.getRevision()), path }); } return err; }
public void deleteEntry(String path, long revision) throws SVNException { String fullPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.append(myBasePath, path)); SVNNodeKind kind = myTxnRoot.checkNodeKind(fullPath); if (kind == SVNNodeKind.NONE) { SVNErrorManager.error(FSErrors.errorOutOfDate(fullPath, kind), SVNLogType.FSFS); } FSRevisionNode existingNode = myTxnRoot.getRevisionNode(fullPath); long createdRev = existingNode.getCreatedRevision(); if (FSRepository.isValidRevision(revision) && revision < createdRev) { SVNErrorManager.error(FSErrors.errorOutOfDate(fullPath, kind), SVNLogType.FSFS); } myCommitter.deleteNode(fullPath); }
public void openFile(String path, long revision) throws SVNException { String fullPath = SVNPathUtil.concatToAbs(myBasePath, path); FSRevisionNode revNode = myTxnRoot.getRevisionNode(fullPath); if (FSRepository.isValidRevision(revision) && revision < revNode.getId().getRevision()) { SVNErrorManager.error(FSErrors.errorOutOfDate(fullPath, myTxnRoot.getTxnID())); } }
public void storeP2LIndexEntry(FSP2LEntry entry) throws SVNException { final FSFS fsfs = getOwner(); final String txnID = getTxnID(); if (getOwner().isUseLogAddressing()) { final FSP2LProtoIndex protoIndex = FSP2LProtoIndex.open(fsfs, txnID, true); assert protoIndex != null; try { protoIndex.writeEntry(entry); } finally { if (protoIndex != null) { protoIndex.close(); } } } }
public void addFile(String path, String copyFromPath, long copyFromRevision) throws SVNException { DirBaton parentBaton = (DirBaton) myDirsStack.peek(); String fullPath = SVNPathUtil.concatToAbs(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); } else if (copyFromPath != null) { SVNNodeKind kind = myTxnRoot.checkNodeKind(fullPath); if (kind != SVNNodeKind.NONE && !parentBaton.isCopied()) { SVNErrorManager.error(FSErrors.errorOutOfDate(fullPath, myTxnRoot.getTxnID())); } copyFromPath = myRepository.getRepositoryPath(copyFromPath); FSRevisionRoot copyRoot = myFSFS.createRevisionRoot(copyFromRevision); myCommitter.makeCopy(copyRoot, copyFromPath, fullPath, true); } else { myCommitter.makeFile(fullPath); } }
public void openDir(String path, long revision) throws SVNException { DirBaton parentBaton = (DirBaton) myDirsStack.peek(); String fullPath = SVNPathUtil.concatToAbs(myBasePath, path); SVNNodeKind kind = myTxnRoot.checkNodeKind(fullPath); if (kind == SVNNodeKind.NONE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_DIRECTORY, "Path ''{0}'' not present", path); SVNErrorManager.error(err); } DirBaton dirBaton = new DirBaton(revision, fullPath, parentBaton.isCopied()); myDirsStack.push(dirBaton); }
public static FSTransactionInfo beginTransactionForCommit(long baseRevision, SVNProperties revisionProperties, FSFS owner) throws SVNException { List caps = new ArrayList(); caps.add("mergeinfo"); String author = revisionProperties.getStringValue(SVNRevisionProperty.AUTHOR); FSHooks.runStartCommitHook(owner.getRepositoryRoot(), author, caps); FSTransactionInfo txn = FSTransactionRoot.beginTransaction(baseRevision, FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS, owner); owner.changeTransactionProperties(txn.getTxnId(), revisionProperties); return txn; }