Mercurial > hg4j
diff test/org/tmatesoft/hg/test/TestBranches.java @ 315:8952f89be195
Allow to query specific branch heads if they are closed
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 28 Sep 2011 12:18:21 +0200 |
parents | 962f78aac342 |
children |
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestBranches.java Tue Sep 27 06:34:54 2011 +0200 +++ b/test/org/tmatesoft/hg/test/TestBranches.java Wed Sep 28 12:18:21 2011 +0200 @@ -18,14 +18,22 @@ import static org.junit.Assert.*; -import org.junit.Assert; import org.junit.Test; +import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.repo.HgBranches; import org.tmatesoft.hg.repo.HgBranches.BranchInfo; import org.tmatesoft.hg.repo.HgRepository; /** - * + * <pre> + * branches-1/create.bat: + * branch1 to have fork, two heads, both closed -- shall be recognized as closed + * branch2 to have fork, two heads, one closed -- shall be recognized as active + * branch3 no active head -- shall be recognized as inactive + * branch4 to fork, with 1 inactive and 1 active heads + * branch5 to be closed and reopened + * </pre> + * * @author Artem Tikhomirov * @author TMate Software Ltd. */ @@ -69,4 +77,31 @@ assertEquals(1, b5.getHeads().size()); assertEquals("9cb6ad32b9074021356c38050e2aab6addba4393", b5.getHeads().get(0).toString()); } + + @Test + public void testBranchInfoClosedHeads() throws Exception{ + HgRepository repo = Configuration.get().find("branches-1"); + HgBranches branches = repo.getBranches(); + // branch1 - two closed heads + BranchInfo b1 = branches.getBranch("branch1"); + assertTrue(b1.isClosed(b1.getHeads().get(0))); + assertTrue(b1.isClosed(b1.getHeads().get(1))); + try { + b1.isClosed(Nodeid.fromAscii("9cb6ad32b9074021356c38050e2aab6addba4393")); + fail("Revision that doesn't belong to heads of the branch shall not be handled"); + } catch (IllegalArgumentException ex) { + // good + } + // + // branch2, one closed head + BranchInfo b2 = branches.getBranch("branch2"); + assertFalse(b2.isClosed(b2.getHeads().get(0))); + assertTrue(b2.isClosed(b2.getHeads().get(1))); + // + // branch5, closed and reopened, 1 open head + BranchInfo b5 = branches.getBranch("branch5"); + for (Nodeid h : b5.getHeads()) { + assertFalse(b5.isClosed(h)); + } + } }