Since the copymap is part of the dirstatemap it make more sense for the
dirstatemap to manage it directly.
This is part of a generic effort to move unified logic at lower level and to
clean up higher level API.
Alphare |
hg-reviewers |
Since the copymap is part of the dirstatemap it make more sense for the
dirstatemap to manage it directly.
This is part of a generic effort to move unified logic at lower level and to
clean up higher level API.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
In D11417#175253, @Alphare wrote:Should the same thing be done for _add?
Yes, I am actually working on _add as we "speak"
Path | Packages | |||
---|---|---|---|---|
M | mercurial/dirstate.py (1 line) | |||
M | mercurial/dirstatemap.py (6 lines) |
self._addpath(filename, added=True) | self._addpath(filename, added=True) | ||||
self._map.copymap.pop(filename, None) | self._map.copymap.pop(filename, None) | ||||
def _drop(self, filename): | def _drop(self, filename): | ||||
"""internal function to drop a file from the dirstate""" | """internal function to drop a file from the dirstate""" | ||||
if self._map.dropfile(filename): | if self._map.dropfile(filename): | ||||
self._dirty = True | self._dirty = True | ||||
self._updatedfiles.add(filename) | self._updatedfiles.add(filename) | ||||
self._map.copymap.pop(filename, None) | |||||
def _discoverpath(self, path, normed, ignoremissing, exists, storemap): | def _discoverpath(self, path, normed, ignoremissing, exists, storemap): | ||||
if exists is None: | if exists is None: | ||||
exists = os.path.lexists(os.path.join(self._root, path)) | exists = os.path.lexists(os.path.join(self._root, path)) | ||||
if not exists: | if not exists: | ||||
# Maybe a path component exists | # Maybe a path component exists | ||||
if not ignoremissing and b'/' in path: | if not ignoremissing and b'/' in path: | ||||
d, f = path.rsplit(b'/', 1) | d, f = path.rsplit(b'/', 1) |
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) | ||||
self._dirs_decr(f, old_entry=old_entry) | self._dirs_decr(f, old_entry=old_entry) | ||||
self.nonnormalset.discard(f) | self.nonnormalset.discard(f) | ||||
self.copymap.pop(f, None) | |||||
return old_entry is not None | 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) | ||||
# | # | ||||
# the inner rust dirstate map code need to be adjusted once the API | # the inner rust dirstate map code need to be adjusted once the API | ||||
# for dirstate/dirstatemap/DirstateItem is a bit more settled | # for dirstate/dirstatemap/DirstateItem is a bit more settled | ||||
self._rustmap.removefile(f, in_merge=True) | self._rustmap.removefile(f, in_merge=True) | ||||
def removefile(self, *args, **kwargs): | def removefile(self, *args, **kwargs): | ||||
return self._rustmap.removefile(*args, **kwargs) | return self._rustmap.removefile(*args, **kwargs) | ||||
def dropfile(self, *args, **kwargs): | def dropfile(self, f, *args, **kwargs): | ||||
return self._rustmap.dropfile(*args, **kwargs) | self._rustmap.copymap().pop(f, None) | ||||
return self._rustmap.dropfile(f, *args, **kwargs) | |||||
def clearambiguoustimes(self, *args, **kwargs): | def clearambiguoustimes(self, *args, **kwargs): | ||||
return self._rustmap.clearambiguoustimes(*args, **kwargs) | return self._rustmap.clearambiguoustimes(*args, **kwargs) | ||||
def nonnormalentries(self): | def nonnormalentries(self): | ||||
return self._rustmap.nonnormalentries() | return self._rustmap.nonnormalentries() | ||||
def get(self, *args, **kwargs): | def get(self, *args, **kwargs): |