changeset 50266:307c155e6275

dirstate: deprecate calling `setbranch` without a transaction parameter The new way is now enforced.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 02 Mar 2023 11:54:29 +0100
parents 240a04cedd24
children f92afdf3cff9
files mercurial/dirstate.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Thu Mar 02 14:46:37 2023 +0100
+++ b/mercurial/dirstate.py	Thu Mar 02 11:54:29 2023 +0100
@@ -43,6 +43,9 @@
 parsers = policy.importmod('parsers')
 rustmod = policy.importrust('dirstate')
 
+# use to detect lack of a parameter
+SENTINEL = object()
+
 HAS_FAST_DIRSTATE_V2 = rustmod is not None
 
 propertycache = util.propertycache
@@ -621,8 +624,12 @@
         fold_p2 = oldp2 != nullid and p2 == nullid
         return self._map.setparents(p1, p2, fold_p2=fold_p2)
 
-    def setbranch(self, branch, transaction=None):
+    def setbranch(self, branch, transaction=SENTINEL):
         self.__class__._branch.set(self, encoding.fromlocal(branch))
+        if transaction is SENTINEL:
+            msg = b"setbranch needs a `transaction` argument"
+            self._ui.deprecwarn(msg, b'6.5')
+            transaction = None
         if transaction is not None:
             self._setup_tr_abort(transaction)
             transaction.addfilegenerator(