Examples of HgRepository


Examples of org.tmatesoft.hg.repo.HgRepository

    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
    phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(dstRepo));
    errorCollector.assertEquals(HgPhase.Public, phaseHelper.getPhase(5, null));
    errorCollector.assertEquals(HgPhase.Public, phaseHelper.getPhase(7, null));
    errorCollector.assertEquals(HgPhase.Public, phaseHelper.getPhase(8, null));
    // phase of local-only new revisions shall not change
    errorCollector.assertEquals(HgPhase.Draft, phaseHelper.getPhase(dstRepo.getChangelog().getRevisionIndex(cmt1), cmt1));
    errorCollector.assertEquals(HgPhase.Draft, phaseHelper.getPhase(dstRepo.getChangelog().getRevisionIndex(cmt2), cmt2));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.