obsolete: doc punch the hint about hg stabilize into the push error message. stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 25 Jul 2012 17:40:50 +0200
branchstable
changeset 375 1525b240d806
parent 374 2c969d1b18e0
child 376 188afb394e10
obsolete: doc punch the hint about hg stabilize into the push error message. The goal is to ease the transposition of to default where half of the message may be raised by core directly.
hgext/obsolete.py
--- a/hgext/obsolete.py	Wed Jul 25 17:28:32 2012 +0200
+++ b/hgext/obsolete.py	Wed Jul 25 17:40:50 2012 +0200
@@ -487,23 +487,30 @@
     * patch remote to ignore obsolete heads on remote
     """
     # do not push instability
-    for h in outgoing.missingheads:
-        # checking heads only is enought because any thing base on obsolete
-        # changeset is either obsolete or unstable.
-        ctx =  repo[h]
+    try:
+        for h in outgoing.missingheads:
+            # checking heads only is enought because any thing base on obsolete
+            # changeset is either obsolete or unstable.
+            ctx =  repo[h]
+            if ctx.unstable():
+                raise util.Abort(_("push includes an unstable changeset: %s!")
+                                 % ctx)
+            if ctx.obsolete():
+                raise util.Abort(_("push includes an  obsolete changeset: %s!")
+                                 % ctx)
+            if ctx.latecomer():
+                raise util.Abort(_("push includes an latecomer changeset: %s!")
+                                 % ctx)
+            if ctx.conflicting():
+                raise util.Abort(_("push includes conflicting changeset: %s!")
+                                 % ctx)
+    except util.Abort, ex:
         hint = _("use 'hg stabilize' to get a stable history (or --force to proceed)")
-        if ctx.unstable():
-            raise util.Abort(_("push includes an unstable changeset: %s!") % ctx,
-                             hint=hint)
-        if ctx.obsolete():
-            raise util.Abort(_("push includes an  obsolete changeset: %s!") % ctx,
-                             hint=hint)
-        if ctx.latecomer():
-            raise util.Abort(_("push includes an latecomer changeset: %s!") % ctx,
-                             hint=hint)
-        if ctx.conflicting():
-            raise util.Abort(_("push includes conflicting changeset: %s!") % ctx,
-                             hint=hint)
+        if (len(ex.args) >= 1
+            and ex.args[0].startswith('push includes ')
+            and ex.hint is None):
+            ex.hint = hint
+        raise
     ### patch remote branch map
     # do not read it this burn eyes
     try: