Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 597:c895b5556937
Wrap manifest revision map completion into single file access
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 03 May 2013 14:10:40 +0200 |
parents | 47dfa0ec7e35 |
children | d29d9dc6c128 |
comparison
equal
deleted
inserted
replaced
596:43cfa08ff3fd | 597:c895b5556937 |
---|---|
19 import static org.tmatesoft.hg.core.Nodeid.NULL; | 19 import static org.tmatesoft.hg.core.Nodeid.NULL; |
20 import static org.tmatesoft.hg.repo.HgRepository.*; | 20 import static org.tmatesoft.hg.repo.HgRepository.*; |
21 import static org.tmatesoft.hg.util.LogFacility.Severity.Info; | 21 import static org.tmatesoft.hg.util.LogFacility.Severity.Info; |
22 | 22 |
23 import java.io.IOException; | 23 import java.io.IOException; |
24 import java.util.ArrayList; | |
25 import java.util.Arrays; | 24 import java.util.Arrays; |
26 | 25 |
27 import org.tmatesoft.hg.core.HgChangesetFileSneaker; | 26 import org.tmatesoft.hg.core.HgChangesetFileSneaker; |
28 import org.tmatesoft.hg.core.Nodeid; | 27 import org.tmatesoft.hg.core.Nodeid; |
29 import org.tmatesoft.hg.internal.ByteVector; | 28 import org.tmatesoft.hg.internal.ByteVector; |
31 import org.tmatesoft.hg.internal.DataAccess; | 30 import org.tmatesoft.hg.internal.DataAccess; |
32 import org.tmatesoft.hg.internal.DigestHelper; | 31 import org.tmatesoft.hg.internal.DigestHelper; |
33 import org.tmatesoft.hg.internal.EncodingHelper; | 32 import org.tmatesoft.hg.internal.EncodingHelper; |
34 import org.tmatesoft.hg.internal.IdentityPool; | 33 import org.tmatesoft.hg.internal.IdentityPool; |
35 import org.tmatesoft.hg.internal.IntMap; | 34 import org.tmatesoft.hg.internal.IntMap; |
35 import org.tmatesoft.hg.internal.IntVector; | |
36 import org.tmatesoft.hg.internal.IterateControlMediator; | 36 import org.tmatesoft.hg.internal.IterateControlMediator; |
37 import org.tmatesoft.hg.internal.Lifecycle; | 37 import org.tmatesoft.hg.internal.Lifecycle; |
38 import org.tmatesoft.hg.internal.RevlogStream; | 38 import org.tmatesoft.hg.internal.RevlogStream; |
39 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | |
39 import org.tmatesoft.hg.util.CancelSupport; | 40 import org.tmatesoft.hg.util.CancelSupport; |
40 import org.tmatesoft.hg.util.LogFacility.Severity; | 41 import org.tmatesoft.hg.util.LogFacility.Severity; |
41 import org.tmatesoft.hg.util.Path; | 42 import org.tmatesoft.hg.util.Path; |
42 import org.tmatesoft.hg.util.ProgressSupport; | 43 import org.tmatesoft.hg.util.ProgressSupport; |
43 | 44 |
635 public void finish(Object token) { | 636 public void finish(Object token) { |
636 if (changelog2manifest == null) { | 637 if (changelog2manifest == null) { |
637 return; | 638 return; |
638 } | 639 } |
639 // I assume there'd be not too many revisions we don't know manifest of | 640 // I assume there'd be not too many revisions we don't know manifest of |
640 ArrayList<Integer> undefinedChangelogRevision = new ArrayList<Integer>(); | 641 IntVector undefinedChangelogRevision = new IntVector(); |
641 for (int i = 0; i < changelog2manifest.length; i++) { | 642 for (int i = 0; i < changelog2manifest.length; i++) { |
642 if (changelog2manifest[i] == BAD_REVISION) { | 643 if (changelog2manifest[i] == BAD_REVISION) { |
643 undefinedChangelogRevision.add(i); | 644 undefinedChangelogRevision.add(i); |
644 } | 645 } |
645 } | 646 } |
646 for (int u : undefinedChangelogRevision) { | 647 if (undefinedChangelogRevision.size() > 0) { |
647 Nodeid manifest = repo.getChangelog().range(u, u).get(0).manifest(); | 648 final IntMap<Nodeid> missingCsetToManifest = new IntMap<Nodeid>(undefinedChangelogRevision.size()); |
648 // TODO calculate those missing effectively (e.g. cache and sort nodeids to speed lookup | 649 int[] undefinedClogRevs = undefinedChangelogRevision.toArray(); |
649 // right away in the #next (may refactor ParentWalker's sequential and sorted into dedicated helper and reuse here) | 650 // undefinedChangelogRevision is sorted by the nature it's created |
650 if (manifest.isNull()) { | 651 repo.getChangelog().rangeInternal(new HgChangelog.Inspector() { |
651 repo.getSessionContext().getLog().dump(getClass(), Severity.Warn, "Changeset %d has no associated manifest entry", u); | 652 |
652 // keep -1 in the changelog2manifest map. | 653 public void next(int revisionIndex, Nodeid nodeid, RawChangeset cset) { |
653 } else { | 654 missingCsetToManifest.put(revisionIndex, cset.manifest()); |
654 changelog2manifest[u] = repo.getManifest().getRevisionIndex(manifest); | 655 } |
656 }, undefinedClogRevs); | |
657 assert missingCsetToManifest.size() == undefinedChangelogRevision.size(); | |
658 for (int u : undefinedClogRevs) { | |
659 Nodeid manifest = missingCsetToManifest.get(u); | |
660 // TODO calculate those missing effectively (e.g. cache and sort nodeids to speed lookup | |
661 // right away in the #next (may refactor ParentWalker's sequential and sorted into dedicated helper and reuse here) | |
662 if (manifest == null || manifest.isNull()) { | |
663 repo.getSessionContext().getLog().dump(getClass(), Severity.Warn, "Changeset %d has no associated manifest entry", u); | |
664 // keep -1 in the changelog2manifest map. | |
665 } else { | |
666 changelog2manifest[u] = repo.getManifest().getRevisionIndex(manifest); | |
667 } | |
655 } | 668 } |
656 } | 669 } |
657 } | 670 } |
658 } | 671 } |
659 | 672 |