[PATCH evolve-ext] evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea

Matt Harbison matt_harbison at yahoo.com
Thu Oct 2 20:21:42 CDT 2014


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1412298648 14400
#      Thu Oct 02 21:10:48 2014 -0400
# Node ID ab3f0da59d421fab9c60cc0e74e2a9aaea3bab9b
# Parent  7068ccfed963f65680583660c4b54d5d425dae6c
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -611,28 +611,21 @@
         ui.warn(_('%i new divergent changesets\n') % newdivergents)
     return ret
 
- at eh.reposetup
-def _repostabilizesetup(ui, repo):
+ at 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):


More information about the Mercurial-devel mailing list