public static boolean areFileContentsChanged(
     FSRoot root1, String path1, FSRoot root2, String path2) throws SVNException {
   if (root1.checkNodeKind(path1) != SVNNodeKind.FILE) {
     SVNErrorMessage err =
         SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "''{0}'' is not a file", path1);
     SVNErrorManager.error(err);
   }
   if (root2.checkNodeKind(path2) != SVNNodeKind.FILE) {
     SVNErrorMessage err =
         SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "''{0}'' is not a file", path2);
     SVNErrorManager.error(err);
   }
   FSRevisionNode revNode1 = root1.getRevisionNode(path1);
   FSRevisionNode revNode2 = root2.getRevisionNode(path2);
   return !areRepresentationsEqual(revNode1, revNode2, false);
 }
  public static void replay(
      FSFS fsfs,
      FSRoot root,
      String basePath,
      long lowRevision,
      boolean sendDeltas,
      ISVNEditor editor)
      throws SVNException {
    Map fsChanges = root.getChangedPaths();
    basePath = basePath.startsWith("/") ? basePath.substring(1) : basePath;
    Collection interestingPaths = new LinkedList();
    Map changedPaths = new HashMap();
    for (Iterator paths = fsChanges.keySet().iterator(); paths.hasNext(); ) {
      String path = (String) paths.next();
      FSPathChange change = (FSPathChange) fsChanges.get(path);

      path = path.startsWith("/") ? path.substring(1) : path;
      if ("".equals(basePath)
          || (path.startsWith(basePath)
              && (path.charAt(basePath.length()) == '/' || path.length() == basePath.length()))) {
        path = path.startsWith("/") ? path.substring(1) : path;
        interestingPaths.add(path);
        changedPaths.put(path, change);
      }
    }
    if (FSRepository.isInvalidRevision(lowRevision)) {
      lowRevision = 0;
    }

    FSRoot compareRoot = null;
    if (sendDeltas && root instanceof FSRevisionRoot) {
      FSRevisionRoot revRoot = (FSRevisionRoot) root;
      compareRoot = fsfs.createRevisionRoot(revRoot.getRevision() - 1);
    }

    if (root instanceof FSRevisionRoot) {
      FSRevisionRoot revRoot = (FSRevisionRoot) root;
      editor.targetRevision(revRoot.getRevision());
    }

    ISVNCommitPathHandler handler =
        new FSReplayPathHandler(fsfs, root, compareRoot, changedPaths, basePath, lowRevision);
    SVNCommitUtil.driveCommitEditor(handler, interestingPaths, editor, -1);
  }
Example #3
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);
  }
 public static boolean arePropertiesChanged(FSRoot root1, String path1, FSRoot root2, String path2)
     throws SVNException {
   FSRevisionNode node1 = root1.getRevisionNode(path1);
   FSRevisionNode node2 = root2.getRevisionNode(path2);
   return !areRepresentationsEqual(node1, node2, true);
 }