Patchwork [1,of,2] error: add a way to exit early without an error code

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 9, 2015, 6:31 p.m.
Message ID <2f84f71b9b546f121e9f.1449685884@waste.org>
Download mbox | patch
Permalink /patch/11950/
State Deferred
Headers show

Comments

timeless@mozdev.org - Dec. 9, 2015, 6:31 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1449685742 0
#      Wed Dec 09 18:29:02 2015 +0000
# Node ID 2f84f71b9b546f121e9f94771e268b3b0cef0956
# Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
error: add a way to exit early without an error code

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -266,6 +266,8 @@ 
     except error.InterventionRequired as inst:
         ui.warn("%s\n" % inst)
         return 1
+    except error.EarlyNormalExit as inst:
+        return 0
     except error.Abort as inst:
         ui.warn(_("abort: %s\n") % inst)
         if inst.hint:
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -53,6 +53,9 @@ 
 class InterventionRequired(Exception):
     """Exception raised when a command requires human intervention."""
 
+class EarlyNormalExit(Exception):
+    """Exception raised when a command is done and wants to skip normal execution."""
+
 class Abort(HintException):
     """Raised if a command needs to print an error and exit."""