Patchwork [1,of,2,stable] context: drop caching 'copies' method

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 12, 2013, 3:08 a.m.
Message ID <82165da0edded3801c42.1384225697@localhost.localdomain>
Download mbox | patch
Permalink /patch/2916/
State Superseded
Commit d0097d5818f984465e4f0db184056ee6716e8c72
Headers show

Comments

Mads Kiilerich - Nov. 12, 2013, 3:08 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1384225286 -3600
#      Tue Nov 12 04:01:26 2013 +0100
# Branch stable
# Node ID 82165da0edded3801c421273d49ebccbf382878a
# Parent  ba6486076429e5c20d910b8a5d4f8acf1e9dc1b1
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.
Matt Mackall - Nov. 22, 2013, 9:21 p.m.
On Tue, 2013-11-12 at 04:08 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1384225286 -3600
> #      Tue Nov 12 04:01:26 2013 +0100
> # Branch stable
> # Node ID 82165da0edded3801c421273d49ebccbf382878a
> # Parent  ba6486076429e5c20d910b8a5d4f8acf1e9dc1b1
> context: drop caching 'copies' method

Please stop doing cleanups on stable. This is the third or fourth such
patch you've sent in the last month, so here are the rules:

http://mercurial.selenic.com/wiki/TimeBasedReleasePlan

4. Rules for code freeze and stable branch commits

Because the code freeze is on the stable branch, the rules for each are
the same. The following are allowed:

 -   bug fixes
 -   error message improvements
 -   doc fixes
 -   template fixes
 -   improved translations 

Everything else (including trivial cleanups) is not allowed. 


Why is this the rule? It's a matter of rewards vs risks. A cleanup is a
patch with no user-visible rewards, thus it has nothing to outweigh the
background risks of making changes. And the background risks include
things like the non-zero probability of incorrectly analyzing code as
dead and thus introducing new bugs.

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
@@ -722,14 +721,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."""