[PATCH] dispatch: split out warning message generation to separate function
Martijn Pieters
mj at zopatista.com
Tue Apr 5 21:43:14 UTC 2016
# HG changeset patch
# User Martijn Pieters <mjpieters at fb.com>
# Date 1459882883 -3600
# Tue Apr 05 20:01:23 2016 +0100
# Node ID 80d54d0b5fc4dd420f9736e08ffdf3b97f50a59e
# Parent 1e97bcbb87767e1a96909900595a0b6a7791407b
dispatch: split out warning message generation to separate function
Allow for patching warning message generation, or for patching out the ui.log /
ui.warn behaviour (but still generate the warning message).
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -1015,12 +1015,9 @@
else:
return checkargs()
-def handlecommandexception(ui):
- """Produce a warning message for broken commands
+def _exceptionwarning(ui):
+ """Produce a warning message for the current active exception"""
- Called when handling an exception; the exception is reraised if
- this function returns False, ignored otherwise.
- """
# For compatibility checking, we discard the portion of the hg
# version after the + on the assumption that if a "normal
# user" is running a build with a + in it the packager
@@ -1072,6 +1069,15 @@
util.version()) +
(_("** Extensions loaded: %s\n") %
", ".join([x[0] for x in extensions.extensions()])))
+ return warning
+
+def handlecommandexception(ui):
+ """Produce a warning message for broken commands
+
+ Called when handling an exception; the exception is reraised if
+ this function returns False, ignored otherwise.
+ """
+ warning = _exceptionwarning(ui)
ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc())
ui.warn(warning)
return False # re-raise the exception
More information about the Mercurial-devel
mailing list