Patchwork D3307: context: set stack level for deprecation warning

login
register
mail settings
Submitter phabricator
Date April 13, 2018, 5:08 p.m.
Message ID <differential-rev-PHID-DREV-3dv3bj4lzewmbqovdfjc-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30855/
State Superseded
Headers show

Comments

phabricator - April 13, 2018, 5:08 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch makes the deprecation warning print the caller of
  repo.__getitem__. That's not quite correct, since there could also be
  other callers of changectx.__init__, but it seems like the most
  helpful stack level in practice.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3307

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -399,7 +399,7 @@ 
     #  * If "x" can be a mix of the above, you'll have to figure it out
     #    yourself
     repo.ui.deprecwarn("changectx.__init__ is getting more limited, see source "
-                       "for details", "4.6")
+                       "for details", "4.6", stacklevel=4)
 
 class changectx(basectx):
     """A changecontext object makes access to data related to a particular