comparison tests/comprehensive/test_rebuildmeta.py @ 1092:cd0d14e25757

layouts: add custom layout for those of us that need weird mappings This adds a config-driven custom layout, targeted at the case where you need to fetch a small subset of a large number of subversion branches, or where your subversion layout doesn't match the standard trunk/branches/tags layout very well.
author David Schleimer <dschleimer@fb.com>
date Mon, 26 Aug 2013 16:40:31 -0700
parents cd256960b622
children 6e1dbf6cbc92
comparison
equal deleted inserted replaced
1091:384eb7e05b61 1092:cd0d14e25757
28 ('unrelatedbranch.svndump', True, False), 28 ('unrelatedbranch.svndump', True, False),
29 ] 29 ]
30 30
31 31
32 32
33 def _do_case(self, name, single): 33 def _do_case(self, name, layout):
34 subdir = test_util.subdir.get(name, '') 34 subdir = test_util.subdir.get(name, '')
35 layout = 'auto' 35 single = layout == 'single'
36 if single: 36 u = ui.ui()
37 layout = 'single' 37 config = {}
38 if layout == 'custom':
39 for branch, path in test_util.custom.get(name, {}).iteritems():
40 config['hgsubversionbranch.%s' % branch] = path
41 u.setconfig('hgsubversionbranch', branch, path)
38 repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout) 42 repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout)
39 assert test_util.repolen(self.repo) > 0 43 assert test_util.repolen(self.repo) > 0
40 wc2_path = self.wc_path + '_clone' 44 wc2_path = self.wc_path + '_clone'
41 u = ui.ui()
42 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) 45 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False)
43 src = test_util.getlocalpeer(src) 46 src = test_util.getlocalpeer(src)
44 dest = test_util.getlocalpeer(dest) 47 dest = test_util.getlocalpeer(dest)
45 48
46 # insert a wrapper that prevents calling changectx.children() 49 # insert a wrapper that prevents calling changectx.children()
134 revkeys), reverse=True)[0][0] 137 revkeys), reverse=True)[0][0]
135 self.assertEqual(pr, destinfo[1]) 138 self.assertEqual(pr, destinfo[1])
136 self.assertEqual(srcinfo[2], destinfo[2]) 139 self.assertEqual(srcinfo[2], destinfo[2])
137 140
138 141
139 def buildmethod(case, name, single): 142 def buildmethod(case, name, layout):
140 m = lambda self: self._do_case(case, single) 143 m = lambda self: self._do_case(case, layout)
141 m.__name__ = name 144 m.__name__ = name
142 m.__doc__ = ('Test rebuildmeta on %s (%s)' % 145 m.__doc__ = ('Test rebuildmeta on %s (%s)' %
143 (case, (single and 'single') or 'standard')) 146 (case, layout))
144 return m 147 return m
145 148
146 149
147 skip = set([ 150 skip = set([
148 'project_root_not_repo_root.svndump', 151 'project_root_not_repo_root.svndump',
156 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: 159 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
157 # this fixture results in an empty repository, don't use it 160 # this fixture results in an empty repository, don't use it
158 if case in skip: 161 if case in skip:
159 continue 162 continue
160 bname = 'test_' + case[:-len('.svndump')] 163 bname = 'test_' + case[:-len('.svndump')]
161 attrs[bname] = buildmethod(case, bname, False) 164 attrs[bname] = buildmethod(case, bname, 'auto')
162 name = bname + '_single' 165 attrs[bname + '_single'] = buildmethod(case, bname + '_single', 'single')
163 attrs[name] = buildmethod(case, name, True) 166 if case in test_util.custom:
167 attrs[bname + '_custom'] = buildmethod(case,
168 bname + '_custom',
169 'single')
164 170
165 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase,), attrs) 171 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase,), attrs)