changeset 28498:d09be0b8a3c6

ui: log devel warnings
author timeless <timeless@mozdev.org>
date Fri, 29 Jan 2016 14:37:16 +0000
parents 906fece80cfa
children 8b90367c4cf3
files mercurial/ui.py tests/test-devel-warnings.t
diffstat 2 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Fri Mar 11 17:22:04 2016 +0000
+++ b/mercurial/ui.py	Fri Jan 29 14:37:16 2016 +0000
@@ -1069,11 +1069,15 @@
         stacklevel += 1 # get in develwarn
         if self.tracebackflag:
             util.debugstacktrace(msg, stacklevel, self.ferr, self.fout)
+            self.log('develwarn', '%s at:\n%s' %
+                     (msg, ''.join(util.getstackframes(stacklevel))))
         else:
             curframe = inspect.currentframe()
             calframe = inspect.getouterframes(curframe, 2)
             self.write_err('%s at: %s:%s (%s)\n'
                            % ((msg,) + calframe[stacklevel][1:4]))
+            self.log('develwarn', '%s at: %s:%s (%s)\n',
+                     msg, *calframe[stacklevel][1:4])
 
     def deprecwarn(self, msg, version):
         """issue a deprecation warning
--- a/tests/test-devel-warnings.t	Fri Mar 11 17:22:04 2016 +0000
+++ b/tests/test-devel-warnings.t	Fri Jan 29 14:37:16 2016 +0000
@@ -63,6 +63,8 @@
   $ cat << EOF >> $HGRCPATH
   > [extensions]
   > buggylocking=$TESTTMP/buggylocking.py
+  > mock=$TESTDIR/mockblackbox.py
+  > blackbox=
   > [devel]
   > all-warnings=1
   > EOF
@@ -138,4 +140,27 @@
    */mercurial/dispatch.py:* in <lambda> (glob)
    */mercurial/util.py:* in check (glob)
    $TESTTMP/buggylocking.py:* in oldanddeprecated (glob)
+  $ hg blackbox -l 9
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> devel-warn: revset "oldstyle" use list instead of smartset, (upgrade your code) at: */mercurial/revset.py:* (mfunc) (glob)
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> log -r oldstyle() -T {rev}\n exited 0 after * seconds (glob)
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> devel-warn: foorbar is deprecated, go shopping
+  (compatibility will be dropped after Mercurial-42.1337, update your code.) at: $TESTTMP/buggylocking.py:* (oldanddeprecated) (glob)
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated exited 0 after * seconds (glob)
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated --traceback
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> devel-warn: foorbar is deprecated, go shopping
+  (compatibility will be dropped after Mercurial-42.1337, update your code.) at:
+   */hg:* in <module> (glob)
+   */mercurial/dispatch.py:* in run (glob)
+   */mercurial/dispatch.py:* in dispatch (glob)
+   */mercurial/dispatch.py:* in _runcatch (glob)
+   */mercurial/dispatch.py:* in _dispatch (glob)
+   */mercurial/dispatch.py:* in runcommand (glob)
+   */mercurial/dispatch.py:* in _runcommand (glob)
+   */mercurial/dispatch.py:* in checkargs (glob)
+   */mercurial/dispatch.py:* in <lambda> (glob)
+   */mercurial/util.py:* in check (glob)
+   $TESTTMP/buggylocking.py:* in oldanddeprecated (glob)
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated --traceback exited 0 after * seconds (glob)
+  1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> blackbox -l 9
   $ cd ..