comparison test/org/tmatesoft/hg/test/TestStatus.java @ 377:86f049e6bcae

Issue 22: Test for subsequent empty manifest entries case for separate .i and .d repository control files
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 02 Feb 2012 16:16:19 +0100
parents 155c1893bda4
children cdea37239b01
comparison
equal deleted inserted replaced
376:d45ad07dc94c 377:86f049e6bcae
473 for (HgStatus.Kind k : HgStatus.Kind.values()) { 473 for (HgStatus.Kind k : HgStatus.Kind.values()) {
474 assertTrue("Kind " + k.name() + " shall be empty",sc.get(k).isEmpty()); 474 assertTrue("Kind " + k.name() + " shall be empty",sc.get(k).isEmpty());
475 } 475 }
476 } 476 }
477 477
478 /**
479 * Issue 22, two subsequent commits that remove all repository files, each in a different branch.
480 * Here's excerpt from my RevlogWriter utility:
481 * <pre>
482 * final List<String> filesList = Collections.singletonList("file1");
483 * //
484 * file1.writeUncompressed(-1, -1, 0, 0, "garbage".getBytes());
485 * //
486 * ManifestBuilder mb = new ManifestBuilder();
487 * mb.reset().add("file1", file1.getRevision(0));
488 * manifest.writeUncompressed(-1, -1, 0, 0, mb.build()); // manifest revision 0
489 * final byte[] cset1 = buildChangelogEntry(manifest.getRevision(0), Collections.<String, String>emptyMap(), filesList, "Add a file");
490 * changelog.writeUncompressed(-1, -1, 0, 0, cset1);
491 * //
492 * // pretend we delete all files in a branch 1
493 * manifest.writeUncompressed(0, -1, 1, 1, new byte[0]); // manifest revision 1
494 * final byte[] cset2 = buildChangelogEntry(manifest.getRevision(1), Collections.singletonMap("branch", "delete-all-1"), filesList, "Delete all files in a first branch");
495 * changelog.writeUncompressed(0, -1, 1, 1, cset2);
496 * //
497 * // pretend we delete all files in a branch 2 (which is based on revision 0, same as branch 1)
498 * manifest.writeUncompressed(1, -1, 1 /*!!! here comes baseRevision != index * /, 2, new byte[0]); // manifest revision 2
499 * final byte[] cset3 = buildChangelogEntry(manifest.getRevision(2), Collections.singletonMap("branch", "delete-all-2"), filesList, "Again delete all files but in another branch");
500 * changelog.writeUncompressed(0, -1, 2, 2, cset3);
501 * </pre>
502 */
503 @Test
504 public void testOnEmptyRepositoryWithAllFilesDeletedInBranch() throws Exception {
505 repo = Configuration.get().find("status-3");
506 HgStatusCommand cmd = new HgStatusCommand(repo);
507 cmd.all();
508 StatusCollector sc = new StatusCollector();
509 cmd.execute(sc);
510 // shall pass without exception
511 assertTrue(sc.getErrors().isEmpty());
512 for (HgStatus.Kind k : HgStatus.Kind.values()) {
513 assertTrue("Kind " + k.name() + " shall be empty",sc.get(k).isEmpty());
514 }
515 }
516
517
478 /* 518 /*
479 * With warm-up of previous tests, 10 runs, time in milliseconds 519 * With warm-up of previous tests, 10 runs, time in milliseconds
480 * 'hg status -A': Native client total 953 (95 per run), Java client 94 (9) 520 * 'hg status -A': Native client total 953 (95 per run), Java client 94 (9)
481 * 'hg status -A --rev 3:80': Native client total 1828 (182 per run), Java client 235 (23) 521 * 'hg status -A --rev 3:80': Native client total 1828 (182 per run), Java client 235 (23)
482 * 'hg log --debug', 10 runs: Native client total 1766 (176 per run), Java client 78 (7) 522 * 'hg log --debug', 10 runs: Native client total 1766 (176 per run), Java client 78 (7)