annotate tests/comprehensive/test_updatemeta.py @ 1483:4379baf58f9e stable

test_fetch_renames: refactoring to make debugging easier
author Augie Fackler <raf@durin42.com>
date Sun, 26 Jun 2016 20:25:52 -0400
parents c6b01fd34694
children
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
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
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
26 def _do_case(self, name, layout):
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
27 subdir = test_util.subdir.get(name, '')
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
28 single = layout == 'single'
1342
c6b01fd34694 trying to fix progress output
Augie Fackler <raf@durin42.com>
parents: 1092
diff changeset
29 u = test_util.testui()
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
30 config = {}
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
31 if layout == 'custom':
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
32 config['hgsubversion.layout'] = 'custom'
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
33 u.setconfig('hgsubversion', 'layout', 'custom')
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
34 for branch, path in test_util.custom.get(name, {}).iteritems():
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
35 config['hgsubversionbranch.%s' % branch] = path
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
36 u.setconfig('hgsubversionbranch', branch, path)
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
37
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
38 repo, repo_path = self.load_and_fetch(name,
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
39 subdir=subdir,
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
40 layout=layout,
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
41 config=config)
1048
903c9c9dfe6a tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
42 assert test_util.repolen(self.repo) > 0
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
43 wc2_path = self.wc_path + '_clone'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
44 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
45 src = test_util.getlocalpeer(src)
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 922
diff changeset
46 dest = test_util.getlocalpeer(dest)
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
47
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
48 # insert a wrapper that prevents calling changectx.children()
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
49 def failfn(orig, ctx):
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
50 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
51 'when rebuilding large repositories' % orig)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
52
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
53 origchildren = getattr(context.changectx, 'children')
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
54 extensions.wrapfunction(context.changectx, 'children', failfn)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
55
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
56 # test updatemeta on an empty repo
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
57 try:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
58 svncommands.updatemeta(u, dest,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
59 args=[test_util.fileurl(repo_path +
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
60 subdir), ])
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
61 finally:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
62 # remove the wrapper
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
63 context.changectx.children = origchildren
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
64
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
65 self._run_assertions(name, single, src, dest, u)
922
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
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
68 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
69 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
70
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 skip = set([
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
73 'project_root_not_repo_root.svndump',
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
74 'corrupt.svndump',
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
75 ])
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
76
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
77 attrs = {'_do_case': _do_case,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
78 '_run_assertions': _run_assertions,
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
79 'stupid_mode_tests': 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 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
82 # 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
83 if case in skip:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
84 continue
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
85 bname = 'test_' + case[:-len('.svndump')]
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
86 attrs[bname] = test_rebuildmeta.buildmethod(case, bname, 'auto')
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
87 attrs[bname + '_single'] = test_rebuildmeta.buildmethod(case,
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
88 bname + '_single',
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
89 'single')
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
90 if case in test_util.custom:
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
91 attrs[bname + '_custom'] = test_rebuildmeta.buildmethod(case,
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
92 bname + '_custom',
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
93 'custom')
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1085
diff changeset
94
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
95
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
96 UpdateMetaTests = type('UpdateMetaTests', (test_util.TestBase,), attrs)