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 (15 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): | def _dirs_decr(self, filename, old_entry=None, remove_variant=False): | ||||
"""decremente the dirstate counter if applicable""" | """decremente the dirstate counter if applicable""" | ||||
if old_entry is not None: | if old_entry is not None: | ||||
if "_dirs" in self.__dict__ and not old_entry.removed: | if "_dirs" in self.__dict__ and not old_entry.removed: | ||||
self._dirs.delpath(filename) | self._dirs.delpath(filename) | ||||
if "_alldirs" in self.__dict__: | if "_alldirs" in self.__dict__ and not remove_variant: | ||||
self._alldirs.delpath(filename) | self._alldirs.delpath(filename) | ||||
elif remove_variant and "_alldirs" in self.__dict__: | |||||
self._alldirs.addpath(filename) | |||||
if "filefoldmap" in self.__dict__: | if "filefoldmap" in self.__dict__: | ||||
normed = util.normcase(filename) | normed = util.normcase(filename) | ||||
self.filefoldmap.pop(normed, None) | self.filefoldmap.pop(normed, None) | ||||
def addfile( | def addfile( | ||||
self, | self, | ||||
f, | f, | ||||
mode=0, | mode=0, | ||||
# backup the previous state | # backup the previous state | ||||
if entry.merged: # merge | if entry.merged: # merge | ||||
size = NONNORMAL | size = NONNORMAL | ||||
elif entry.from_p2: | elif entry.from_p2: | ||||
size = FROM_P2 | size = FROM_P2 | ||||
self.otherparentset.add(f) | self.otherparentset.add(f) | ||||
if entry is not None and not (entry.merged or entry.from_p2): | if entry is not None and not (entry.merged or entry.from_p2): | ||||
self.copymap.pop(f, None) | self.copymap.pop(f, None) | ||||
self._dirs_decr(f, old_entry=entry, remove_variant=True) | |||||
if entry is not None and not entry.removed and "_dirs" in self.__dict__: | |||||
self._dirs.delpath(f) | |||||
if entry is None and "_alldirs" in self.__dict__: | |||||
self._alldirs.addpath(f) | |||||
if "filefoldmap" in self.__dict__: | |||||
normed = util.normcase(f) | |||||
self.filefoldmap.pop(normed, None) | |||||
self._map[f] = DirstateItem(b'r', 0, size, 0) | self._map[f] = DirstateItem(b'r', 0, size, 0) | ||||
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. | ||||
""" | """ |