[PATCH 2 of 2 V2] traceback: allow providing of a local support contact point

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Sep 17 14:11:35 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1442000719 25200
#      Fri Sep 11 12:45:19 2015 -0700
# Node ID 224402df539757ac09d1ec0b0f707aa8fab75634
# Parent  75a8b3abe7bc407e84153134dadfa3815443210d
traceback: allow providing of 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.

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -333,11 +333,11 @@ def _runcatch(req):
         # of date) will be clueful enough to notice the implausible
         # version number and try updating.
         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.'))
                 if not testedwith.strip():
                     # We found an untested extension. It's likely the culprit.
@@ -365,13 +365,15 @@ def _runcatch(req):
                          '** which supports versions %s of Mercurial.\n'
                          '** Please disable %s and try your action again.\n'
                          '** 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") %
                      ", ".join([x[0] for x in extensions.extensions()])))
         ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc())
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1509,10 +1509,15 @@ User interface controls.
     abbreviations. True or False. (default: False)
 
 ``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)
 
 ``traceback``
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -941,10 +941,19 @@ Older extension is tested with current v
   ** If that fixes the bug please report it to http://example.com/bts
   ** Python * (glob)
   ** 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
   $ if [ -z "$hgver" ]; then
   >   echo "unable to fetch a mercurial version. Make sure __version__ is correct";


More information about the Mercurial-devel mailing list