# HG changeset patch # User Pierre-Yves David # Date 1428863262 14400 # Node ID 3ad1571d48527cf99cc2dc7b511099f7cacc02b6 # Parent d6caadff47790d738f256ad44ee2b635e643ad03 develwarn: include call site in the simple message version Just displaying the warning makes it quite hard to recognise the guilty code quickly and using --traceback for all calls is not very convenient. So we include the call site with all simple message to help developer to recognise errors sources. diff -r d6caadff4779 -r 3ad1571d4852 mercurial/scmutil.py --- a/mercurial/scmutil.py Sun Apr 12 14:26:11 2015 -0400 +++ b/mercurial/scmutil.py Sun Apr 12 14:27:42 2015 -0400 @@ -10,7 +10,7 @@ import util, error, osutil, revset, similar, encoding, phases import pathutil import match as matchmod -import os, errno, re, glob, tempfile, shutil, stat +import os, errno, re, glob, tempfile, shutil, stat, inspect if os.name == 'nt': import scmwindows as scmplatform @@ -177,7 +177,9 @@ if tui.tracebackflag: util.debugstacktrace(msg, 2) else: - tui.write_err(msg + '\n') + curframe = inspect.currentframe() + calframe = inspect.getouterframes(curframe, 2) + tui.write_err('%s at: %s:%s (%s)\n' % ((msg,) + calframe[2][1:4])) def filteredhash(repo, maxrev): """build hash of filtered revisions in the current repoview. diff -r d6caadff4779 -r 3ad1571d4852 tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t Sun Apr 12 14:26:11 2015 -0400 +++ b/tests/test-devel-warnings.t Sun Apr 12 14:27:42 2015 -0400 @@ -43,16 +43,16 @@ $ hg init lock-checker $ cd lock-checker $ hg buggylocking - transaction with no lock - "wlock" acquired after "lock" + transaction with no lock at: $TESTTMP/buggylocking.py:11 (buggylocking) + "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:13 (buggylocking) $ cat << EOF >> $HGRCPATH > [devel] > all=0 > check-locks=1 > EOF $ hg buggylocking - transaction with no lock - "wlock" acquired after "lock" + transaction with no lock at: $TESTTMP/buggylocking.py:11 (buggylocking) + "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:13 (buggylocking) $ hg buggylocking --traceback transaction with no lock at: */hg:* in * (glob)