changeset 1554:258fb67fb956

externals: correctly enable hgsubversion externals support during tests For now this is defaulted to off, because it's a subclass of the Subversion support which we've disabled by default in core.
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 15:44:11 -0400
parents 601eaa89ca98
children cff81f35b31e
files tests/test_externals.py tests/test_util.py
diffstat 2 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_externals.py
+++ b/tests/test_externals.py
@@ -18,6 +18,15 @@ from hgsubversion import svnexternals
 class TestFetchExternals(test_util.TestBase):
     stupid_mode_tests = True
 
+    def setUp(self):
+        test_util.TestBase.setUp(self)
+        with open(self.hgrc, 'a') as rc:
+            rc.write('\n[subrepos]\nhgsubversion:allowed = true\n')
+
+    def ui(self, *args, **kwargs):
+        kwargs['subrepo'] = True
+        return test_util.TestBase.ui(self, *args, **kwargs)
+
     def test_externalsfile(self):
         f = svnexternals.externalsfile()
         f['t1'] = 'dir1 -r10 svn://foobar'
@@ -139,7 +148,7 @@ class TestFetchExternals(test_util.TestB
                 self.assertTrue(not os.path.isdir(p),
                                 'unexpected: %s@%r' % (d, rev))
 
-        ui = self.ui()
+        ui = self.ui(subrepo=True)
         repo = self._load_fixture_and_fetch('externals.svndump')
         commands.update(ui, repo)
         checkdeps(['deps/project1'], [], repo, 0)
@@ -239,7 +248,7 @@ 2 deps/project2
         if subrepo is None:
             return
 
-        ui = self.ui()
+        ui = self.ui(subrepo=True)
         repo = self._load_fixture_and_fetch('externals.svndump',
                                             externals='subrepos')
         checkdeps(ui, repo, 0, ['deps/project1'], [])
@@ -271,6 +280,15 @@ class TestPushExternals(test_util.TestBa
     stupid_mode_tests = True
     obsolete_mode_tests = True
 
+    def setUp(self):
+        test_util.TestBase.setUp(self)
+        with open(self.hgrc, 'a') as rc:
+            rc.write('\n[subrepos]\nhgsubversion:allowed = true\n')
+
+    def ui(self, *args, **kwargs):
+        kwargs['subrepo'] = True
+        return test_util.TestBase.ui(self, *args, **kwargs)
+
     def test_push_externals(self):
         repo = self._load_fixture_and_fetch('pushexternals.svndump')
         # Add a new reference on an existing and non-existing directory
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -298,7 +298,7 @@ class _testui(ui.ui):
         return ui.ui.develwarn(self, msg, stacklevel=stacklevel,
                                *args, **kwargs)
 
-def testui(stupid=False, layout='auto', startrev=0):
+def testui(stupid=False, layout='auto', startrev=0, subrepo=False):
     u = _testui()
     bools = {True: 'true', False: 'false'}
     u.setconfig('ui', 'quiet', bools[True])
@@ -307,6 +307,7 @@ def testui(stupid=False, layout='auto', 
     u.setconfig('hgsubversion', 'stupid', bools[stupid])
     u.setconfig('hgsubversion', 'layout', layout)
     u.setconfig('hgsubversion', 'startrev', startrev)
+    u.setconfig('subrepos', 'hgsubversion:allowed', subrepo)
     u.setconfig('devel', 'all-warnings', True)
     return u
 
@@ -544,8 +545,8 @@ class TestBase(unittest.TestCase):
 
         _verify_our_modules()
 
-    def ui(self, layout='auto'):
-        return testui(self.stupid, layout)
+    def ui(self, layout='auto', subrepo=False):
+        return testui(self.stupid, layout, subrepo=subrepo)
 
     def load_svndump(self, fixture_name):
         '''Loads an svnadmin dump into a fresh repo. Return the svn repo
@@ -603,13 +604,14 @@ class TestBase(unittest.TestCase):
         config = dict(config or {})
         if externals:
             config['hgsubversion.externals'] = str(externals)
+            config['subrepos.hgsubversion:allowed'] = 'true'
         for k,v in reversed(sorted(config.iteritems())):
             cmd[:0] = ['--config', '%s=%s' % (k, v)]
 
         r = dispatch(cmd)
         assert not r, 'fetch of %s failed' % projectpath
 
-        return hg.repository(testui(), self.wc_path)
+        return hg.repository(self.ui(subrepo=bool(externals)), self.wc_path)
 
     def load(self, fixture_name):
         if fixture_name.endswith('.svndump'):
@@ -654,7 +656,7 @@ class TestBase(unittest.TestCase):
     # define this as a property so that it reloads anytime we need it
     @property
     def repo(self):
-        return hg.repository(testui(), self.wc_path)
+        return hg.repository(self.ui(), self.wc_path)
 
     def pushrevisions(self, expected_extra_back=0):
         before = repolen(self.repo)