Package org.tmatesoft.hg.repo

Examples of org.tmatesoft.hg.repo.HgBundle$GroupElement


    if (hgRepo.isInvalid()) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
      return;
    }
    File bundleFile = new File("/temp/hg/hg-bundle-cpython.tmp");
    HgBundle hgBundle = new HgLookup().loadBundle(bundleFile);
    hgBundle.inspectFiles(new Dump());
    if (Boolean.parseBoolean("true")) {
      return;
    }
    /* pass -R <path-to-repo-with-less-revisions-than-bundle>, e.g. for bundle with tip=168 and -R \temp\hg4j-50 with tip:159
    +Changeset {User: ..., Comment: Integer ....}
    +Changeset {User: ..., Comment: Approach with ...}
    -Changeset {User: ..., Comment: Correct project name...}
    -Changeset {User: ..., Comment: Record possible...}
    */
    hgBundle.changes(hgRepo, new HgChangelog.Inspector() {
      private final HgChangelog changelog = hgRepo.getChangelog();
     
      public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) throws HgRuntimeException {
        if (changelog.isKnown(nodeid)) {
          System.out.print("+");
View Full Code Here


      final RepositoryComparator comparator = new RepositoryComparator(parentHelper, remote);
      // get incoming revisions
      comparator.compare(new ProgressSupport.Sub(progress, 50), getCancelSupport(null, true));
      final List<Nodeid> common = comparator.getCommon();
      // get bundle with changes from remote
      HgBundle incoming = remote.getChanges(common);
      //
      // add revisions to changelog, manifest, files
      final Internals implRepo = HgInternals.getImplementationRepo(repo);
      final AddRevInspector insp;
      Transaction.Factory trFactory = implRepo.getTransactionFactory();
      Transaction tr = trFactory.create(repo);
      try {
        incoming.inspectAll(insp = new AddRevInspector(implRepo, tr));
        insp.done();
        tr.commit();
      } catch (HgRuntimeException ex) {
        tr.rollback();
        throw ex;
      } catch (HgIOException ex) {
        tr.rollback();
        throw ex;
      } catch (RuntimeException ex) {
        tr.rollback();
        throw ex;
      }
      progress.worked(45);
      added = insp.addedChangesets();
     
      if (!added.isEmpty()) {
        parentHelper.init(); // refresh the map, we use it for phases below
      }
      // 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);
    } finally {
      progress.done();
    }
View Full Code Here

    // can use 'stream_out' wireproto
    //
    try {
      // pull all changes from the very beginning
      // XXX consult getContext() if by any chance has a bundle ready, if not, then read and register
      HgBundle completeChanges = srcRepo.getChanges(Collections.singletonList(NULL));
      cancel.checkCancelled();
      WriteDownMate mate = new WriteDownMate(srcRepo.getSessionContext(), destination, progress, cancel);
      try {
        // instantiate new repo in the destdir
        mate.initEmptyRepository();
        // pull changes
        completeChanges.inspectAll(mate);
        mate.checkFailure();
        mate.complete();
      } finally {
        completeChanges.unlink();
        progress.done();
      }
    } catch (HgRuntimeException ex) {
      throw new HgLibraryFailureException(ex);
    }
View Full Code Here

      throw new IllegalArgumentException("Delegate can't be null");
    }
    final ProgressSupport ps = getProgressSupport(handler);
    try {
      final List<Nodeid> common = getCommon();
      HgBundle changegroup = remoteRepo.getChanges(common);
      final ChangesetTransformer transformer = new ChangesetTransformer(localRepo, handler, getParentHelper(), ps, getCancelSupport(handler, true));
      transformer.limitBranches(branches);
      changegroup.changes(localRepo, new HgChangelog.Inspector() {
        private int localIndex;
        private final HgParentChildMap<HgChangelog> parentHelper;
     
        {
          parentHelper = getParentHelper();
View Full Code Here

        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());
              }
            } catch (HgRemoteConnectionException ex) {
              implRepo.getLog().dump(getClass(), Severity.Error, ex, String.format("Failed to update phase of %s", n.shortNotation()));
            }
          }
        }
      }
      progress.worked(5);
      //
      // update bookmark information
      HgBookmarks localBookmarks = repo.getBookmarks();
      if (!localBookmarks.getAllBookmarks().isEmpty()) {
        for (Pair<String,Nodeid> bm : remoteRepo.getBookmarks()) {
          Nodeid localRevision = localBookmarks.getRevision(bm.first());
          if (localRevision == null || !parentHelper.knownNode(bm.second())) {
            continue;
          }
          // we know both localRevision and revision of remote bookmark,
          // need to make sure we don't push  older revision than it's at the server
          if (parentHelper.isChild(bm.second(), localRevision)) {
            remoteRepo.updateBookmark(bm.first(), bm.second(), localRevision);
          }
        }
      }
      // XXX WTF is obsolete in namespaces key??
      progress.worked(5);
      if (b != null) {
        b.unlink(); // keep the file only in case of failure
      }
    } catch (IOException ex) {
      throw new HgIOException(ex.getMessage(), null); // XXX not a nice idea to throw IOException from BundleGenerator#create
    } catch (HgRepositoryNotFoundException ex) {
      final HgInvalidStateException e = new HgInvalidStateException("Failed to load a just-created bundle");
View Full Code Here

    ArrayList<Nodeid> l = new ArrayList<Nodeid>();
    l.add(Nodeid.fromAscii("9ef1fab9f5e3d51d70941121dc27410e28069c2d")); // 640
    l.add(Nodeid.fromAscii("2f33f102a8fa59274a27ebbe1c2903cecac6c5d5")); // 639
    l.add(Nodeid.fromAscii("d074971287478f69ab0a64176ce2284d8c1e91c3")); // 638
    File bundleFile = bg.create(l);
    HgBundle b = new HgLookup().loadBundle(bundleFile);
    //
    DumbInspector insp = new DumbInspector();
    b.inspectChangelog(insp);
    errorCollector.assertTrue(insp.clogEnter && insp.clogExit);
    errorCollector.assertFalse(insp.csets.isEmpty());
    errorCollector.assertFalse(insp.manifestEnter || insp.manifestExit);
    Collections.sort(l);
    Collections.sort(insp.csets);
    errorCollector.assertEquals(l, insp.csets);
    errorCollector.assertEquals(0, insp.filesEnter);
    errorCollector.assertEquals(0, insp.filesExit);
    errorCollector.assertTrue(insp.manifests == null || insp.manifests.isEmpty());
    errorCollector.assertTrue(insp.files.isEmpty());
    //
    insp = new DumbInspector();
    b.inspectFiles(insp);
    errorCollector.assertFalse(insp.clogEnter && insp.clogExit);
    errorCollector.assertFalse(insp.manifestEnter || insp.manifestExit);
    // $ hg log -r 638:640 --debug | grep files
    List<String> affectedFiles = Arrays.asList("src/org/tmatesoft/hg/repo/HgDataFile.java", "COPYING", "build.gradle", ".hgtags");
    // "src/org/tmatesoft/hg/repo/HgBlameInspector.java" was deleted in r638 and hence not part of the bundle
    ArrayList<String> foundFiles = new ArrayList<String>(insp.files.keySet());
    Collections.sort(affectedFiles);
    Collections.sort(foundFiles);
    errorCollector.assertEquals(affectedFiles, foundFiles);
    errorCollector.assertEquals(affectedFiles.size(), insp.filesEnter);
    errorCollector.assertEquals(affectedFiles.size(), insp.filesExit);
    b.unlink();
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.repo.HgBundle$GroupElement

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.