comparison mercurial/dirstatemap.py @ 47689:f2aef39abc14

dirstate-map: factor out the change to _dirs and _alldirs on removing 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/D11131
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 15 Jul 2021 02:19:41 +0200
parents b37ab6b5c438
children e5fb14a07866
comparison
equal deleted inserted replaced
47688:b37ab6b5c438 47689:f2aef39abc14
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 157
158 def _dirs_decr(self, filename, old_entry=None): 158 def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
159 """decremente the dirstate counter if applicable""" 159 """decremente the dirstate counter if applicable"""
160 if old_entry is not None: 160 if old_entry is not None:
161 if "_dirs" in self.__dict__ and not old_entry.removed: 161 if "_dirs" in self.__dict__ and not old_entry.removed:
162 self._dirs.delpath(filename) 162 self._dirs.delpath(filename)
163 if "_alldirs" in self.__dict__: 163 if "_alldirs" in self.__dict__ and not remove_variant:
164 self._alldirs.delpath(filename) 164 self._alldirs.delpath(filename)
165 elif remove_variant and "_alldirs" in self.__dict__:
166 self._alldirs.addpath(filename)
165 if "filefoldmap" in self.__dict__: 167 if "filefoldmap" in self.__dict__:
166 normed = util.normcase(filename) 168 normed = util.normcase(filename)
167 self.filefoldmap.pop(normed, None) 169 self.filefoldmap.pop(normed, None)
168 170
169 def addfile( 171 def addfile(
239 elif entry.from_p2: 241 elif entry.from_p2:
240 size = FROM_P2 242 size = FROM_P2
241 self.otherparentset.add(f) 243 self.otherparentset.add(f)
242 if entry is not None and not (entry.merged or entry.from_p2): 244 if entry is not None and not (entry.merged or entry.from_p2):
243 self.copymap.pop(f, None) 245 self.copymap.pop(f, None)
244 246 self._dirs_decr(f, old_entry=entry, remove_variant=True)
245 if entry is not None and not entry.removed and "_dirs" in self.__dict__:
246 self._dirs.delpath(f)
247 if entry is None and "_alldirs" in self.__dict__:
248 self._alldirs.addpath(f)
249 if "filefoldmap" in self.__dict__:
250 normed = util.normcase(f)
251 self.filefoldmap.pop(normed, None)
252 self._map[f] = DirstateItem(b'r', 0, size, 0) 247 self._map[f] = DirstateItem(b'r', 0, size, 0)
253 self.nonnormalset.add(f) 248 self.nonnormalset.add(f)
254 249
255 def dropfile(self, f): 250 def dropfile(self, f):
256 """ 251 """