comparison test/org/tmatesoft/hg/test/TestBranches.java @ 308:3f40262153a4

Recognize closed branches
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 24 Sep 2011 07:29:05 +0200
parents
children 962f78aac342
comparison
equal deleted inserted replaced
307:2f2ab5c27f41 308:3f40262153a4
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.test;
18
19 import static org.junit.Assert.*;
20
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.tmatesoft.hg.repo.HgBranches;
24 import org.tmatesoft.hg.repo.HgBranches.BranchInfo;
25 import org.tmatesoft.hg.repo.HgRepository;
26
27 /**
28 *
29 * @author Artem Tikhomirov
30 * @author TMate Software Ltd.
31 */
32 public class TestBranches {
33
34 @Test
35 public void testClosedInactiveBranches() throws Exception {
36 HgRepository repo = Configuration.get().find("branches-1");
37 HgBranches branches = repo.getBranches();
38 BranchInfo b1 = branches.getBranch("branch1");
39 assertNotNull(b1);
40 assertTrue(b1.isClosed());
41 assertEquals(2, b1.getHeads().size());
42 // order is important!
43 assertEquals("131e84b878d25b5eab7f529ebb35e57b2a439db7", b1.getHeads().get(0).toString());
44 assertEquals("c993cda1f5a7afd771efa87fe95fb7c5f73169e6", b1.getHeads().get(1).toString());
45 //
46 BranchInfo b2 = branches.getBranch("branch2");
47 assertNotNull(b2);
48 assertFalse(b2.isClosed());
49 assertEquals(2, b2.getHeads().size());
50 assertEquals("537f548adfd7eb9ce2a73ed7e7ca163eb1b61401", b2.getHeads().get(0).toString());
51 assertEquals("e698babd9479b1c07e0ed3155f5e290ee15affed", b2.getHeads().get(1).toString());
52 //
53 BranchInfo b3 = branches.getBranch("branch3");
54 assertNotNull(b3);
55 assertFalse(b3.isClosed());
56 assertEquals(1, b3.getHeads().size());
57 assertEquals("b103f33723f37c7bb4b81d74a66135d6fdaf0ced", b3.getHeads().get(0).toString());
58 //
59 BranchInfo b4 = branches.getBranch("branch4");
60 assertNotNull(b4);
61 assertFalse(b4.isClosed());
62 // assertEquals(2, b4.getHeads().size());
63 assertEquals("fceabd402f0193fb30605aed0ee3a9d5feb99f60", b4.getHeads().get(0).toString());
64 // FIXME second branch is not present when HgBranches builds cache itself!!!
65 // assertEquals("892b6a504be7835f1748ba632fe15a9389d4479b", b4.getHeads().get(1).toString());
66 //
67 BranchInfo b5 = branches.getBranch("branch5");
68 assertNotNull(b5);
69 assertFalse(b5.isClosed());
70 assertEquals(1, b5.getHeads().size());
71 assertEquals("9cb6ad32b9074021356c38050e2aab6addba4393", b5.getHeads().get(0).toString());
72 }
73 }