Patchwork D1252: dirstate: move clear onto dirstatemap class

login
register
mail settings
Submitter phabricator
Date Oct. 26, 2017, 11:25 p.m.
Message ID <differential-rev-PHID-DREV-333lc5csjh6utpkvsmqj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25288/
State Superseded
Headers show

Comments

phabricator - Oct. 26, 2017, 11:25 p.m.
durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  A future diff will move the lazy loading aspect of dirstate to the dirstatemap
  class. This means it requires a slightly different strategy of clearing than
  just reinstantiating the object (since just reinstantiating the object will
  lazily load the on disk data again later instead of remaining permanently
  empty).
  
  So let's give it it's own clear function.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -593,8 +593,7 @@ 
         return path
 
     def clear(self):
-        self._map = dirstatemap(self._ui, self._opener, self._root)
-        self._map.setparents(nullid, nullid)
+        self._map.clear()
         self._lastnormaltime = 0
         self._updatedfiles.clear()
         self._dirty = True
@@ -1210,6 +1209,11 @@ 
         # for consistent view between _pl() and _read() invocations
         self._pendingmode = None
 
+    def clear(self):
+        self._map = {}
+        self.copymap = {}
+        self.setparents(nullid, nullid)
+
     def iteritems(self):
         return self._map.iteritems()