Mercurial > hg
comparison mercurial/dirstatemap.py @ 47972:5a6c1ef4bcac
dirstate: make dirstatemap.set_untracked deal with added file
This merge dropfile in set_untracked.
Differential Revision: https://phab.mercurial-scm.org/D11419
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Sep 2021 02:53:47 +0200 |
parents | 7ab99007fce5 |
children | 4e6f27230aee |
comparison
equal
deleted
inserted
replaced
47971:c0157aca5bf5 | 47972:5a6c1ef4bcac |
---|---|
297 self.otherparentset.discard(filename) | 297 self.otherparentset.discard(filename) |
298 self._map[filename] = entry | 298 self._map[filename] = entry |
299 | 299 |
300 def set_untracked(self, f): | 300 def set_untracked(self, f): |
301 """Mark a file as no longer tracked in the dirstate map""" | 301 """Mark a file as no longer tracked in the dirstate map""" |
302 entry = self[f] | 302 entry = self.get(f) |
303 self._dirs_decr(f, old_entry=entry, remove_variant=True) | 303 if entry is None: |
304 if entry.from_p2: | 304 return False |
305 self.otherparentset.add(f) | 305 else: |
306 elif not entry.merged: | 306 self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added) |
307 self.copymap.pop(f, None) | 307 if not entry.merged: |
308 entry.set_untracked() | 308 self.copymap.pop(f, None) |
309 self.nonnormalset.add(f) | 309 if entry.added: |
310 self.nonnormalset.discard(f) | |
311 self._map.pop(f, None) | |
312 else: | |
313 self.nonnormalset.add(f) | |
314 if entry.from_p2: | |
315 self.otherparentset.add(f) | |
316 entry.set_untracked() | |
317 return True | |
310 | 318 |
311 def dropfile(self, f): | 319 def dropfile(self, f): |
312 """ | 320 """ |
313 Remove a file from the dirstate. Returns True if the file was | 321 Remove a file from the dirstate. Returns True if the file was |
314 previously recorded. | 322 previously recorded. |
646 """Mark a file as no longer tracked in the dirstate map""" | 654 """Mark a file as no longer tracked in the dirstate map""" |
647 # in merge is only trigger more logic, so it "fine" to pass it. | 655 # in merge is only trigger more logic, so it "fine" to pass it. |
648 # | 656 # |
649 # the inner rust dirstate map code need to be adjusted once the API | 657 # the inner rust dirstate map code need to be adjusted once the API |
650 # for dirstate/dirstatemap/DirstateItem is a bit more settled | 658 # for dirstate/dirstatemap/DirstateItem is a bit more settled |
651 self._rustmap.removefile(f, in_merge=True) | 659 entry = self.get(f) |
660 if entry is None: | |
661 return False | |
662 else: | |
663 if entry.added: | |
664 self._rustmap.copymap().pop(f, None) | |
665 self._rustmap.dropfile(f) | |
666 else: | |
667 self._rustmap.removefile(f, in_merge=True) | |
668 return True | |
652 | 669 |
653 def removefile(self, *args, **kwargs): | 670 def removefile(self, *args, **kwargs): |
654 return self._rustmap.removefile(*args, **kwargs) | 671 return self._rustmap.removefile(*args, **kwargs) |
655 | 672 |
656 def dropfile(self, f, *args, **kwargs): | 673 def dropfile(self, f, *args, **kwargs): |