# HG changeset patch # User Patrick Mezard # Date 1347309769 -7200 # Node ID 5bacb9c63e3eef7991dbe17bb1e6d08e673c1a45 # Parent 8417be758047c55fb711aeffc57a695df33e58a3 Fix more peer breakage with old hg versions diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -72,6 +72,12 @@ def getpeer(ui, opts, source): return peer(ui, opts, source) return hg.repository(ui, source) +def getlocalpeer(ui, opts, source): + peer = getpeer(ui, opts, source) + repo = getattr(peer, 'local', lambda: peer)() + if isinstance(repo, bool): + repo = peer + return repo def getcaps(other): return (getattr(other, 'caps', None) or @@ -262,8 +268,7 @@ def push(repo, dest, force, revs): # Reload the repo after the rebase. Do not reuse # contexts across this. newtip = newtipctx.node() - repo = getpeer(ui, {}, meta.path) - repo = getattr(repo, 'local', lambda: repo)() + repo = getlocalpeer(ui, {}, meta.path) newtipctx = repo[newtip] # Rewrite the node ids in outgoing to their rebased versions. rebasemap = dict() @@ -554,7 +559,11 @@ def clone(orig, ui, source, dest=None, * if dstrepo.local() and srcrepo.capable('subversion'): dst = dstrepo.local() - fd = dst.opener("hgrc", "a", text=True) + if isinstance(dst, bool): + # Apparently <= hg@1.9 + fd = dstrepo.opener("hgrc", "a", text=True) + else: + fd = dst.opener("hgrc", "a", text=True) for section in set(s for s, v in optionmap.itervalues()): config = dict(ui.configitems(section)) for name in dontretain[section]: 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 @@ -245,8 +245,8 @@ class MapTests(test_util.TestBase): ui = self.ui(stupid) src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone', update=False) - src = getattr(src, 'local', lambda: src)() - dest = getattr(dest, 'local', lambda: dest)() + src = test_util.getlocalpeer(src) + dest = test_util.getlocalpeer(dest) svncommands.rebuildmeta(ui, dest, args=[test_util.fileurl(repo_path)]) diff --git a/tests/test_rebuildmeta.py b/tests/test_rebuildmeta.py --- a/tests/test_rebuildmeta.py +++ b/tests/test_rebuildmeta.py @@ -34,8 +34,8 @@ def _do_case(self, name, stupid, single) wc2_path = self.wc_path + '_clone' u = ui.ui() src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) - src = getattr(src, 'local', lambda: src)() - dest = getattr(dest, 'local', lambda: dest)() + src = test_util.getlocalpeer(src) + dest = test_util.getlocalpeer(dest) # insert a wrapper that prevents calling changectx.children() def failfn(orig, ctx): @@ -61,8 +61,8 @@ def _do_case(self, name, stupid, single) wc3_path, update=False, rev=[0]) - srcrepo = getattr(src, 'local', lambda: src)() - dest = getattr(dest, 'local', lambda: dest)() + srcrepo = test_util.getlocalpeer(src) + dest = test_util.getlocalpeer(dest) # insert a wrapper that prevents calling changectx.children() extensions.wrapfunction(context.changectx, 'children', failfn) diff --git a/tests/test_tags.py b/tests/test_tags.py --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -112,7 +112,7 @@ rename a tag "You should check that before assuming issues with this test.\n") wc2_path = self.wc_path + '2' src, dest = test_util.hgclone(repo.ui, self.wc_path, wc2_path, update=False) - dest = getattr(dest, 'local', lambda: dest)() + dest = test_util.getlocalpeer(dest) svncommands.rebuildmeta(repo.ui, dest, args=[test_util.fileurl(repo_path), ]) diff --git a/tests/test_updatemeta.py b/tests/test_updatemeta.py --- a/tests/test_updatemeta.py +++ b/tests/test_updatemeta.py @@ -26,8 +26,8 @@ def _do_case(self, name, stupid, single) wc2_path = self.wc_path + '_clone' u = ui.ui() src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) - src = getattr(src, 'local', lambda: src)() - dest = getattr(dest, 'local', lambda: dest)() + src = test_util.getlocalpeer(src) + dest = test_util.getlocalpeer(dest) # insert a wrapper that prevents calling changectx.children() def failfn(orig, ctx): diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -104,6 +104,11 @@ subdir = {'truncatedhistory.svndump': '/ FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'fixtures') +def getlocalpeer(repo): + localrepo = getattr(repo, 'local', lambda: repo)() + if isinstance(localrepo, bool): + localrepo = repo + return localrepo def _makeskip(name, message): if SkipTest: