Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 37675:5b8a260769a2
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
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 13 Apr 2018 14:18:26 -0700 |
parents | 1765ed63db40 |
children | 5cab6f5016fa |
comparison
equal
deleted
inserted
replaced
37674:f83cb91b052e | 37675:5b8a260769a2 |
---|---|
3779 def _deprecatedfunc(func, version, modname=None): | 3779 def _deprecatedfunc(func, version, modname=None): |
3780 def wrapped(*args, **kwargs): | 3780 def wrapped(*args, **kwargs): |
3781 fn = pycompat.sysbytes(func.__name__) | 3781 fn = pycompat.sysbytes(func.__name__) |
3782 mn = modname or pycompat.sysbytes(func.__module__)[len('mercurial.'):] | 3782 mn = modname or pycompat.sysbytes(func.__module__)[len('mercurial.'):] |
3783 msg = "'util.%s' is deprecated, use '%s.%s'" % (fn, mn, fn) | 3783 msg = "'util.%s' is deprecated, use '%s.%s'" % (fn, mn, fn) |
3784 nouideprecwarn(msg, version) | 3784 nouideprecwarn(msg, version, stacklevel=2) |
3785 return func(*args, **kwargs) | 3785 return func(*args, **kwargs) |
3786 wrapped.__name__ = func.__name__ | 3786 wrapped.__name__ = func.__name__ |
3787 return wrapped | 3787 return wrapped |
3788 | 3788 |
3789 defaultdateformats = dateutil.defaultdateformats | 3789 defaultdateformats = dateutil.defaultdateformats |