Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 88:61eedab3eb3e
Status between two revisions to recognize copy/rename
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 26 Jan 2011 05:46:47 +0100 |
| parents | 4222b04f34ee |
| children | a3a2e5deb320 |
comparison
equal
deleted
inserted
replaced
| 87:25f2e5d1cd8b | 88:61eedab3eb3e |
|---|---|
| 108 return rv; | 108 return rv; |
| 109 } catch (IOException ex) { | 109 } catch (IOException ex) { |
| 110 ex.printStackTrace(); | 110 ex.printStackTrace(); |
| 111 throw new IllegalStateException(); | 111 throw new IllegalStateException(); |
| 112 } finally { | 112 } finally { |
| 113 daIndex.done(); | |
| 114 } | |
| 115 } | |
| 116 | |
| 117 public int linkRevision(int revision) { | |
| 118 final int last = revisionCount() - 1; | |
| 119 if (revision == TIP) { | |
| 120 revision = last; | |
| 121 } | |
| 122 if (revision < 0 || revision > last) { | |
| 123 throw new IllegalArgumentException(Integer.toString(revision)); | |
| 124 } | |
| 125 DataAccess daIndex = getIndexStream(); | |
| 126 try { | |
| 127 int recordOffset = inline ? (int) index.get(revision).offset : revision * REVLOGV1_RECORD_SIZE; | |
| 128 daIndex.seek(recordOffset + 20); | |
| 129 int linkRev = daIndex.readInt(); | |
| 130 return linkRev; | |
| 131 } catch (IOException ex) { | |
| 132 ex.printStackTrace(); | |
| 133 throw new IllegalStateException(); | |
| 134 } finally { | |
| 135 daIndex.done(); | |
| 113 } | 136 } |
| 114 } | 137 } |
| 115 | 138 |
| 116 // Perhaps, RevlogStream should be limited to use of plain int revisions for access, | 139 // Perhaps, RevlogStream should be limited to use of plain int revisions for access, |
| 117 // while Nodeids should be kept on the level up, in Revlog. Guess, Revlog better keep | 140 // while Nodeids should be kept on the level up, in Revlog. Guess, Revlog better keep |
| 187 i = start; | 210 i = start; |
| 188 } | 211 } |
| 189 | 212 |
| 190 daIndex.seek(inline ? (int) index.get(i).offset : i * REVLOGV1_RECORD_SIZE); | 213 daIndex.seek(inline ? (int) index.get(i).offset : i * REVLOGV1_RECORD_SIZE); |
| 191 for (; i <= end; i++ ) { | 214 for (; i <= end; i++ ) { |
| 192 long l = daIndex.readLong(); | 215 long l = daIndex.readLong(); // 0 |
| 193 @SuppressWarnings("unused") | 216 @SuppressWarnings("unused") |
| 194 long offset = l >>> 16; | 217 long offset = l >>> 16; |
| 195 @SuppressWarnings("unused") | 218 @SuppressWarnings("unused") |
| 196 int flags = (int) (l & 0X0FFFF); | 219 int flags = (int) (l & 0X0FFFF); |
| 197 int compressedLen = daIndex.readInt(); | 220 int compressedLen = daIndex.readInt(); // +8 |
| 198 int actualLen = daIndex.readInt(); | 221 int actualLen = daIndex.readInt(); // +12 |
| 199 int baseRevision = daIndex.readInt(); | 222 int baseRevision = daIndex.readInt(); // +16 |
| 200 int linkRevision = daIndex.readInt(); | 223 int linkRevision = daIndex.readInt(); // +20 |
| 201 int parent1Revision = daIndex.readInt(); | 224 int parent1Revision = daIndex.readInt(); |
| 202 int parent2Revision = daIndex.readInt(); | 225 int parent2Revision = daIndex.readInt(); |
| 203 // Hg has 32 bytes here, uses 20 for nodeid, and keeps 12 last bytes empty | 226 // Hg has 32 bytes here, uses 20 for nodeid, and keeps 12 last bytes empty |
| 204 daIndex.readBytes(nodeidBuf, 0, 20); | 227 daIndex.readBytes(nodeidBuf, 0, 20); // +32 |
| 205 daIndex.skip(12); | 228 daIndex.skip(12); |
| 206 byte[] data = null; | 229 byte[] data = null; |
| 207 if (needData) { | 230 if (needData) { |
| 208 byte[] dataBuf = new byte[compressedLen]; | 231 byte[] dataBuf = new byte[compressedLen]; |
| 209 if (inline) { | 232 if (inline) { |
