Patchwork context: drop caching 'copies' method

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 12, 2014, 7:01 p.m.
Message ID <57abc08c399b28aa8624.1389553309@localhost.localdomain>
Download mbox | patch
Permalink /patch/3308/
State Accepted
Commit d0097d5818f984465e4f0db184056ee6716e8c72
Headers show

Comments

Mads Kiilerich - Jan. 12, 2014, 7:01 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1384634789 18000
#      Sat Nov 16 15:46:29 2013 -0500
# Node ID 57abc08c399b28aa86248f6db2cc63a7cf0b0f13
# Parent  d2704c48f4176d8cd6f21d33500820d44763585c
context: drop caching 'copies' method

The 'copies' method has no test coverage and calls copies.pathcopies with an
incorrect number of parameters and is thus (fortunately) not used. Kill it.
Pierre-Yves David - Jan. 13, 2014, 6:25 a.m.
Yeah! code drop, looks good to me!

On 01/12/2014 11:01 AM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1384634789 18000
> #      Sat Nov 16 15:46:29 2013 -0500
> # Node ID 57abc08c399b28aa86248f6db2cc63a7cf0b0f13
> # Parent  d2704c48f4176d8cd6f21d33500820d44763585c
> context: drop caching 'copies' method
>
> The 'copies' method has no test coverage and calls copies.pathcopies with an
> incorrect number of parameters and is thus (fortunately) not used. Kill it.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -8,7 +8,6 @@
>   from node import nullid, nullrev, short, hex, bin
>   from i18n import _
>   import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
> -import copies
>   import match as matchmod
>   import os, errno, stat
>   import obsolete as obsmod
> @@ -737,14 +736,6 @@ class basefilectx(object):
>               c = visit.pop(max(visit))
>               yield c
>   
> -    def copies(self, c2):
> -        if not util.safehasattr(self, "_copycache"):
> -            self._copycache = {}
> -        sc2 = str(c2)
> -        if sc2 not in self._copycache:
> -            self._copycache[sc2] = copies.pathcopies(c2)
> -        return self._copycache[sc2]
> -
>   class filectx(basefilectx):
>       """A filecontext object makes access to data related to a particular
>          filerevision convenient."""
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - Jan. 14, 2014, 7:04 p.m.
On Sun, Jan 12, 2014 at 08:01:49PM +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1384634789 18000
> #      Sat Nov 16 15:46:29 2013 -0500
> # Node ID 57abc08c399b28aa86248f6db2cc63a7cf0b0f13
> # Parent  d2704c48f4176d8cd6f21d33500820d44763585c
> context: drop caching 'copies' method
>
queued, thanks

>
> The 'copies' method has no test coverage and calls copies.pathcopies with an
> incorrect number of parameters and is thus (fortunately) not used. Kill it.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -8,7 +8,6 @@
>  from node import nullid, nullrev, short, hex, bin
>  from i18n import _
>  import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
> -import copies
>  import match as matchmod
>  import os, errno, stat
>  import obsolete as obsmod
> @@ -737,14 +736,6 @@ class basefilectx(object):
>              c = visit.pop(max(visit))
>              yield c
>
> -    def copies(self, c2):
> -        if not util.safehasattr(self, "_copycache"):
> -            self._copycache = {}
> -        sc2 = str(c2)
> -        if sc2 not in self._copycache:
> -            self._copycache[sc2] = copies.pathcopies(c2)
> -        return self._copycache[sc2]
> -
>  class filectx(basefilectx):
>      """A filecontext object makes access to data related to a particular
>         filerevision convenient."""
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -8,7 +8,6 @@ 
 from node import nullid, nullrev, short, hex, bin
 from i18n import _
 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
-import copies
 import match as matchmod
 import os, errno, stat
 import obsolete as obsmod
@@ -737,14 +736,6 @@  class basefilectx(object):
             c = visit.pop(max(visit))
             yield c
 
-    def copies(self, c2):
-        if not util.safehasattr(self, "_copycache"):
-            self._copycache = {}
-        sc2 = str(c2)
-        if sc2 not in self._copycache:
-            self._copycache[sc2] = copies.pathcopies(c2)
-        return self._copycache[sc2]
-
 class filectx(basefilectx):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""