Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 223:80a3433ace91
HgBadStateException (IOException from FileAccess) on isCopy for empty data file
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 23 May 2011 04:42:12 +0200 |
parents | e39cf474ef94 |
children | ad6a046943be |
comparison
equal
deleted
inserted
replaced
222:373e07cd3991 | 223:80a3433ace91 |
---|---|
243 // Hg has 32 bytes here, uses 20 for nodeid, and keeps 12 last bytes empty | 243 // Hg has 32 bytes here, uses 20 for nodeid, and keeps 12 last bytes empty |
244 daIndex.readBytes(nodeidBuf, 0, 20); // +32 | 244 daIndex.readBytes(nodeidBuf, 0, 20); // +32 |
245 daIndex.skip(12); | 245 daIndex.skip(12); |
246 DataAccess userDataAccess = null; | 246 DataAccess userDataAccess = null; |
247 if (needData) { | 247 if (needData) { |
248 final byte firstByte; | |
249 int streamOffset; | 248 int streamOffset; |
250 DataAccess streamDataAccess; | 249 DataAccess streamDataAccess; |
251 if (inline) { | 250 if (inline) { |
252 streamDataAccess = daIndex; | 251 streamDataAccess = daIndex; |
253 streamOffset = getIndexOffsetInt(i) + REVLOGV1_RECORD_SIZE; // don't need to do seek as it's actual position in the index stream | 252 streamOffset = getIndexOffsetInt(i) + REVLOGV1_RECORD_SIZE; // don't need to do seek as it's actual position in the index stream |
255 streamOffset = (int) offset; | 254 streamOffset = (int) offset; |
256 streamDataAccess = daData; | 255 streamDataAccess = daData; |
257 daData.seek(streamOffset); | 256 daData.seek(streamOffset); |
258 } | 257 } |
259 final boolean patchToPrevious = baseRevision != i; // the only way I found to tell if it's a patch | 258 final boolean patchToPrevious = baseRevision != i; // the only way I found to tell if it's a patch |
260 firstByte = streamDataAccess.readByte(); | 259 if (streamDataAccess.isEmpty()) { |
261 if (firstByte == 0x78 /* 'x' */) { | 260 userDataAccess = new DataAccess(); // empty |
262 userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, patchToPrevious ? -1 : actualLen); | |
263 } else if (firstByte == 0x75 /* 'u' */) { | |
264 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1); | |
265 } else { | 261 } else { |
266 // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0' | 262 final byte firstByte = streamDataAccess.readByte(); |
267 // but I don't see reason not to return data as is | 263 if (firstByte == 0x78 /* 'x' */) { |
268 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset, compressedLen); | 264 userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, patchToPrevious ? -1 : actualLen); |
265 } else if (firstByte == 0x75 /* 'u' */) { | |
266 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1); | |
267 } else { | |
268 // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0' | |
269 // but I don't see reason not to return data as is | |
270 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset, compressedLen); | |
271 } | |
269 } | 272 } |
270 // XXX | 273 // XXX |
271 if (patchToPrevious) { | 274 if (patchToPrevious) { |
272 // this is a patch | 275 // this is a patch |
273 LinkedList<PatchRecord> patches = new LinkedList<PatchRecord>(); | 276 LinkedList<PatchRecord> patches = new LinkedList<PatchRecord>(); |