Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/RevisionDescendants.java @ 648:690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 25 Jun 2013 20:48:37 +0200 |
parents | 6526d8adbc0f |
children |
comparison
equal
deleted
inserted
replaced
647:c75297c17867 | 648:690e71d29bf6 |
---|---|
14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.internal; | 17 package org.tmatesoft.hg.internal; |
18 | 18 |
19 import java.util.ArrayList; | |
19 import java.util.BitSet; | 20 import java.util.BitSet; |
20 | 21 |
21 import org.tmatesoft.hg.core.Nodeid; | 22 import org.tmatesoft.hg.core.Nodeid; |
22 import org.tmatesoft.hg.repo.HgChangelog; | 23 import org.tmatesoft.hg.repo.HgChangelog; |
23 import org.tmatesoft.hg.repo.HgInvalidStateException; | 24 import org.tmatesoft.hg.repo.HgInvalidStateException; |
35 | 36 |
36 private final HgRepository repo; | 37 private final HgRepository repo; |
37 private final int rootRevIndex; | 38 private final int rootRevIndex; |
38 private final int tipRevIndex; // this is the last revision we cache to | 39 private final int tipRevIndex; // this is the last revision we cache to |
39 private final BitSet descendants; | 40 private final BitSet descendants; |
41 private RevisionSet revset; | |
40 | 42 |
41 // in fact, may be refactored to deal not only with changelog, but any revlog (not sure what would be the usecase, though) | 43 // in fact, may be refactored to deal not only with changelog, but any revlog (not sure what would be the usecase, though) |
42 public RevisionDescendants(HgRepository hgRepo, int revisionIndex) throws HgRuntimeException { | 44 public RevisionDescendants(HgRepository hgRepo, int revisionIndex) throws HgRuntimeException { |
43 repo = hgRepo; | 45 repo = hgRepo; |
44 rootRevIndex = revisionIndex; | 46 rootRevIndex = revisionIndex; |
106 assert isCandidate(revisionIndex); | 108 assert isCandidate(revisionIndex); |
107 int ix = revisionIndex - rootRevIndex; | 109 int ix = revisionIndex - rootRevIndex; |
108 assert ix < descendants.size(); | 110 assert ix < descendants.size(); |
109 return descendants.get(ix); | 111 return descendants.get(ix); |
110 } | 112 } |
113 | |
114 public RevisionSet asRevisionSet() { | |
115 if (revset == null) { | |
116 final ArrayList<Nodeid> revisions = new ArrayList<Nodeid>(descendants.cardinality()); | |
117 repo.getChangelog().indexWalk(rootRevIndex, tipRevIndex, new HgChangelog.RevisionInspector() { | |
118 | |
119 public void next(int revisionIndex, Nodeid revision, int linkedRevisionIndex) throws HgRuntimeException { | |
120 if (isDescendant(revisionIndex)) { | |
121 revisions.add(revision); | |
122 } | |
123 } | |
124 }); | |
125 assert revisions.size() == descendants.cardinality(); | |
126 revset = new RevisionSet(revisions); | |
127 } | |
128 return revset; | |
129 } | |
111 } | 130 } |