diff hgsubversion/__init__.py @ 1246:2179747e7fea

push: wrap exchange.push when localrepository.push isn't available Mercurial rev 4d52e6eb98ea removed localrepository.push. We don't do it the other way round (wrap push if exchange.push 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:55:27 -0700
parents c8aa5616eec5
children 3a4d74823187
line wrap: on
line diff
--- a/hgsubversion/__init__.py
+++ b/hgsubversion/__init__.py
@@ -20,9 +20,16 @@ import sys
 import traceback
 
 from mercurial import commands
+try:
+    from mercurial import exchange
+    exchange.push  # existed in first iteration of this file
+except ImportError:
+    # We only *use* the exchange module in hg 3.2+, so this is safe
+    pass
 from mercurial import extensions
 from mercurial import help
 from mercurial import hg
+from mercurial import localrepo
 from mercurial import util as hgutil
 from mercurial import demandimport
 demandimport.ignore.extend([
@@ -136,6 +143,10 @@ def extsetup(ui):
     except:
         pass
 
+    if not hgutil.safehasattr(localrepo.localrepository, 'push'):
+        # Mercurial >= 3.2
+        extensions.wrapfunction(exchange, 'push', wrappers.exchangepush)
+
     helpdir = os.path.join(os.path.dirname(__file__), 'help')
 
     entries = (