Mercurial > hg
comparison mercurial/dirstatemap.py @ 47687:e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
This logic is complicated enough to deserves its own function. So it now does.
This will make it easier to reuse that logic in later changeset.
Differential Revision: https://phab.mercurial-scm.org/D11129
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 15 Jul 2021 01:58:31 +0200 |
parents | e43128ee436f |
children | b37ab6b5c438 |
comparison
equal
deleted
inserted
replaced
47686:e43128ee436f | 47687:e59bd6723f2f |
---|---|
143 return self._map.keys() | 143 return self._map.keys() |
144 | 144 |
145 def preload(self): | 145 def preload(self): |
146 """Loads the underlying data, if it's not already loaded""" | 146 """Loads the underlying data, if it's not already loaded""" |
147 self._map | 147 self._map |
148 | |
149 def _dirs_incr(self, filename, old_entry=None): | |
150 """incremente the dirstate counter if applicable""" | |
151 if ( | |
152 old_entry is None or old_entry.removed | |
153 ) and "_dirs" in self.__dict__: | |
154 self._dirs.addpath(filename) | |
155 if old_entry is None and "_alldirs" in self.__dict__: | |
156 self._alldirs.addpath(filename) | |
148 | 157 |
149 def addfile( | 158 def addfile( |
150 self, | 159 self, |
151 f, | 160 f, |
152 mode=0, | 161 mode=0, |
188 mtime = mtime & rangemask | 197 mtime = mtime & rangemask |
189 assert state is not None | 198 assert state is not None |
190 assert size is not None | 199 assert size is not None |
191 assert mtime is not None | 200 assert mtime is not None |
192 old_entry = self.get(f) | 201 old_entry = self.get(f) |
193 if ( | 202 self._dirs_incr(f, old_entry) |
194 old_entry is None or old_entry.removed | |
195 ) and "_dirs" in self.__dict__: | |
196 self._dirs.addpath(f) | |
197 if old_entry is None and "_alldirs" in self.__dict__: | |
198 self._alldirs.addpath(f) | |
199 e = self._map[f] = DirstateItem(state, mode, size, mtime) | 203 e = self._map[f] = DirstateItem(state, mode, size, mtime) |
200 if e.dm_nonnormal: | 204 if e.dm_nonnormal: |
201 self.nonnormalset.add(f) | 205 self.nonnormalset.add(f) |
202 if e.dm_otherparent: | 206 if e.dm_otherparent: |
203 self.otherparentset.add(f) | 207 self.otherparentset.add(f) |