Mercurial > hg
comparison mercurial/dirstatemap.py @ 47990:0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
This move more implementation details withing the DirstateItem itself, which is
what we have been doing for a while.
Differential Revision: https://phab.mercurial-scm.org/D11430
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 15 Sep 2021 18:05:39 +0200 |
parents | ffde999a3ea9 |
children | aa442fde0ea5 |
comparison
equal
deleted
inserted
replaced
47989:87b3010c08e0 | 47990:0d2a404f1932 |
---|---|
305 self.otherparentset.add(filename) | 305 self.otherparentset.add(filename) |
306 else: | 306 else: |
307 self.otherparentset.discard(filename) | 307 self.otherparentset.discard(filename) |
308 self._map[filename] = entry | 308 self._map[filename] = entry |
309 | 309 |
310 def set_tracked(self, filename): | |
311 new = False | |
312 entry = self.get(filename) | |
313 if entry is None: | |
314 self._dirs_incr(filename) | |
315 entry = DirstateItem( | |
316 p1_tracked=False, | |
317 p2_tracked=False, | |
318 wc_tracked=True, | |
319 merged=False, | |
320 clean_p1=False, | |
321 clean_p2=False, | |
322 possibly_dirty=False, | |
323 parentfiledata=None, | |
324 ) | |
325 self._map[filename] = entry | |
326 if entry.dm_nonnormal: | |
327 self.nonnormalset.add(filename) | |
328 new = True | |
329 elif not entry.tracked: | |
330 self._dirs_incr(filename, entry) | |
331 entry.set_tracked() | |
332 new = True | |
333 else: | |
334 # XXX This is probably overkill for more case, but we need this to | |
335 # fully replace the `normallookup` call with `set_tracked` one. | |
336 # Consider smoothing this in the future. | |
337 self.set_possibly_dirty(filename) | |
338 return new | |
339 | |
310 def set_untracked(self, f): | 340 def set_untracked(self, f): |
311 """Mark a file as no longer tracked in the dirstate map""" | 341 """Mark a file as no longer tracked in the dirstate map""" |
312 entry = self.get(f) | 342 entry = self.get(f) |
313 if entry is None: | 343 if entry is None: |
314 return False | 344 return False |
661 self.addfile(filename, mode=mode, size=size, mtime=mtime) | 691 self.addfile(filename, mode=mode, size=size, mtime=mtime) |
662 self.nonnormalset.discard(filename) | 692 self.nonnormalset.discard(filename) |
663 else: | 693 else: |
664 assert False, 'unreachable' | 694 assert False, 'unreachable' |
665 | 695 |
696 def set_tracked(self, filename): | |
697 new = False | |
698 entry = self.get(filename) | |
699 if entry is None: | |
700 self.addfile(filename, added=True) | |
701 new = True | |
702 elif not entry.tracked: | |
703 entry.set_tracked() | |
704 self._rustmap.set_v1(filename, entry) | |
705 new = True | |
706 else: | |
707 # XXX This is probably overkill for more case, but we need this to | |
708 # fully replace the `normallookup` call with `set_tracked` one. | |
709 # Consider smoothing this in the future. | |
710 self.set_possibly_dirty(filename) | |
711 return new | |
712 | |
666 def set_untracked(self, f): | 713 def set_untracked(self, f): |
667 """Mark a file as no longer tracked in the dirstate map""" | 714 """Mark a file as no longer tracked in the dirstate map""" |
668 # in merge is only trigger more logic, so it "fine" to pass it. | 715 # in merge is only trigger more logic, so it "fine" to pass it. |
669 # | 716 # |
670 # the inner rust dirstate map code need to be adjusted once the API | 717 # the inner rust dirstate map code need to be adjusted once the API |