Patchwork D11184: dirstate: deprecate the `otherparent` method in all cases

login
register
mail settings
Submitter phabricator
Date July 19, 2021, 3:07 p.m.
Message ID <differential-rev-PHID-DREV-mptlemf63irjeqtwx5iv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49498/
State Superseded
Headers show

Comments

phabricator - July 19, 2021, 3:07 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  All code have been migrated to the new APIs.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11184

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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'''