# HG changeset patch # User Artem Tikhomirov # Date 1328195779 -3600 # Node ID 86f049e6bcae74db26af9339a21fde01d30401fe # Parent d45ad07dc94c6c0f477e3141b9291eb5f692be5a Issue 22: Test for subsequent empty manifest entries case for separate .i and .d repository control files diff -r d45ad07dc94c -r 86f049e6bcae src/org/tmatesoft/hg/internal/RevlogStream.java --- a/src/org/tmatesoft/hg/internal/RevlogStream.java Thu Feb 02 16:10:50 2012 +0100 +++ b/src/org/tmatesoft/hg/internal/RevlogStream.java Thu Feb 02 16:16:19 2012 +0100 @@ -480,7 +480,7 @@ } } // XXX - if (patchToPrevious && !userDataAccess.isEmpty()) { + if (patchToPrevious && !userDataAccess.isEmpty() /* Issue 22, empty patch to an empty base revision*/) { // this is a patch patch.read(userDataAccess); userDataAccess.done(); diff -r d45ad07dc94c -r 86f049e6bcae test-data/test-repos.jar Binary file test-data/test-repos.jar has changed diff -r d45ad07dc94c -r 86f049e6bcae test/org/tmatesoft/hg/test/TestStatus.java --- a/test/org/tmatesoft/hg/test/TestStatus.java Thu Feb 02 16:10:50 2012 +0100 +++ b/test/org/tmatesoft/hg/test/TestStatus.java Thu Feb 02 16:16:19 2012 +0100 @@ -475,6 +475,46 @@ } } + /** + * Issue 22, two subsequent commits that remove all repository files, each in a different branch. + * Here's excerpt from my RevlogWriter utility: + *
+	 * 		final List filesList = Collections.singletonList("file1");
+	 *	//
+	 *	file1.writeUncompressed(-1, -1, 0, 0, "garbage".getBytes());
+	 *	//
+	 *	ManifestBuilder mb = new ManifestBuilder();
+	 *	mb.reset().add("file1", file1.getRevision(0));
+	 *	manifest.writeUncompressed(-1, -1, 0, 0, mb.build()); // manifest revision 0
+	 *	final byte[] cset1 = buildChangelogEntry(manifest.getRevision(0), Collections.emptyMap(), filesList, "Add a file");
+	 *	changelog.writeUncompressed(-1, -1, 0, 0, cset1);
+	 *	//
+	 *	// pretend we delete all files in a branch 1
+	 *	manifest.writeUncompressed(0, -1, 1, 1, new byte[0]); // manifest revision 1
+	 *	final byte[] cset2 = buildChangelogEntry(manifest.getRevision(1), Collections.singletonMap("branch", "delete-all-1"), filesList, "Delete all files in a first branch");
+	 *	 changelog.writeUncompressed(0, -1, 1, 1, cset2);
+	 *	//
+	 *	// pretend we delete all files in a branch 2 (which is based on revision 0, same as branch 1)
+	 *	manifest.writeUncompressed(1, -1, 1 /*!!! here comes baseRevision != index * /, 2, new byte[0]); // manifest revision 2
+	 *	final byte[] cset3 = buildChangelogEntry(manifest.getRevision(2), Collections.singletonMap("branch", "delete-all-2"), filesList, "Again delete all files but in another branch");
+	 *	changelog.writeUncompressed(0, -1, 2, 2, cset3);
+	 * 
+ */ + @Test + public void testOnEmptyRepositoryWithAllFilesDeletedInBranch() throws Exception { + repo = Configuration.get().find("status-3"); + HgStatusCommand cmd = new HgStatusCommand(repo); + cmd.all(); + StatusCollector sc = new StatusCollector(); + cmd.execute(sc); + // shall pass without exception + assertTrue(sc.getErrors().isEmpty()); + for (HgStatus.Kind k : HgStatus.Kind.values()) { + assertTrue("Kind " + k.name() + " shall be empty",sc.get(k).isEmpty()); + } + } + + /* * With warm-up of previous tests, 10 runs, time in milliseconds * 'hg status -A': Native client total 953 (95 per run), Java client 94 (9)