Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheBuilder


  public void testDF_GapByOne() throws Exception {
    final DirCache tree0 = db.readDirCache();
    final DirCache tree1 = db.readDirCache();
    {
      final DirCacheBuilder b0 = tree0.builder();
      final DirCacheBuilder b1 = tree1.builder();

      b0.add(makeEntry("a", REGULAR_FILE));
      b0.add(makeEntry("a.b", EXECUTABLE_FILE));
      b1.add(makeEntry("a.b", EXECUTABLE_FILE));
      b1.add(makeEntry("a/b", REGULAR_FILE));
      b0.add(makeEntry("a0b", SYMLINK));

      b0.finish();
      b1.finish();
      assertEquals(3, tree0.getEntryCount());
      assertEquals(2, tree1.getEntryCount());
    }

    final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
View Full Code Here


  public void testDF_SkipsSeenSubtree() throws Exception {
    final DirCache tree0 = db.readDirCache();
    final DirCache tree1 = db.readDirCache();
    {
      final DirCacheBuilder b0 = tree0.builder();
      final DirCacheBuilder b1 = tree1.builder();

      b0.add(makeEntry("a", REGULAR_FILE));
      b1.add(makeEntry("a.b", EXECUTABLE_FILE));
      b1.add(makeEntry("a/b", REGULAR_FILE));
      b0.add(makeEntry("a0b", SYMLINK));
      b1.add(makeEntry("a0b", SYMLINK));

      b0.finish();
      b1.finish();
      assertEquals(2, tree0.getEntryCount());
      assertEquals(3, tree1.getEntryCount());
    }

    final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
View Full Code Here

  public void testDF_DetectConflict() throws Exception {
    final DirCache tree0 = db.readDirCache();
    final DirCache tree1 = db.readDirCache();
    {
      final DirCacheBuilder b0 = tree0.builder();
      final DirCacheBuilder b1 = tree1.builder();

      b0.add(makeEntry("0", REGULAR_FILE));
      b0.add(makeEntry("a", REGULAR_FILE));
      b1.add(makeEntry("0", REGULAR_FILE));
      b1.add(makeEntry("a.b", REGULAR_FILE));
      b1.add(makeEntry("a/b", REGULAR_FILE));
      b1.add(makeEntry("a/c/e", REGULAR_FILE));

      b0.finish();
      b1.finish();
      assertEquals(2, tree0.getEntryCount());
      assertEquals(4, tree1.getEntryCount());
    }

    final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
View Full Code Here

  public void testNonRecursiveFiltering() throws IOException {
    final ObjectInserter odi = db.newObjectInserter();
    final ObjectId aSth = odi.insert(OBJ_BLOB, "a.sth".getBytes());
    final ObjectId aTxt = odi.insert(OBJ_BLOB, "a.txt".getBytes());
    final DirCache dc = db.readDirCache();
    final DirCacheBuilder builder = dc.builder();
    final DirCacheEntry aSthEntry = new DirCacheEntry("a.sth");
    aSthEntry.setFileMode(FileMode.REGULAR_FILE);
    aSthEntry.setObjectId(aSth);
    final DirCacheEntry aTxtEntry = new DirCacheEntry("a.txt");
    aTxtEntry.setFileMode(FileMode.REGULAR_FILE);
    aTxtEntry.setObjectId(aTxt);
    builder.add(aSthEntry);
    builder.add(aTxtEntry);
    builder.finish();
    final ObjectId treeId = dc.writeTree(odi);
    odi.flush();


    final TreeWalk tw = new TreeWalk(db);
View Full Code Here

    final ObjectId aSth = odi.insert(OBJ_BLOB, "a.sth".getBytes());
    final ObjectId aTxt = odi.insert(OBJ_BLOB, "a.txt".getBytes());
    final ObjectId bSth = odi.insert(OBJ_BLOB, "b.sth".getBytes());
    final ObjectId bTxt = odi.insert(OBJ_BLOB, "b.txt".getBytes());
    final DirCache dc = db.readDirCache();
    final DirCacheBuilder builder = dc.builder();
    final DirCacheEntry aSthEntry = new DirCacheEntry("a.sth");
    aSthEntry.setFileMode(FileMode.REGULAR_FILE);
    aSthEntry.setObjectId(aSth);
    final DirCacheEntry aTxtEntry = new DirCacheEntry("a.txt");
    aTxtEntry.setFileMode(FileMode.REGULAR_FILE);
    aTxtEntry.setObjectId(aTxt);
    builder.add(aSthEntry);
    builder.add(aTxtEntry);
    final DirCacheEntry bSthEntry = new DirCacheEntry("sub/b.sth");
    bSthEntry.setFileMode(FileMode.REGULAR_FILE);
    bSthEntry.setObjectId(bSth);
    final DirCacheEntry bTxtEntry = new DirCacheEntry("sub/b.txt");
    bTxtEntry.setFileMode(FileMode.REGULAR_FILE);
    bTxtEntry.setObjectId(bTxt);
    builder.add(bSthEntry);
    builder.add(bTxtEntry);
    builder.finish();
    final ObjectId treeId = dc.writeTree(odi);
    odi.flush();


    final TreeWalk tw = new TreeWalk(db);
View Full Code Here

    }

    CommitBuilder(CommitBuilder prior) throws Exception {
      branch = prior.branch;

      DirCacheBuilder b = tree.builder();
      for (int i = 0; i < prior.tree.getEntryCount(); i++)
        b.add(prior.tree.getEntry(i));
      b.finish();

      parents.add(prior.create());
    }
View Full Code Here

      parents.add(prior.create());
    }

    public CommitBuilder parent(RevCommit p) throws Exception {
      if (parents.isEmpty()) {
        DirCacheBuilder b = tree.builder();
        parseBody(p);
        b.addTree(new byte[0], DirCacheEntry.STAGE_0, pool
            .getObjectReader(), p.getTree());
        b.finish();
      }
      parents.add(p);
      return this;
    }
View Full Code Here

        indexState(SMUDGE|MOD_TIME|LENGTH));
  }

  private void addToIndex(TreeSet<Long> modTimes)
      throws FileNotFoundException, IOException {
    DirCacheBuilder builder = db.lockDirCache().builder();
    FileTreeIterator fIt = new FileTreeIteratorWithTimeControl(
        db, modTimes);
    DirCacheEntry dce;
    while (!fIt.eof()) {
      dce = new DirCacheEntry(fIt.getEntryPathString());
      dce.setFileMode(fIt.getEntryFileMode());
      dce.setLastModified(fIt.getEntryLastModified());
      dce.setLength((int) fIt.getEntryLength());
      dce.setObjectId(fIt.getEntryObjectId());
      builder.add(dce);
      fIt.next(1);
    }
    builder.commit();
  }
View Full Code Here

  public void testTrivialTwoWay_validSubtreeSort() throws Exception {
    final DirCache treeB = db.readDirCache();
    final DirCache treeO = db.readDirCache();
    final DirCache treeT = db.readDirCache();
    {
      final DirCacheBuilder b = treeB.builder();
      final DirCacheBuilder o = treeO.builder();
      final DirCacheBuilder t = treeT.builder();

      b.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
      b.add(makeEntry("libelf/c", FileMode.REGULAR_FILE));

      o.add(makeEntry("Makefile", FileMode.REGULAR_FILE));
      o.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
      o.add(makeEntry("libelf/c", FileMode.REGULAR_FILE));

      t.add(makeEntry("libelf-po/a", FileMode.REGULAR_FILE));
      t.add(makeEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));

      b.finish();
      o.finish();
      t.finish();
    }

    final ObjectInserter ow = db.newObjectInserter();
    final ObjectId b = commit(ow, treeB, new ObjectId[] {});
    final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
View Full Code Here

  public void testTrivialTwoWay_concurrentSubtreeChange() throws Exception {
    final DirCache treeB = db.readDirCache();
    final DirCache treeO = db.readDirCache();
    final DirCache treeT = db.readDirCache();
    {
      final DirCacheBuilder b = treeB.builder();
      final DirCacheBuilder o = treeO.builder();
      final DirCacheBuilder t = treeT.builder();

      b.add(makeEntry("d/o", FileMode.REGULAR_FILE));
      b.add(makeEntry("d/t", FileMode.REGULAR_FILE));

      o.add(makeEntry("d/o", FileMode.REGULAR_FILE, "o !"));
      o.add(makeEntry("d/t", FileMode.REGULAR_FILE));

      t.add(makeEntry("d/o", FileMode.REGULAR_FILE));
      t.add(makeEntry("d/t", FileMode.REGULAR_FILE, "t !"));

      b.finish();
      o.finish();
      t.finish();
    }

    final ObjectInserter ow = db.newObjectInserter();
    final ObjectId b = commit(ow, treeB, new ObjectId[] {});
    final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.dircache.DirCacheBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.