[PATCH 4 of 6] ui: log devel warnings
timeless
timeless at mozdev.org
Tue Mar 1 06:51:46 EST 2016
# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1454078236 0
# Fri Jan 29 14:37:16 2016 +0000
# Node ID b7684e135b04f0549a094c542ec934ff82690c04
# Parent c30da8f7af8b18641911c972197e69a2a2aa46d8
ui: log devel warnings
This makes it easier for the blackbox extension to log
what is happening.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -89,6 +89,17 @@
# pager =""",
}
+class uilogasfile(object):
+ """ shim to present a file-like object and map output to ui.log
+ """
+ def __init__(self, ui, service='develwarn'):
+ def write(msg):
+ ui.log(service, msg)
+ def flush():
+ ui.flush()
+ self.write = write
+ self.flush = flush
+
class ui(object):
def __init__(self, src=None):
# _buffers: used for temporary capture of output
@@ -1069,11 +1080,14 @@
stacklevel += 1 # get in develwarn
if self.tracebackflag:
util.debugstacktrace(msg, stacklevel, self.ferr, self.fout)
+ util.debugstacktrace(msg, stacklevel, uilogasfile(self))
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
diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t
--- a/tests/test-devel-warnings.t
+++ b/tests/test-devel-warnings.t
@@ -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 20
+ 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:
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */hg:* in <module> (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in run (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in dispatch (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in _runcatch (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in _dispatch (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in runcommand (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in _runcommand (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in checkargs (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/dispatch.py:* in <lambda> (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> */mercurial/util.py:* in check (glob)
+ 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> $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 20
$ cd ..
More information about the Mercurial-devel
mailing list