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.
Alphare | |
pulkit |
hg-reviewers |
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.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/dirstatemap.py (27 lines) |
"""incremente the dirstate counter if applicable""" | """incremente the dirstate counter if applicable""" | ||||
if ( | if ( | ||||
old_entry is None or old_entry.removed | old_entry is None or old_entry.removed | ||||
) and "_dirs" in self.__dict__: | ) and "_dirs" in self.__dict__: | ||||
self._dirs.addpath(filename) | self._dirs.addpath(filename) | ||||
if old_entry is None and "_alldirs" in self.__dict__: | if old_entry is None and "_alldirs" in self.__dict__: | ||||
self._alldirs.addpath(filename) | self._alldirs.addpath(filename) | ||||
def _dirs_decr(self, filename, old_entry=None): | |||||
"""decremente the dirstate counter if applicable""" | |||||
if old_entry is not None: | |||||
if "_dirs" in self.__dict__ and not old_entry.removed: | |||||
self._dirs.delpath(filename) | |||||
if "_alldirs" in self.__dict__: | |||||
self._alldirs.delpath(filename) | |||||
if "filefoldmap" in self.__dict__: | |||||
normed = util.normcase(filename) | |||||
self.filefoldmap.pop(normed, None) | |||||
def addfile( | def addfile( | ||||
self, | self, | ||||
f, | f, | ||||
mode=0, | mode=0, | ||||
size=None, | size=None, | ||||
mtime=None, | mtime=None, | ||||
added=False, | added=False, | ||||
merged=False, | merged=False, | ||||
self.nonnormalset.add(f) | self.nonnormalset.add(f) | ||||
def dropfile(self, f): | def dropfile(self, f): | ||||
""" | """ | ||||
Remove a file from the dirstate. Returns True if the file was | Remove a file from the dirstate. Returns True if the file was | ||||
previously recorded. | previously recorded. | ||||
""" | """ | ||||
old_entry = self._map.pop(f, None) | old_entry = self._map.pop(f, None) | ||||
exists = False | self._dirs_decr(f, old_entry=old_entry) | ||||
oldstate = b'?' | |||||
if old_entry is not None: | |||||
exists = True | |||||
oldstate = old_entry.state | |||||
if exists: | |||||
if oldstate != b"r" and "_dirs" in self.__dict__: | |||||
self._dirs.delpath(f) | |||||
if "_alldirs" in self.__dict__: | |||||
self._alldirs.delpath(f) | |||||
if "filefoldmap" in self.__dict__: | |||||
normed = util.normcase(f) | |||||
self.filefoldmap.pop(normed, None) | |||||
self.nonnormalset.discard(f) | self.nonnormalset.discard(f) | ||||
return exists | return old_entry is not None | ||||
def clearambiguoustimes(self, files, now): | def clearambiguoustimes(self, files, now): | ||||
for f in files: | for f in files: | ||||
e = self.get(f) | e = self.get(f) | ||||
if e is not None and e.need_delay(now): | if e is not None and e.need_delay(now): | ||||
e.set_possibly_dirty() | e.set_possibly_dirty() | ||||
self.nonnormalset.add(f) | self.nonnormalset.add(f) | ||||