private static FSTransactionInfo createTxn(long baseRevision, FSFS owner) throws SVNException { String txnID = createTxnDir(baseRevision, owner); FSTransactionInfo txn = new FSTransactionInfo(baseRevision, txnID); FSRevisionRoot root = owner.createRevisionRoot(baseRevision); FSRevisionNode rootNode = root.getRootRevisionNode(); owner.createNewTxnNodeRevisionFromRevision(txnID, rootNode); SVNFileUtil.createEmptyFile(new File(owner.getTransactionDir(txn.getTxnId()), FSFS.TXN_PATH_REV)); SVNFileUtil.createEmptyFile(new File(owner.getTransactionDir(txn.getTxnId()), "changes")); owner.writeNextIDs(txnID, "0", "0"); return txn; }
public void openRoot(long revision) throws SVNException { long youngestRev = myFSFS.getYoungestRevision(); if (isTxnOwner) { myTxn = FSTransactionRoot.beginTransactionForCommit(youngestRev, myRevProps, myFSFS); } else { myFSFS.changeTransactionProperties(myTxn.getTxnId(), myRevProps); } myTxnRoot = myFSFS.createTransactionRoot(myTxn); myCommitter = new FSCommitter(myFSFS, myTxnRoot, myTxn, myLockTokens, getAuthor()); DirBaton dirBaton = new DirBaton(revision, myBasePath, false); myDirsStack.push(dirBaton); }
public FSTransactionRoot createTransactionRoot(String txnId) throws SVNException { Map txnProps = getTransactionProperties(txnId); int flags = 0; if (txnProps.get(SVNProperty.TXN_CHECK_OUT_OF_DATENESS) != null) { flags |= FSTransactionRoot.SVN_FS_TXN_CHECK_OUT_OF_DATENESS; } if (txnProps.get(SVNProperty.TXN_CHECK_LOCKS) != null) { flags |= FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS; } return new FSTransactionRoot(this, txnId, flags); }
public void parseUUID(String uuid) throws SVNException { if (myUUIDAction == SVNUUIDAction.IGNORE_UUID) { return; } if (myUUIDAction != SVNUUIDAction.FORCE_UUID) { long latestRevision = myFSFS.getYoungestRevision(); if (latestRevision != 0) { return; } } myFSFS.setUUID(uuid); }
public static void allowLockedOperation(FSFS fsfs, String path, final String username, final Collection lockTokens, boolean recursive, boolean haveWriteLock) throws SVNException { if (recursive) { ISVNLockHandler handler = new ISVNLockHandler() { private String myUsername = username; private Collection myTokens = lockTokens; public void handleLock(String path, SVNLock lock, SVNErrorMessage error) throws SVNException { verifyLock(lock, myTokens, myUsername); } public void handleUnlock(String path, SVNLock lock, SVNErrorMessage error) throws SVNException { } }; fsfs.walkDigestFiles(fsfs.getDigestFileFromRepositoryPath(path), handler, haveWriteLock); } else { SVNLock lock = fsfs.getLockHelper(path, haveWriteLock); if (lock != null) { verifyLock(lock, lockTokens, username); } } }
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); if (owner != null && owner.isHooksEnabled()) { 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; }
FSRoot root = null; if (txnName == null) { long revNum = SVNAdminHelper.getRevisionNumber(revision, fsfs.getYoungestRevision(), fsfs); if (revProps) { return fsfs.getRevisionProperties(revNum); root = fsfs.createRevisionRoot(revNum); } else { FSTransactionInfo txn = fsfs.openTxn(txnName); if (revProps) { return fsfs.getTransactionProperties(txn.getTxnId()); root = fsfs.createTransactionRoot(txn);
/** * Returns author information for the given transaction. * * @param repositoryRoot a repository root directory path * @param transactionName a transaction name * @return a transaction owner * @throws SVNException <ul> * <li>no repository is found at * <code>repositoryRoot</code></li> * <li>if the specified transaction is not found</li> * </ul> */ public String doGetAuthor(File repositoryRoot, String transactionName) throws SVNException { FSFS fsfs = open(repositoryRoot, transactionName); try { FSTransactionInfo txn = fsfs.openTxn(transactionName); SVNProperties txnProps = fsfs.getTransactionProperties(txn.getTxnId()); return txnProps.getStringValue(SVNRevisionProperty.AUTHOR); } finally { SVNAdminHelper.closeRepository(fsfs); } }
private FSRoot getTargetRoot() throws SVNException { if (myTargetRoot == null) { myTargetRoot = myFSFS.createRevisionRoot(myTargetRevision); } return myTargetRoot; }
private Date getRevisionTime(long revision) throws SVNException { Map revisionProperties = myFSFS.getRevisionProperties(revision); String timeString = (String) revisionProperties.get(SVNRevisionProperty.DATE); if (timeString == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "Failed to find time on revision {0,number,integer}", new Long(revision)); SVNErrorManager.error(err); } return SVNTimeUtil.parseDateString(timeString); }
public FSClosestCopy getClosestCopy(String path) throws SVNException { FSParentPath parentPath = openPath(path, true, true); SVNLocationEntry copyDstEntry = FSNodeHistory.findYoungestCopyroot(getOwner().getRepositoryRoot(), parentPath); if (copyDstEntry == null || copyDstEntry.getRevision() == 0) { return null; } FSRevisionRoot copyDstRoot = getOwner().createRevisionRoot(copyDstEntry.getRevision()); if (copyDstRoot.checkNodeKind(path) == SVNNodeKind.NONE) { return null; } FSParentPath copyDstParentPath = copyDstRoot.openPath(path, true, true); FSRevisionNode copyDstNode = copyDstParentPath.getRevNode(); if (!copyDstNode.getId().isRelated(parentPath.getRevNode().getId())) { return null; } long createdRev = copyDstNode.getCreatedRevision(); if (createdRev == copyDstEntry.getRevision()) { if (copyDstNode.getPredecessorId() == null) { return null; } } return new FSClosestCopy(copyDstRoot, copyDstEntry.getPath()); }
public void openRevision(Map headers) throws SVNException { myCurrentRevisionBaton = new RevisionBaton(); long revision = -1; if (headers.containsKey(SVNAdminHelper.DUMPFILE_REVISION_NUMBER)) { try { revision = Long.parseLong((String) headers.get(SVNAdminHelper.DUMPFILE_REVISION_NUMBER)); } catch (NumberFormatException nfe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.STREAM_MALFORMED_DATA, "Cannot parse revision ({0}) in dump file", headers.get(SVNAdminHelper.DUMPFILE_REVISION_NUMBER)); SVNErrorManager.error(err, SVNLogType.FSFS); } } myCurrentRevisionBaton.myRevision = revision; long headRevision = myFSFS.getYoungestRevision(); myCurrentRevisionBaton.myRevisionOffset = revision - (headRevision + 1); if (revision > 0) { myCurrentRevisionBaton.myTxn = FSTransactionRoot.beginTransaction(headRevision, 0, myFSFS); myCurrentRevisionBaton.myTxnRoot = myFSFS.createTransactionRoot(myCurrentRevisionBaton.myTxn); String message = "<<< Started new transaction, based on original revision " + revision; if (myProgressHandler != null) { SVNAdminEvent event = new SVNAdminEvent(revision, SVNAdminEventAction.REVISION_LOAD, message); myProgressHandler.handleAdminEvent(event, ISVNEventHandler.UNKNOWN); } } }
if (myResource.getType() == DAVResourceType.WORKING) { FSTransactionInfo txn = myResource.getTxnInfo(); props = fsfs.getTransactionProperties(txn.getTxnId()); } else { long revision = myResource.getRevision(); props = fsfs.getRevisionProperties(revision); props = fsfs.getProperties(root.getRevisionNode(myResource.getResourceURI().getPath()));
protected FSRoot getFSRoot() throws SVNException { FSRepository repository = getSVNLookEnvironment().getRepository(); if (getSVNLookEnvironment().isRevision()) { long rev = getSVNLookEnvironment().getRevision(); if (rev < 0) { rev = repository.getLatestRevision(); } return repository.getFSFS().createRevisionRoot(rev); } return repository.getFSFS().createTransactionRoot(getSVNLookEnvironment().getTransactionInfo()); }
protected SVNProperties getProperties() throws SVNException { FSRoot root = getFSRoot(); if (root instanceof FSTransactionRoot) { return root.getOwner().getTransactionProperties(((FSTransactionRoot) root).getTxnID()); } return root.getOwner().getRevisionProperties(root.getRevision()); }
public void openRoot(long revision) throws SVNException { long youngestRev = myFSFS.getYoungestRevision(); if (isTxnOwner) { myTxn = beginTransactionForCommit(youngestRev); } else { if (myAuthor != null && !"".equals(myAuthor)) { myFSFS.setTransactionProperty(myTxn.getTxnId(), SVNRevisionProperty.AUTHOR, myAuthor); } if (myLogMessage != null && !"".equals(myLogMessage)) { myFSFS.setTransactionProperty(myTxn.getTxnId(), SVNRevisionProperty.LOG, myLogMessage); } } myTxnRoot = myFSFS.createTransactionRoot(myTxn.getTxnId()); myCommitter = new FSCommitter(myFSFS, myTxnRoot, myTxn, myLockTokens, myAuthor); DirBaton dirBaton = new DirBaton(revision, myBasePath, false); myDirsStack.push(dirBaton); }
public File getDBRevsDir() { if (myRevisionsRoot == null) { myRevisionsRoot = new File(getDBRoot(), REVS_DIR); } return myRevisionsRoot; }
private Map computeMetaProperties(long revision) throws SVNException { Map metaProperties = new SVNHashMap(); if (FSRepository.isValidRevision(revision)) { SVNProperties entryProps = myFSFS.compoundMetaProperties(revision); metaProperties.put(SVNProperty.COMMITTED_REVISION, entryProps.getSVNPropertyValue(SVNProperty.COMMITTED_REVISION)); metaProperties.put(SVNProperty.COMMITTED_DATE, entryProps.getSVNPropertyValue(SVNProperty.COMMITTED_DATE)); metaProperties.put(SVNProperty.LAST_AUTHOR, entryProps.getSVNPropertyValue(SVNProperty.LAST_AUTHOR)); metaProperties.put(SVNProperty.UUID, entryProps.getSVNPropertyValue(SVNProperty.UUID)); } else if (!FSRepository.isValidRevision(revision) && isTransactionTarget()) { FSTransactionRoot txnRoot = (FSTransactionRoot) getTargetRoot(); SVNProperties txnProperties = myFSFS.getTransactionProperties(txnRoot.getTxnID()); metaProperties.put(SVNProperty.COMMITTED_REVISION, SVNPropertyValue.create(Long.toString(getTargetRevision()))); metaProperties.put(SVNProperty.COMMITTED_DATE, txnProperties.getSVNPropertyValue(SVNRevisionProperty.DATE)); metaProperties.put(SVNProperty.LAST_AUTHOR, txnProperties.getSVNPropertyValue(SVNRevisionProperty.AUTHOR)); metaProperties.put(SVNProperty.UUID, SVNPropertyValue.create(myFSFS.getUUID())); } else { metaProperties = null; } return metaProperties; }
/** * Returns the size in bytes for the specified path in given transaction * * @param repositoryRoot a repository root directory path * @param path a path to the file inside the repository * @param transactionName a transaction name * @return file size in bytes * @throws SVNException <ul> * <li>no repository is found at * <code>repositoryRoot</code> * </li> * <li>if the specified transaction is not found * </li> * </ul> */ public long doGetFileSize(File repositoryRoot, String path, String transactionName) throws SVNException { if (path == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS, "Missing repository path argument"); SVNErrorManager.error(err, SVNLogType.FSFS); } FSFS fsfs = open(repositoryRoot, transactionName); try { FSTransactionInfo txn = fsfs.openTxn(transactionName); FSRoot root = fsfs.createTransactionRoot(txn); return getFileSize(root, path); } finally { SVNAdminHelper.closeRepository(fsfs); } }
public SVNNodeKind checkPath(String path, long revision) throws SVNException { try { openRepository(); if (!SVNRepository.isValidRevision(revision)) { revision = myFSFS.getYoungestRevision(); } String repositoryPath = getRepositoryPath(path); FSRevisionRoot root = myFSFS.createRevisionRoot(revision); return root.checkNodeKind(repositoryPath); } finally { closeRepository(); } }