Mercurial > hgsubversion
comparison tests/test_fetch_command.py @ 1062:36a5fa6420a0
test_fetch_command: use stupid mode metaclass
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 09 Aug 2013 23:45:54 +0200 |
parents | c41e993f0892 |
children | ca36d5915dc7 |
comparison
equal
deleted
inserted
replaced
1061:b8142bbf6656 | 1062:36a5fa6420a0 |
---|---|
9 from mercurial import node | 9 from mercurial import node |
10 from mercurial import ui | 10 from mercurial import ui |
11 from mercurial import encoding | 11 from mercurial import encoding |
12 | 12 |
13 class TestBasicRepoLayout(test_util.TestBase): | 13 class TestBasicRepoLayout(test_util.TestBase): |
14 stupid_mode_tests = True | |
14 | 15 |
15 def test_no_dates(self): | 16 def test_no_dates(self): |
16 repo = self._load_fixture_and_fetch('test_no_dates.svndump') | 17 repo = self._load_fixture_and_fetch('test_no_dates.svndump') |
17 local_epoch = repo[0].date() | 18 local_epoch = repo[0].date() |
18 self.assertEqual(local_epoch[0], local_epoch[1]) | 19 self.assertEqual(local_epoch[0], local_epoch[1]) |
60 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') | 61 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') |
61 self.assertEqual(len(repo['tip'].parents()), 1) | 62 self.assertEqual(len(repo['tip'].parents()), 1) |
62 self.assertEqual(repo['tip'], repo['default']) | 63 self.assertEqual(repo['tip'], repo['default']) |
63 self.assertEqual(len(repo.heads()), 2) | 64 self.assertEqual(len(repo.heads()), 2) |
64 | 65 |
65 def test_many_special_cases_replay(self): | 66 def test_many_special_cases(self): |
66 repo = self._load_fixture_and_fetch('many_special_cases.svndump') | 67 repo = self._load_fixture_and_fetch('many_special_cases.svndump') |
67 self._many_special_cases_checks(repo) | 68 |
68 | |
69 | |
70 def test_many_special_cases_diff(self): | |
71 repo = self._load_fixture_and_fetch('many_special_cases.svndump', | |
72 stupid=True) | |
73 self._many_special_cases_checks(repo) | |
74 | |
75 def _many_special_cases_checks(self, repo): | |
76 self.assertEquals(node.hex(repo[0].node()), | 69 self.assertEquals(node.hex(repo[0].node()), |
77 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') | 70 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') |
78 # two possible hashes for bw compat to hg < 1.5, since hg 1.5 | 71 # two possible hashes for bw compat to hg < 1.5, since hg 1.5 |
79 # sorts entries in extra() | 72 # sorts entries in extra() |
80 self.assertTrue(node.hex(repo['tip'].node()) in | 73 self.assertTrue(node.hex(repo['tip'].node()) in |
93 self.assertEqual(node.hex(repo['default'].node()), | 86 self.assertEqual(node.hex(repo['default'].node()), |
94 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') | 87 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') |
95 assert 'README' not in repo | 88 assert 'README' not in repo |
96 assert '../branches' not in repo | 89 assert '../branches' not in repo |
97 | 90 |
98 def test_files_copied_from_outside_btt(self, stupid=False): | 91 def test_files_copied_from_outside_btt(self): |
99 repo = self._load_fixture_and_fetch( | 92 repo = self._load_fixture_and_fetch( |
100 'test_files_copied_from_outside_btt.svndump', stupid=stupid) | 93 'test_files_copied_from_outside_btt.svndump') |
101 self.assertEqual(node.hex(repo['tip'].node()), | 94 self.assertEqual(node.hex(repo['tip'].node()), |
102 '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') | 95 '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') |
103 self.assertEqual(test_util.repolen(repo.changelog), 2) | 96 self.assertEqual(test_util.repolen(repo.changelog), 2) |
104 | |
105 def test_files_copied_from_outside_btt_stupid(self): | |
106 self.test_files_copied_from_outside_btt(stupid=True) | |
107 | 97 |
108 def test_file_renamed_in_from_outside_btt(self): | 98 def test_file_renamed_in_from_outside_btt(self): |
109 repo = self._load_fixture_and_fetch( | 99 repo = self._load_fixture_and_fetch( |
110 'file_renamed_in_from_outside_btt.svndump') | 100 'file_renamed_in_from_outside_btt.svndump') |
111 self.assert_('LICENSE.file' in repo['default']) | 101 self.assert_('LICENSE.file' in repo['default']) |
128 self.assertEqual(repo['tip'].parents()[0].parents()[0], | 118 self.assertEqual(repo['tip'].parents()[0].parents()[0], |
129 repo['oldest']) | 119 repo['oldest']) |
130 self.assertEqual(node.hex(repo['tip'].node()), | 120 self.assertEqual(node.hex(repo['tip'].node()), |
131 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') | 121 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') |
132 | 122 |
133 def test_propedit_with_nothing_else(self, stupid=False): | 123 def test_propedit_with_nothing_else(self): |
134 repo = self._load_fixture_and_fetch('branch_prop_edit.svndump', | 124 repo = self._load_fixture_and_fetch('branch_prop_edit.svndump') |
135 stupid=stupid) | |
136 self.assertEqual(repo['tip'].description(), 'Commit bogus propchange.') | 125 self.assertEqual(repo['tip'].description(), 'Commit bogus propchange.') |
137 self.assertEqual(repo['tip'].branch(), 'dev_branch') | 126 self.assertEqual(repo['tip'].branch(), 'dev_branch') |
138 | 127 |
139 def test_propedit_with_nothing_else_stupid(self): | 128 def test_entry_deletion(self): |
140 self.test_propedit_with_nothing_else(stupid=True) | 129 repo = self._load_fixture_and_fetch('delentries.svndump') |
141 | |
142 def test_entry_deletion(self, stupid=False): | |
143 repo = self._load_fixture_and_fetch('delentries.svndump', | |
144 stupid=stupid) | |
145 files = list(sorted(repo['tip'].manifest())) | 130 files = list(sorted(repo['tip'].manifest())) |
146 self.assertEqual(['aa', 'd1/c', 'd1/d2prefix'], files) | 131 self.assertEqual(['aa', 'd1/c', 'd1/d2prefix'], files) |
147 | 132 |
148 def test_entry_deletion_stupid(self): | 133 def test_fetch_when_trunk_has_no_files(self): |
149 self.test_entry_deletion(stupid=True) | 134 repo = self._load_fixture_and_fetch('file_not_in_trunk_root.svndump') |
150 | |
151 def test_fetch_when_trunk_has_no_files(self, stupid=False): | |
152 repo = self._load_fixture_and_fetch('file_not_in_trunk_root.svndump', stupid=stupid) | |
153 self.assertEqual(repo['tip'].branch(), 'default') | 135 self.assertEqual(repo['tip'].branch(), 'default') |
154 | 136 |
155 def test_fetch_when_trunk_has_no_files_stupid(self): | 137 def test_path_quoting(self): |
156 self.test_fetch_when_trunk_has_no_files(stupid=True) | |
157 | |
158 def test_path_quoting(self, stupid=False): | |
159 repo_path = self.load_svndump('non_ascii_path_1.svndump') | 138 repo_path = self.load_svndump('non_ascii_path_1.svndump') |
160 subdir = '/b\xC3\xB8b' | 139 subdir = '/b\xC3\xB8b' |
161 quoted_subdir = urllib.quote(subdir) | 140 quoted_subdir = urllib.quote(subdir) |
162 | 141 |
163 repo_url = test_util.fileurl(repo_path) | 142 repo_url = test_util.fileurl(repo_path) |
164 wc_path = self.wc_path | 143 wc_path = self.wc_path |
165 wc2_path = wc_path + '-2' | 144 wc2_path = wc_path + '-2' |
166 | 145 |
167 ui = self.ui(stupid=stupid) | 146 ui = self.ui() |
168 | 147 |
169 commands.clone(ui, repo_url + subdir, wc_path) | 148 commands.clone(ui, repo_url + subdir, wc_path) |
170 commands.clone(ui, repo_url + quoted_subdir, wc2_path) | 149 commands.clone(ui, repo_url + quoted_subdir, wc2_path) |
171 repo = hg.repository(ui, wc_path) | 150 repo = hg.repository(ui, wc_path) |
172 repo2 = hg.repository(ui, wc2_path) | 151 repo2 = hg.repository(ui, wc2_path) |
175 repo2['tip'].extra()['convert_revision']) | 154 repo2['tip'].extra()['convert_revision']) |
176 self.assertEqual(test_util.repolen(repo), test_util.repolen(repo2)) | 155 self.assertEqual(test_util.repolen(repo), test_util.repolen(repo2)) |
177 | 156 |
178 for r in repo: | 157 for r in repo: |
179 self.assertEqual(repo[r].hex(), repo2[r].hex()) | 158 self.assertEqual(repo[r].hex(), repo2[r].hex()) |
180 | |
181 def test_path_quoting_stupid(self): | |
182 repo = self.test_path_quoting(True) | |
183 | |
184 | 159 |
185 def test_identical_fixtures(self): | 160 def test_identical_fixtures(self): |
186 '''ensure that the non_ascii_path_N fixtures are identical''' | 161 '''ensure that the non_ascii_path_N fixtures are identical''' |
187 fixturepaths = [ | 162 fixturepaths = [ |
188 os.path.join(test_util.FIXTURES, 'non_ascii_path_1.svndump'), | 163 os.path.join(test_util.FIXTURES, 'non_ascii_path_1.svndump'), |
189 os.path.join(test_util.FIXTURES, 'non_ascii_path_2.svndump'), | 164 os.path.join(test_util.FIXTURES, 'non_ascii_path_2.svndump'), |
190 ] | 165 ] |
191 self.assertMultiLineEqual(open(fixturepaths[0]).read(), | 166 self.assertMultiLineEqual(open(fixturepaths[0]).read(), |
192 open(fixturepaths[1]).read()) | 167 open(fixturepaths[1]).read()) |
193 | 168 |
194 def test_invalid_message(self, stupid=False): | 169 def test_invalid_message(self): |
195 repo = self._load_fixture_and_fetch('invalid_utf8.tar.gz', stupid=stupid) | 170 repo = self._load_fixture_and_fetch('invalid_utf8.tar.gz') |
196 # changelog returns descriptions in local encoding | 171 # changelog returns descriptions in local encoding |
197 desc = encoding.fromlocal(repo[0].description()) | 172 desc = encoding.fromlocal(repo[0].description()) |
198 self.assertEqual(desc.decode('utf8'), | 173 self.assertEqual(desc.decode('utf8'), |
199 u'bl\xe5b\xe6rgr\xf8d') | 174 u'bl\xe5b\xe6rgr\xf8d') |
200 | 175 |
201 def test_invalid_message_stupid(self): | |
202 self.test_invalid_message(True) | |
203 | |
204 | 176 |
205 class TestStupidPull(test_util.TestBase): | 177 class TestStupidPull(test_util.TestBase): |
178 stupid_mode_tests = True | |
179 | |
206 def test_stupid(self): | 180 def test_stupid(self): |
207 repo = self._load_fixture_and_fetch('two_heads.svndump', stupid=True) | 181 repo = self._load_fixture_and_fetch('two_heads.svndump') |
208 self.assertEqual(node.hex(repo[0].node()), | 182 self.assertEqual(node.hex(repo[0].node()), |
209 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') | 183 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') |
210 self.assertEqual(node.hex(repo['tip'].node()), | 184 self.assertEqual(node.hex(repo['tip'].node()), |
211 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') | 185 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') |
212 self.assertEqual(node.hex(repo['the_branch'].node()), | 186 self.assertEqual(node.hex(repo['the_branch'].node()), |
221 self.assertEqual(repo['tip'], repo['default']) | 195 self.assertEqual(repo['tip'], repo['default']) |
222 self.assertEqual(len(repo.heads()), 2) | 196 self.assertEqual(len(repo.heads()), 2) |
223 | 197 |
224 def test_oldest_not_trunk_and_tag_vendor_branch(self): | 198 def test_oldest_not_trunk_and_tag_vendor_branch(self): |
225 repo = self._load_fixture_and_fetch( | 199 repo = self._load_fixture_and_fetch( |
226 'tagged_vendor_and_oldest_not_trunk.svndump', | 200 'tagged_vendor_and_oldest_not_trunk.svndump') |
227 stupid=True) | |
228 self.assertEqual(node.hex(repo['oldest'].node()), | 201 self.assertEqual(node.hex(repo['oldest'].node()), |
229 '926671740dec045077ab20f110c1595f935334fa') | 202 '926671740dec045077ab20f110c1595f935334fa') |
230 self.assertEqual(repo['tip'].parents()[0].parents()[0], | 203 self.assertEqual(repo['tip'].parents()[0].parents()[0], |
231 repo['oldest']) | 204 repo['oldest']) |
232 self.assertEqual(node.hex(repo['tip'].node()), | 205 self.assertEqual(node.hex(repo['tip'].node()), |
233 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') | 206 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') |
234 | 207 |
235 def test_empty_repo(self, stupid=False): | 208 def test_empty_repo(self): |
236 # This used to crash HgEditor because it could be closed without | 209 # This used to crash HgEditor because it could be closed without |
237 # having been initialized again. | 210 # having been initialized again. |
238 self._load_fixture_and_fetch('emptyrepo2.svndump', stupid=stupid) | 211 self._load_fixture_and_fetch('emptyrepo2.svndump') |
239 | 212 |
240 def test_empty_repo_stupid(self): | 213 def test_fetch_revert(self): |
241 self.test_empty_repo(stupid=True) | 214 repo = self._load_fixture_and_fetch('revert.svndump') |
242 | |
243 def test_fetch_revert(self, stupid=False): | |
244 repo = self._load_fixture_and_fetch('revert.svndump', stupid=stupid) | |
245 graph = self.getgraph(repo) | 215 graph = self.getgraph(repo) |
246 refgraph = """\ | 216 refgraph = """\ |
247 o changeset: 3:937dcd1206d4 | 217 o changeset: 3:937dcd1206d4 |
248 | branch: | 218 | branch: |
249 | tags: tip | 219 | tags: tip |
269 files: a dir/b | 239 files: a dir/b |
270 | 240 |
271 """ | 241 """ |
272 self.assertMultiLineEqual(refgraph, graph) | 242 self.assertMultiLineEqual(refgraph, graph) |
273 | 243 |
274 def test_fetch_revert_stupid(self): | 244 def test_fetch_movetotrunk(self): |
275 self.test_fetch_revert(stupid=True) | |
276 | |
277 def test_fetch_movetotrunk(self, stupid=False): | |
278 repo = self._load_fixture_and_fetch('movetotrunk.svndump', | 245 repo = self._load_fixture_and_fetch('movetotrunk.svndump', |
279 stupid=stupid, subdir='sub1/sub2') | 246 subdir='sub1/sub2') |
280 graph = self.getgraph(repo) | 247 graph = self.getgraph(repo) |
281 refgraph = """\ | 248 refgraph = """\ |
282 o changeset: 0:02996a5980ba | 249 o changeset: 0:02996a5980ba |
283 branch: | 250 branch: |
284 tags: tip | 251 tags: tip |
286 files: a dir/b | 253 files: a dir/b |
287 | 254 |
288 """ | 255 """ |
289 self.assertMultiLineEqual(refgraph, graph) | 256 self.assertMultiLineEqual(refgraph, graph) |
290 | 257 |
291 def test_fetch_movetotrunk_stupid(self): | |
292 self.test_fetch_movetotrunk(stupid=True) |