comparison mercurial/dirstatemap.py @ 49118:2c78dd3f11de

dirstatemap: move `_dirs_incr` and `_dirs_decr` methods out of the common They are only used by the Python implementation now Differential Revision: https://phab.mercurial-scm.org/D12516
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 28 Mar 2022 23:42:16 +0200
parents 4c562108384f
children 3df46f3a3d6c
comparison
equal deleted inserted replaced
49117:4c562108384f 49118:2c78dd3f11de
76 def __contains__(self, key): 76 def __contains__(self, key):
77 return key in self._map 77 return key in self._map
78 78
79 def __getitem__(self, item): 79 def __getitem__(self, item):
80 return self._map[item] 80 return self._map[item]
81
82 ### sub-class utility method
83 #
84 # Use to allow for generic implementation of some method while still coping
85 # with minor difference between implementation.
86
87 def _dirs_incr(self, filename, old_entry=None):
88 """increment the dirstate counter if applicable
89
90 This might be a no-op for some subclasses who deal with directory
91 tracking in a different way.
92 """
93
94 def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
95 """decrement the dirstate counter if applicable
96
97 This might be a no-op for some subclasses who deal with directory
98 tracking in a different way.
99 """
100 81
101 ### disk interaction 82 ### disk interaction
102 83
103 def _opendirstatefile(self): 84 def _opendirstatefile(self):
104 fp, mode = txnutil.trypending(self._root, self._opener, self._filename) 85 fp, mode = txnutil.trypending(self._root, self._opener, self._filename)
352 333
353 ### code related to maintaining and accessing "extra" property 334 ### code related to maintaining and accessing "extra" property
354 # (e.g. "has_dir") 335 # (e.g. "has_dir")
355 336
356 def _dirs_incr(self, filename, old_entry=None): 337 def _dirs_incr(self, filename, old_entry=None):
357 """incremente the dirstate counter if applicable""" 338 """increment the dirstate counter if applicable"""
358 if ( 339 if (
359 old_entry is None or old_entry.removed 340 old_entry is None or old_entry.removed
360 ) and "_dirs" in self.__dict__: 341 ) and "_dirs" in self.__dict__:
361 self._dirs.addpath(filename) 342 self._dirs.addpath(filename)
362 if old_entry is None and "_alldirs" in self.__dict__: 343 if old_entry is None and "_alldirs" in self.__dict__:
363 self._alldirs.addpath(filename) 344 self._alldirs.addpath(filename)
364 345
365 def _dirs_decr(self, filename, old_entry=None, remove_variant=False): 346 def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
366 """decremente the dirstate counter if applicable""" 347 """decrement the dirstate counter if applicable"""
367 if old_entry is not None: 348 if old_entry is not None:
368 if "_dirs" in self.__dict__ and not old_entry.removed: 349 if "_dirs" in self.__dict__ and not old_entry.removed:
369 self._dirs.delpath(filename) 350 self._dirs.delpath(filename)
370 if "_alldirs" in self.__dict__ and not remove_variant: 351 if "_alldirs" in self.__dict__ and not remove_variant:
371 self._alldirs.delpath(filename) 352 self._alldirs.delpath(filename)