# HG changeset patch # User Patrick Mezard # Date 1308141854 -7200 # Node ID f07bfd66db130bedd1390e1db313c502c9d1c547 # Parent 8c7447b4b004e4e91ab00137480182f879859940 test_util: handle dispatch.dispatch() taking a request This was introduced in hg.08bfec2ef031 diff --git a/tests/test_single_dir_clone.py b/tests/test_single_dir_clone.py --- a/tests/test_single_dir_clone.py +++ b/tests/test_single_dir_clone.py @@ -4,7 +4,6 @@ import errno import shutil import unittest -from mercurial import dispatch from mercurial import commands from mercurial import context from mercurial import hg @@ -236,7 +235,7 @@ class TestSingleDir(test_util.TestBase): if stupid: cmd.append('--stupid') cmd += [test_util.fileurl(self.repo_path), self.wc_path] - dispatch.dispatch(cmd) + test_util.dispatch(cmd) def file_callback(repo, memctx, path): if path == 'adding_file': diff --git a/tests/test_unaffected_core.py b/tests/test_unaffected_core.py --- a/tests/test_unaffected_core.py +++ b/tests/test_unaffected_core.py @@ -10,6 +10,13 @@ from mercurial import hg from mercurial import node from mercurial import ui +def _dispatch(ui, cmd): + try: + req = dispatch.request(cmd, ui=ui) + dispatch._dispatch(req) + except AttributeError: + dispatch._dispatch(ui, cmd) + class TestMercurialCore(test_util.TestBase): ''' Test that the core Mercurial operations aren't broken by hgsubversion. @@ -19,7 +26,7 @@ class TestMercurialCore(test_util.TestBa def test_update(self): ''' Test 'clone --updaterev' ''' ui = self.ui() - dispatch._dispatch(ui, ['init', self.wc_path]) + _dispatch(ui, ['init', self.wc_path]) repo = self.repo repo.ui.setconfig('ui', 'username', 'anonymous') @@ -39,7 +46,7 @@ class TestMercurialCore(test_util.TestBa self.assertEqual(len(repo), 3) updaterev = 1 - dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', + _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', '--updaterev=%s' % updaterev]) repo2 = hg.repository(ui, self.wc_path + '2') @@ -50,7 +57,7 @@ class TestMercurialCore(test_util.TestBa def test_branch(self): ''' Test 'clone --branch' ''' ui = self.ui() - dispatch._dispatch(ui, ['init', self.wc_path]) + _dispatch(ui, ['init', self.wc_path]) repo = self.repo repo.ui.setconfig('ui', 'username', 'anonymous') @@ -73,7 +80,7 @@ class TestMercurialCore(test_util.TestBa self.assertEqual(len(repo), 3) branch = 'B1' - dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', + _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', '--branch', branch]) repo2 = hg.repository(ui, self.wc_path + '2') diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -18,7 +18,7 @@ sys.path.insert(0, _rootdir) from mercurial import cmdutil from mercurial import commands from mercurial import context -from mercurial import dispatch +from mercurial import dispatch as dispatchmod from mercurial import hg from mercurial import i18n from mercurial import node @@ -170,6 +170,13 @@ def load_svndump_fixture(path, fixture_n stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc.communicate() +def dispatch(cmd): + try: + req = dispatchmod.request(cmd) + dispatchmod.dispatch(req) + except AttributeError, e: + dispatchmod.dispatch(cmd) + def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='', noupdate=True, layout='auto', startrev=0, externals=None): @@ -191,7 +198,7 @@ def load_fixture_and_fetch(fixture_name, if externals: cmd[:0] = ['--config', 'hgsubversion.externals=%s' % externals] - dispatch.dispatch(cmd) + dispatch(cmd) return hg.repository(testui(), wc_path)