Mercurial > hg
comparison mercurial/dirstate.py @ 47918:496a8e383aeb
dirstate: drop the `_otherparent` method
It only has one caller with a lot of the logic already implemented. So lets
inline it and cleans things up further.
Differential Revision: https://phab.mercurial-scm.org/D11353
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 24 Aug 2021 21:25:35 +0200 |
parents | 1b3c753b62c6 |
children | 7ab99007fce5 |
comparison
equal
deleted
inserted
replaced
47917:1b3c753b62c6 | 47918:496a8e383aeb |
---|---|
727 if entry is not None: | 727 if entry is not None: |
728 # XXX this should probably be dealt with a a lower level | 728 # XXX this should probably be dealt with a a lower level |
729 # (see `merged_removed` and `from_p2_removed`) | 729 # (see `merged_removed` and `from_p2_removed`) |
730 if entry.merged_removed or entry.from_p2_removed: | 730 if entry.merged_removed or entry.from_p2_removed: |
731 source = self._map.copymap.get(f) | 731 source = self._map.copymap.get(f) |
732 if entry.merged_removed: | 732 self._addpath(f, from_p2=True) |
733 self._otherparent(f) | 733 self._map.copymap.pop(f, None) |
734 elif entry.from_p2_removed: | |
735 self._otherparent(f) | |
736 if source is not None: | 734 if source is not None: |
737 self.copy(source, f) | 735 self.copy(source, f) |
738 return | 736 return |
739 elif entry.merged or entry.from_p2: | 737 elif entry.merged or entry.from_p2: |
740 return | 738 return |
741 self._addpath(f, possibly_dirty=True) | 739 self._addpath(f, possibly_dirty=True) |
742 self._map.copymap.pop(f, None) | |
743 | |
744 def _otherparent(self, f): | |
745 if not self.in_merge: | |
746 msg = _(b"setting %r to other parent only allowed in merges") % f | |
747 raise error.Abort(msg) | |
748 entry = self._map.get(f) | |
749 if entry is not None and entry.tracked: | |
750 # merge-like | |
751 self._addpath(f, merged=True) | |
752 else: | |
753 # add-like | |
754 self._addpath(f, from_p2=True) | |
755 self._map.copymap.pop(f, None) | 740 self._map.copymap.pop(f, None) |
756 | 741 |
757 def _add(self, filename): | 742 def _add(self, filename): |
758 """internal function to mark a file as added""" | 743 """internal function to mark a file as added""" |
759 self._addpath(filename, added=True) | 744 self._addpath(filename, added=True) |