comparison tests/test_rebuildmeta.py @ 499:1fd3cfa47c5e

Support for single-directory clones.
author Augie Fackler <durin42@gmail.com>
date Fri, 16 Oct 2009 23:33:41 -0400
parents 63cb630d667d
children 00393e9abff8
comparison
equal deleted inserted replaced
498:990e07054f29 499:1fd3cfa47c5e
8 from mercurial import ui 8 from mercurial import ui
9 9
10 from hgsubversion import svncommands 10 from hgsubversion import svncommands
11 from hgsubversion import svnmeta 11 from hgsubversion import svnmeta
12 12
13 def _do_case(self, name, stupid): 13 def _do_case(self, name, stupid, single):
14 subdir = test_util.subdir.get(name, '') 14 subdir = test_util.subdir.get(name, '')
15 self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid) 15 layout = 'auto'
16 if single:
17 layout = 'single'
18 self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout)
16 assert len(self.repo) > 0 19 assert len(self.repo) > 0
17 wc2_path = self.wc_path + '_clone' 20 wc2_path = self.wc_path + '_clone'
18 u = ui.ui() 21 u = ui.ui()
19 src, dest = hg.clone(u, self.wc_path, wc2_path, update=False) 22 src, dest = hg.clone(u, self.wc_path, wc2_path, update=False)
20 svncommands.rebuildmeta(u, 23 svncommands.rebuildmeta(u,
25 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')), 28 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
26 'no .hg/svn directory in the source!') 29 'no .hg/svn directory in the source!')
27 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')), 30 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
28 'no .hg/svn directory in the destination!') 31 'no .hg/svn directory in the destination!')
29 dest = hg.repository(u, os.path.dirname(dest.path)) 32 dest = hg.repository(u, os.path.dirname(dest.path))
30 for tf in ('rev_map', 'uuid', 'tagmap', ): 33 for tf in ('rev_map', 'uuid', 'tagmap', 'layout', ):
31 stf = os.path.join(src.path, 'svn', tf) 34 stf = os.path.join(src.path, 'svn', tf)
32 self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf) 35 self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf)
33 dtf = os.path.join(dest.path, 'svn', tf) 36 dtf = os.path.join(dest.path, 'svn', tf)
34 self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf) 37 self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf)
35 old, new = open(stf).read(), open(dtf).read() 38 old, new = open(stf).read(), open(dtf).read()
52 revkeys), reverse=True)[0][0] 55 revkeys), reverse=True)[0][0]
53 self.assertEqual(pr, destinfo[1]) 56 self.assertEqual(pr, destinfo[1])
54 self.assertEqual(srcinfo[2], destinfo[2]) 57 self.assertEqual(srcinfo[2], destinfo[2])
55 58
56 59
57 def buildmethod(case, name, stupid): 60 def buildmethod(case, name, stupid, single):
58 m = lambda self: self._do_case(case, stupid) 61 m = lambda self: self._do_case(case, stupid, single)
59 m.__name__ = name 62 m.__name__ = name
60 m.__doc__ = ('Test rebuildmeta on %s with %s replay.' % 63 m.__doc__ = ('Test rebuildmeta on %s with %s replay. (%s)' %
61 (case, (stupid and 'stupid') or 'real')) 64 (case,
65 (stupid and 'stupid') or 'real',
66 (single and 'single') or 'standard',
67 )
68 )
62 return m 69 return m
63 70
64 71
65 attrs = {'_do_case': _do_case, 72 attrs = {'_do_case': _do_case,
66 } 73 }
67 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: 74 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
68 # this fixture results in an empty repository, don't use it 75 # this fixture results in an empty repository, don't use it
69 if case == 'project_root_not_repo_root.svndump': 76 if case == 'project_root_not_repo_root.svndump':
70 continue 77 continue
71 name = 'test_' + case[:-len('.svndump')] 78 bname = 'test_' + case[:-len('.svndump')]
72 attrs[name] = buildmethod(case, name, False) 79 attrs[bname] = buildmethod(case, bname, False, False)
73 name += '_stupid' 80 name = bname + '_stupid'
74 attrs[name] = buildmethod(case, name, True) 81 attrs[name] = buildmethod(case, name, True, False)
82 name = bname + '_single'
83 attrs[name] = buildmethod(case, name, False, True)
84
75 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase, ), attrs) 85 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase, ), attrs)
76 86
77 87
78 def suite(): 88 def suite():
79 all = [unittest.TestLoader().loadTestsFromTestCase(RebuildMetaTests), 89 all = [unittest.TestLoader().loadTestsFromTestCase(RebuildMetaTests),