Mercurial > hgsubversion
comparison tests/test_util.py @ 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 | ed2df771f578 |
| children | 4afe8d7e4602 |
comparison
equal
deleted
inserted
replaced
| 1553:601eaa89ca98 | 1554:258fb67fb956 |
|---|---|
| 296 config = args[0] if args else kwargs['config'] | 296 config = args[0] if args else kwargs['config'] |
| 297 raise Exception('flunked develwarn: %r (%r)' % (msg, config)) | 297 raise Exception('flunked develwarn: %r (%r)' % (msg, config)) |
| 298 return ui.ui.develwarn(self, msg, stacklevel=stacklevel, | 298 return ui.ui.develwarn(self, msg, stacklevel=stacklevel, |
| 299 *args, **kwargs) | 299 *args, **kwargs) |
| 300 | 300 |
| 301 def testui(stupid=False, layout='auto', startrev=0): | 301 def testui(stupid=False, layout='auto', startrev=0, subrepo=False): |
| 302 u = _testui() | 302 u = _testui() |
| 303 bools = {True: 'true', False: 'false'} | 303 bools = {True: 'true', False: 'false'} |
| 304 u.setconfig('ui', 'quiet', bools[True]) | 304 u.setconfig('ui', 'quiet', bools[True]) |
| 305 u.setconfig('ui', 'username', 'automated tests') | 305 u.setconfig('ui', 'username', 'automated tests') |
| 306 u.setconfig('extensions', 'hgsubversion', '') | 306 u.setconfig('extensions', 'hgsubversion', '') |
| 307 u.setconfig('hgsubversion', 'stupid', bools[stupid]) | 307 u.setconfig('hgsubversion', 'stupid', bools[stupid]) |
| 308 u.setconfig('hgsubversion', 'layout', layout) | 308 u.setconfig('hgsubversion', 'layout', layout) |
| 309 u.setconfig('hgsubversion', 'startrev', startrev) | 309 u.setconfig('hgsubversion', 'startrev', startrev) |
| 310 u.setconfig('subrepos', 'hgsubversion:allowed', subrepo) | |
| 310 u.setconfig('devel', 'all-warnings', True) | 311 u.setconfig('devel', 'all-warnings', True) |
| 311 return u | 312 return u |
| 312 | 313 |
| 313 def dispatch(cmd): | 314 def dispatch(cmd): |
| 314 assert '--quiet' in cmd | 315 assert '--quiet' in cmd |
| 542 rmtree(self.tmpdir) | 543 rmtree(self.tmpdir) |
| 543 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) | 544 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) |
| 544 | 545 |
| 545 _verify_our_modules() | 546 _verify_our_modules() |
| 546 | 547 |
| 547 def ui(self, layout='auto'): | 548 def ui(self, layout='auto', subrepo=False): |
| 548 return testui(self.stupid, layout) | 549 return testui(self.stupid, layout, subrepo=subrepo) |
| 549 | 550 |
| 550 def load_svndump(self, fixture_name): | 551 def load_svndump(self, fixture_name): |
| 551 '''Loads an svnadmin dump into a fresh repo. Return the svn repo | 552 '''Loads an svnadmin dump into a fresh repo. Return the svn repo |
| 552 path. | 553 path. |
| 553 ''' | 554 ''' |
| 601 if rev is not None: | 602 if rev is not None: |
| 602 cmd.append('--rev=%s' % rev) | 603 cmd.append('--rev=%s' % rev) |
| 603 config = dict(config or {}) | 604 config = dict(config or {}) |
| 604 if externals: | 605 if externals: |
| 605 config['hgsubversion.externals'] = str(externals) | 606 config['hgsubversion.externals'] = str(externals) |
| 607 config['subrepos.hgsubversion:allowed'] = 'true' | |
| 606 for k,v in reversed(sorted(config.iteritems())): | 608 for k,v in reversed(sorted(config.iteritems())): |
| 607 cmd[:0] = ['--config', '%s=%s' % (k, v)] | 609 cmd[:0] = ['--config', '%s=%s' % (k, v)] |
| 608 | 610 |
| 609 r = dispatch(cmd) | 611 r = dispatch(cmd) |
| 610 assert not r, 'fetch of %s failed' % projectpath | 612 assert not r, 'fetch of %s failed' % projectpath |
| 611 | 613 |
| 612 return hg.repository(testui(), self.wc_path) | 614 return hg.repository(self.ui(subrepo=bool(externals)), self.wc_path) |
| 613 | 615 |
| 614 def load(self, fixture_name): | 616 def load(self, fixture_name): |
| 615 if fixture_name.endswith('.svndump'): | 617 if fixture_name.endswith('.svndump'): |
| 616 repo_path = self.load_svndump(fixture_name) | 618 repo_path = self.load_svndump(fixture_name) |
| 617 elif fixture_name.endswith('tar.gz'): | 619 elif fixture_name.endswith('tar.gz'): |
| 652 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 654 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 653 | 655 |
| 654 # define this as a property so that it reloads anytime we need it | 656 # define this as a property so that it reloads anytime we need it |
| 655 @property | 657 @property |
| 656 def repo(self): | 658 def repo(self): |
| 657 return hg.repository(testui(), self.wc_path) | 659 return hg.repository(self.ui(), self.wc_path) |
| 658 | 660 |
| 659 def pushrevisions(self, expected_extra_back=0): | 661 def pushrevisions(self, expected_extra_back=0): |
| 660 before = repolen(self.repo) | 662 before = repolen(self.repo) |
| 661 self.repo.ui.setconfig('hgsubversion', 'stupid', str(self.stupid)) | 663 self.repo.ui.setconfig('hgsubversion', 'stupid', str(self.stupid)) |
| 662 res = commands.push(self.repo.ui, self.repo) | 664 res = commands.push(self.repo.ui, self.repo) |
