Commits

Patrick Mézard  committed 5bacb9c

Fix more peer breakage with old hg versions

  • Participants
  • Parent commits 8417be7

Comments (0)

Files changed (6)

File hgsubversion/wrappers.py

         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
                 # 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()
 
     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]:

File tests/test_fetch_mappings.py

         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)])
 

File tests/test_rebuildmeta.py

     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):
                                   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)

File tests/test_tags.py

             "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), ])

File tests/test_updatemeta.py

     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):

File tests/test_util.py

 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: