# HG changeset patch # User Artem Tikhomirov # Date 1306118532 -7200 # Node ID 80a3433ace9143e641b3eecdb37dc18965a4b145 # Parent 373e07cd39914c3cdbe0d9a57c61472bed3ecfda HgBadStateException (IOException from FileAccess) on isCopy for empty data file diff -r 373e07cd3991 -r 80a3433ace91 src/org/tmatesoft/hg/internal/RevlogStream.java --- 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) {