// copy, not clone as latter updates phase information
File srcRepoLoc = RepoUtils.copyRepoToTempLocation("test-phases", "test-pull-pub-src");
File dstRepoLoc = RepoUtils.copyRepoToTempLocation("test-phases", "test-pull-pub-dst");
File f1 = new File(dstRepoLoc, "hello.c");
assertTrue("[sanity]", f1.canWrite());
final HgLookup hgLookup = new HgLookup();
HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(dstRepo));
//
// new child revision for shared public parent
assertEquals(HgPhase.Public, phaseHelper.getPhase(4, null));
new HgCheckoutCommand(dstRepo).changeset(4).clean(true).execute();
RepoUtils.modifyFileAppend(f1, "// aaa");
HgCommitCommand commitCmd = new HgCommitCommand(dstRepo).message("Commit 1");
assertTrue(commitCmd.execute().isOk());
final Nodeid cmt1 = commitCmd.getCommittedRevision();
//
// new child rev for parent locally draft, remotely public
assertEquals(HgPhase.Draft, phaseHelper.getPhase(5, null));
assertEquals(HgPhase.Draft, phaseHelper.getPhase(7, null));
assertEquals(HgPhase.Draft, phaseHelper.getPhase(8, null));
new HgCheckoutCommand(dstRepo).changeset(8).clean(true).execute();
RepoUtils.modifyFileAppend(f1, "// bbb");
commitCmd = new HgCommitCommand(dstRepo).message("Commit 2");
assertTrue(commitCmd.execute().isOk());
final Nodeid cmt2 = commitCmd.getCommittedRevision();
// both new revisions shall be draft
phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(dstRepo)); // refresh PhasesHelper
assertEquals(HgPhase.Draft, phaseHelper.getPhase(dstRepo.getChangelog().getRevisionIndex(cmt1), cmt1));
assertEquals(HgPhase.Draft, phaseHelper.getPhase(dstRepo.getChangelog().getRevisionIndex(cmt2), cmt2));
//
HgServer server = new HgServer().publishing(true).start(srcRepoLoc);
try {
final HgRemoteRepository srcRemote = hgLookup.detect(server.getURL());
new HgPullCommand(dstRepo).source(srcRemote).execute();
} finally {
server.stop();
}
// refresh PhasesHelper