@Test
public void testDetectRenamesInNonFirstRev() throws Exception {
repo = Configuration.get().find("log-renames");
eh.cwd(repo.getWorkingDir());
final HgStatusCommand cmd = new HgStatusCommand(repo).defaults();
StatusCollector sc;
for (int r : new int[] {2,3,4}) {
statusParser.reset();
eh.run("hg", "status", "-C", "--change", String.valueOf(r));
cmd.change(r).execute(sc = new StatusCollector());
sr.report("hg status -C --change " + r, sc);
}
// a and d from r5 are missing in r3
statusParser.reset();
eh.run("hg", "status", "-C", "--rev", "3", "--rev", "5");
cmd.base(3).revision(5).execute(sc = new StatusCollector());
sr.report("hg status -C 3..5 ", sc);
//
// a is c which is initially b
// d is b which is initially a
Path fa = Path.create("a");
Path fb = Path.create("b");
Path fc = Path.create("c");
Path fd = Path.create("d");
// neither initial a nor b have isCopy(() == true
assertFalse("[sanity]", repo.getFileNode(fa).isCopy());
// check HgStatusCollector
// originals (base revision) doesn't contain first copy origin (there's no b in r2)
cmd.base(2).revision(5).execute(sc = new StatusCollector());
errorCollector.assertEquals(fa, sc.new2oldName.get(fd));
errorCollector.assertEquals(Collections.singletonList(Removed), sc.get(fc));
// ensure same result with HgWorkingCopyStatusCollector
cmd.base(2).revision(WORKING_COPY).execute(sc = new StatusCollector());
errorCollector.assertEquals(fa, sc.new2oldName.get(fd));
errorCollector.assertEquals(Collections.singletonList(Removed), sc.get(fc));
// originals (base revision) does contain first copy origin (b is in r1)
cmd.base(1).revision(5).execute(sc = new StatusCollector());
errorCollector.assertEquals(fa, sc.new2oldName.get(fd));
errorCollector.assertEquals(Collections.singletonList(Removed), sc.get(fb));
}