comparison src/com/tmate/hgkit/ll/Changelog.java @ 51:9429c7bd1920 wrap-data-access

Try DataAccess to reach revision data instead of plain byte arrays
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 16 Jan 2011 01:20:26 +0100
parents e34f90b9ded1
children
comparison
equal deleted inserted replaced
50:f1db8610da62 51:9429c7bd1920
4 package com.tmate.hgkit.ll; 4 package com.tmate.hgkit.ll;
5 5
6 import java.util.ArrayList; 6 import java.util.ArrayList;
7 import java.util.Arrays; 7 import java.util.Arrays;
8 import java.util.List; 8 import java.util.List;
9
10 import com.tmate.hgkit.fs.DataAccess;
9 11
10 /** 12 /**
11 * Representation of the Mercurial changelog file (list of ChangeSets) 13 * Representation of the Mercurial changelog file (list of ChangeSets)
12 * @author artem 14 * @author artem
13 */ 15 */
22 } 24 }
23 25
24 public void range(int start, int end, final Changeset.Inspector inspector) { 26 public void range(int start, int end, final Changeset.Inspector inspector) {
25 Revlog.Inspector i = new Revlog.Inspector() { 27 Revlog.Inspector i = new Revlog.Inspector() {
26 28
27 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { 29 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess da) {
30 byte[] data = da.byteArray();
28 Changeset cset = Changeset.parse(data, 0, data.length); 31 Changeset cset = Changeset.parse(data, 0, data.length);
29 // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse 32 // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse
30 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); 33 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset);
31 } 34 }
32 }; 35 };
35 38
36 public List<Changeset> range(int start, int end) { 39 public List<Changeset> range(int start, int end) {
37 final ArrayList<Changeset> rv = new ArrayList<Changeset>(end - start + 1); 40 final ArrayList<Changeset> rv = new ArrayList<Changeset>(end - start + 1);
38 Revlog.Inspector i = new Revlog.Inspector() { 41 Revlog.Inspector i = new Revlog.Inspector() {
39 42
40 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { 43 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess da) {
44 byte[] data = da.byteArray();
41 Changeset cset = Changeset.parse(data, 0, data.length); 45 Changeset cset = Changeset.parse(data, 0, data.length);
42 rv.add(cset); 46 rv.add(cset);
43 } 47 }
44 }; 48 };
45 content.iterate(start, end, true, i); 49 content.iterate(start, end, true, i);
50 if (revisions == null || revisions.length == 0) { 54 if (revisions == null || revisions.length == 0) {
51 return; 55 return;
52 } 56 }
53 Revlog.Inspector i = new Revlog.Inspector() { 57 Revlog.Inspector i = new Revlog.Inspector() {
54 58
55 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, DataAccess da) {
56 if (Arrays.binarySearch(revisions, revisionNumber) >= 0) { 60 if (Arrays.binarySearch(revisions, revisionNumber) >= 0) {
61 byte[] data = da.byteArray();
57 Changeset cset = Changeset.parse(data, 0, data.length); 62 Changeset cset = Changeset.parse(data, 0, data.length);
58 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); 63 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset);
59 } 64 }
60 } 65 }
61 }; 66 };