comparison tests/testlib/crash_transaction_late.py @ 44634:01b0805534bb

nodemap: make sure on disk change get rolled back with the transaction In case of errors, we need to rollback the change made to the persistent nodemap. Differential Revision: https://phab.mercurial-scm.org/D8191
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 28 Feb 2020 03:05:52 +0100
parents
children 21ac6aedd5e5
comparison
equal deleted inserted replaced
44633:dd5b47fb0860 44634:01b0805534bb
1 # tiny extension to abort a transaction very late during test
2 #
3 # Copyright 2020 Pierre-Yves David <pierre-yves.david@octobus.net>
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
7
8 from __future__ import absolute_import
9
10 from mercurial import (
11 error,
12 transaction,
13 )
14
15
16 def abort(fp):
17 raise error.Abort(b"This is a late abort")
18
19
20 def reposetup(ui, repo):
21
22 transaction.postfinalizegenerators.add(b'late-abort')
23
24 class LateAbortRepo(repo.__class__):
25 def transaction(self, *args, **kwargs):
26 tr = super(LateAbortRepo, self).transaction(*args, **kwargs)
27 tr.addfilegenerator(
28 b'late-abort', [b'late-abort'], abort, order=9999999
29 )
30 return tr
31
32 repo.__class__ = LateAbortRepo