comparison src/org/tmatesoft/hg/repo/Changelog.java @ 77:c677e1593919

Moved RevlogStream implementation into .internal
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 24 Jan 2011 05:33:47 +0100
parents 6f1b88693d48
children
comparison
equal deleted inserted replaced
76:658fa6b3a371 77:c677e1593919
19 import java.util.ArrayList; 19 import java.util.ArrayList;
20 import java.util.Arrays; 20 import java.util.Arrays;
21 import java.util.List; 21 import java.util.List;
22 22
23 import org.tmatesoft.hg.core.Nodeid; 23 import org.tmatesoft.hg.core.Nodeid;
24 import org.tmatesoft.hg.internal.RevlogStream;
24 25
25 26
26 /** 27 /**
27 * Representation of the Mercurial changelog file (list of ChangeSets) 28 * Representation of the Mercurial changelog file (list of ChangeSets)
28 * 29 *
38 public void all(final Changeset.Inspector inspector) { 39 public void all(final Changeset.Inspector inspector) {
39 range(0, content.revisionCount() - 1, inspector); 40 range(0, content.revisionCount() - 1, inspector);
40 } 41 }
41 42
42 public void range(int start, int end, final Changeset.Inspector inspector) { 43 public void range(int start, int end, final Changeset.Inspector inspector) {
43 Revlog.Inspector i = new Revlog.Inspector() { 44 RevlogStream.Inspector i = new RevlogStream.Inspector() {
44 45
45 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { 46 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
46 Changeset cset = Changeset.parse(data, 0, data.length); 47 Changeset cset = Changeset.parse(data, 0, data.length);
47 // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse 48 // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse
48 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); 49 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset);
51 content.iterate(start, end, true, i); 52 content.iterate(start, end, true, i);
52 } 53 }
53 54
54 public List<Changeset> range(int start, int end) { 55 public List<Changeset> range(int start, int end) {
55 final ArrayList<Changeset> rv = new ArrayList<Changeset>(end - start + 1); 56 final ArrayList<Changeset> rv = new ArrayList<Changeset>(end - start + 1);
56 Revlog.Inspector i = new Revlog.Inspector() { 57 RevlogStream.Inspector i = new RevlogStream.Inspector() {
57 58
58 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { 59 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
59 Changeset cset = Changeset.parse(data, 0, data.length); 60 Changeset cset = Changeset.parse(data, 0, data.length);
60 rv.add(cset); 61 rv.add(cset);
61 } 62 }
66 67
67 public void range(final Changeset.Inspector inspector, final int... revisions) { 68 public void range(final Changeset.Inspector inspector, final int... revisions) {
68 if (revisions == null || revisions.length == 0) { 69 if (revisions == null || revisions.length == 0) {
69 return; 70 return;
70 } 71 }
71 Revlog.Inspector i = new Revlog.Inspector() { 72 RevlogStream.Inspector i = new RevlogStream.Inspector() {
72 73
73 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { 74 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
74 if (Arrays.binarySearch(revisions, revisionNumber) >= 0) { 75 if (Arrays.binarySearch(revisions, revisionNumber) >= 0) {
75 Changeset cset = Changeset.parse(data, 0, data.length); 76 Changeset cset = Changeset.parse(data, 0, data.length);
76 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); 77 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset);