tests/testlib/crash_transaction_late.py
changeset 48685 21ac6aedd5e5
parent 44634 01b0805534bb
child 48875 6000f5b25c9b
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