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

login
register
mail settings
Submitter Matt Harbison
Date Oct. 3, 2014, 1:21 a.m.
Message ID <ab3f0da59d421fab9c60.1412299302@Envy>
Download mbox | patch
Permalink /patch/6089/
State Not Applicable
Headers show

Comments

Matt Harbison - Oct. 3, 2014, 1:21 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@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
Pierre-Yves David - Oct. 9, 2014, 3:56 a.m.
On 10/02/2014 06:21 PM, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@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

Pushed to the main repo. Thanks you very much!

Patch

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
 
-@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):