Mercurial > hgsubversion
annotate tests/comprehensive/test_updatemeta.py @ 1085:48379ebd2763
tests: unbreak running test_updatemeta individually
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Thu, 05 Sep 2013 10:51:58 -0700 |
parents | cd256960b622 |
children | cd0d14e25757 |
rev | line source |
---|---|
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
1 import os |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
2 import pickle |
1085
48379ebd2763
tests: unbreak running test_updatemeta individually
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
3 import sys |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
4 import unittest |
1042
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
5 |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
6 # wrapped in a try/except because of weirdness in how |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
7 # run.py works as compared to nose. |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
8 try: |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
9 import test_util |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
10 except ImportError: |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
11 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
12 import test_util |
af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
930
diff
changeset
|
13 |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
14 import test_rebuildmeta |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
15 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
16 from mercurial import context |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
17 from mercurial import extensions |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
18 from mercurial import hg |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
19 from mercurial import ui |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
20 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
21 from hgsubversion import svncommands |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
22 from hgsubversion import svnmeta |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
23 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
24 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
25 |
1057
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
26 def _do_case(self, name, single): |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
27 subdir = test_util.subdir.get(name, '') |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
28 layout = 'auto' |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
29 if single: |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
30 layout = 'single' |
1057
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
31 repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout) |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
32 assert test_util.repolen(self.repo) > 0 |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
33 wc2_path = self.wc_path + '_clone' |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
34 u = ui.ui() |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
35 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) |
930
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
922
diff
changeset
|
36 src = test_util.getlocalpeer(src) |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
922
diff
changeset
|
37 dest = test_util.getlocalpeer(dest) |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
38 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
39 # insert a wrapper that prevents calling changectx.children() |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
40 def failfn(orig, ctx): |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
41 self.fail('calling %s is forbidden; it can cause massive slowdowns ' |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
42 'when rebuilding large repositories' % orig) |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
43 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
44 origchildren = getattr(context.changectx, 'children') |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
45 extensions.wrapfunction(context.changectx, 'children', failfn) |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
46 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
47 # test updatemeta on an empty repo |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
48 try: |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
49 svncommands.updatemeta(u, dest, |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
50 args=[test_util.fileurl(repo_path + |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
51 subdir), ]) |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
52 finally: |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
53 # remove the wrapper |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
54 context.changectx.children = origchildren |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
55 |
1057
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
56 self._run_assertions(name, single, src, dest, u) |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
57 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
58 |
1057
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
59 def _run_assertions(self, name, single, src, dest, u): |
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
60 test_rebuildmeta._run_assertions(self, name, single, src, dest, u) |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
61 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
62 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
63 skip = set([ |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
64 'project_root_not_repo_root.svndump', |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
65 'corrupt.svndump', |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
66 ]) |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
67 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
68 attrs = {'_do_case': _do_case, |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
69 '_run_assertions': _run_assertions, |
1057
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
70 'stupid_mode_tests': True, |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
71 } |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
72 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
73 # this fixture results in an empty repository, don't use it |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
74 if case in skip: |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
75 continue |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
76 bname = 'test_' + case[:-len('.svndump')] |
1057
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
77 attrs[bname] = test_rebuildmeta.buildmethod(case, bname, False) |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
78 name = bname + '_single' |
1057
cd256960b622
comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1048
diff
changeset
|
79 attrs[name] = test_rebuildmeta.buildmethod(case, name, True) |
922
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
80 |
6b7ac659c855
updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff
changeset
|
81 UpdateMetaTests = type('UpdateMetaTests', (test_util.TestBase,), attrs) |