3r1co / hg4j

Automatically exported from code.google.com/p/hg4j
GNU General Public License v2.0
0 stars 1 forks source link

UnsupportedOperationException on repository with all files deleted #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If there's a repository with a history, and all files are deleted, status 
attempt fails with exception:

Apparently, manifest entry is legitimately empty (no files for the tip 
revision), but the code that parses manifest doesn't expect this.

Original issue reported on code.google.com by tikhomir...@gmail.com on 5 Jan 2012 at 8:28

GoogleCodeExporter commented 8 years ago
java.lang.UnsupportedOperationException
    at org.tmatesoft.hg.internal.DataAccess.readBytes(DataAccess.java:72)
    at org.tmatesoft.hg.internal.DataAccess.byteArray(DataAccess.java:99)
    at
org.tmatesoft.hg.repo.HgManifest$ManifestParser.next(HgManifest.java:331)
    at
org.tmatesoft.hg.internal.RevlogStream$ReaderN1.range(RevlogStream.java:505)
    at org.tmatesoft.hg.internal.RevlogStream.iterate(RevlogStream.java:203)
    at org.tmatesoft.hg.repo.HgManifest.walk(HgManifest.java:117)
    at
org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector.getManifest(HgWorkingCopyStat
usCollector.java:132)
    at
org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector.initDirstateParentManifest(Hg
WorkingCopyStatusCollector.java:143)
    at
org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector.walk(HgWorkingCopyStatusColle
ctor.java:163)

Original comment by tikhomir...@gmail.com on 5 Jan 2012 at 8:28

GoogleCodeExporter commented 8 years ago
Fixed, respect the case.
Tests: TestStatus#testOnEmptyRepositoryWithAllFilesDeleted()

Original comment by tikhomir...@gmail.com on 5 Jan 2012 at 8:43

GoogleCodeExporter commented 8 years ago
Similar exception when all files were deleted from a branch. Switching to 
default branch and back to the empty branch yields:

    at org.tmatesoft.hg.internal.DataAccess.seek(DataAccess.java:49)
    at org.tmatesoft.hg.internal.Patch.apply(Patch.java:120)
    at
org.tmatesoft.hg.internal.RevlogStream$ReaderN1.range(RevlogStream.java:493)
    at org.tmatesoft.hg.internal.RevlogStream.iterate(RevlogStream.java:203)
    at org.tmatesoft.hg.repo.HgManifest.walk(HgManifest.java:117)
    at
org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector.getManifest(HgWorkingCopyStat
usCollector.java:132)
    at
org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector.initDirstateParentManifest(Hg
WorkingCopyStatusCollector.java:143)
    at
org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector.walk(HgWorkingCopyStatusColle
ctor.java:163)

Original comment by tikhomir...@gmail.com on 20 Jan 2012 at 6:45

GoogleCodeExporter commented 8 years ago
This new issue can be reproduced on repositories with separate 00manifest.i and 
00manifest.d. To reproduce:  add a new branch, remove all files from the 
working directory and commit that removal.

Original comment by tikhomir...@gmail.com on 23 Jan 2012 at 3:58

GoogleCodeExporter commented 8 years ago
It turns out to be slightly more complicated to reproduce than outlined in the 
last comment. Manifest needs to have two subsequent empty entries - only the 
second of these two may have baseRevision not equal to the entry index (if 
content of base revision is not empty, content of revision that patches it 
would need to bear a patch. Empty patch is allowed to empty base revisions 
only). Hence, to reproduce:
a) make sure you've got separate .i and .d manifest files (either create huge 
repository or create them manually). You'll need at least one file in the repo.
b) commit a revision in a branch (it may be sole revision in this branch) that 
removes all the files
c) commit another revision, based on a revision with files, into another 
branch, again removing all the files.

After that, your manifest would look pretty much like the one I've added to 
TestStatus#testOnEmptyRepositoryWithAllFilesDeletedInBranch()
     0x1, inline: false
Index    Offset   Packed     Actual   Base Rev   Link Rev  Parent1  Parent2     
nodeid
0:          0      48         47          0          0       -1       -1     
a864...
1:         48       0          0          1          1        0       -1     
198b...
2:         48       0          0          1          2        1       -1     
7420...

Revision 1 and 2 here belong to different branches. Revision 1 can't have Base 
Revision other than 1 because manifest contents is empty (Mercurial doesn't 
patch list of files to get it empty). To reproduce the issue, we need a 
revision that would be empty and at the same time would attempt to patch 
another revision, hence Revision 2.

Original comment by tikhomir...@gmail.com on 2 Feb 2012 at 3:11

GoogleCodeExporter commented 8 years ago
Issue 26 tracks similar problem related to non-empty patch applied to empty 
base revision.

Original comment by tikhomir...@gmail.com on 22 Feb 2012 at 9:40