obsolete Move merge failure handling into stabilize code
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 20 Aug 2012 12:25:08 +0200
changeset 463 3f91654713dd
parent 462 d38e02332c2c
child 464 d88c761f97c4
obsolete Move merge failure handling into stabilize code This violate less Layer. For this purpose we crate an easy to recognize Exception Class.
hgext/evolve.py
--- a/hgext/evolve.py	Mon Aug 20 22:18:10 2012 +0200
+++ b/hgext/evolve.py	Mon Aug 20 12:25:08 2012 +0200
@@ -131,6 +131,9 @@
 
     return newid, created
 
+class MergeFailure(util.Abort):
+    pass
+
 def relocate(repo, orig, dest):
     """rewrite <rev> on dest"""
     try:
@@ -152,10 +155,10 @@
         try:
             nodenew = rebase.concludenode(repo, orig.node(), dest.node(),
                                           node.nullid)
-        except util.Abort:
-            repo.ui.write_err(_('/!\\ stabilize failed                          /!\\\n'))
-            repo.ui.write_err(_('/!\\ Their is no "hg stabilize --continue"     /!\\\n'))
-            repo.ui.write_err(_('/!\\ use "hg up -C . ; hg stabilize --dry-run" /!\\\n'))
+        except util.Abort, exc:
+            class LocalMergeFailure(MergeFailure, exc.__class__):
+                pass
+            exc.__class__ = LocalMergeFailure
             raise
         oldbookmarks = repo.nodebookmarks(nodesrc)
         obsolete = extensions.find('obsolete')
@@ -286,6 +289,11 @@
         lock = repo.lock()
         try:
             relocate(repo, node, target)
+        except MergeFailure:
+            repo.ui.write_err(_('/!\\ stabilize failed                          /!\\\n'))
+            repo.ui.write_err(_('/!\\ Their is no "hg stabilize --continue"     /!\\\n'))
+            repo.ui.write_err(_('/!\\ use "hg up -C . ; hg stabilize --dry-run" /!\\\n'))
+            raise
         finally:
             lock.release()