tests/test-fncache.t
changeset 23512 0ff6b65afeb0
parent 23510 065c0334846f
child 23786 7d63398fbfd1
equal deleted inserted replaced
23511:acc73273b27e 23512:0ff6b65afeb0
   239 
   239 
   240 Aborted transactions can be recovered later
   240 Aborted transactions can be recovered later
   241 
   241 
   242   $ cat > ../exceptionext.py <<EOF
   242   $ cat > ../exceptionext.py <<EOF
   243   > import os
   243   > import os
   244   > from mercurial import commands, util, transaction
   244   > from mercurial import commands, util, transaction, localrepo
   245   > from mercurial.extensions import wrapfunction
   245   > from mercurial.extensions import wrapfunction
   246   > 
   246   > 
   247   > def closewrapper(orig, self, *args, **kwargs):
   247   > def trwrapper(orig, self, *args, **kwargs):
   248   >     origonclose = self.onclose
   248   >     tr = orig(self, *args, **kwargs)
   249   >     def onclose():
   249   >     def fail(tr):
   250   >         origonclose()
       
   251   >         raise util.Abort("forced transaction failure")
   250   >         raise util.Abort("forced transaction failure")
   252   >     self.onclose = onclose
   251   >     # zzz prefix to ensure it sorted after store.write
   253   >     return orig(self, *args, **kwargs)
   252   >     tr.addfinalize('zzz-forcefails', fail)
       
   253   >     return tr
   254   > 
   254   > 
   255   > def abortwrapper(orig, self, *args, **kwargs):
   255   > def abortwrapper(orig, self, *args, **kwargs):
   256   >     raise util.Abort("forced transaction failure")
   256   >     raise util.Abort("forced transaction failure")
   257   > 
   257   > 
   258   > def uisetup(ui):
   258   > def uisetup(ui):
   259   >     wrapfunction(transaction.transaction, 'close', closewrapper)
   259   >     wrapfunction(localrepo.localrepository, 'transaction', trwrapper)
   260   >     wrapfunction(transaction.transaction, '_abort', abortwrapper)
   260   >     wrapfunction(transaction.transaction, '_abort', abortwrapper)
   261   > 
   261   > 
   262   > cmdtable = {}
   262   > cmdtable = {}
   263   > 
   263   > 
   264   > EOF
   264   > EOF