dirstate: deprecate the `otherparent` method in all cases
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 19 Jul 2021 00:31:59 +0200
changeset 47742 f51aaa0f1485
parent 47741 9f19d9f2d191
child 47743 8c73818c67dd
dirstate: deprecate the `otherparent` method in all cases All code have been migrated to the new APIs. Differential Revision: https://phab.mercurial-scm.org/D11184
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Jul 19 00:26:02 2021 +0200
+++ b/mercurial/dirstate.py	Mon Jul 19 00:31:59 2021 +0200
@@ -777,7 +777,7 @@
                     if entry.merged_removed:
                         self.merge(f)
                     elif entry.from_p2_removed:
-                        self.otherparent(f)
+                        self._otherparent(f)
                     if source is not None:
                         self.copy(source, f)
                     return
@@ -788,6 +788,23 @@
 
     def otherparent(self, f):
         '''Mark as coming from the other parent, always dirty.'''
+        if self.pendingparentchange():
+            util.nouideprecwarn(
+                b"do not use `otherparent` inside of update/merge context."
+                b" Use `update_file` or `update_file_p1`",
+                b'6.0',
+                stacklevel=2,
+            )
+        else:
+            util.nouideprecwarn(
+                b"do not use `otherparent` outside of update/merge context."
+                b"It should have been set by the update/merge code",
+                b'6.0',
+                stacklevel=2,
+            )
+        self._otherparent(f)
+
+    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)
@@ -844,7 +861,7 @@
         '''Mark a file merged.'''
         if not self.in_merge:
             return self._normallookup(f)
-        return self.otherparent(f)
+        return self._otherparent(f)
 
     def drop(self, f):
         '''Drop a file from the dirstate'''