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

login
register
mail settings
Submitter Jun Wu
Date June 30, 2016, 4:59 p.m.
Message ID <7c2dc6643d1c37dbc388.1467305944@x1c>
Download mbox | patch
Permalink /patch/15673/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - June 30, 2016, 4:59 p.m.
# HG changeset patch
# User Jun Wu <quark@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.
Jun Wu - July 1, 2016, 11:06 a.m.
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@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

Patch

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