changeset 1247:3a4d74823187

pull: wrap exchange.pull if localrepository.pull isn't available Mercurial rev 73b5b8312ce6 removed localrepository.pull. We don't do it the other way round (wrap pull if exchange.pull is available) because that's been available with a different signature since Mercurial 3.0.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 13 Oct 2014 23:56:13 -0700
parents 2179747e7fea
children 2d1f6687980b
files hgsubversion/__init__.py hgsubversion/svnrepo.py hgsubversion/wrappers.py
diffstat 3 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/__init__.py
+++ b/hgsubversion/__init__.py
@@ -146,6 +146,9 @@ def extsetup(ui):
     if not hgutil.safehasattr(localrepo.localrepository, 'push'):
         # Mercurial >= 3.2
         extensions.wrapfunction(exchange, 'push', wrappers.exchangepush)
+    if not hgutil.safehasattr(localrepo.localrepository, 'pull'):
+        # Mercurial >= 3.2
+        extensions.wrapfunction(exchange, 'pull', wrappers.exchangepull)
 
     helpdir = os.path.join(os.path.dirname(__file__), 'help')
 
--- a/hgsubversion/svnrepo.py
+++ b/hgsubversion/svnrepo.py
@@ -103,9 +103,11 @@ def generate_repo_class(ui, repo):
             def push(self, remote, force=False, revs=None, newbranch=None):
                 return wrappers.push(self, remote, force, revs)
 
-        @remotesvn
-        def pull(self, remote, heads=[], force=False):
-            return wrappers.pull(self, remote, heads, force)
+        if hgutil.safehasattr(localrepo.localrepository, 'pull'):
+            # Mercurial < 3.2
+            @remotesvn
+            def pull(self, remote, heads=[], force=False):
+                return wrappers.pull(self, remote, heads, force)
 
         @remotesvn
         def findoutgoing(self, remote, base=None, heads=None, force=False):
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -518,6 +518,19 @@ def pull(repo, source, heads=[], force=F
     else:
         ui.status("pulled %d revisions\n" % revisions)
 
+def exchangepull(orig, repo, remote, heads=None, force=False, bookmarks=()):
+    capable = getattr(remote, 'capable', lambda x: False)
+    if capable('subversion'):
+        pullop = exchange.pulloperation(repo, remote, heads, force,
+                                        bookmarks=bookmarks)
+        try:
+            pullop.cgresult = pull(repo, remote, heads, force)
+            return pullop
+        finally:
+            pullop.releasetransaction()
+    else:
+        return orig(repo, remote, heads, force, bookmarks=bookmarks)
+
 def rebase(orig, ui, repo, **opts):
     """rebase current unpushed revisions onto the Subversion head