Mercurial > hg4j
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 314:fb74133d2025 | 315:8952f89be195 |
|---|---|
| 16 */ | 16 */ |
| 17 package org.tmatesoft.hg.test; | 17 package org.tmatesoft.hg.test; |
| 18 | 18 |
| 19 import static org.junit.Assert.*; | 19 import static org.junit.Assert.*; |
| 20 | 20 |
| 21 import org.junit.Assert; | |
| 22 import org.junit.Test; | 21 import org.junit.Test; |
| 22 import org.tmatesoft.hg.core.Nodeid; | |
| 23 import org.tmatesoft.hg.repo.HgBranches; | 23 import org.tmatesoft.hg.repo.HgBranches; |
| 24 import org.tmatesoft.hg.repo.HgBranches.BranchInfo; | 24 import org.tmatesoft.hg.repo.HgBranches.BranchInfo; |
| 25 import org.tmatesoft.hg.repo.HgRepository; | 25 import org.tmatesoft.hg.repo.HgRepository; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * | 28 * <pre> |
| 29 * branches-1/create.bat: | |
| 30 * branch1 to have fork, two heads, both closed -- shall be recognized as closed | |
| 31 * branch2 to have fork, two heads, one closed -- shall be recognized as active | |
| 32 * branch3 no active head -- shall be recognized as inactive | |
| 33 * branch4 to fork, with 1 inactive and 1 active heads | |
| 34 * branch5 to be closed and reopened | |
| 35 * </pre> | |
| 36 * | |
| 29 * @author Artem Tikhomirov | 37 * @author Artem Tikhomirov |
| 30 * @author TMate Software Ltd. | 38 * @author TMate Software Ltd. |
| 31 */ | 39 */ |
| 32 public class TestBranches { | 40 public class TestBranches { |
| 33 | 41 |
| 67 assertNotNull(b5); | 75 assertNotNull(b5); |
| 68 assertFalse(b5.isClosed()); | 76 assertFalse(b5.isClosed()); |
| 69 assertEquals(1, b5.getHeads().size()); | 77 assertEquals(1, b5.getHeads().size()); |
| 70 assertEquals("9cb6ad32b9074021356c38050e2aab6addba4393", b5.getHeads().get(0).toString()); | 78 assertEquals("9cb6ad32b9074021356c38050e2aab6addba4393", b5.getHeads().get(0).toString()); |
| 71 } | 79 } |
| 80 | |
| 81 @Test | |
| 82 public void testBranchInfoClosedHeads() throws Exception{ | |
| 83 HgRepository repo = Configuration.get().find("branches-1"); | |
| 84 HgBranches branches = repo.getBranches(); | |
| 85 // branch1 - two closed heads | |
| 86 BranchInfo b1 = branches.getBranch("branch1"); | |
| 87 assertTrue(b1.isClosed(b1.getHeads().get(0))); | |
| 88 assertTrue(b1.isClosed(b1.getHeads().get(1))); | |
| 89 try { | |
| 90 b1.isClosed(Nodeid.fromAscii("9cb6ad32b9074021356c38050e2aab6addba4393")); | |
| 91 fail("Revision that doesn't belong to heads of the branch shall not be handled"); | |
| 92 } catch (IllegalArgumentException ex) { | |
| 93 // good | |
| 94 } | |
| 95 // | |
| 96 // branch2, one closed head | |
| 97 BranchInfo b2 = branches.getBranch("branch2"); | |
| 98 assertFalse(b2.isClosed(b2.getHeads().get(0))); | |
| 99 assertTrue(b2.isClosed(b2.getHeads().get(1))); | |
| 100 // | |
| 101 // branch5, closed and reopened, 1 open head | |
| 102 BranchInfo b5 = branches.getBranch("branch5"); | |
| 103 for (Nodeid h : b5.getHeads()) { | |
| 104 assertFalse(b5.isClosed(h)); | |
| 105 } | |
| 106 } | |
| 72 } | 107 } |
