hgext/evolve.py
changeset 1122 c8750f4388c8
parent 1120 9bc4857f573b
child 1128 aabb145058d7
--- 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):