aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java305
1 files changed, 149 insertions, 156 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
index 36805d3241..798aebe3b0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
@@ -109,33 +109,33 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
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(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- b.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
-
- o.add(createEntry("Makefile", FileMode.REGULAR_FILE));
- o.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- o.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
-
- t.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- t.add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
+
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("Makefile", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ tTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ tTreeBuilder
+ .add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -163,32 +163,31 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
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(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- o.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -212,32 +211,31 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_conflictSubtreeChange() 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(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
-
- t.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -246,31 +244,30 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_leftDFconflict1() 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();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+ oTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -279,31 +276,30 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_rightDFconflict1() 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();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
- t.add(createEntry("d", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -312,29 +308,28 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_leftDFconflict2() 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();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d", FileMode.REGULAR_FILE, "o !"));
+ bTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE, "o !"));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -343,29 +338,28 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_rightDFconflict2() 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();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- t.add(createEntry("d", FileMode.REGULAR_FILE, "t !"));
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -377,10 +371,9 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
.getObjectId(0));
}
- private static ObjectId commit(final ObjectInserter odi,
- final DirCache treeB,
- final ObjectId[] parentIds) throws Exception {
- final CommitBuilder c = new CommitBuilder();
+ private static ObjectId commit(ObjectInserter odi, DirCache treeB,
+ ObjectId[] parentIds) throws Exception {
+ CommitBuilder c = new CommitBuilder();
c.setTreeId(treeB.writeTree(odi));
c.setAuthor(new PersonIdent("A U Thor", "a.u.thor", 1L, 0));
c.setCommitter(c.getAuthor());