예제 #1
0
 public void testInitialize_TogglePostOrder() throws Exception {
   final TreeWalk tw = new TreeWalk(db);
   assertFalse(tw.isPostOrderTraversal());
   tw.setPostOrderTraversal(true);
   assertTrue(tw.isPostOrderTraversal());
   tw.setPostOrderTraversal(false);
   assertFalse(tw.isPostOrderTraversal());
 }
예제 #2
0
  public void testResetDoesNotAffectPostOrder() throws Exception {
    final TreeWalk tw = new TreeWalk(db);
    tw.setPostOrderTraversal(true);
    assertTrue(tw.isPostOrderTraversal());
    tw.reset();
    assertTrue(tw.isPostOrderTraversal());

    tw.setPostOrderTraversal(false);
    assertFalse(tw.isPostOrderTraversal());
    tw.reset();
    assertFalse(tw.isPostOrderTraversal());
  }
예제 #3
0
  public void testNoPostOrder() throws Exception {
    final DirCache tree = db.readDirCache();
    {
      final DirCacheBuilder b = tree.builder();

      b.add(makeFile("a"));
      b.add(makeFile("b/c"));
      b.add(makeFile("b/d"));
      b.add(makeFile("q"));

      b.finish();
      assertEquals(4, tree.getEntryCount());
    }

    final TreeWalk tw = new TreeWalk(db);
    tw.reset();
    tw.setPostOrderTraversal(false);
    tw.addTree(new DirCacheIterator(tree));

    assertModes("a", REGULAR_FILE, tw);
    assertModes("b", TREE, tw);
    assertTrue(tw.isSubtree());
    assertFalse(tw.isPostChildren());
    tw.enterSubtree();
    assertModes("b/c", REGULAR_FILE, tw);
    assertModes("b/d", REGULAR_FILE, tw);
    assertModes("q", REGULAR_FILE, tw);
  }
예제 #4
0
 public List<String> readElementsAt(Repository repository, String commit) throws IOException {
   RevWalk revWalk = new RevWalk(repository);
   RevCommit revCommit = revWalk.parseCommit(ObjectId.fromString(commit));
   RevTree tree = revCommit.getTree();
   List<String> items = new ArrayList<>();
   TreeWalk treeWalk = new TreeWalk(repository);
   treeWalk.addTree(tree);
   treeWalk.setRecursive(true);
   treeWalk.setPostOrderTraversal(true);
   while (treeWalk.next()) {
     items.add(treeWalk.getPathString());
   }
   return items;
 }