Пример #1
0
 /**
  * Recursively add an entire tree into this builder.
  * <p>
  * If pathPrefix is "a/b" and the tree contains file "c" then the resulting
  * DirCacheEntry will have the path "a/b/c".
  * <p>
  * All entries are inserted at stage 0, therefore assuming that the
  * application will not insert any other paths with the same pathPrefix.
  *
  * @param pathPrefix
  *            UTF-8 encoded prefix to mount the tree's entries at. If the
  *            path does not end with '/' one will be automatically inserted
  *            as necessary.
  * @param stage
  *            stage of the entries when adding them.
  * @param db
  *            repository the tree(s) will be read from during recursive
  *            traversal. This must be the same repository that the resulting
  *            DirCache would be written out to (or used in) otherwise the
  *            caller is simply asking for deferred MissingObjectExceptions.
  * @param tree
  *            the tree to recursively add. This tree's contents will appear
  *            under <code>pathPrefix</code>. The ObjectId must be that of a
  *            tree; the caller is responsible for dereferencing a tag or
  *            commit (if necessary).
  * @throws IOException
  *             a tree cannot be read to iterate through its entries.
  */
 public void addTree(byte[] pathPrefix, int stage, Repository db, AnyObjectId tree)
 {
     var tw = new TreeWalk.TreeWalk(db);
     tw.reset();
     var curs = new WindowCursor();
     try
     {
         tw.addTree(new CanonicalTreeParser(pathPrefix, db, tree.ToObjectId(), curs));
     }
     finally
     {
         curs.release();
     }
     tw.setRecursive(true);
     if (tw.next())
     {
         DirCacheEntry newEntry = toEntry(stage, tw);
         beforeAdd(newEntry);
         fastAdd(newEntry);
         while (tw.next())
             fastAdd(toEntry(stage, tw));
     }
 }
Пример #2
0
 public RewriteTreeFilter(RevWalk walker, TreeFilter t)
 {
     pathFilter = new TreeWalk.TreeWalk(walker.db);
     pathFilter.setFilter(t);
     pathFilter.setRecursive(t.shouldBeRecursive());
 }