Patchwork [2,of,2] match: define exactmatcher.matchfn statically

login
register
mail settings
Submitter Yuya Nishihara
Date May 28, 2017, 3:26 p.m.
Message ID <543c18862df7b1f17802.1495985169@mimosa>
Download mbox | patch
Permalink /patch/20985/
State Accepted
Headers show

Comments

Yuya Nishihara - May 28, 2017, 3:26 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1495983271 -32400
#      Sun May 28 23:54:31 2017 +0900
# Node ID 543c18862df7b1f17802d95da087388ba99a64d2
# Parent  cad7aca56f0bf3d5865cc07ee9616568ada78c36
match: define exactmatcher.matchfn statically

This should eliminate the reference cycle, self.matchfn -> self.exact -> self.
via Mercurial-devel - May 30, 2017, 4:40 a.m.
On Sun, May 28, 2017 at 8:26 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1495983271 -32400
> #      Sun May 28 23:54:31 2017 +0900
> # Node ID 543c18862df7b1f17802d95da087388ba99a64d2
> # Parent  cad7aca56f0bf3d5865cc07ee9616568ada78c36
> match: define exactmatcher.matchfn statically
>
> This should eliminate the reference cycle, self.matchfn -> self.exact -> self.

Queuing this, thanks.

It took me a while to understand this and it made me realize that I
still didn't know when methods are bound in Python and why not every
bound method would result in a cycle (because they are bound only at
access time and then discarded, IIUC), so thanks for the (probably
unintended) lesson.

>
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -415,7 +415,8 @@ class exactmatcher(basematcher):
>              self._files = files
>          else:
>              self._files = list(files)
> -        self.matchfn = self.exact
> +
> +    matchfn = basematcher.exact
>
>      @propertycache
>      def _dirs(self):

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -415,7 +415,8 @@  class exactmatcher(basematcher):
             self._files = files
         else:
             self._files = list(files)
-        self.matchfn = self.exact
+
+    matchfn = basematcher.exact
 
     @propertycache
     def _dirs(self):