Mercurial > hg
comparison mercurial/dirstatemap.py @ 48059:5d68c4eedd66
dirstate: move parent state handling in the dirstatemap
This involves dirstatemap data mostly. Moving this one level down will remove
the needs for the dirstatemap to expose some of its internals.
This will help us to simplify more code further.
Differential Revision: https://phab.mercurial-scm.org/D11505
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 22 Sep 2021 15:17:12 +0200 |
parents | cd13d3c2ad2e |
children | a660d8a53267 |
comparison
equal
deleted
inserted
replaced
48058:40dd56086056 | 48059:5d68c4eedd66 |
---|---|
426 _(b'working directory state appears damaged!') | 426 _(b'working directory state appears damaged!') |
427 ) | 427 ) |
428 | 428 |
429 return self._parents | 429 return self._parents |
430 | 430 |
431 def setparents(self, p1, p2): | 431 def setparents(self, p1, p2, fold_p2=False): |
432 self._parents = (p1, p2) | 432 self._parents = (p1, p2) |
433 self._dirtyparents = True | 433 self._dirtyparents = True |
434 copies = {} | |
435 if fold_p2: | |
436 candidatefiles = self.non_normal_or_other_parent_paths() | |
437 | |
438 for f in candidatefiles: | |
439 s = self.get(f) | |
440 if s is None: | |
441 continue | |
442 | |
443 # Discard "merged" markers when moving away from a merge state | |
444 if s.merged: | |
445 source = self.copymap.get(f) | |
446 if source: | |
447 copies[f] = source | |
448 self.reset_state( | |
449 f, | |
450 wc_tracked=True, | |
451 p1_tracked=True, | |
452 possibly_dirty=True, | |
453 ) | |
454 # Also fix up otherparent markers | |
455 elif s.from_p2: | |
456 source = self.copymap.get(f) | |
457 if source: | |
458 copies[f] = source | |
459 self.reset_state( | |
460 f, | |
461 p1_tracked=False, | |
462 wc_tracked=True, | |
463 ) | |
464 return copies | |
434 | 465 |
435 def read(self): | 466 def read(self): |
436 # ignore HG_PENDING because identity is used only for writing | 467 # ignore HG_PENDING because identity is used only for writing |
437 self.identity = util.filestat.frompath( | 468 self.identity = util.filestat.frompath( |
438 self._opener.join(self._filename) | 469 self._opener.join(self._filename) |
767 if err.errno != errno.ENOENT: | 798 if err.errno != errno.ENOENT: |
768 raise | 799 raise |
769 # File doesn't exist, so the current state is empty | 800 # File doesn't exist, so the current state is empty |
770 return b'' | 801 return b'' |
771 | 802 |
772 def setparents(self, p1, p2): | 803 def setparents(self, p1, p2, fold_p2=False): |
773 self._parents = (p1, p2) | 804 self._parents = (p1, p2) |
774 self._dirtyparents = True | 805 self._dirtyparents = True |
806 copies = {} | |
807 if fold_p2: | |
808 candidatefiles = self.non_normal_or_other_parent_paths() | |
809 | |
810 for f in candidatefiles: | |
811 s = self.get(f) | |
812 if s is None: | |
813 continue | |
814 | |
815 # Discard "merged" markers when moving away from a merge state | |
816 if s.merged: | |
817 source = self.copymap.get(f) | |
818 if source: | |
819 copies[f] = source | |
820 self.reset_state( | |
821 f, | |
822 wc_tracked=True, | |
823 p1_tracked=True, | |
824 possibly_dirty=True, | |
825 ) | |
826 # Also fix up otherparent markers | |
827 elif s.from_p2: | |
828 source = self.copymap.get(f) | |
829 if source: | |
830 copies[f] = source | |
831 self.reset_state( | |
832 f, | |
833 p1_tracked=False, | |
834 wc_tracked=True, | |
835 ) | |
836 return copies | |
775 | 837 |
776 def parents(self): | 838 def parents(self): |
777 if not self._parents: | 839 if not self._parents: |
778 if self._use_dirstate_v2: | 840 if self._use_dirstate_v2: |
779 self._parents = self.docket.parents | 841 self._parents = self.docket.parents |