Patchwork [05,of,11] filectx: remove __new__

login
register
mail settings
Submitter Jun Wu
Date May 10, 2017, 8:34 a.m.
Message ID <f736ea580edbf4ec199b.1494405264@x1c>
Download mbox | patch
Permalink /patch/20551/
State Accepted
Headers show

Comments

Jun Wu - May 10, 2017, 8:34 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1494382608 25200
#      Tue May 09 19:16:48 2017 -0700
# Node ID f736ea580edbf4ec199b55af586b31f2798cbee4
# Parent  b022d125236c47e07db6209e4de648bb70a8de65
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r f736ea580edb
filectx: remove __new__

It does not seem to be used anywhere, and breaks a later patch.
Sean Farley - May 10, 2017, 5:18 p.m.
Jun Wu <quark@fb.com> writes:

> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1494382608 25200
> #      Tue May 09 19:16:48 2017 -0700
> # Node ID f736ea580edbf4ec199b55af586b31f2798cbee4
> # Parent  b022d125236c47e07db6209e4de648bb70a8de65
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r f736ea580edb
> filectx: remove __new__
>
> It does not seem to be used anywhere, and breaks a later patch.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -689,7 +689,4 @@ class basefilectx(object):
>                      directory,
>      memfilectx: a filecontext that represents files in-memory."""
> -    def __new__(cls, repo, path, *args, **kwargs):
> -        return super(basefilectx, cls).__new__(cls)
> -

I remember writing __new__ for basectx due to mpm and I talking about
fast-pathing reusing a ctx without duplicating it. As for filectx, I
seem to recall wanting to do something similar for self.data but ran
into issues of cyclic dependencies later down the line.

So, yes, this patch seems fine to me.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -689,7 +689,4 @@  class basefilectx(object):
                     directory,
     memfilectx: a filecontext that represents files in-memory."""
-    def __new__(cls, repo, path, *args, **kwargs):
-        return super(basefilectx, cls).__new__(cls)
-
     @propertycache
     def _filelog(self):