exchange: fix locking to actually be scoped
The previous code was taking locks before entering with statements, so
exception before the with statement would not release the lock (except for
garbage collection).
--- a/mercurial/exchange.py Mon Jun 10 10:59:44 2024 +0200
+++ b/mercurial/exchange.py Tue Jun 11 11:13:36 2024 +0200
@@ -1694,10 +1694,10 @@
)
pullop.trmanager = transactionmanager(repo, b'pull', remote.url())
- wlock = util.nullcontextmanager()
+ wlock = util.nullcontextmanager
if not bookmod.bookmarksinstore(repo):
- wlock = repo.wlock()
- with wlock, repo.lock(), pullop.trmanager:
+ wlock = repo.wlock
+ with wlock(), repo.lock(), pullop.trmanager:
if confirm or (
repo.ui.configbool(b"pull", b"confirm") and not repo.ui.plain()
):