Mercurial > hgsubversion
comparison tests/comprehensive/test_updatemeta.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 | c6b01fd34694 |
comparison
equal
deleted
inserted
replaced
1020:b5b1fce26f1f | 1106:5cb6c95e0283 |
---|---|
1 import os | |
2 import pickle | |
3 import sys | |
4 import unittest | |
5 | |
6 # wrapped in a try/except because of weirdness in how | |
7 # run.py works as compared to nose. | |
8 try: | |
9 import test_util | |
10 except ImportError: | |
11 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) | |
12 import test_util | |
13 | |
14 import test_rebuildmeta | |
15 | |
16 from mercurial import context | |
17 from mercurial import extensions | |
18 from mercurial import hg | |
19 from mercurial import ui | |
20 | |
21 from hgsubversion import svncommands | |
22 from hgsubversion import svnmeta | |
23 | |
24 | |
25 | |
26 def _do_case(self, name, layout): | |
27 subdir = test_util.subdir.get(name, '') | |
28 single = layout == 'single' | |
29 u = ui.ui() | |
30 config = {} | |
31 if layout == 'custom': | |
32 config['hgsubversion.layout'] = 'custom' | |
33 u.setconfig('hgsubversion', 'layout', 'custom') | |
34 for branch, path in test_util.custom.get(name, {}).iteritems(): | |
35 config['hgsubversionbranch.%s' % branch] = path | |
36 u.setconfig('hgsubversionbranch', branch, path) | |
37 | |
38 repo, repo_path = self.load_and_fetch(name, | |
39 subdir=subdir, | |
40 layout=layout, | |
41 config=config) | |
42 assert test_util.repolen(self.repo) > 0 | |
43 wc2_path = self.wc_path + '_clone' | |
44 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) | |
45 src = test_util.getlocalpeer(src) | |
46 dest = test_util.getlocalpeer(dest) | |
47 | |
48 # insert a wrapper that prevents calling changectx.children() | |
49 def failfn(orig, ctx): | |
50 self.fail('calling %s is forbidden; it can cause massive slowdowns ' | |
51 'when rebuilding large repositories' % orig) | |
52 | |
53 origchildren = getattr(context.changectx, 'children') | |
54 extensions.wrapfunction(context.changectx, 'children', failfn) | |
55 | |
56 # test updatemeta on an empty repo | |
57 try: | |
58 svncommands.updatemeta(u, dest, | |
59 args=[test_util.fileurl(repo_path + | |
60 subdir), ]) | |
61 finally: | |
62 # remove the wrapper | |
63 context.changectx.children = origchildren | |
64 | |
65 self._run_assertions(name, single, src, dest, u) | |
66 | |
67 | |
68 def _run_assertions(self, name, single, src, dest, u): | |
69 test_rebuildmeta._run_assertions(self, name, single, src, dest, u) | |
70 | |
71 | |
72 skip = set([ | |
73 'project_root_not_repo_root.svndump', | |
74 'corrupt.svndump', | |
75 ]) | |
76 | |
77 attrs = {'_do_case': _do_case, | |
78 '_run_assertions': _run_assertions, | |
79 'stupid_mode_tests': True, | |
80 } | |
81 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: | |
82 # this fixture results in an empty repository, don't use it | |
83 if case in skip: | |
84 continue | |
85 bname = 'test_' + case[:-len('.svndump')] | |
86 attrs[bname] = test_rebuildmeta.buildmethod(case, bname, 'auto') | |
87 attrs[bname + '_single'] = test_rebuildmeta.buildmethod(case, | |
88 bname + '_single', | |
89 'single') | |
90 if case in test_util.custom: | |
91 attrs[bname + '_custom'] = test_rebuildmeta.buildmethod(case, | |
92 bname + '_custom', | |
93 'custom') | |
94 | |
95 | |
96 UpdateMetaTests = type('UpdateMetaTests', (test_util.TestBase,), attrs) |