Mercurial > hg-stable
changeset 8732:3507f6c7715c
dirstate: eliminate reference cycle from normalize
Bound methods hold a reference to self, so assigning a bound method to
an instance unavoidably creates a cycle. Work around this by choosing
a normalize method at walk time instead. Eliminate default arg while
we're at it.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 08 Jun 2009 18:14:44 -0500 |
parents | f037187a6f68 |
children | f8be48c6b08c |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Sun Jun 07 21:16:05 2009 +0200 +++ b/mercurial/dirstate.py Mon Jun 08 18:14:44 2009 -0500 @@ -114,12 +114,6 @@ def _checkcase(self): return not util.checkcase(self._join('.hg')) - @propertycache - def normalize(self): - if self._checkcase: - return self._normalize - return lambda x, y=False: x - def _join(self, f): # much faster than os.path.join() # it's safe because f is always a relative path @@ -345,7 +339,7 @@ except KeyError: self._ui.warn(_("not in dirstate: %s\n") % f) - def _normalize(self, path, knownpath=False): + def _normalize(self, path, knownpath): norm_path = os.path.normcase(path) fold_path = self._foldmap.get(norm_path, None) if fold_path is None: @@ -450,7 +444,6 @@ badfn = match.bad dmap = self._map normpath = util.normpath - normalize = self.normalize listdir = osutil.listdir lstat = os.lstat getkind = stat.S_IFMT @@ -461,6 +454,11 @@ work = [] wadd = work.append + if self._checkcase: + normalize = self._normalize + else: + normalize = lambda x, y: x + exact = skipstep3 = False if matchfn == match.exact: # match.exact exact = True @@ -475,7 +473,7 @@ # step 1: find all explicit files for ff in sorted(files): - nf = normalize(normpath(ff)) + nf = normalize(normpath(ff), True) if nf in results: continue