Patchwork [3,of,4] hook: for python hook exceptions, add note to run with --traceback

login
register
mail settings
Submitter Siddharth Agarwal
Date Feb. 12, 2016, 10:53 p.m.
Message ID <c9fcff42975be8331c4e.1455317630@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/13167/
State Accepted
Headers show

Comments

Siddharth Agarwal - Feb. 12, 2016, 10:53 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1455306275 28800
#      Fri Feb 12 11:44:35 2016 -0800
# Node ID c9fcff42975be8331c4e10add62d3bca983d155e
# Parent  81e7825e881bac3132ac3d89ed4d4a6988685c6f
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r c9fcff42975b
hook: for python hook exceptions, add note to run with --traceback

Just like with ImportErrors, it isn't obvious that --traceback will produce
helpful debugging output here.

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -106,6 +106,8 @@  def _pythonhook(ui, repo, name, hname, f
                            '%s\n') % (hname, exc))
         if throw:
             raise
+        if not ui.tracebackflag:
+            ui.warn(_('(run with --traceback for stack trace)\n'))
         ui.traceback()
         return True, True
     finally:
diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -541,6 +541,7 @@  post- python hooks that fail to *run* do
   searching for changes
   no changes found
   error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
+  (run with --traceback for stack trace)
 
 but post- python hooks that fail to *load* do
   $ echo '[hooks]' > .hg/hgrc