Mercurial > hgsubversion
comparison tests/test_fetch_branches.py @ 1061:b8142bbf6656
test_fetch_branches: use stupid mode metaclass
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 09 Aug 2013 23:45:54 +0200 |
parents | 903c9c9dfe6a |
children | 791382a21cc4 |
comparison
equal
deleted
inserted
replaced
1060:7d82131e7801 | 1061:b8142bbf6656 |
---|---|
5 from mercurial import error | 5 from mercurial import error |
6 from mercurial import hg | 6 from mercurial import hg |
7 from mercurial import node | 7 from mercurial import node |
8 | 8 |
9 class TestFetchBranches(test_util.TestBase): | 9 class TestFetchBranches(test_util.TestBase): |
10 stupid_mode_tests = True | |
11 | |
10 def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor): | 12 def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor): |
11 repo_path = self.load_svndump(fixture_name) | 13 repo_path = self.load_svndump(fixture_name) |
12 source = '%s#%s' % (test_util.fileurl(repo_path), anchor) | 14 source = '%s#%s' % (test_util.fileurl(repo_path), anchor) |
13 test_util.hgclone(self.ui(), source, self.wc_path) | 15 test_util.hgclone(self.ui(), source, self.wc_path) |
14 return hg.repository(self.ui(), self.wc_path) | 16 return hg.repository(self.ui(), self.wc_path) |
22 return sorted(openbranches), sorted(closedbranches) | 24 return sorted(openbranches), sorted(closedbranches) |
23 | 25 |
24 def openbranches(self, repo): | 26 def openbranches(self, repo): |
25 return self.branches(repo)[0] | 27 return self.branches(repo)[0] |
26 | 28 |
27 def test_rename_branch_parent(self, stupid=False): | 29 def test_rename_branch_parent(self): |
28 repo = self._load_fixture_and_fetch('rename_branch_parent_dir.svndump', | 30 repo = self._load_fixture_and_fetch('rename_branch_parent_dir.svndump') |
29 stupid=stupid) | |
30 heads = [repo[n] for n in repo.heads()] | 31 heads = [repo[n] for n in repo.heads()] |
31 heads = dict([(ctx.branch(), ctx) for ctx in heads]) | 32 heads = dict([(ctx.branch(), ctx) for ctx in heads]) |
32 # Let these tests disabled yet as the fix is not obvious | 33 # Let these tests disabled yet as the fix is not obvious |
33 self.assertEqual(['dev_branch'], self.openbranches(repo)) | 34 self.assertEqual(['dev_branch'], self.openbranches(repo)) |
34 | 35 |
35 def test_rename_branch_parent_stupid(self): | 36 def test_unrelatedbranch(self): |
36 self.test_rename_branch_parent(stupid=True) | 37 repo = self._load_fixture_and_fetch('unrelatedbranch.svndump') |
37 | |
38 def test_unrelatedbranch(self, stupid=False): | |
39 repo = self._load_fixture_and_fetch('unrelatedbranch.svndump', | |
40 stupid=stupid) | |
41 heads = [repo[n] for n in repo.heads()] | 38 heads = [repo[n] for n in repo.heads()] |
42 heads = dict([(ctx.branch(), ctx) for ctx in heads]) | 39 heads = dict([(ctx.branch(), ctx) for ctx in heads]) |
43 # Let these tests disabled yet as the fix is not obvious | 40 # Let these tests disabled yet as the fix is not obvious |
44 self.assertEqual(heads['branch1'].manifest().keys(), ['b']) | 41 self.assertEqual(heads['branch1'].manifest().keys(), ['b']) |
45 self.assertEqual(heads['branch2'].manifest().keys(), ['a', 'b']) | 42 self.assertEqual(heads['branch2'].manifest().keys(), ['a', 'b']) |
46 | 43 |
47 def test_unrelatedbranch_stupid(self): | 44 def test_unorderedbranch(self): |
48 self.test_unrelatedbranch(True) | 45 repo = self._load_fixture_and_fetch('unorderedbranch.svndump') |
49 | |
50 def test_unorderedbranch(self, stupid=False): | |
51 repo = self._load_fixture_and_fetch('unorderedbranch.svndump', | |
52 stupid=stupid) | |
53 r = repo['branch'] | 46 r = repo['branch'] |
54 self.assertEqual(0, r.parents()[0].rev()) | 47 self.assertEqual(0, r.parents()[0].rev()) |
55 self.assertEqual(['a', 'c', 'z'], sorted(r.manifest())) | 48 self.assertEqual(['a', 'c', 'z'], sorted(r.manifest())) |
56 | 49 |
57 def test_unorderedbranch_stupid(self): | 50 def test_renamed_branch_to_trunk(self): |
58 self.test_unorderedbranch(True) | |
59 | |
60 def test_renamed_branch_to_trunk(self, stupid=False): | |
61 config = {'hgsubversion.failonmissing': 'true'} | 51 config = {'hgsubversion.failonmissing': 'true'} |
62 repo = self._load_fixture_and_fetch('branch_rename_to_trunk.svndump', | 52 repo = self._load_fixture_and_fetch('branch_rename_to_trunk.svndump', |
63 stupid=stupid, config=config) | 53 config=config) |
64 self.assertEqual(repo['default'].parents()[0].branch(), 'dev_branch') | 54 self.assertEqual(repo['default'].parents()[0].branch(), 'dev_branch') |
65 self.assert_('iota' in repo['default']) | 55 self.assert_('iota' in repo['default']) |
66 self.assertEqual(repo['old_trunk'].parents()[0].branch(), 'default') | 56 self.assertEqual(repo['old_trunk'].parents()[0].branch(), 'default') |
67 self.assert_('iota' not in repo['old_trunk']) | 57 self.assert_('iota' not in repo['old_trunk']) |
68 expected = ['default', 'old_trunk'] | 58 expected = ['default', 'old_trunk'] |
69 self.assertEqual(self.openbranches(repo), expected) | 59 self.assertEqual(self.openbranches(repo), expected) |
70 | 60 |
71 def test_renamed_branch_to_trunk_stupid(self): | 61 def test_replace_trunk_with_branch(self): |
72 self.test_renamed_branch_to_trunk(stupid=True) | 62 repo = self._load_fixture_and_fetch('replace_trunk_with_branch.svndump') |
73 | |
74 def test_replace_trunk_with_branch(self, stupid=False): | |
75 repo = self._load_fixture_and_fetch('replace_trunk_with_branch.svndump', | |
76 stupid=stupid) | |
77 self.assertEqual(repo['default'].parents()[0].branch(), 'test') | 63 self.assertEqual(repo['default'].parents()[0].branch(), 'test') |
78 self.assertEqual(repo['tip'].branch(), 'default') | 64 self.assertEqual(repo['tip'].branch(), 'default') |
79 self.assertEqual(repo['tip'].extra().get('close'), '1') | 65 self.assertEqual(repo['tip'].extra().get('close'), '1') |
80 self.assertEqual(self.openbranches(repo), ['default']) | 66 self.assertEqual(self.openbranches(repo), ['default']) |
81 | 67 |
82 def test_copybeforeclose(self, stupid=False): | 68 def test_copybeforeclose(self): |
83 repo = self._load_fixture_and_fetch('copybeforeclose.svndump', | 69 repo = self._load_fixture_and_fetch('copybeforeclose.svndump') |
84 stupid=stupid) | |
85 self.assertEqual(repo['tip'].branch(), 'test') | 70 self.assertEqual(repo['tip'].branch(), 'test') |
86 self.assertEqual(repo['test'].extra().get('close'), '1') | 71 self.assertEqual(repo['test'].extra().get('close'), '1') |
87 self.assertEqual(repo['test']['b'].data(), 'a\n') | 72 self.assertEqual(repo['test']['b'].data(), 'a\n') |
88 | 73 |
89 def test_copybeforeclose_stupid(self): | 74 def test_branch_create_with_dir_delete_works(self): |
90 self.test_copybeforeclose(True) | 75 repo = self._load_fixture_and_fetch('branch_create_with_dir_delete.svndump') |
91 | |
92 def test_replace_trunk_with_branch_stupid(self): | |
93 self.test_replace_trunk_with_branch(stupid=True) | |
94 | |
95 def test_branch_create_with_dir_delete_works(self, stupid=False): | |
96 repo = self._load_fixture_and_fetch('branch_create_with_dir_delete.svndump', | |
97 stupid=stupid) | |
98 self.assertEqual(repo['tip'].manifest().keys(), | 76 self.assertEqual(repo['tip'].manifest().keys(), |
99 ['alpha', 'beta', 'iota', 'gamma', ]) | 77 ['alpha', 'beta', 'iota', 'gamma', ]) |
100 | 78 |
101 def test_branch_tip_update_to_default(self, stupid=False): | 79 def test_branch_tip_update_to_default(self): |
102 repo = self._load_fixture_and_fetch('unorderedbranch.svndump', | 80 repo = self._load_fixture_and_fetch('unorderedbranch.svndump', |
103 stupid=stupid, noupdate=False) | 81 noupdate=False) |
104 self.assertEqual(repo[None].branch(), 'default') | 82 self.assertEqual(repo[None].branch(), 'default') |
105 self.assertTrue('tip' not in repo[None].tags()) | 83 self.assertTrue('tip' not in repo[None].tags()) |
106 | |
107 def test_branch_tip_update_to_default_stupid(self): | |
108 self.test_branch_tip_update_to_default(True) | |
109 | 84 |
110 def test_branch_pull_anchor(self): | 85 def test_branch_pull_anchor(self): |
111 self.assertRaises(error.RepoLookupError, | 86 self.assertRaises(error.RepoLookupError, |
112 self._load_fixture_and_fetch_with_anchor, | 87 self._load_fixture_and_fetch_with_anchor, |
113 'unorderedbranch.svndump', 'NaN') | 88 'unorderedbranch.svndump', 'NaN') |
114 repo = self._load_fixture_and_fetch_with_anchor( | 89 repo = self._load_fixture_and_fetch_with_anchor( |
115 'unorderedbranch.svndump', '4') | 90 'unorderedbranch.svndump', '4') |
116 self.assertTrue('c' not in repo.branchtags()) | 91 self.assertTrue('c' not in repo.branchtags()) |
117 | 92 |
118 def test_branches_weird_moves(self, stupid=False): | 93 def test_branches_weird_moves(self): |
119 repo = self._load_fixture_and_fetch('renamedproject.svndump', | 94 repo = self._load_fixture_and_fetch('renamedproject.svndump', |
120 stupid=stupid, | |
121 subdir='project') | 95 subdir='project') |
122 heads = [repo[n] for n in repo.heads()] | 96 heads = [repo[n] for n in repo.heads()] |
123 heads = dict((ctx.branch(), ctx) for ctx in heads) | 97 heads = dict((ctx.branch(), ctx) for ctx in heads) |
124 mdefault = sorted(heads['default'].manifest().keys()) | 98 mdefault = sorted(heads['default'].manifest().keys()) |
125 mbranch = sorted(heads['branch'].manifest().keys()) | 99 mbranch = sorted(heads['branch'].manifest().keys()) |
126 self.assertEqual(mdefault, ['a', 'b', 'd/a']) | 100 self.assertEqual(mdefault, ['a', 'b', 'd/a']) |
127 self.assertEqual(mbranch, ['a']) | 101 self.assertEqual(mbranch, ['a']) |
128 | 102 |
129 def test_branches_weird_moves_stupid(self): | 103 def test_branch_delete_parent_dir(self): |
130 self.test_branches_weird_moves(True) | 104 repo = self._load_fixture_and_fetch('branch_delete_parent_dir.svndump') |
131 | |
132 def test_branch_delete_parent_dir(self, stupid=False): | |
133 repo = self._load_fixture_and_fetch('branch_delete_parent_dir.svndump', | |
134 stupid=stupid) | |
135 openb, closedb = self.branches(repo) | 105 openb, closedb = self.branches(repo) |
136 self.assertEqual(openb, []) | 106 self.assertEqual(openb, []) |
137 self.assertEqual(closedb, ['dev_branch']) | 107 self.assertEqual(closedb, ['dev_branch']) |
138 self.assertEqual(list(repo['dev_branch']), ['foo']) | 108 self.assertEqual(list(repo['dev_branch']), ['foo']) |
139 | 109 |
140 def test_replace_branch_with_branch(self, stupid=False): | 110 def test_replace_branch_with_branch(self): |
141 repo = self._load_fixture_and_fetch('replace_branch_with_branch.svndump', | 111 repo = self._load_fixture_and_fetch('replace_branch_with_branch.svndump') |
142 stupid=stupid) | |
143 self.assertEqual(7, test_util.repolen(repo)) | 112 self.assertEqual(7, test_util.repolen(repo)) |
144 # tip is former topological branch1 being closed | 113 # tip is former topological branch1 being closed |
145 ctx = repo['tip'] | 114 ctx = repo['tip'] |
146 self.assertEqual('1', ctx.extra().get('close', '0')) | 115 self.assertEqual('1', ctx.extra().get('close', '0')) |
147 self.assertEqual('branch1', ctx.branch()) | 116 self.assertEqual('branch1', ctx.branch()) |
157 self.assertEqual('f\n', ctx['f'].data()) | 126 self.assertEqual('f\n', ctx['f'].data()) |
158 self.assertEqual('g\n', ctx['g'].data()) | 127 self.assertEqual('g\n', ctx['g'].data()) |
159 for f in ctx: | 128 for f in ctx: |
160 self.assertTrue(not ctx[f].renamed()) | 129 self.assertTrue(not ctx[f].renamed()) |
161 | 130 |
162 def test_replace_branch_with_branch_stupid(self, stupid=False): | |
163 self.test_replace_branch_with_branch(True) |