Examples of HgChangelog


Examples of org.tmatesoft.hg.repo.HgChangelog

    if (hgRepo.isInvalid()) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
      return;
    }
    HgTags tags = hgRepo.getTags();
    final HgChangelog clog = hgRepo.getChangelog();
    final Map<TagInfo, Integer> ti2index = new HashMap<TagInfo, Integer>();
    final TreeSet<TagInfo> sorted = new TreeSet<HgTags.TagInfo>(new Comparator<TagInfo>() {

      public int compare(TagInfo o1, TagInfo o2) {
        // reverse, from newer to older (bigger indexes first);
        // never ==, tags from same revision in any order, just next to each other
        int x1 = ti2index.get(o1);
        int x2 = ti2index.get(o2);
        return x1 < x2 ? 1 : -1;
      }
    });
    for (TagInfo ti : tags.getAllTags().values()) {
      int x = clog.getRevisionIndex(ti.revision()); // XXX in fact, performance hog. Need batch revisionIndex or another improvement
      ti2index.put(ti, x);
      sorted.add(ti);
    }
    for (TagInfo ti : sorted) {
      int x = ti2index.get(ti);
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

    The only difference is latter instantiates Nodeids, while former compares binary content as is.
    Hence, with 20-30 ms per regular getLocalRevision, it pays off to use RevisionMap with at least 15-20
    queries
   */
  private void testRevisionMap() throws Exception {
    HgChangelog changelog = hgRepo.getChangelog();
    HgRevisionMap<HgChangelog> rmap = new HgRevisionMap<HgChangelog>(changelog).init(); // warm-up, ensure complete file read
    int tip = changelog.getLastRevision();
    // take 5 arbitrary revisions at 0, 1/4, 2/4, 3/4 and 4/4
    final Nodeid[] revs = new Nodeid[5];
    revs[4] = changelog.getRevision(0);
    revs[3] = changelog.getRevision(tip / 4);
    revs[2] = changelog.getRevision(tip / 2);
    revs[1] = changelog.getRevision(tip / 4 + tip / 2);
    revs[0] = changelog.getRevision(tip);
    long start = System.currentTimeMillis();
    for (int i = 0; i < revs.length; i++) {
      final int localRev = changelog.getRevisionIndex(revs[i]);
      System.out.printf("%d:%s\n", localRev, revs[i]);
    }
    System.out.println(System.currentTimeMillis() - start);
    System.out.println();
    //
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

    errorCollector.assertTrue("Draft,no ParentChildMap:" + s3.toString(), s3.isEmpty());
    errorCollector.assertTrue("Draft, with ParentChildMap:" + s4.toString(), s4.isEmpty());
  }

  private HgPhase[] initAndCheck(PhasesHelper ph, HgPhase[] expected) throws HgRuntimeException {
    HgChangelog clog = ph.getRepo().getChangelog();
    HgPhase[] result = new HgPhase[clog.getRevisionCount()];
    for (int i = 0, l = clog.getLastRevision(); i <= l; i++) {
      result[i] = ph.getPhase(i, null);
    }
    assertEquals(expected.length, result.length);
    for (int i = 0; i < result.length; i++) {
      errorCollector.assertTrue(result[i] == expected[i]);
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

  }
 
  // this method doesn't roll transaction back in case of failure, caller's responsibility
  // this method expects repository to be locked, if needed
  public Nodeid commit(String message, Transaction transaction) throws HgIOException, HgRepositoryLockException, HgRuntimeException {
    final HgChangelog clog = repo.getRepo().getChangelog();
    final int clogRevisionIndex = clog.getRevisionCount();
    ManifestRevision c1Manifest = new ManifestRevision(null, null);
    ManifestRevision c2Manifest = new ManifestRevision(null, null);
    final Nodeid p1Cset = p1Commit == NO_REVISION ? null : clog.getRevision(p1Commit);
    final Nodeid p2Cset = p2Commit == NO_REVISION ? null : clog.getRevision(p2Commit);
    if (p1Commit != NO_REVISION) {
      repo.getRepo().getManifest().walk(p1Commit, p1Commit, c1Manifest);
    }
    if (p2Commit != NO_REVISION) {
      repo.getRepo().getManifest().walk(p2Commit, p2Commit, c2Manifest);
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

  @Test
  public void testRevisionMap() throws HgException {
    // XXX this test may benefit from external huge repository
    final HgRepository repo = Configuration.get().find("test-annotate");
    Nodeid[] allRevs = RepoUtils.allRevisions(repo);
    final HgChangelog clog = repo.getChangelog();
    final HgRevisionMap<HgChangelog> rmap = new HgRevisionMap<HgChangelog>(clog).init();
    doTestRevisionMap(allRevs, rmap);
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

  public void execute() throws HgRemoteConnectionException, HgIOException, HgLibraryFailureException, CancelledException {
    final ProgressSupport progress = getProgressSupport(null);
    try {
      progress.start(100);
      // TODO refactor same code in HgIncomingCommand #getComparator and #getParentHelper
      final HgChangelog clog = repo.getChangelog();
      final HgParentChildMap<HgChangelog> parentHelper = new HgParentChildMap<HgChangelog>(clog);
      parentHelper.init();
      final RepositoryComparator comparator = new RepositoryComparator(parentHelper, remote);
      // get incoming revisions
      comparator.compare(new ProgressSupport.Sub(progress, 50), getCancelSupport(null, true));
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

    HgDataFile df = repo.getFileNode(fname);
    AnnotateRunner ar = new AnnotateRunner(df.getPath(), null);

    final HgDiffCommand diffCmd = new HgDiffCommand(repo);
    diffCmd.file(df).order(NewToOld);
    final HgChangelog clog = repo.getChangelog();
    final int[] toTest = new int[] {
      clog.getRevisionIndex(Nodeid.fromAscii("946b131962521f9199e1fedbdc2487d3aaef5e46")), // 539
      clog.getRevisionIndex(Nodeid.fromAscii("1e95f48d9886abe79b9711ab371bc877ca5e773e")), // 541
      /*, TIP */};
    for (int cs : toTest) {
      ar.run(cs, false);
      diffCmd.range(0, cs);
      final ReverseAnnotateInspector insp = new ReverseAnnotateInspector();
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

   */
  public RevisionSet roots(HgRepository repo) {
    // TODO introduce parent access interface, use it here, provide implementations
    // that delegate to HgParentChildMap or HgRepository
    HashSet<Nodeid> copy = new HashSet<Nodeid>(elements);
    final HgChangelog clog = repo.getChangelog();
    byte[] parent1 = new byte[Nodeid.SIZE], parent2 = new byte[Nodeid.SIZE];
    int[] parentRevs = new int[2];
    for (Nodeid n : elements) {
      assert clog.isKnown(n);
      clog.parents(clog.getRevisionIndex(n), parentRevs, parent1, parent2);
      if (parentRevs[0] != NO_REVISION && elements.contains(new Nodeid(parent1, false))) {
        copy.remove(n);
        continue;
      }
      if (parentRevs[1] != NO_REVISION && elements.contains(new Nodeid(parent2, false))) {
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

    return new HgInternals(repo).getNextCommitUsername();
  }

  private void detectParentFromDirstate(int[] parents) throws HgRuntimeException {
    Pair<Nodeid, Nodeid> pn = repo.getWorkingCopyParents();
    HgChangelog clog = repo.getChangelog();
    parents[0] = pn.first().isNull() ? NO_REVISION : clog.getRevisionIndex(pn.first());
    parents[1] = pn.second().isNull() ? NO_REVISION : clog.getRevisionIndex(pn.second());
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgChangelog

 
  /**
   * @return never <code>null</code>. empty file if no changesets were written
   */
  public File create(List<Nodeid> changesets) throws HgIOException, IOException {
    final HgChangelog clog = repo.getRepo().getChangelog();
    final HgManifest manifest = repo.getRepo().getManifest();
    IntVector clogRevsVector = new IntVector(changesets.size(), 0);
    for (Nodeid n : changesets) {
      clogRevsVector.add(clog.getRevisionIndex(n));
    }
    clogRevsVector.sort(true);
    final int[] clogRevs = clogRevsVector.toArray();
    final IntMap<Nodeid> clogMap = new IntMap<Nodeid>(changesets.size());
    final IntVector manifestRevs = new IntVector(changesets.size(), 0);
    final List<HgDataFile> files = new ArrayList<HgDataFile>();
    clog.range(new HgChangelog.Inspector() {
      private Set<String> seenFiles = new HashSet<String>();
      public void next(int revisionIndex, Nodeid nodeid, RawChangeset cset) throws HgRuntimeException {
        clogMap.put(revisionIndex, nodeid);
        manifestRevs.add(manifest.getRevisionIndex(cset.manifest()));
        for (String f : cset.files()) {
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.