changeset 26263:bf2bfc6f45fb

traceback: allow providing a local support contact point The extensions blaming code is fine for casual users but pretty terrible for corporate environments that can deploy a large amount of extensions to unsuspecting users. Reports will likely blame a random "innocent" extension (in our case crecord) and the hint in the message will triggers endless debug attempts from the user. We introduce a "ui.supportcontact" option that allow such big company to redirect their users to their own support desk. This disables all extensions blaming and just point people to the local support in all cases.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 11 Sep 2015 12:45:19 -0700
parents 3e79ec0ba589
children ac4ed8d6ec50
files mercurial/dispatch.py mercurial/help/config.txt tests/test-extension.t
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Thu Sep 17 11:50:55 2015 -0700
+++ b/mercurial/dispatch.py	Fri Sep 11 12:45:19 2015 -0700
@@ -335,7 +335,7 @@
         compare = myver.split('+')[0]
         ct = tuplever(compare)
         worst = None, ct, ''
-        if True:
+        if ui.config('ui', 'supportcontact', None) is None:
             for name, mod in extensions.extensions():
                 testedwith = getattr(mod, 'testedwith', '')
                 report = getattr(mod, 'buglink', _('the extension author.'))
@@ -367,9 +367,11 @@
                          '** If that fixes the bug please report it to %s\n')
                        % (name, testedwith, name, report))
         else:
+            bugtracker = ui.config('ui', 'supportcontact', None)
+            if bugtracker is None:
+                bugtracker = _("http://mercurial.selenic.com/wiki/BugTracker")
             warning = (_("** unknown exception encountered, "
-                         "please report by visiting\n") +
-                       _("** http://mercurial.selenic.com/wiki/BugTracker\n"))
+                         "please report by visiting\n** ") + bugtracker + '\n')
         warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) +
                     (_("** Mercurial Distributed SCM (version %s)\n") % myver) +
                     (_("** Extensions loaded: %s\n") %
--- a/mercurial/help/config.txt	Thu Sep 17 11:50:55 2015 -0700
+++ b/mercurial/help/config.txt	Fri Sep 11 12:45:19 2015 -0700
@@ -1511,6 +1511,11 @@
 ``style``
     Name of style to use for command output.
 
+``supportcontact``
+    Location pointed at in Mercurial traceback for reporting crash. Use this if
+    you are a large organisation with it's own Mercurial deployement process and
+    crash reports should be addressed to your internal support.
+
 ``timeout``
     The timeout used when a lock is held (in seconds), a negative value
     means no timeout. (default: 600)
--- a/tests/test-extension.t	Thu Sep 17 11:50:55 2015 -0700
+++ b/tests/test-extension.t	Fri Sep 11 12:45:19 2015 -0700
@@ -943,6 +943,15 @@
   ** Mercurial Distributed SCM (version 1.9.3)
   ** Extensions loaded: throw, older
 
+Ability to point to a different point
+  $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
+  >   --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
+  ** unknown exception encountered, please report by visiting
+  ** Your Local Goat Lenders
+  ** Python * (glob)
+  ** Mercurial Distributed SCM (*) (glob)
+  ** Extensions loaded: throw, older
+
 Declare the version as supporting this hg version, show regular bts link:
   $ hgver=`$PYTHON -c 'from mercurial import util; print util.version().split("+")[0]'`
   $ echo 'testedwith = """'"$hgver"'"""' >> throw.py