Mercurial > hgsubversion
comparison tests/comprehensive/test_custom_layout.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 | |
children | ff4e102932ed |
comparison
equal
deleted
inserted
replaced
1091:384eb7e05b61 | 1092:cd0d14e25757 |
---|---|
1 import os | |
2 import pickle | |
3 import sys | |
4 import unittest | |
5 | |
6 from mercurial import hg | |
7 from mercurial import ui | |
8 | |
9 # wrapped in a try/except because of weirdness in how | |
10 # run.py works as compared to nose. | |
11 try: | |
12 import test_util | |
13 except ImportError: | |
14 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) | |
15 import test_util | |
16 | |
17 from hgsubversion import wrappers | |
18 | |
19 | |
20 def _do_case(self, name, stupid): | |
21 subdir = test_util.subdir.get(name, '') | |
22 config = { | |
23 'hgsubversion.stupid': stupid and '1' or '0', | |
24 } | |
25 repo, repo_path = self.load_and_fetch(name, | |
26 subdir=subdir, | |
27 layout='auto', | |
28 config=config) | |
29 assert test_util.repolen(self.repo) > 0, \ | |
30 'Repo had no changes, maybe you need to add a subdir entry in test_util?' | |
31 wc2_path = self.wc_path + '_custom' | |
32 checkout_path = repo_path | |
33 if subdir: | |
34 checkout_path += '/' + subdir | |
35 u = ui.ui() | |
36 if stupid: | |
37 u.setconfig('hgsubversion', 'stupid', '1') | |
38 u.setconfig('hgsubversion', 'layout', 'custom') | |
39 for branch, path in test_util.custom.get(name, {}).iteritems(): | |
40 u.setconfig('hgsubversionbranch', branch, path) | |
41 test_util.hgclone(u, | |
42 test_util.fileurl(checkout_path), | |
43 wc2_path, | |
44 update=False) | |
45 self.repo2 = hg.repository(ui.ui(), wc2_path) | |
46 self.assertEqual(self.repo.heads(), self.repo2.heads()) | |
47 | |
48 | |
49 def buildmethod(case, name, stupid): | |
50 m = lambda self: self._do_case(case, stupid) | |
51 m.__name__ = name | |
52 replay = stupid and 'stupid' or 'regular' | |
53 m.__doc__ = 'Test custom produces same as standard on %s. (%s)' % (case, | |
54 replay) | |
55 return m | |
56 | |
57 attrs = {'_do_case': _do_case, | |
58 } | |
59 for case in test_util.custom: | |
60 name = 'test_' + case[:-len('.svndump')].replace('-', '_') | |
61 attrs[name] = buildmethod(case, name, stupid=False) | |
62 name += '_stupid' | |
63 attrs[name] = buildmethod(case, name, stupid=True) | |
64 | |
65 CustomPullTests = type('CustomPullTests', (test_util.TestBase,), attrs) |