File repoLoc1 = RepoUtils.copyRepoToTempLocation("merge-1", "test-merge-no-conflicts");
File repoLoc2 = RepoUtils.copyRepoToTempLocation("merge-1", "test-merge-with-conflicts");
HgRepository repo = new HgLookup().detect(repoLoc1);
Assert.assertEquals("[sanity]", repo.getChangelog().getRevisionIndex(repo.getWorkingCopyParents().first()), 1);
HgMergeCommand cmd = new HgMergeCommand(repo);
cmd.changeset(2).execute(new HgMergeCommand.MediatorBase() {
public void resolve(HgFileRevision base, HgFileRevision first, HgFileRevision second, Resolver resolver) throws HgCallbackTargetException {
errorCollector.fail("There's no conflict in changesets 1 and 2 merge");
}
});
RepoUtils.assertHgVerifyOk(errorCollector, repoLoc1);
TestStatus.StatusCollector status = new TestStatus.StatusCollector();
new HgStatusCommand(repo).all().execute(status);
final List<Path> clean = status.get(Kind.Clean);
final List<Path> modified = status.get(Kind.Modified);
Collections.sort(clean);
Collections.sort(modified);
errorCollector.assertEquals(new Path[] {create("file1"), create("file3"), create("file4")}, clean.toArray());
errorCollector.assertEquals(new Path[] {create("file2"), create("file5")}, modified.toArray());
repo = new HgLookup().detect(repoLoc2);
cmd = new HgMergeCommand(repo);
cmd.changeset(3).execute(new HgMergeCommand.MediatorBase());
RepoUtils.assertHgVerifyOk(errorCollector, repoLoc2);
new HgStatusCommand(repo).all().execute(status = new TestStatus.StatusCollector());
errorCollector.assertEquals(1, status.get(Kind.Modified).size());
errorCollector.assertEquals(create("file1"), status.get(Kind.Modified).get(0));
final HgMergeState ms = repo.getMergeState();