Patchwork D982: dirstate: remove _dirs property cache

login
register
mail settings
Submitter phabricator
Date Oct. 14, 2017, 4:55 a.m.
Message ID <fdec201b070a2326856308b647d321b3@localhost.localdomain>
Download mbox | patch
Permalink /patch/24865/
State Not Applicable
Headers show

Comments

phabricator - Oct. 14, 2017, 4:55 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG014bd2a555c8: dirstate: remove _dirs property cache (authored by durham, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D982?vs=2512&id=2711

REVISION DETAIL
  https://phab.mercurial-scm.org/D982

AFFECTED FILES
  contrib/perf.py
  mercurial/dirstate.py

CHANGE DETAILS




To: durham, #hg-reviewers, quark, durin42
Cc: mercurial-devel

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -136,7 +136,7 @@ 
     def _dirfoldmap(self):
         f = {}
         normcase = util.normcase
-        for name in self._dirs:
+        for name in self._map.dirs:
             f[normcase(name)] = name
         return f
 
@@ -166,12 +166,8 @@ 
     def _pl(self):
         return self._map.parents()
 
-    @propertycache
-    def _dirs(self):
-        return self._map.dirs()
-
     def dirs(self):
-        return self._dirs
+        return self._map.dirs
 
     @rootcache('.hgignore')
     def _ignore(self):
@@ -377,7 +373,7 @@ 
         check whether the dirstate has changed before rereading it.'''
 
         for a in ("_map", "_dirfoldmap", "_branch",
-                  "_dirs", "_ignore"):
+                  "_ignore"):
             if a in self.__dict__:
                 delattr(self, a)
         self._lastnormaltime = 0
@@ -405,8 +401,8 @@ 
         return self._map.copymap
 
     def _droppath(self, f):
-        if self[f] not in "?r" and "_dirs" in self.__dict__:
-            self._dirs.delpath(f)
+        if self[f] not in "?r" and "dirs" in self._map.__dict__:
+            self._map.dirs.delpath(f)
 
         if "filefoldmap" in self._map.__dict__:
             normed = util.normcase(f)
@@ -419,18 +415,18 @@ 
         oldstate = self[f]
         if state == 'a' or oldstate == 'r':
             scmutil.checkfilename(f)
-            if f in self._dirs:
+            if f in self._map.dirs:
                 raise error.Abort(_('directory %r already in dirstate') % f)
             # shadows
             for d in util.finddirs(f):
-                if d in self._dirs:
+                if d in self._map.dirs:
                     break
                 entry = self._map.get(d)
                 if entry is not None and entry[0] != 'r':
                     raise error.Abort(
                         _('file %r in dirstate clashes with %r') % (d, f))
-        if oldstate in "?r" and "_dirs" in self.__dict__:
-            self._dirs.addpath(f)
+        if oldstate in "?r" and "dirs" in self._map.__dict__:
+            self._map.dirs.addpath(f)
         self._dirty = True
         self._updatedfiles.add(f)
         self._map[f] = dirstatetuple(state, mode, size, mtime)
@@ -607,8 +603,6 @@ 
 
     def clear(self):
         self._map = dirstatemap(self._ui, self._opener, self._root)
-        if "_dirs" in self.__dict__:
-            delattr(self, "_dirs")
         self._map.setparents(nullid, nullid)
         self._lastnormaltime = 0
         self._updatedfiles.clear()
@@ -1287,6 +1281,7 @@ 
         f['.'] = '.' # prevents useless util.fspath() invocation
         return f
 
+    @propertycache
     def dirs(self):
         """Returns a set-like object containing all the directories in the
         current dirstate.
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -519,7 +519,7 @@ 
     'a' in dirstate
     def d():
         dirstate.dirs()
-        del dirstate._dirs
+        del dirstate._map.dirs
     timer(d)
     fm.end()
 
@@ -538,8 +538,8 @@ 
     timer, fm = gettimer(ui, opts)
     "a" in repo.dirstate
     def d():
-        "a" in repo.dirstate._dirs
-        del repo.dirstate._dirs
+        "a" in repo.dirstate._map.dirs
+        del repo.dirstate._map.dirs
     timer(d)
     fm.end()
 
@@ -562,7 +562,7 @@ 
     def d():
         dirstate._dirfoldmap.get('a')
         del dirstate._dirfoldmap
-        del dirstate._dirs
+        del dirstate._map.dirs
     timer(d)
     fm.end()