Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/Revlog.java @ 317:09628675bcee
Rework file history build approach to match rest of the API
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 29 Sep 2011 03:20:28 +0200 |
parents | 3f40262153a4 |
children | 283b294d1079 |
comparison
equal
deleted
inserted
replaced
316:ee6b467c1a5f | 317:09628675bcee |
---|---|
19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; | 19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; |
20 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 20 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
21 | 21 |
22 import java.io.IOException; | 22 import java.io.IOException; |
23 import java.nio.ByteBuffer; | 23 import java.nio.ByteBuffer; |
24 import java.util.ArrayList; | |
24 import java.util.Arrays; | 25 import java.util.Arrays; |
25 import java.util.Collection; | 26 import java.util.Collection; |
26 import java.util.HashSet; | 27 import java.util.HashSet; |
27 import java.util.LinkedList; | 28 import java.util.LinkedList; |
28 import java.util.List; | 29 import java.util.List; |
84 } | 85 } |
85 | 86 |
86 public final Nodeid getRevision(int revision) { | 87 public final Nodeid getRevision(int revision) { |
87 // XXX cache nodeids? | 88 // XXX cache nodeids? |
88 return Nodeid.fromBinary(content.nodeid(revision), 0); | 89 return Nodeid.fromBinary(content.nodeid(revision), 0); |
90 } | |
91 | |
92 public final List<Nodeid> getRevisions(int... revisions) { | |
93 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(revisions.length); | |
94 Arrays.sort(revisions); | |
95 getRevisionsInternal(rv, revisions); | |
96 return rv; | |
97 } | |
98 | |
99 /*package-local*/ void getRevisionsInternal(final List<Nodeid> retVal, int[] sortedRevs) { | |
100 // once I have getRevisionMap and may find out whether it is avalable from cache, | |
101 // may use it, perhaps only for small number of revisions | |
102 content.iterate(sortedRevs, false, new RevlogStream.Inspector() { | |
103 | |
104 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) { | |
105 retVal.add(Nodeid.fromBinary(nodeid, 0)); | |
106 } | |
107 }); | |
89 } | 108 } |
90 | 109 |
91 /** | 110 /** |
92 * Get local revision number (index) of the specified revision. | 111 * Get local revision number (index) of the specified revision. |
93 * | 112 * |
193 content.iterate(parentRevisions[1], parentRevisions[1], false, pc); | 212 content.iterate(parentRevisions[1], parentRevisions[1], false, pc); |
194 System.arraycopy(pc.nodeid, 0, parent2, 0, 20); | 213 System.arraycopy(pc.nodeid, 0, parent2, 0, 20); |
195 } | 214 } |
196 } | 215 } |
197 } | 216 } |
198 | 217 |
199 /* | 218 /* |
200 * XXX think over if it's better to do either: | 219 * XXX think over if it's better to do either: |
201 * pw = getChangelog().new ParentWalker(); pw.init() and pass pw instance around as needed | 220 * pw = getChangelog().new ParentWalker(); pw.init() and pass pw instance around as needed |
202 * or | 221 * or |
203 * add Revlog#getParentWalker(), static class, make cons() and #init package-local, and keep SoftReference to allow walker reuse. | 222 * add Revlog#getParentWalker(), static class, make cons() and #init package-local, and keep SoftReference to allow walker reuse. |