예제 #1
0
  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,
        SVNRepository.INVALID_REVISION,
        null,
        kind);
  }
예제 #2
0
 public void incrementMergeInfoUpTree(FSParentPath parentPath, long increment)
     throws SVNException {
   while (parentPath != null) {
     FSTransactionRoot txnRoot = getTxnRoot();
     txnRoot.incrementMergeInfoCount(parentPath.getRevNode(), increment);
     parentPath = parentPath.getParent();
   }
 }
예제 #3
0
  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) {
      FSCommitter.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,
        SVNRepository.INVALID_REVISION,
        null,
        SVNNodeKind.DIR);
  }
예제 #4
0
  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();

    if ((txnRoot.getTxnFlags() & FSTransactionRoot.SVN_FS_TXN_CHECK_LOCKS) != 0) {
      FSCommitter.allowLockedOperation(myFSFS, path, myAuthor, myLockTokens, false, false);
    }

    makePathMutable(parentPath, path);
    SVNProperties properties = parentPath.getRevNode().getProperties(myFSFS);

    if (properties.isEmpty() && propValue == null) {
      return;
    }

    if (myFSFS.supportsMergeInfo() && name.equals(SVNProperty.MERGE_INFO)) {
      long increment = 0;
      boolean hadMergeInfo = parentPath.getRevNode().hasMergeInfo();
      if (propValue != null && !hadMergeInfo) {
        increment = 1;
      } else if (propValue == null && hadMergeInfo) {
        increment = -1;
      }
      if (increment != 0) {
        parentPath.getRevNode().setHasMergeInfo(propValue != null);
        incrementMergeInfoUpTree(parentPath, increment);
      }
    }

    if (propValue == null) {
      properties.remove(name);
    } else {
      properties.put(name, propValue);
    }

    txnRoot.setProplist(parentPath.getRevNode(), properties);
    addChange(
        path,
        parentPath.getRevNode().getId(),
        FSPathChangeKind.FS_PATH_CHANGE_MODIFY,
        false,
        true,
        SVNRepository.INVALID_REVISION,
        null,
        kind);
  }
예제 #5
0
  public void makePathMutable(FSParentPath parentPath, String errorPath) throws SVNException {
    FSTransactionRoot txnRoot = getTxnRoot();
    String txnId = txnRoot.getTxnID();

    if (parentPath.getRevNode().getId().isTxn()) {
      return;
    }
    FSRevisionNode clone = null;

    if (parentPath.getParent() != null) {
      makePathMutable(parentPath.getParent(), errorPath);
      FSID parentId = null;
      String copyId = null;

      switch (parentPath.getCopyStyle()) {
        case FSCopyInheritance.COPY_ID_INHERIT_PARENT:
          parentId = parentPath.getParent().getRevNode().getId();
          copyId = parentId.getCopyID();
          break;
        case FSCopyInheritance.COPY_ID_INHERIT_NEW:
          copyId = reserveCopyId(txnId);
          break;
        case FSCopyInheritance.COPY_ID_INHERIT_SELF:
          copyId = null;
          break;
        case FSCopyInheritance.COPY_ID_INHERIT_UNKNOWN:
        default:
          SVNErrorMessage err =
              SVNErrorMessage.create(
                  SVNErrorCode.UNKNOWN,
                  "FATAL error: can not make path ''{0}'' mutable",
                  errorPath);
          SVNErrorManager.error(err, SVNLogType.FSFS);
      }

      String copyRootPath = parentPath.getRevNode().getCopyRootPath();
      long copyRootRevision = parentPath.getRevNode().getCopyRootRevision();

      FSRoot copyrootRoot = myFSFS.createRevisionRoot(copyRootRevision);
      FSRevisionNode copyRootNode = copyrootRoot.getRevisionNode(copyRootPath);
      FSID childId = parentPath.getRevNode().getId();
      FSID copyRootId = copyRootNode.getId();
      boolean isParentCopyRoot = false;
      if (!childId.getNodeID().equals(copyRootId.getNodeID())) {
        isParentCopyRoot = true;
      }

      String clonePath = parentPath.getParent().getAbsPath();
      clone =
          txnRoot.cloneChild(
              parentPath.getParent().getRevNode(),
              clonePath,
              parentPath.getEntryName(),
              copyId,
              isParentCopyRoot);

      txnRoot.putRevNodeToCache(parentPath.getAbsPath(), clone);
    } else {
      FSTransactionInfo txn = txnRoot.getTxn();

      if (txn.getRootID().equals(txn.getBaseID())) {
        SVNErrorMessage err =
            SVNErrorMessage.create(
                SVNErrorCode.UNKNOWN,
                "FATAL error: txn ''{0}'' root id ''{1}'' matches base id ''{2}''",
                new Object[] {txnId, txn.getRootID(), txn.getBaseID()});
        SVNErrorManager.error(err, SVNLogType.FSFS);
      }
      clone = myFSFS.getRevisionNode(txn.getRootID());
    }

    parentPath.setRevNode(clone);
  }
예제 #6
0
  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());
  }