diff hgext/evolve.py @ 1122:c8750f4388c8

evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 02 Oct 2014 21:10:48 -0400
parents 9bc4857f573b
children aabb145058d7
line wrap: on
line diff
--- 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):