util: set correct stack level on deprecation warnings
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 13 Apr 2018 14:18:26 -0700
changeset 37675 5b8a260769a2
parent 37674 f83cb91b052e
child 37676 1764527af92e
util: set correct stack level on deprecation warnings Without this patch, you'll get something like this: <path>/mercurial/util.py:3784: DeprecationWarning: 'util.hgexecutable' is deprecated, use 'utils.procutil.hgexecutable' (but on one line) Differential Revision: https://phab.mercurial-scm.org/D3331
mercurial/util.py
--- a/mercurial/util.py	Sat Apr 14 12:57:32 2018 +0900
+++ b/mercurial/util.py	Fri Apr 13 14:18:26 2018 -0700
@@ -3781,7 +3781,7 @@
         fn = pycompat.sysbytes(func.__name__)
         mn = modname or pycompat.sysbytes(func.__module__)[len('mercurial.'):]
         msg = "'util.%s' is deprecated, use '%s.%s'" % (fn, mn, fn)
-        nouideprecwarn(msg, version)
+        nouideprecwarn(msg, version, stacklevel=2)
         return func(*args, **kwargs)
     wrapped.__name__ = func.__name__
     return wrapped