destination: use the correct abort class for error
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Sun, 14 Aug 2016 23:17:09 +0200
changeset 1980 3c4a20244771
parent 1979 bee7a1ef8ba8
child 1981 b467fe430404
destination: use the correct abort class for error These errors have been in Mercurial long enough. Having them will make the coming changesets simpler.
hgext3rd/topic/destination.py
--- a/hgext3rd/topic/destination.py	Sun Aug 14 19:40:53 2016 +0200
+++ b/hgext3rd/topic/destination.py	Sun Aug 14 23:17:09 2016 +0200
@@ -22,14 +22,15 @@
             # should look at all branch involved but... later
             bhead = ngtip(repo, p1.branch(), all=True)
             if not bhead:
-                raise error.Abort(_("nothing to merge"))
+                raise error.NoMergeDestAbort(_("nothing to merge"))
             elif 1 == len(bhead):
                 return bhead.first()
             else:
-                raise error.Abort(_("branch '%s' has %d heads - "
-                                    "please merge with an explicit rev")
-                                  % (p1.branch(), len(bhead)),
-                                  hint=_("run 'hg heads .' to see heads"))
+                msg = _("branch '%s' has %d heads "
+                        "- please merge with an explicit rev")
+                hint = _("run 'hg heads .' to see heads")
+                raise error.ManyMergeDestAbort(msg % (p1.branch(), len(bhead)),
+                                               hint=hint)
         elif 2 == len(heads):
             heads = [r for r in heads if r != p1.rev()]
             # XXX: bla bla bla bla bla
@@ -39,9 +40,9 @@
                                          "explicit revision"))
             return heads[0]
         elif 2 < len(heads):
-            raise error.Abort(_("topic '%s' has %d heads - "
-                                "please merge with an explicit rev")
-                              % (top, len(heads)))
+            msg = _("topic '%s' has %d heads "
+                    "- please merge with an explicit rev") % (top, len(heads))
+            raise error.ManyMergeDestAbort(msg)
         else:
             assert False # that's impossible
     if len(getattr(orig, 'func_defaults', ())) == 3: # version hg-3.7