annotate tests/comprehensive/test_updatemeta.py @ 1066:825fd4c0396c

test_fetch_truncated: use stupid mode metaclass
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 09 Aug 2013 23:45:56 +0200
parents cd256960b622
children 48379ebd2763
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
3 import unittest
1042
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
4
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
5 # 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
6 # 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
7 try:
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
8 import test_util
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
9 except ImportError:
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
10 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
11 import test_util
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
12
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
13 import test_rebuildmeta
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
14
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
15 from mercurial import context
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
16 from mercurial import extensions
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
17 from mercurial import hg
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
18 from mercurial import ui
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
19
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
20 from hgsubversion import svncommands
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
21 from hgsubversion import svnmeta
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
22
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
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
25 def _do_case(self, name, single):
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
26 subdir = test_util.subdir.get(name, '')
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
27 layout = 'auto'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
28 if single:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
29 layout = 'single'
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
30 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
31 assert test_util.repolen(self.repo) > 0
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
32 wc2_path = self.wc_path + '_clone'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
33 u = ui.ui()
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
34 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
35 src = test_util.getlocalpeer(src)
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 922
diff changeset
36 dest = test_util.getlocalpeer(dest)
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
37
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
38 # insert a wrapper that prevents calling changectx.children()
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
39 def failfn(orig, ctx):
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
40 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
41 'when rebuilding large repositories' % orig)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
42
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
43 origchildren = getattr(context.changectx, 'children')
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
44 extensions.wrapfunction(context.changectx, 'children', failfn)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
45
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
46 # test updatemeta on an empty repo
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
47 try:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
48 svncommands.updatemeta(u, dest,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
49 args=[test_util.fileurl(repo_path +
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
50 subdir), ])
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
51 finally:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
52 # remove the wrapper
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
53 context.changectx.children = origchildren
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
54
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
55 self._run_assertions(name, single, src, dest, u)
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
56
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
57
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
58 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
59 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
60
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 skip = set([
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
63 'project_root_not_repo_root.svndump',
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
64 'corrupt.svndump',
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
65 ])
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 attrs = {'_do_case': _do_case,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
68 '_run_assertions': _run_assertions,
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
69 'stupid_mode_tests': True,
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
70 }
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
71 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
72 # 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
73 if case in skip:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
74 continue
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
75 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
76 attrs[bname] = test_rebuildmeta.buildmethod(case, bname, False)
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
77 name = bname + '_single'
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
78 attrs[name] = test_rebuildmeta.buildmethod(case, name, True)
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
79
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
80 UpdateMetaTests = type('UpdateMetaTests', (test_util.TestBase,), attrs)