dirstate: deprecate calling `setbranch` without a transaction parameter
The new way is now enforced.
--- 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(