evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
authorMatt Harbison <matt_harbison@yahoo.com>
Thu, 02 Oct 2014 21:10:48 -0400
changeset 1122 c8750f4388c8
parent 1121 1a39b1b8e092
child 1123 d6c065a7a6b1
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
hgext/evolve.py
--- a/hgext/evolve.py	Wed Oct 08 18:17:21 2014 -0700
+++ b/hgext/evolve.py	Thu Oct 02 21:10:48 2014 -0400
@@ -611,28 +611,21 @@
         ui.warn(_('%i new divergent changesets\n') % newdivergents)
     return ret
 
-@eh.reposetup
-def _repostabilizesetup(ui, repo):
+@eh.wrapfunction(mercurial.exchange, 'push')
+def push(orig, repo, *args, **opts):
     """Add a hint for "hg evolve" when troubles make push fails
     """
-    if not repo.local():
-        return
-
-    class evolvingrepo(repo.__class__):
-        def push(self, remote, *args, **opts):
-            """wrapper around pull that pull obsolete relation"""
-            try:
-                result = super(evolvingrepo, self).push(remote, *args, **opts)
-            except util.Abort, ex:
-                hint = _("use 'hg evolve' to get a stable history "
-                         "or --force to ignore warnings")
-                if (len(ex.args) >= 1
-                    and ex.args[0].startswith('push includes ')
-                    and ex.hint is None):
-                    ex.hint = hint
-                raise
-            return result
-    repo.__class__ = evolvingrepo
+    try:
+        return orig(repo, *args, **opts)
+    except util.Abort, ex:
+        hint = _("use 'hg evolve' to get a stable history "
+                 "or --force to ignore warnings")
+        if (len(ex.args) >= 1
+            and ex.args[0].startswith('push includes ')
+            and ex.hint is None):
+            ex.hint = hint
+        raise
+    return result
 
 def summaryhook(ui, repo):
     def write(fmt, count):