comparison tests/testlib/crash_transaction_late.py @ 48685:21ac6aedd5e5

transaction: do not rely on a global variable to post_finalize file We can just add a new argument to the `addfilegenerator` function. This is more explicit and therefor clearer and less error prone. Differential Revision: https://phab.mercurial-scm.org/D12125
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 31 Jan 2022 18:38:15 +0100
parents 01b0805534bb
children 6000f5b25c9b
comparison
equal deleted inserted replaced
48684:568f63b5a30f 48685:21ac6aedd5e5
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 from mercurial import ( 10 from mercurial import (
11 error, 11 error,
12 transaction,
13 ) 12 )
14 13
15 14
16 def abort(fp): 15 def abort(fp):
17 raise error.Abort(b"This is a late abort") 16 raise error.Abort(b"This is a late abort")
18 17
19 18
20 def reposetup(ui, repo): 19 def reposetup(ui, repo):
21
22 transaction.postfinalizegenerators.add(b'late-abort')
23
24 class LateAbortRepo(repo.__class__): 20 class LateAbortRepo(repo.__class__):
25 def transaction(self, *args, **kwargs): 21 def transaction(self, *args, **kwargs):
26 tr = super(LateAbortRepo, self).transaction(*args, **kwargs) 22 tr = super(LateAbortRepo, self).transaction(*args, **kwargs)
27 tr.addfilegenerator( 23 tr.addfilegenerator(
28 b'late-abort', [b'late-abort'], abort, order=9999999 24 b'late-abort',
25 [b'late-abort'],
26 abort,
27 order=9999999,
28 post_finalize=True,
29 ) 29 )
30 return tr 30 return tr
31 31
32 repo.__class__ = LateAbortRepo 32 repo.__class__ = LateAbortRepo