[PATCH 3 of 8] hg: extend warning when debugging configured
Simon Heimberg
simohe at besonet.ch
Mon Oct 22 09:55:57 UTC 2012
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1349824684 -7200
# Node ID adb1eddcd5341db6979b609ba5d89947de4d50ea
# Parent a20a8a4dd3c5dc4d25cb38d04bff96e75b50e95f
hg: extend warning when debugging configured
When debugging is enabled, extend the warning with more info and a stack trace.
This helps the developer to locate the place where a wrong ui object is passed.
diff -r a20a8a4dd3c5 -r adb1eddcd534 mercurial/ui.py
--- a/mercurial/ui.py Don Okt 04 19:46:43 2012 +0200
+++ b/mercurial/ui.py Mit Okt 10 01:18:04 2012 +0200
@@ -770,5 +770,16 @@
there is copied into the new ui object.
'''
if self.isinrepo:
- src.write_err(' PROGRAMMER WARNING: %s\n' % warnmsg)
+ msg = 'PROGRAMMER WARNING: %s' % warnmsg
+ if self.debugflag:
+ msg += '\n'.join(self.notinrepo.__doc__.split('\n')[1:-1])
+ msg += '\n Traceback (most recent call last):\n'
+ # traceback, maximum 6 calls
+ tb = traceback.format_stack(limit=7)[:-1]
+ if len(tb) == 6:
+ msg += ' ...\n'
+ msg += ''.join(tb)
+ else:
+ msg += ' (--debug for more info)\n'
+ self.warn(msg)
More information about the Mercurial-devel
mailing list