# HG changeset patch # User Pierre-Yves David # Date 1629833135 -7200 # Node ID 496a8e383aeb718f7c4f2433b92e2bc2bb055bd8 # Parent 1b3c753b62c61fb362297e9a37ab733b05e7af2c 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 diff -r 1b3c753b62c6 -r 496a8e383aeb mercurial/dirstate.py --- a/mercurial/dirstate.py Tue Aug 24 21:18:28 2021 +0200 +++ b/mercurial/dirstate.py Tue Aug 24 21:25:35 2021 +0200 @@ -729,10 +729,8 @@ # (see `merged_removed` and `from_p2_removed`) if entry.merged_removed or entry.from_p2_removed: source = self._map.copymap.get(f) - if entry.merged_removed: - self._otherparent(f) - elif entry.from_p2_removed: - self._otherparent(f) + self._addpath(f, from_p2=True) + self._map.copymap.pop(f, None) if source is not None: self.copy(source, f) return @@ -741,19 +739,6 @@ self._addpath(f, possibly_dirty=True) self._map.copymap.pop(f, None) - def _otherparent(self, f): - if not self.in_merge: - msg = _(b"setting %r to other parent only allowed in merges") % f - raise error.Abort(msg) - entry = self._map.get(f) - if entry is not None and entry.tracked: - # merge-like - self._addpath(f, merged=True) - else: - # add-like - self._addpath(f, from_p2=True) - self._map.copymap.pop(f, None) - def _add(self, filename): """internal function to mark a file as added""" self._addpath(filename, added=True)