[PATCH 09 of 10] ui: drop frame objects in develwarn explicitly

Jun Wu quark at fb.com
Fri Jul 1 11:06:50 UTC 2016


The real issue here is the frame object creates a cycle. The comment is
inaccurate and should be changed to:

  # frame objects create a cycle. drop them explicitly.

Excerpts from Jun Wu's message of 2016-06-30 17:59:04 +0100:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1467299113 -3600
> #      Thu Jun 30 16:05:13 2016 +0100
> # Node ID 7c2dc6643d1c37dbc388ce4ac7112341f0926f28
> # Parent  ef2f1cd2bea11c00bd325f9f3ef52afe2e972c44
> # Available At https://bitbucket.org/quark-zju/hg-draft 
> #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r 7c2dc6643d1c
> ui: drop frame objects in develwarn explicitly
> 
> The next patch will do reference counting on the ui object and the frame object
> can mess up the count. Explicitly setting them to None solves the issue.
> 
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -1178,6 +1178,10 @@ class ui(object):
>                             % ((msg,) + calframe[stacklevel][1:4]))
>              self.log('develwarn', '%s at: %s:%s (%s)\n',
>                       msg, *calframe[stacklevel][1:4])
> +            # frame objects keep references to a lot of other objects,
> +            # drop them explicitly.
> +            curframe = None
> +            calframe = None
>  
>      def deprecwarn(self, msg, version):
>          """issue a deprecation warning


More information about the Mercurial-devel mailing list