Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.RevisionSet


      case Draft : draft.add(n); break;
      case Public : pub.add(n); break;
      default : throw new IllegalStateException();
      }
    }
    final RevisionSet rsSecret = new RevisionSet(secret);
    final RevisionSet rsDraft = new RevisionSet(draft);
    assertFalse("[sanity]", rsSecret.isEmpty());
    assertFalse("[sanity]", rsDraft.isEmpty());
    HgParentChildMap<HgChangelog> pw = new HgParentChildMap<HgChangelog>(repo.getChangelog());
    pw.init();
    PhasesHelper ph1 = new PhasesHelper(implRepo, null);
    PhasesHelper ph2 = new PhasesHelper(implRepo, pw);
    RevisionSet s1 = ph1.allSecret().symmetricDifference(rsSecret);
    RevisionSet s2 = ph2.allSecret().symmetricDifference(rsSecret);
    errorCollector.assertTrue("Secret,no ParentChildMap:" + s1.toString(), s1.isEmpty());
    errorCollector.assertTrue("Secret, with ParentChildMap:" + s2.toString(), s2.isEmpty());
    RevisionSet s3 = ph1.allDraft().symmetricDifference(rsDraft);
    RevisionSet s4 = ph2.allDraft().symmetricDifference(rsDraft);
    errorCollector.assertTrue("Draft,no ParentChildMap:" + s3.toString(), s3.isEmpty());
    errorCollector.assertTrue("Draft, with ParentChildMap:" + s4.toString(), s4.isEmpty());
  }
View Full Code Here


    final RepositoryComparator c = getComparator(new ProgressSupport.Sub(ps, 5), cs);
    List<Nodeid> local = c.getLocalOnlyRevisions();
    ps.worked(3);
    PhasesHelper phaseHelper = new PhasesHelper(Internals.getInstance(localRepo));
    if (phaseHelper.isCapableOfPhases() && phaseHelper.withSecretRoots()) {
      local = new RevisionSet(local).subtract(phaseHelper.allSecret()).asList();
    }
    ps.worked(2);
    return local;
  }
View Full Code Here

    PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(dstRepo));
    errorCollector.assertEquals(HgPhase.Public, phaseHelper.getPhase(4, null));
    errorCollector.assertEquals(HgPhase.Draft, phaseHelper.getPhase(5, null));
    errorCollector.assertEquals(HgPhase.Draft, phaseHelper.getPhase(dstRepo.getChangelog().getRevisionIndex(r7), r7));
    errorCollector.assertEquals(HgPhase.Draft, phaseHelper.getPhase(dstRepo.getChangelog().getRevisionIndex(r8), r8));
    final RevisionSet dstSecret = phaseHelper.allSecret();
    errorCollector.assertTrue(dstSecret.toString(), dstSecret.isEmpty());
  }
View Full Code Here

      }
      // get remote phases, update local phases to match that of remote
      // do not update any remote phase (it's pull, after all)
      final PhasesHelper phaseHelper = new PhasesHelper(implRepo, parentHelper);
      if (phaseHelper.isCapableOfPhases()) {
        RevisionSet rsCommon = new RevisionSet(common);
        HgRemoteRepository.Phases remotePhases = remote.getPhases();
        phaseHelper.synchronizeWithRemote(remotePhases, rsCommon.union(added));
      }
      progress.worked(5);
      incoming.unlink(); // keep the file only in case of failure
    } catch (HgRuntimeException ex) {
      throw new HgLibraryFailureException(ex);
View Full Code Here

    try {
      final HgLookup hgLookup = new HgLookup();
      final HgRepository srcRepo = hgLookup.detect(srcRepoLoc);
      final HgRemoteRepository dstRemote = hgLookup.detect(server.getURL());
      PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
      final RevisionSet allDraft = phaseHelper.allDraft();
      assertFalse("[sanity]", allDraft.isEmpty());
      final int publicCsetToBranchAt = 4;
      assertEquals("[sanity]", HgPhase.Public, phaseHelper.getPhase(publicCsetToBranchAt, null));
      // in addition to existing draft csets, add one more draft, branching at some other public revision
      new HgCheckoutCommand(srcRepo).changeset(publicCsetToBranchAt).clean(true).execute();
      RepoUtils.modifyFileAppend(f1, "// aaa");
View Full Code Here

    try {
      final HgLookup hgLookup = new HgLookup();
      final HgRepository srcRepo = hgLookup.detect(srcRepoLoc);
      final HgRemoteRepository dstRemote = hgLookup.detect(server.getURL());
      PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
      final RevisionSet allDraft = phaseHelper.allDraft();
      assertFalse("[sanity]", allDraft.isEmpty());
      // push all changes
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      final HgChangelog srcClog = srcRepo.getChangelog();
      final HgChangelog dstClog = dstRepo.getChangelog();
View Full Code Here

    try {
      final HgLookup hgLookup = new HgLookup();
      final HgRepository srcRepo = hgLookup.detect(srcRepoLoc);
      final HgRemoteRepository dstRemote = hgLookup.detect(server.getURL());
      PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
      final RevisionSet allSecret = phaseHelper.allSecret();
      assertFalse("[sanity]", allSecret.isEmpty());
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      final HgChangelog srcClog = srcRepo.getChangelog();
      final HgChangelog dstClog = dstRepo.getChangelog();
      errorCollector.assertEquals(srcClog.getRevisionCount() - allSecret.size(), dstClog.getRevisionCount());
      for (Nodeid n : allSecret) {   
        errorCollector.assertTrue(n.toString(), !dstClog.isKnown(n));
      }
    } finally {
      server.stop();
View Full Code Here

      final PhasesHelper phaseHelper = new PhasesHelper(implRepo, parentHelper);
      final RepositoryComparator comparator = new RepositoryComparator(parentHelper, remoteRepo);
      comparator.compare(new ProgressSupport.Sub(progress, 50), getCancelSupport(null, true));
      List<Nodeid> l = comparator.getLocalOnlyRevisions();
      if (phaseHelper.isCapableOfPhases() && phaseHelper.withSecretRoots()) {
        RevisionSet secret = phaseHelper.allSecret();
        outgoing = new RevisionSet(l).subtract(secret);
      } else {
        outgoing = new RevisionSet(l);
      }
      HgBundle b = null;
      if (!outgoing.isEmpty()) {
        //
        // prepare bundle
        BundleGenerator bg = new BundleGenerator(implRepo);
        File bundleFile = bg.create(outgoing.asList());
        progress.worked(20);
        b = new HgLookup(repo.getSessionContext()).loadBundle(bundleFile);
        //
        // send changes
        remoteRepo.unbundle(b, comparator.getRemoteHeads());
      } // update phase information nevertheless
      progress.worked(20);
      //
      // update phase information
      if (phaseHelper.isCapableOfPhases()) {
        HgRemoteRepository.Phases remotePhases = remoteRepo.getPhases();
        RevisionSet remoteDraftsLocalPublic = phaseHelper.synchronizeWithRemote(remotePhases, outgoing);
        if (!remoteDraftsLocalPublic.isEmpty()) {
          // foreach remoteDraftsLocallyPublic.heads() do push Draft->Public
          for (Nodeid n : remoteDraftsLocalPublic.heads(parentHelper)) {
            try {
              Outcome upo = remoteRepo.updatePhase(HgPhase.Draft, HgPhase.Public, n);
              if (!upo.isOk()) {
                implRepo.getLog().dump(getClass(), Severity.Info, "Failed to update remote phase, reason: %s", upo.getMessage());
              }
View Full Code Here

    Nodeid n1 = Nodeid.fromAscii("c75297c1786734589175c673db40e8ecaa032b09");
    Nodeid n2 = Nodeid.fromAscii("3b7d51ed4c65082f9235e3459e282d7ff723aa97");
    Nodeid n3 = Nodeid.fromAscii("14dac192aa262feb8ff6645a102648498483a188");
    Nodeid n4 = Nodeid.fromAscii("1deea2f332183c947937f6df988c2c6417efc217");
    Nodeid[] nodes = { n1, n2, n3 };
    RevisionSet a = new RevisionSet(nodes);
    Nodeid[] nodes1 = { n3, n4 };
    RevisionSet b = new RevisionSet(nodes1);
    Nodeid[] nodes2 = { n1, n2, n3, n4 };
    RevisionSet union_ab = new RevisionSet(nodes2);
    Nodeid[] nodes3 = { n3 };
    RevisionSet intersect_ab = new RevisionSet(nodes3);
    Nodeid[] nodes4 = { n1, n2 };
    RevisionSet subtract_ab = new RevisionSet(nodes4);
    Nodeid[] nodes5 = { n4 };
    RevisionSet subtract_ba = new RevisionSet(nodes5);
    Nodeid[] nodes6 = { n1, n2, n4 };
    RevisionSet symDiff_ab = new RevisionSet(nodes6);
   
    errorCollector.assertEquals(union_ab, a.union(b));
    errorCollector.assertEquals(union_ab, b.union(a));
    errorCollector.assertEquals(intersect_ab, a.intersect(b));
    errorCollector.assertEquals(intersect_ab, b.intersect(a));
    errorCollector.assertEquals(subtract_ab, a.subtract(b));
    errorCollector.assertEquals(subtract_ba, b.subtract(a));
    errorCollector.assertEquals(symDiff_ab, a.symmetricDifference(b));
    errorCollector.assertEquals(symDiff_ab, b.symmetricDifference(a));
    Nodeid[] nodes7 = { n1, n2, n4 };
    Nodeid[] nodes8 = { n4, n1, n2 };
    errorCollector.assertTrue(new RevisionSet(nodes7).equals(new RevisionSet(nodes8)));
    Nodeid[] nodes9 = {};
    Nodeid[] nodes10 = {};
    errorCollector.assertTrue(new RevisionSet(nodes9).equals(new RevisionSet(nodes10)));
    Nodeid[] nodes11 = { n1 };
    Nodeid[] nodes12 = { n2 };
    errorCollector.assertFalse(new RevisionSet(nodes11).equals(new RevisionSet(nodes12)));
  }
View Full Code Here

  public void testRootsAndHeads() throws Exception {
    final HgRepository repo = Configuration.get().find("test-annotate");
    Nodeid[] allRevs = RepoUtils.allRevisions(repo);
    HgParentChildMap<HgChangelog> parentHelper = new HgParentChildMap<HgChangelog>(repo.getChangelog());
    parentHelper.init();
    final RevisionSet complete = new RevisionSet(allRevs);
    Nodeid[] nodes = { allRevs[0] };
    // roots
    errorCollector.assertEquals(new RevisionSet(nodes), complete.roots(parentHelper));
    Nodeid[] nodes1 = { allRevs[0], allRevs[1] };
    RevisionSet fromR2 = complete.subtract(new RevisionSet(nodes1));
    Nodeid[] nodes2 = { allRevs[0], allRevs[1], allRevs[2] };
    RevisionSet fromR3 = complete.subtract(new RevisionSet(nodes2));
    Nodeid[] nodes3 = { allRevs[2], allRevs[3] };
    errorCollector.assertEquals(new RevisionSet(nodes3), fromR2.roots(parentHelper));
    Nodeid[] nodes4 = { allRevs[3], allRevs[4], allRevs[5] };
    errorCollector.assertEquals(new RevisionSet(nodes4), fromR3.roots(parentHelper));
    Nodeid[] nodes5 = { allRevs[9], allRevs[7] };
    // heads
    errorCollector.assertEquals(new RevisionSet(nodes5), complete.heads(parentHelper));
    Nodeid[] nodes6 = { allRevs[9], allRevs[8] };
    RevisionSet toR7 = complete.subtract(new RevisionSet(nodes6));
    Nodeid[] nodes7 = { allRevs[7], allRevs[6], allRevs[4] };
    errorCollector.assertEquals(new RevisionSet(nodes7), toR7.heads(parentHelper));
    Nodeid[] nodes8 = { allRevs[5], allRevs[7] };
    RevisionSet withoutNoMergeBranch = toR7.subtract(new RevisionSet(nodes8));
    Nodeid[] nodes9 = { allRevs[6], allRevs[4] };
    errorCollector.assertEquals(new RevisionSet(nodes9), withoutNoMergeBranch.heads(parentHelper));
    errorCollector.assertEquals(complete.heads(parentHelper), complete.heads(parentHelper).heads(parentHelper));
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.RevisionSet

Copyright © 2018 www.massapicom. 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.