tests/testlib/crash_transaction_late.py
author Matt Harbison <matt_harbison@yahoo.com>
Mon, 21 Nov 2022 15:04:42 -0500
changeset 49643 e1c586b9a43c
parent 48875 6000f5b25c9b
permissions -rw-r--r--
attr: vendor 22.1.0 The previous version was 5 years old, and pytype 2022.06.30 started complaining about various uses (e.g. seeing `mercurial.thirdparty.attr._make._CountingAttr` instead of `bytearray`). Hopefully this helps. Additionally, this has official python 3.11 support. The `attrs` package is left out, because it is simply a bunch of *.pyi stubs and `from attr.X import *`, and that's not how they've been used up to this point. We'd probably need to customize those anyway to `from mercurial.thirdparty.attr import *`.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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