comparison tests/test_rebuildmeta.py @ 638:ea0f42e0004d

tests: disallow calling changectx.children() during rebuildmeta
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sat, 10 Jul 2010 14:39:30 +0200
parents 25714b4954b7
children d2ef7220a079
comparison
equal deleted inserted replaced
637:92f4a4b60696 638:ea0f42e0004d
2 import pickle 2 import pickle
3 import unittest 3 import unittest
4 4
5 import test_util 5 import test_util
6 6
7 from mercurial import context
8 from mercurial import extensions
7 from mercurial import hg 9 from mercurial import hg
8 from mercurial import ui 10 from mercurial import ui
9 11
10 from hgsubversion import svncommands 12 from hgsubversion import svncommands
11 from hgsubversion import svnmeta 13 from hgsubversion import svnmeta
18 self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout) 20 self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout)
19 assert len(self.repo) > 0 21 assert len(self.repo) > 0
20 wc2_path = self.wc_path + '_clone' 22 wc2_path = self.wc_path + '_clone'
21 u = ui.ui() 23 u = ui.ui()
22 src, dest = hg.clone(u, self.wc_path, wc2_path, update=False) 24 src, dest = hg.clone(u, self.wc_path, wc2_path, update=False)
23 svncommands.rebuildmeta(u, 25
24 dest, 26 # insert a wrapper that prevents calling changectx.children()
25 args=[test_util.fileurl(self.repo_path + 27 def failfn(orig, ctx):
26 subdir), ]) 28 self.fail('calling %s is forbidden; it can cause massive slowdowns '
29 'when rebuilding large repositories' % orig)
30
31 origchildren = getattr(context.changectx, 'children')
32 extensions.wrapfunction(context.changectx, 'children', failfn)
33
34 try:
35 svncommands.rebuildmeta(u, dest,
36 args=[test_util.fileurl(self.repo_path +
37 subdir), ])
38 finally:
39 # remove the wrapper
40 context.changectx.children = origchildren
41
27 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')), 42 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
28 'no .hg/svn directory in the source!') 43 'no .hg/svn directory in the source!')
29 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')), 44 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
30 'no .hg/svn directory in the destination!') 45 'no .hg/svn directory in the destination!')
31 dest = hg.repository(u, os.path.dirname(dest.path)) 46 dest = hg.repository(u, os.path.dirname(dest.path))