comparison src/com/tmate/hgkit/ll/RevlogStream.java @ 24:d4fdd1845b3f

Nodeid with array of exactly 20 bytes
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 06 Jan 2011 04:42:15 +0100
parents 603806cd2dc6
children 565ce0835674
comparison
equal deleted inserted replaced
23:6f9aca1a97be 24:d4fdd1845b3f
76 public int findLocalRevisionNumber(Nodeid nodeid) { 76 public int findLocalRevisionNumber(Nodeid nodeid) {
77 // XXX this one may be implemented with iterate() once there's mechanism to stop iterations 77 // XXX this one may be implemented with iterate() once there's mechanism to stop iterations
78 final int indexSize = revisionCount(); 78 final int indexSize = revisionCount();
79 DataAccess daIndex = getIndexStream(); 79 DataAccess daIndex = getIndexStream();
80 try { 80 try {
81 byte[] nodeidBuf = new byte[20];
81 for (int i = 0; i < indexSize; i++) { 82 for (int i = 0; i < indexSize; i++) {
82 daIndex.skip(8); 83 daIndex.skip(8);
83 int compressedLen = daIndex.readInt(); 84 int compressedLen = daIndex.readInt();
84 daIndex.skip(20); 85 daIndex.skip(20);
85 byte[] buf = new byte[20]; 86 daIndex.readBytes(nodeidBuf, 0, 20);
86 daIndex.readBytes(buf, 0, 20); 87 if (nodeid.equalsTo(nodeidBuf)) {
87 if (nodeid.equalsTo(buf)) {
88 return i; 88 return i;
89 } 89 }
90 daIndex.skip(inline ? 12 + compressedLen : 12); 90 daIndex.skip(inline ? 12 + compressedLen : 12);
91 } 91 }
92 } catch (IOException ex) { 92 } catch (IOException ex) {
127 daIndex = getIndexStream(); 127 daIndex = getIndexStream();
128 if (needData && !inline) { 128 if (needData && !inline) {
129 daData = getDataStream(); 129 daData = getDataStream();
130 } 130 }
131 try { 131 try {
132 byte[] nodeidBuf = new byte[20];
132 byte[] lastData = null; 133 byte[] lastData = null;
133 int i; 134 int i;
134 boolean extraReadsToBaseRev = false; 135 boolean extraReadsToBaseRev = false;
135 if (needData && index.get(start).baseRevision < start) { 136 if (needData && index.get(start).baseRevision < start) {
136 i = index.get(start).baseRevision; 137 i = index.get(start).baseRevision;
148 int actualLen = daIndex.readInt(); 149 int actualLen = daIndex.readInt();
149 int baseRevision = daIndex.readInt(); 150 int baseRevision = daIndex.readInt();
150 int linkRevision = daIndex.readInt(); 151 int linkRevision = daIndex.readInt();
151 int parent1Revision = daIndex.readInt(); 152 int parent1Revision = daIndex.readInt();
152 int parent2Revision = daIndex.readInt(); 153 int parent2Revision = daIndex.readInt();
153 byte[] buf = new byte[32]; 154 // Hg has 32 bytes here, uses 20 for nodeid, and keeps 12 last bytes empty
154 // XXX Hg keeps 12 last bytes empty, we move them into front here 155 daIndex.readBytes(nodeidBuf, 0, 20);
155 daIndex.readBytes(buf, 12, 20);
156 daIndex.skip(12); 156 daIndex.skip(12);
157 byte[] data = null; 157 byte[] data = null;
158 if (needData) { 158 if (needData) {
159 byte[] dataBuf = new byte[compressedLen]; 159 byte[] dataBuf = new byte[compressedLen];
160 if (inline) { 160 if (inline) {
205 if (inline) { 205 if (inline) {
206 daIndex.skip(compressedLen); 206 daIndex.skip(compressedLen);
207 } 207 }
208 } 208 }
209 if (!extraReadsToBaseRev || i >= start) { 209 if (!extraReadsToBaseRev || i >= start) {
210 inspector.next(i, actualLen, baseRevision, linkRevision, parent1Revision, parent2Revision, buf, data); 210 inspector.next(i, actualLen, baseRevision, linkRevision, parent1Revision, parent2Revision, nodeidBuf, data);
211 } 211 }
212 lastData = data; 212 lastData = data;
213 } 213 }
214 } catch (IOException ex) { 214 } catch (IOException ex) {
215 throw new IllegalStateException(ex); // FIXME need better handling 215 throw new IllegalStateException(ex); // FIXME need better handling