Mercurial > public > mercurial-scm > hg
comparison mercurial/dispatch.py @ 28821:d3369dc6c1d0
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).
author | Martijn Pieters <mjpieters@fb.com> |
---|---|
date | Tue, 05 Apr 2016 20:01:23 +0100 |
parents | 09750b1231c2 |
children | 3640c1702c43 |
comparison
equal
deleted
inserted
replaced
28820:9848a6c77a9b | 28821:d3369dc6c1d0 |
---|---|
1013 ui.log('profile', val) | 1013 ui.log('profile', val) |
1014 fp.close() | 1014 fp.close() |
1015 else: | 1015 else: |
1016 return checkargs() | 1016 return checkargs() |
1017 | 1017 |
1018 def handlecommandexception(ui): | 1018 def _exceptionwarning(ui): |
1019 """Produce a warning message for broken commands | 1019 """Produce a warning message for the current active exception""" |
1020 | 1020 |
1021 Called when handling an exception; the exception is reraised if | |
1022 this function returns False, ignored otherwise. | |
1023 """ | |
1024 # For compatibility checking, we discard the portion of the hg | 1021 # For compatibility checking, we discard the portion of the hg |
1025 # version after the + on the assumption that if a "normal | 1022 # version after the + on the assumption that if a "normal |
1026 # user" is running a build with a + in it the packager | 1023 # user" is running a build with a + in it the packager |
1027 # probably built from fairly close to a tag and anyone with a | 1024 # probably built from fairly close to a tag and anyone with a |
1028 # 'make local' copy of hg (where the version number can be out | 1025 # 'make local' copy of hg (where the version number can be out |
1070 warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) + | 1067 warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) + |
1071 (_("** Mercurial Distributed SCM (version %s)\n") % | 1068 (_("** Mercurial Distributed SCM (version %s)\n") % |
1072 util.version()) + | 1069 util.version()) + |
1073 (_("** Extensions loaded: %s\n") % | 1070 (_("** Extensions loaded: %s\n") % |
1074 ", ".join([x[0] for x in extensions.extensions()]))) | 1071 ", ".join([x[0] for x in extensions.extensions()]))) |
1072 return warning | |
1073 | |
1074 def handlecommandexception(ui): | |
1075 """Produce a warning message for broken commands | |
1076 | |
1077 Called when handling an exception; the exception is reraised if | |
1078 this function returns False, ignored otherwise. | |
1079 """ | |
1080 warning = _exceptionwarning(ui) | |
1075 ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc()) | 1081 ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc()) |
1076 ui.warn(warning) | 1082 ui.warn(warning) |
1077 return False # re-raise the exception | 1083 return False # re-raise the exception |