Browse Source

MergeCommandTest: Open TestRepository in try-with-resource

Change-Id: If620f6a98c5e8436a3edb4ee365ec02f41d0ea6a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.4
David Pursehouse 6 years ago
parent
commit
babdae6412
  1. 57
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java

57
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java

@ -1557,32 +1557,37 @@ public class MergeCommandTest extends RepositoryTestCase {
@Test @Test
public void testRecursiveMergeWithConflict() throws Exception { public void testRecursiveMergeWithConflict() throws Exception {
TestRepository<Repository> db_t = new TestRepository<>(db); try (TestRepository<Repository> db_t = new TestRepository<>(db)) {
BranchBuilder master = db_t.branch("master"); BranchBuilder master = db_t.branch("master");
RevCommit m0 = master.commit().add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9\n") RevCommit m0 = master.commit()
.message("m0").create(); .add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9\n").message("m0")
RevCommit m1 = master.commit() .create();
.add("f", "1-master\n2\n3\n4\n5\n6\n7\n8\n9\n").message("m1") RevCommit m1 = master.commit()
.create(); .add("f", "1-master\n2\n3\n4\n5\n6\n7\n8\n9\n")
db_t.getRevWalk().parseCommit(m1); .message("m1").create();
db_t.getRevWalk().parseCommit(m1);
BranchBuilder side = db_t.branch("side");
RevCommit s1 = side.commit().parent(m0) BranchBuilder side = db_t.branch("side");
.add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9-side\n").message("s1") RevCommit s1 = side.commit().parent(m0)
.create(); .add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9-side\n").message("s1")
RevCommit s2 = side.commit().parent(m1) .create();
.add("f", "1-master\n2\n3\n4\n5\n6\n7-res(side)\n8\n9-side\n") RevCommit s2 = side.commit().parent(m1)
.message("s2(merge)").create(); .add("f",
master.commit().parent(s1) "1-master\n2\n3\n4\n5\n6\n7-res(side)\n8\n9-side\n")
.add("f", "1-master\n2\n3\n4\n5\n6\n7-conflict\n8\n9-side\n") .message("s2(merge)").create();
.message("m2(merge)").create(); master.commit().parent(s1)
.add("f",
Git git = Git.wrap(db); "1-master\n2\n3\n4\n5\n6\n7-conflict\n8\n9-side\n")
git.checkout().setName("master").call(); .message("m2(merge)").create();
MergeResult result = git.merge().setStrategy(MergeStrategy.RECURSIVE) Git git = Git.wrap(db);
.include("side", s2).call(); git.checkout().setName("master").call();
assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus());
MergeResult result = git.merge()
.setStrategy(MergeStrategy.RECURSIVE).include("side", s2)
.call();
assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus());
}
} }
private Ref prepareSuccessfulMerge(Git git) throws Exception { private Ref prepareSuccessfulMerge(Git git) throws Exception {

Loading…
Cancel
Save