comparison mercurial/dirstate.py @ 48384:9f1b9e128788

dirstate: do no use `set_clean` in revert The current `set_clean` usage is racy (the file might be modified between its restoration and the `set_clean` call). So we simply leave the file as ambiguous and the next status will fix that. We still have to make sure the copy information is dropped, so we teach dirstate how to do that. The win32txt extension is confused after this because current logic is broken in more location. However this series will ultimately fix that so we "ignore" it for now. Fixing it now is complicated without some extra fix landing later. Differential Revision: https://phab.mercurial-scm.org/D11788
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 22 Nov 2021 15:58:51 +0100
parents 08b060abd658
children 080151f18f3a
comparison
equal deleted inserted replaced
48383:4237be881bb6 48384:9f1b9e128788
450 450
451 def copies(self): 451 def copies(self):
452 return self._map.copymap 452 return self._map.copymap
453 453
454 @requires_no_parents_change 454 @requires_no_parents_change
455 def set_tracked(self, filename): 455 def set_tracked(self, filename, reset_copy=False):
456 """a "public" method for generic code to mark a file as tracked 456 """a "public" method for generic code to mark a file as tracked
457 457
458 This function is to be called outside of "update/merge" case. For 458 This function is to be called outside of "update/merge" case. For
459 example by a command like `hg add X`. 459 example by a command like `hg add X`.
460
461 if reset_copy is set, any existing copy information will be dropped.
460 462
461 return True the file was previously untracked, False otherwise. 463 return True the file was previously untracked, False otherwise.
462 """ 464 """
463 self._dirty = True 465 self._dirty = True
464 entry = self._map.get(filename) 466 entry = self._map.get(filename)
465 if entry is None or not entry.tracked: 467 if entry is None or not entry.tracked:
466 self._check_new_tracked_filename(filename) 468 self._check_new_tracked_filename(filename)
467 return self._map.set_tracked(filename) 469 pre_tracked = self._map.set_tracked(filename)
470 if reset_copy:
471 self._map.copymap.pop(filename, None)
472 return pre_tracked
468 473
469 @requires_no_parents_change 474 @requires_no_parents_change
470 def set_untracked(self, filename): 475 def set_untracked(self, filename):
471 """a "public" method for generic code to mark a file as untracked 476 """a "public" method for generic code to mark a file as untracked
472 477