Mercurial > hg
annotate tests/testlib/crash_transaction_late.py @ 48875:6000f5b25c9b
py2: remove simple from __future__ statements
These were needed for Python 2 support. Now that our linter no longer
mandates these, we can start deleting them.
Differential Revision: https://phab.mercurial-scm.org/D12254
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 03 Mar 2022 17:34:00 +0100 |
parents | 21ac6aedd5e5 |
children |
rev | line source |
---|---|
44634
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 # tiny extension to abort a transaction very late during test |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 # |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 # Copyright 2020 Pierre-Yves David <pierre-yves.david@octobus.net> |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 # |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
9 from mercurial import ( |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
10 error, |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
11 ) |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
12 |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
13 |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 def abort(fp): |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
15 raise error.Abort(b"This is a late abort") |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 def reposetup(ui, repo): |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 class LateAbortRepo(repo.__class__): |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 def transaction(self, *args, **kwargs): |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 tr = super(LateAbortRepo, self).transaction(*args, **kwargs) |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 tr.addfilegenerator( |
48685
21ac6aedd5e5
transaction: do not rely on a global variable to post_finalize file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44634
diff
changeset
|
23 b'late-abort', |
21ac6aedd5e5
transaction: do not rely on a global variable to post_finalize file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44634
diff
changeset
|
24 [b'late-abort'], |
21ac6aedd5e5
transaction: do not rely on a global variable to post_finalize file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44634
diff
changeset
|
25 abort, |
21ac6aedd5e5
transaction: do not rely on a global variable to post_finalize file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44634
diff
changeset
|
26 order=9999999, |
21ac6aedd5e5
transaction: do not rely on a global variable to post_finalize file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44634
diff
changeset
|
27 post_finalize=True, |
44634
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
28 ) |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
29 return tr |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
30 |
01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
31 repo.__class__ = LateAbortRepo |