Mercurial > hg4j
diff 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 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/Revlog.java Wed Sep 28 13:09:16 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/Revlog.java Thu Sep 29 03:20:28 2011 +0200 @@ -21,6 +21,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -87,6 +88,24 @@ // XXX cache nodeids? return Nodeid.fromBinary(content.nodeid(revision), 0); } + + public final List<Nodeid> getRevisions(int... revisions) { + ArrayList<Nodeid> rv = new ArrayList<Nodeid>(revisions.length); + Arrays.sort(revisions); + getRevisionsInternal(rv, revisions); + return rv; + } + + /*package-local*/ void getRevisionsInternal(final List<Nodeid> retVal, int[] sortedRevs) { + // once I have getRevisionMap and may find out whether it is avalable from cache, + // may use it, perhaps only for small number of revisions + content.iterate(sortedRevs, false, new RevlogStream.Inspector() { + + public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) { + retVal.add(Nodeid.fromBinary(nodeid, 0)); + } + }); + } /** * Get local revision number (index) of the specified revision. @@ -195,7 +214,7 @@ } } } - + /* * XXX think over if it's better to do either: * pw = getChangelog().new ParentWalker(); pw.init() and pass pw instance around as needed