tests/testlib/crash_transaction_late.py
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 26 Apr 2024 19:10:35 +0100
changeset 51626 865efc020c33
parent 48875 6000f5b25c9b
permissions -rw-r--r--
dirstate: remove the python-side whitelist of allowed matchers This whitelist is too permissive because it allows matchers that contain disallowed ones deep inside, for example through `intersectionmatcher`. It is also too restrictive because it doesn't pass through some of the matchers we support, such as `patternmatcher`. It's also unnecessary because unsupported matchers raise `FallbackError` and we fall back anyway. Making this change makes more of the tests use rust code path, and therefore subtly change behavior. For example, rust status in largefiles repos seems to have strange behavior.
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