# HG changeset patch # User Patrick Mezard # Date 1308141854 -7200 # Node ID 86d124a8768ed81a16ebecab3f0be3d604aeae30 # Parent e62e84a9464b7ceb286edd62bf57c90cc998ca6b Fix hg.clone() calls changed by d976542986d2 diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -449,7 +449,13 @@ def clone(orig, ui, source, dest=None, * """ data = {} - def hgclonewrapper(orig, ui, origsource, dest, **opts): + def hgclonewrapper(orig, ui, *args, **opts): + if getattr(hg, 'peer', None): + # Since 1.9 (d976542986d2) + origsource = args[1] + else: + origsource = args[0] + if isinstance(origsource, str): source, branch, checkout = util.parseurl(ui.expandpath(origsource), opts.get('branch')) @@ -463,7 +469,7 @@ def clone(orig, ui, source, dest=None, * data['branches'] = branches ui.setconfig('hgsubversion', 'branch', branches[-1]) - data['srcrepo'], data['dstrepo'] = orig(ui, origsource, dest, **opts) + data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts) for opt, (section, name) in optionmap.iteritems(): if opt in opts and opts[opt]: diff --git a/tests/comprehensive/test_stupid_pull.py b/tests/comprehensive/test_stupid_pull.py --- a/tests/comprehensive/test_stupid_pull.py +++ b/tests/comprehensive/test_stupid_pull.py @@ -28,7 +28,7 @@ def _do_case(self, name, layout): checkout_path += '/' + subdir u.setconfig('hgsubversion', 'stupid', '1') u.setconfig('hgsubversion', 'layout', layout) - hg.clone(u, test_util.fileurl(checkout_path), wc2_path, update=False) + test_util.hgclone(u, test_util.fileurl(checkout_path), wc2_path, update=False) if layout == 'single': self.assertEqual(len(self.repo.heads()), 1) self.repo2 = hg.repository(ui.ui(), wc2_path) diff --git a/tests/test_fetch_branches.py b/tests/test_fetch_branches.py --- a/tests/test_fetch_branches.py +++ b/tests/test_fetch_branches.py @@ -16,7 +16,7 @@ class TestFetchBranches(test_util.TestBa def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor): test_util.load_svndump_fixture(self.repo_path, fixture_name) source = '%s#%s' % (test_util.fileurl(self.repo_path), anchor) - repo = hg.clone(self.ui(), source=source, dest=self.wc_path) + test_util.hgclone(self.ui(), source, self.wc_path) return hg.repository(self.ui(), self.wc_path) def branches(self, repo): diff --git a/tests/test_fetch_mappings.py b/tests/test_fetch_mappings.py --- a/tests/test_fetch_mappings.py +++ b/tests/test_fetch_mappings.py @@ -220,8 +220,8 @@ class MapTests(test_util.TestBase): # clone & rebuild ui = self.ui(stupid) - src, dest = hg.clone(ui, self.wc_path, self.wc_path + '_clone', - update=False) + src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone', + update=False) svncommands.rebuildmeta(ui, dest, args=[test_util.fileurl(self.repo_path)]) diff --git a/tests/test_push_command.py b/tests/test_push_command.py --- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -278,14 +278,14 @@ class PushTests(test_util.TestBase): self.test_push_to_branch(push=False) wc2path = self.wc_path + '_clone' u = self.repo.ui - hg.clone(self.repo.ui, self.wc_path, wc2path, update=False) + test_util.hgclone(self.repo.ui, self.wc_path, wc2path, update=False) res = self.pushrevisions() self.assertEqual(0, res) oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc')) hgrc = oldf.read() oldf.close() shutil.rmtree(self.wc_path) - hg.clone(u, wc2path, self.wc_path, update=False) + test_util.hgclone(u, wc2path, self.wc_path, update=False) oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc'), 'w') oldf.write(hgrc) oldf.close() diff --git a/tests/test_rebuildmeta.py b/tests/test_rebuildmeta.py --- a/tests/test_rebuildmeta.py +++ b/tests/test_rebuildmeta.py @@ -21,7 +21,7 @@ def _do_case(self, name, stupid, single) assert len(self.repo) > 0 wc2_path = self.wc_path + '_clone' u = ui.ui() - src, dest = hg.clone(u, self.wc_path, wc2_path, update=False) + src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) # insert a wrapper that prevents calling changectx.children() def failfn(orig, ctx): diff --git a/tests/test_tags.py b/tests/test_tags.py --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -115,7 +115,7 @@ rename a tag "Note: this test failing may be because of a rebuildmeta failure.\n" "You should check that before assuming issues with this test.\n") wc2_path = self.wc_path + '2' - src, dest = hg.clone(repo.ui, self.wc_path, wc2_path, update=False) + src, dest = test_util.hgclone(repo.ui, self.wc_path, wc2_path, update=False) svncommands.rebuildmeta(repo.ui, dest, args=[test_util.fileurl(self.repo_path), ]) diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -236,6 +236,14 @@ def _verify_our_modules(): 'from the wrong path!' ) +def hgclone(ui, source, dest, update=True): + if getattr(hg, 'peer', None): + # Since 1.9 (d976542986d2) + src, dest = hg.clone(ui, {}, source, dest, update=update) + else: + src, dest = hg.clone(ui, source, dest, update=update) + return src, dest + class TestBase(unittest.TestCase): def setUp(self): _verify_our_modules()