comparison mercurial/dirstatemap.py @ 47688:b37ab6b5c438

dirstate-map: factor out the change to _dirs and _alldirs on dropping 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/D11130
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 15 Jul 2021 01:58:50 +0200
parents e59bd6723f2f
children f2aef39abc14
comparison
equal deleted inserted replaced
47687:e59bd6723f2f 47688:b37ab6b5c438
152 old_entry is None or old_entry.removed 152 old_entry is None or old_entry.removed
153 ) and "_dirs" in self.__dict__: 153 ) and "_dirs" in self.__dict__:
154 self._dirs.addpath(filename) 154 self._dirs.addpath(filename)
155 if old_entry is None and "_alldirs" in self.__dict__: 155 if old_entry is None and "_alldirs" in self.__dict__:
156 self._alldirs.addpath(filename) 156 self._alldirs.addpath(filename)
157
158 def _dirs_decr(self, filename, old_entry=None):
159 """decremente the dirstate counter if applicable"""
160 if old_entry is not None:
161 if "_dirs" in self.__dict__ and not old_entry.removed:
162 self._dirs.delpath(filename)
163 if "_alldirs" in self.__dict__:
164 self._alldirs.delpath(filename)
165 if "filefoldmap" in self.__dict__:
166 normed = util.normcase(filename)
167 self.filefoldmap.pop(normed, None)
157 168
158 def addfile( 169 def addfile(
159 self, 170 self,
160 f, 171 f,
161 mode=0, 172 mode=0,
245 """ 256 """
246 Remove a file from the dirstate. Returns True if the file was 257 Remove a file from the dirstate. Returns True if the file was
247 previously recorded. 258 previously recorded.
248 """ 259 """
249 old_entry = self._map.pop(f, None) 260 old_entry = self._map.pop(f, None)
250 exists = False 261 self._dirs_decr(f, old_entry=old_entry)
251 oldstate = b'?'
252 if old_entry is not None:
253 exists = True
254 oldstate = old_entry.state
255 if exists:
256 if oldstate != b"r" and "_dirs" in self.__dict__:
257 self._dirs.delpath(f)
258 if "_alldirs" in self.__dict__:
259 self._alldirs.delpath(f)
260 if "filefoldmap" in self.__dict__:
261 normed = util.normcase(f)
262 self.filefoldmap.pop(normed, None)
263 self.nonnormalset.discard(f) 262 self.nonnormalset.discard(f)
264 return exists 263 return old_entry is not None
265 264
266 def clearambiguoustimes(self, files, now): 265 def clearambiguoustimes(self, files, now):
267 for f in files: 266 for f in files:
268 e = self.get(f) 267 e = self.get(f)
269 if e is not None and e.need_delay(now): 268 if e is not None and e.need_delay(now):