# HG changeset patch # User Pierre-Yves David # Date 1676493097 -3600 # Node ID d1215f90581879a7e5061641613ea13b63c5c06e # Parent cf8b9c80d67cc1309d669d44c79941973cf00635 dirstate: avoid transaction backup/restore if we do not hold the lock Doing overwriting the dirstate content without holding the lock is a recipe for disaster. diff -r cf8b9c80d67c -r d1215f905818 mercurial/localrepo.py --- a/mercurial/localrepo.py Tue Dec 13 09:59:22 2022 +0100 +++ b/mercurial/localrepo.py Wed Feb 15 21:31:37 2023 +0100 @@ -2533,7 +2533,8 @@ # out) in this transaction narrowspec.restorebackup(self, b'journal.narrowspec') narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate') - repo.dirstate.restorebackup(None, b'journal.dirstate') + if repo.currentwlock() is not None: + repo.dirstate.restorebackup(None, b'journal.dirstate') repo.invalidate(clearfilecache=True) @@ -2657,7 +2658,8 @@ @unfilteredmethod def _writejournal(self, desc): - self.dirstate.savebackup(None, b'journal.dirstate') + if self.currentwlock() is not None: + self.dirstate.savebackup(None, b'journal.dirstate') narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate') narrowspec.savebackup(self, b'journal.narrowspec') self.vfs.write(