Mercurial > hgsubversion
comparison tests/test_utility_commands.py @ 1106:5cb6c95e0283 stable
Merge default and stable so I can do stable releases again.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Tue, 11 Feb 2014 12:48:49 -0500 |
parents | cd0d14e25757 |
children | e73df57b2b07 |
comparison
equal
deleted
inserted
replaced
1020:b5b1fce26f1f | 1106:5cb6c95e0283 |
---|---|
29 | 29 |
30 def repourl(repo_path): | 30 def repourl(repo_path): |
31 return util.normalize_url(test_util.fileurl(repo_path)) | 31 return util.normalize_url(test_util.fileurl(repo_path)) |
32 | 32 |
33 class UtilityTests(test_util.TestBase): | 33 class UtilityTests(test_util.TestBase): |
34 def test_info_output(self): | 34 stupid_mode_tests = True |
35 repo, repo_path = self.load_and_fetch('two_heads.svndump') | 35 |
36 def test_info_output(self, custom=False): | |
37 if custom: | |
38 config = { | |
39 'hgsubversionbranch.default': 'trunk', | |
40 'hgsubversionbranch.the_branch': 'branches/the_branch', | |
41 } | |
42 else: | |
43 config = {} | |
44 repo, repo_path = self.load_and_fetch('two_heads.svndump', config=config) | |
36 hg.update(self.repo, 'the_branch') | 45 hg.update(self.repo, 'the_branch') |
37 u = self.ui() | 46 u = self.ui() |
38 u.pushbuffer() | 47 u.pushbuffer() |
39 svncommands.info(u, self.repo) | 48 svncommands.info(u, self.repo) |
40 actual = u.popbuffer() | 49 actual = u.popbuffer() |
83 'branch': 'trunk', | 92 'branch': 'trunk', |
84 'rev': 6, | 93 'rev': 6, |
85 }) | 94 }) |
86 self.assertMultiLineEqual(actual, expected) | 95 self.assertMultiLineEqual(actual, expected) |
87 | 96 |
88 def test_info_single(self): | 97 def test_info_output_custom(self): |
89 repo, repo_path = self.load_and_fetch('two_heads.svndump', subdir='trunk') | 98 self.test_info_output(custom=True) |
99 | |
100 def test_info_single(self, custom=False): | |
101 if custom: | |
102 subdir=None | |
103 config = { | |
104 'hgsubversionbranch.default': 'trunk/' | |
105 } | |
106 else: | |
107 subdir='trunk' | |
108 config = {} | |
109 repo, repo_path = self.load_and_fetch('two_heads.svndump', | |
110 subdir=subdir, | |
111 config=config) | |
90 hg.update(self.repo, 'tip') | 112 hg.update(self.repo, 'tip') |
91 u = self.ui() | 113 u = self.ui() |
92 u.pushbuffer() | 114 u.pushbuffer() |
93 svncommands.info(u, self.repo) | 115 svncommands.info(u, self.repo) |
94 actual = u.popbuffer() | 116 actual = u.popbuffer() |
98 'branch': 'trunk', | 120 'branch': 'trunk', |
99 'rev': 6, | 121 'rev': 6, |
100 }) | 122 }) |
101 self.assertMultiLineEqual(expected, actual) | 123 self.assertMultiLineEqual(expected, actual) |
102 | 124 |
125 def test_info_custom_single(self): | |
126 self.test_info_single(custom=True) | |
127 | |
103 def test_missing_metadata(self): | 128 def test_missing_metadata(self): |
104 self._load_fixture_and_fetch('two_heads.svndump') | 129 self._load_fixture_and_fetch('two_heads.svndump') |
130 os.remove(self.repo.join('svn/branch_info')) | |
131 svncommands.updatemeta(self.ui(), self.repo, []) | |
132 | |
105 test_util.rmtree(self.repo.join('svn')) | 133 test_util.rmtree(self.repo.join('svn')) |
106 self.assertRaises(hgutil.Abort, | 134 self.assertRaises(hgutil.Abort, |
107 self.repo.svnmeta) | 135 self.repo.svnmeta) |
108 self.assertRaises(hgutil.Abort, | 136 self.assertRaises(hgutil.Abort, |
109 svncommands.info, | 137 svncommands.info, |
225 wrappers.rebase(rebase.rebase, self.ui(), self.repo, svn=True) | 253 wrappers.rebase(rebase.rebase, self.ui(), self.repo, svn=True) |
226 self.assertEqual(self.repo['tip'].branch(), 'localbranch') | 254 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
227 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) | 255 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) |
228 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) | 256 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) |
229 | 257 |
230 def test_genignore(self): | 258 def test_genignore(self, layout='auto'): |
231 """ Test generation of .hgignore file. """ | 259 """ Test generation of .hgignore file. """ |
232 repo = self._load_fixture_and_fetch('ignores.svndump', noupdate=False) | 260 if layout == 'custom': |
261 config = { | |
262 'hgsubversionbranch.default': 'trunk', | |
263 } | |
264 else: | |
265 config = {} | |
266 repo = self._load_fixture_and_fetch('ignores.svndump', | |
267 layout=layout, | |
268 noupdate=False, | |
269 config=config) | |
233 u = self.ui() | 270 u = self.ui() |
234 u.pushbuffer() | 271 u.pushbuffer() |
235 svncommands.genignore(u, repo, self.wc_path) | 272 svncommands.genignore(u, repo, self.wc_path) |
236 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | 273 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), |
237 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | 274 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') |
238 | 275 |
239 def test_genignore_single(self): | 276 def test_genignore_single(self): |
240 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk') | 277 self.test_genignore(layout='single') |
241 hg.update(self.repo, 'tip') | 278 |
242 u = self.ui() | 279 def test_genignore_custom(self): |
243 u.pushbuffer() | 280 self.test_genignore(layout='custom') |
244 svncommands.genignore(u, self.repo, self.wc_path) | |
245 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | |
246 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | |
247 | 281 |
248 def test_list_authors(self): | 282 def test_list_authors(self): |
249 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') | 283 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') |
250 u = self.ui() | 284 u = self.ui() |
251 u.pushbuffer() | 285 u.pushbuffer() |
261 svncommands.listauthors(self.ui(), | 295 svncommands.listauthors(self.ui(), |
262 args=[test_util.fileurl(repo_path)], | 296 args=[test_util.fileurl(repo_path)], |
263 authors=author_path) | 297 authors=author_path) |
264 self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n') | 298 self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n') |
265 | 299 |
266 def test_svnverify(self, stupid=False): | 300 def test_svnverify(self): |
267 repo, repo_path = self.load_and_fetch('binaryfiles.svndump', | 301 repo, repo_path = self.load_and_fetch('binaryfiles.svndump', |
268 noupdate=False, stupid=stupid) | 302 noupdate=False) |
269 ret = verify.verify(self.ui(), repo, [], rev=1, stupid=stupid) | 303 ret = verify.verify(self.ui(), repo, [], rev=1) |
270 self.assertEqual(0, ret) | 304 self.assertEqual(0, ret) |
271 repo_path = self.load_svndump('binaryfiles-broken.svndump') | 305 repo_path = self.load_svndump('binaryfiles-broken.svndump') |
272 u = self.ui() | 306 u = self.ui() |
273 u.pushbuffer() | 307 u.pushbuffer() |
274 ret = verify.verify(u, repo, [test_util.fileurl(repo_path)], | 308 ret = verify.verify(u, repo, [test_util.fileurl(repo_path)], |
275 rev=1, stupid=stupid) | 309 rev=1) |
276 output = u.popbuffer() | 310 output = u.popbuffer() |
277 self.assertEqual(1, ret) | 311 self.assertEqual(1, ret) |
278 output = re.sub(r'file://\S+', 'file://', output) | 312 output = re.sub(r'file://\S+', 'file://', output) |
279 self.assertMultiLineEqual("""\ | 313 self.assertMultiLineEqual("""\ |
280 verifying d51f46a715a1 against file:// | 314 verifying d51f46a715a1 against file:// |
281 difference in: binary2 | 315 difference in: binary2 |
282 unexpected file: binary1 | 316 unexpected file: binary1 |
283 missing file: binary3 | 317 missing file: binary3 |
284 """, output) | 318 """, output) |
285 | 319 |
286 def test_svnverify_stupid(self): | 320 def test_corruption(self): |
287 self.test_svnverify(True) | |
288 | |
289 def test_corruption(self, stupid=False): | |
290 SUCCESS = 0 | 321 SUCCESS = 0 |
291 FAILURE = 1 | 322 FAILURE = 1 |
292 | 323 |
293 repo, repo_path = self.load_and_fetch('correct.svndump', layout='single', | 324 repo, repo_path = self.load_and_fetch('correct.svndump', layout='single', |
294 subdir='', stupid=stupid) | 325 subdir='') |
295 | 326 |
296 ui = self.ui() | 327 ui = self.ui() |
297 | 328 |
298 self.assertEqual(SUCCESS, verify.verify(ui, self.repo, rev='tip', | 329 self.assertEqual(SUCCESS, verify.verify(ui, self.repo, rev='tip')) |
299 stupid=stupid)) | |
300 | 330 |
301 corrupt_source = test_util.fileurl(self.load_svndump('corrupt.svndump')) | 331 corrupt_source = test_util.fileurl(self.load_svndump('corrupt.svndump')) |
302 | 332 |
303 repo.ui.setconfig('paths', 'default', corrupt_source) | 333 repo.ui.setconfig('paths', 'default', corrupt_source) |
304 | 334 |
320 'unexpected file: empty-file', | 350 'unexpected file: empty-file', |
321 ]) | 351 ]) |
322 | 352 |
323 self.assertEqual((FAILURE, expected), (code, actual)) | 353 self.assertEqual((FAILURE, expected), (code, actual)) |
324 | 354 |
325 def test_corruption_stupid(self): | |
326 self.test_corruption(True) | |
327 | |
328 def test_svnrebuildmeta(self): | 355 def test_svnrebuildmeta(self): |
329 otherpath = self.load_svndump('binaryfiles-broken.svndump') | 356 otherpath = self.load_svndump('binaryfiles-broken.svndump') |
330 otherurl = test_util.fileurl(otherpath) | 357 otherurl = test_util.fileurl(otherpath) |
331 self.load_and_fetch('replace_trunk_with_branch.svndump') | 358 self.load_and_fetch('replace_trunk_with_branch.svndump') |
332 # rebuildmeta with original repo | 359 # rebuildmeta with original repo |
336 svncommands.rebuildmeta, | 363 svncommands.rebuildmeta, |
337 self.ui(), repo=self.repo, args=[otherurl]) | 364 self.ui(), repo=self.repo, args=[otherurl]) |
338 # rebuildmeta --unsafe-skip-uuid-check with unrelated repo | 365 # rebuildmeta --unsafe-skip-uuid-check with unrelated repo |
339 svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[otherurl], | 366 svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[otherurl], |
340 unsafe_skip_uuid_check=True) | 367 unsafe_skip_uuid_check=True) |
341 | |
342 def suite(): | |
343 all_tests = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), | |
344 ] | |
345 return unittest.TestSuite(all_tests) |