diff mercurial/discovery.py @ 11574:6381fa7bfa53

Abort: add a hint argument, printed in the next line inside parenthesis discovery was using a custom made message for this purpose push now returns -1 after aborting, instead of 1 previously
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Thu, 15 Jul 2010 14:41:22 +0200
parents 7ecf4a082c5f
children 98c874a929f1
line wrap: on
line diff
--- a/mercurial/discovery.py	Thu Jul 15 14:40:17 2010 +0200
+++ b/mercurial/discovery.py	Thu Jul 15 14:41:22 2010 +0200
@@ -252,18 +252,16 @@
 
         def fail_multiple_heads(unsynced, branch=None):
             if branch:
-                msg = _("abort: push creates new remote heads"
-                        " on branch '%s'!\n") % branch
+                msg = _("push creates new remote heads "
+                        "on branch '%s'!") % branch
             else:
-                msg = _("abort: push creates new remote heads!\n")
-            repo.ui.warn(msg)
+                msg = _("push creates new remote heads!")
+
             if unsynced:
-                repo.ui.status(_("(you should pull and merge or"
-                                 " use push -f to force)\n"))
+                hint = _("you should pull and merge or use push -f to force")
             else:
-                repo.ui.status(_("(did you forget to merge?"
-                                 " use push -f to force)\n"))
-            return None, 0
+                hint = _("did you forget to merge? use push -f to force")
+            raise util.Abort(msg, hint=hint)
 
         if remote.capable('branchmap'):
             # Check for each named branch if we're creating new remote heads.
@@ -283,12 +281,10 @@
             newbranches = branches - set(remotemap)
             if newbranches and not newbranch: # new branch requires --new-branch
                 branchnames = ', '.join(sorted(newbranches))
-                repo.ui.warn(_("abort: push creates "
-                               "new remote branches: %s!\n")
-                             % branchnames)
-                repo.ui.status(_("(use 'hg push --new-branch' to create new "
-                                 "remote branches)\n"))
-                return None, 0
+                raise util.Abort(_("push creates new remote branches: %s!")
+                                   % branchnames,
+                                 hint=_("use 'hg push --new-branch' to create"
+                                        " new remote branches"))
             branches.difference_update(newbranches)
 
             # 3. Construct the initial oldmap and newmap dicts.