Mercurial > jhg
changeset 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 | 373e07cd3991 |
children | 7fe5982bcac0 |
files | src/org/tmatesoft/hg/internal/RevlogStream.java |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/RevlogStream.java Thu May 19 05:02:07 2011 +0200 +++ b/src/org/tmatesoft/hg/internal/RevlogStream.java Mon May 23 04:42:12 2011 +0200 @@ -245,7 +245,6 @@ daIndex.skip(12); DataAccess userDataAccess = null; if (needData) { - final byte firstByte; int streamOffset; DataAccess streamDataAccess; if (inline) { @@ -257,15 +256,19 @@ daData.seek(streamOffset); } final boolean patchToPrevious = baseRevision != i; // the only way I found to tell if it's a patch - firstByte = streamDataAccess.readByte(); - if (firstByte == 0x78 /* 'x' */) { - userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, patchToPrevious ? -1 : actualLen); - } else if (firstByte == 0x75 /* 'u' */) { - userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1); + if (streamDataAccess.isEmpty()) { + userDataAccess = new DataAccess(); // empty } else { - // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0' - // but I don't see reason not to return data as is - userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset, compressedLen); + final byte firstByte = streamDataAccess.readByte(); + if (firstByte == 0x78 /* 'x' */) { + userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, patchToPrevious ? -1 : actualLen); + } else if (firstByte == 0x75 /* 'u' */) { + userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1); + } else { + // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0' + // but I don't see reason not to return data as is + userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset, compressedLen); + } } // XXX if (patchToPrevious) {