Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.ManifestRevision


    final long end3 = System.nanoTime();
    System.out.printf("\t1st run: %d ms, %b\n\t2nd run: %d ms, %b\n\tfile only: %d ms", (end1 - start1) / 1000000, e1, (end2 - end1) / 1000000, e2, (end3-end2)/1000000);
    if (!fr.equals(fs1.revision()) || !fr.equals(fs2.revision())) {
      throw new AssertionError();
    }
    ManifestRevision mr = new ManifestRevision(null, null);
    final long _s1 = System.nanoTime();
    hgRepo.getManifest().walk(0, 0, mr);
    final long _e1 = System.nanoTime();
    hgRepo.getManifest().getFileRevision(0, fname);
    final long _e2 = System.nanoTime();
View Full Code Here


    return dirstate;
  }
 
  private ManifestRevision getManifest(int changelogLocalRev) throws HgRuntimeException {
    assert changelogLocalRev >= 0;
    ManifestRevision mr;
    if (baseRevisionCollector != null) {
      mr = baseRevisionCollector.raw(changelogLocalRev);
    } else {
      mr = new ManifestRevision(null, null);
      repo.getManifest().walk(changelogLocalRev, changelogLocalRev, mr);
    }
    return mr;
  }
View Full Code Here

    }
    if (getDirstateParentManifest() == null) {
      initDirstateParentManifest();
    }
    // XXX NOTE, use of TIP for working copy parent is questionable, at least. Instead, TIP shall mean latest cset or not allowed at all
    ManifestRevision collect = null; // non null indicates we compare against base revision
    Set<Path> baseRevFiles = Collections.emptySet(); // files from base revision not affected by status calculation
    if (baseRevision != TIP && baseRevision != WORKING_COPY) {
      collect = getManifest(baseRevision);
      baseRevFiles = new TreeSet<Path>(collect.files());
    }
    if (inspector instanceof HgStatusCollector.Record) {
      HgStatusCollector sc = baseRevisionCollector == null ? new HgStatusCollector(repo) : baseRevisionCollector;
      // nodeidAfterChange(dirstate's parent) doesn't make too much sense,
      // because the change might be actually in working copy. Nevertheless,
View Full Code Here

    }
    try {
      ArrayList<Entry> result = new ArrayList<Entry>();
      // pipe (already normalized) names from mergestate through same pool of filenames as use manifest revisions 
      Path.Source pathPool = new Path.SimpleSource(new PathRewrite.Empty(), fnamePool);
      final ManifestRevision m1 = new ManifestRevision(nodeidPool, fnamePool);
      final ManifestRevision m2 = new ManifestRevision(nodeidPool, fnamePool);
      if (!wcp2.isNull()) {
        final int rp2 = hgRepo.getChangelog().getRevisionIndex(wcp2);
        hgRepo.getManifest().walk(rp2, rp2, m2);
      }
      LineReader lr = new LineReader(f, repo.getLog());
      Iterator<String> lines = lr.read(new LineReader.SimpleLineCollector(), new ArrayList<String>()).iterator();
      String s = lines.next();
      stateParent = nodeidPool.unify(Nodeid.fromAscii(s));
      final int rp1 = hgRepo.getChangelog().getRevisionIndex(stateParent);
      hgRepo.getManifest().walk(rp1, rp1, m1);
      while (lines.hasNext()) {
        s = lines.next();
        String[] r = s.split("\\00");
        if (r.length < 7) {
          repo.getLog().dump(getClass(), Severity.Error, "Expect at least 7 zero-separated fields in the merge state file, not %d. Entry skipped", r.length);
          continue;
        }
        Path p1fname = pathPool.path(r[3]);
        Nodeid nidP1 = m1.nodeid(p1fname);
        Nodeid nidCA = nodeidPool.unify(Nodeid.fromAscii(r[5]));
        HgFileRevision p1 = new HgFileRevision(hgRepo, nidP1, m1.flags(p1fname), p1fname);
        HgFileRevision ca;
        if (nidCA == nidP1 && r[3].equals(r[4])) {
          ca = p1;
        } else {
          ca = new HgFileRevision(hgRepo, nidCA, null, pathPool.path(r[4]));
        }
        HgFileRevision p2;
        if (!wcp2.isNull() || !r[6].equals(r[4])) {
          final Path p2fname = pathPool.path(r[6]);
          Nodeid nidP2 = m2.nodeid(p2fname);
          if (nidP2 == null) {
            assert false : "There's not enough information (or I don't know where to look) in merge/state to find out what's the second parent";
            nidP2 = NULL;
          }
          p2 = new HgFileRevision(hgRepo, nidP2, m2.flags(p2fname), p2fname);
        } else {
          // no second parent known. no idea what to do here, assume linear merge, use common ancestor as parent
          p2 = ca;
        }
        final Kind k;
View Full Code Here

  public HgRepository getRepo() {
    return repo;
  }
 
  private ManifestRevision get(int rev) throws HgRuntimeException {
    ManifestRevision i = cache.get(rev);
    if (i == null) {
      if (rev == NO_REVISION) {
        return emptyFakeState;
      }
      ensureCacheSize();
      i = new ManifestRevision(cacheNodes, cacheFilenames);
      cache.put(rev, i);
      repo.getManifest().walk(rev, rev, i);
    }
    return i;
  }
View Full Code Here

      public boolean begin(int manifestRevision, Nodeid nid, int changelogRevision) {
        assert delegate == null;
        if (cache.containsKey(changelogRevision)) { // don't need to check emptyFakeState hit as revision never NO_REVISION here
          cacheHit = true;
        } else {
          cache.put(changelogRevision, delegate = new ManifestRevision(cacheNodes, cacheFilenames));
          // cache may grow bigger than max size here, but it's ok as present simplistic cache clearing mechanism may
          // otherwise remove entries we just added
          delegate.begin(manifestRevision, nid, changelogRevision);
          cacheHit = false;
        }
View Full Code Here

      }
    }, revisionsToCollect);
  }
 
  /*package-local*/ static ManifestRevision createEmptyManifestRevision() {
    ManifestRevision fakeEmptyRev = new ManifestRevision(null, null);
    fakeEmptyRev.begin(NO_REVISION, null, NO_REVISION);
    fakeEmptyRev.end(NO_REVISION);
    return fakeEmptyRev;
  }
View Full Code Here

    if (inspector instanceof Record) {
      ((Record) inspector).init(rev1, rev2, this);
    }
    // in fact, rev1 and rev2 are often next (or close) to each other,
    // thus, we can optimize Manifest reads here (manifest.walk(rev1, rev2))
    ManifestRevision r1, r2 ;
    boolean need1 = !cached(rev1), need2 = !cached(rev2);
    if (need1 || need2) {
      int minRev, maxRev;
      if (need1 && need2 && Math.abs(rev1 - rev2) < 5 /*subjective equivalent of 'close enough'*/) {
        minRev = rev1 < rev2 ? rev1 : rev2;
        maxRev = minRev == rev1 ? rev2 : rev1;
        if (minRev > 0) {
          minRev--; // expand range a bit
        }
        initCacheRange(minRev, maxRev);
        need1 = need2 = false;
      }
      // either both unknown and far from each other, or just one of them.
      // read with neighbors to save potential subsequent calls for neighboring elements
      // XXX perhaps, if revlog.baseRevision is cheap, shall expand minRev up to baseRevision
      // which going to be read anyway
      if (need1) {
        minRev = rev1;
        maxRev = rev1 < lastChangelogRevision-5 ? rev1+5 : lastChangelogRevision;
        initCacheRange(minRev, maxRev);
      }
      if (need2) {
        minRev = rev2;
        maxRev = rev2 < lastChangelogRevision-5 ? rev2+5 : lastChangelogRevision;
        initCacheRange(minRev, maxRev);
      }
    }
    r1 = get(rev1);
    r2 = get(rev2);

    final CancelSupport cs = CancelSupport.Factory.get(inspector);

    Collection<Path> allBaseFiles = r1.files();
    TreeSet<Path> r1Files = new TreeSet<Path>(allBaseFiles);
    for (Path r2fname : r2.files()) {
      if (!scope.accept(r2fname)) {
        continue;
      }
      if (r1Files.remove(r2fname)) {
        Nodeid nidR1 = r1.nodeid(r2fname);
        Nodeid nidR2 = r2.nodeid(r2fname);
        HgManifest.Flags flagsR1 = r1.flags(r2fname);
        HgManifest.Flags flagsR2 = r2.flags(r2fname);
        if (nidR1.equals(nidR2) && flagsR2 == flagsR1) {
          inspector.clean(r2fname);
        } else {
          inspector.modified(r2fname);
View Full Code Here

    Nodeid toExtract = null;
    String phaseMsg = "Extract manifest revision failed";
    try {
      if (cachedManifest == null) {
        int csetRev = repo.getChangelog().getRevisionIndex(cset);
        cachedManifest = new ManifestRevision(null, null); // XXX how about context and cached manifest revisions
        repo.getManifest().walk(csetRev, csetRev, cachedManifest);
        // cachedManifest shall be meaningful - changelog.getRevisionIndex() above ensures we've got version that exists.
      }
      toExtract = cachedManifest.nodeid(file);
      phaseMsg = "Follow copy/rename failed";
View Full Code Here

      dirstateBuilder.parents(headCset1, clog.getRevision(secondCset));
      //
      MergeStateBuilder mergeStateBuilder = new MergeStateBuilder(implRepo);
      mergeStateBuilder.prepare(headCset1);

      ManifestRevision m1, m2, ma;
      m1 = new ManifestRevision(cacheRevs, cacheFiles).init(repo, firstCset);
      m2 = new ManifestRevision(cacheRevs, cacheFiles).init(repo, secondCset);
      ma = new ManifestRevision(cacheRevs, cacheFiles).init(repo, ancestorCset);
      Transaction transaction = implRepo.getTransactionFactory().create(repo);
      ResolverImpl resolver = new ResolverImpl(implRepo, dirstateBuilder, mergeStateBuilder);
      try {
        for (Path f : m1.files()) {
          Nodeid fileRevBase, fileRevA, fileRevB;
          if (m2.contains(f)) {
            fileRevA = m1.nodeid(f);
            fileRevB = m2.nodeid(f);
            fileRevBase = ma.contains(f) ? ma.nodeid(f) : null;
            if (fileRevA.equals(fileRevB)) {
              HgFileRevision fr = new HgFileRevision(repo, fileRevA, m1.flags(f), f);
              resolver.presentState(f, fr, fr, null);
              mediator.same(fr, resolver);
            } else if (fileRevBase == fileRevA) {
              assert fileRevBase != null;
              HgFileRevision frBase = new HgFileRevision(repo, fileRevBase, ma.flags(f), f);
              HgFileRevision frSecond= new HgFileRevision(repo, fileRevB, m2.flags(f), f);
              resolver.presentState(f, frBase, frSecond, frBase);
              mediator.fastForwardB(frBase, frSecond, resolver);
            } else if (fileRevBase == fileRevB) {
              assert fileRevBase != null;
              HgFileRevision frBase = new HgFileRevision(repo, fileRevBase, ma.flags(f), f);
              HgFileRevision frFirst = new HgFileRevision(repo, fileRevA, m1.flags(f), f);
              resolver.presentState(f, frFirst, frBase, frBase);
              mediator.fastForwardA(frBase, frFirst, resolver);
            } else {
              HgFileRevision frBase = fileRevBase == null ? null : new HgFileRevision(repo, fileRevBase, ma.flags(f), f);
              HgFileRevision frFirst = new HgFileRevision(repo, fileRevA, m1.flags(f), f);
              HgFileRevision frSecond= new HgFileRevision(repo, fileRevB, m2.flags(f), f);
              resolver.presentState(f, frFirst, frSecond, frBase);
              mediator.resolve(frBase, frFirst, frSecond, resolver);
            }
          } else {
            // m2 doesn't contain the file, either new in m1, or deleted in m2
            HgFileRevision frFirst = new HgFileRevision(repo, m1.nodeid(f), m1.flags(f), f);
            if (ma.contains(f)) {
              // deleted in m2
              HgFileRevision frBase = new HgFileRevision(repo, ma.nodeid(f), ma.flags(f), f);
              resolver.presentState(f, frFirst, null, frBase);
              mediator.onlyA(frBase, frFirst, resolver);
            } else {
              // new in m1
              resolver.presentState(f, frFirst, null, null);
              mediator.newInA(frFirst, resolver);
            }
          }
          resolver.apply();
        } // for m1 files
        for (Path f : m2.files()) {
          if (m1.contains(f)) {
            continue;
          }
          HgFileRevision frSecond= new HgFileRevision(repo, m2.nodeid(f), m2.flags(f), f);
          // file in m2 is either new or deleted in m1
          if (ma.contains(f)) {
View Full Code Here

TOP

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

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.