Mercurial > hg
changeset 50082:a66926099c0f
localrepo: enforce a clean dirstate when the transaction open
This is important to simplify the backup process. This also seems like a quite
reasonable expectation. See inline documentation for details.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 16 Feb 2023 04:04:40 +0100 |
parents | 9a0778bbae6a |
children | a28cedb26139 |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Feb 16 10:43:22 2023 +0100 +++ b/mercurial/localrepo.py Thu Feb 16 04:04:40 2023 +0100 @@ -2375,6 +2375,21 @@ hint=_(b"run 'hg recover' to clean up transaction"), ) + # At that point your dirstate should be clean: + # + # - If you don't have the wlock, why would you still have a dirty + # dirstate ? + # + # - If you hold the wlock, you should not be opening a transaction in + # the middle of a `distate.changing_*` block. The transaction needs to + # be open before that and wrap the change-context. + # + # - If you are not within a `dirstate.changing_*` context, why is our + # dirstate dirty? + if self.dirstate._dirty: + m = "cannot open a transaction with a dirty dirstate" + raise error.ProgrammingError(m) + idbase = b"%.40f#%f" % (random.random(), time.time()) ha = hex(hashutil.sha1(idbase).digest()) txnid = b'TXN:' + ha