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

timeless timeless at mozdev.org
Wed Dec 9 18:31:24 UTC 2015


# HG changeset patch
# User timeless <timeless at 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

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."""
 


More information about the Mercurial-devel mailing list