tests/test-fncache.t
changeset 26587 56b2bcea2529
parent 26497 ca778cbe94f3
child 26998 4414d500604f
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
   200 
   200 
   201 Aborting lock does not prevent fncache writes
   201 Aborting lock does not prevent fncache writes
   202 
   202 
   203   $ cat > exceptionext.py <<EOF
   203   $ cat > exceptionext.py <<EOF
   204   > import os
   204   > import os
   205   > from mercurial import commands, util
   205   > from mercurial import commands, error
   206   > from mercurial.extensions import wrapfunction
   206   > from mercurial.extensions import wrapfunction
   207   > 
   207   > 
   208   > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
   208   > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
   209   >     def releasewrap():
   209   >     def releasewrap():
   210   >         raise util.Abort("forced lock failure")
   210   >         raise error.Abort("forced lock failure")
   211   >     return orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
   211   >     return orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
   212   > 
   212   > 
   213   > def reposetup(ui, repo):
   213   > def reposetup(ui, repo):
   214   >     wrapfunction(repo, '_lock', lockexception)
   214   >     wrapfunction(repo, '_lock', lockexception)
   215   > 
   215   > 
   229 
   229 
   230 Aborting transaction prevents fncache change
   230 Aborting transaction prevents fncache change
   231 
   231 
   232   $ cat > ../exceptionext.py <<EOF
   232   $ cat > ../exceptionext.py <<EOF
   233   > import os
   233   > import os
   234   > from mercurial import commands, util, localrepo
   234   > from mercurial import commands, error, localrepo
   235   > from mercurial.extensions import wrapfunction
   235   > from mercurial.extensions import wrapfunction
   236   > 
   236   > 
   237   > def wrapper(orig, self, *args, **kwargs):
   237   > def wrapper(orig, self, *args, **kwargs):
   238   >     tr = orig(self, *args, **kwargs)
   238   >     tr = orig(self, *args, **kwargs)
   239   >     def fail(tr):
   239   >     def fail(tr):
   240   >         raise util.Abort("forced transaction failure")
   240   >         raise error.Abort("forced transaction failure")
   241   >     # zzz prefix to ensure it sorted after store.write
   241   >     # zzz prefix to ensure it sorted after store.write
   242   >     tr.addfinalize('zzz-forcefails', fail)
   242   >     tr.addfinalize('zzz-forcefails', fail)
   243   >     return tr
   243   >     return tr
   244   > 
   244   > 
   245   > def uisetup(ui):
   245   > def uisetup(ui):
   260 
   260 
   261 Aborted transactions can be recovered later
   261 Aborted transactions can be recovered later
   262 
   262 
   263   $ cat > ../exceptionext.py <<EOF
   263   $ cat > ../exceptionext.py <<EOF
   264   > import os
   264   > import os
   265   > from mercurial import commands, util, transaction, localrepo
   265   > from mercurial import commands, error, transaction, localrepo
   266   > from mercurial.extensions import wrapfunction
   266   > from mercurial.extensions import wrapfunction
   267   > 
   267   > 
   268   > def trwrapper(orig, self, *args, **kwargs):
   268   > def trwrapper(orig, self, *args, **kwargs):
   269   >     tr = orig(self, *args, **kwargs)
   269   >     tr = orig(self, *args, **kwargs)
   270   >     def fail(tr):
   270   >     def fail(tr):
   271   >         raise util.Abort("forced transaction failure")
   271   >         raise error.Abort("forced transaction failure")
   272   >     # zzz prefix to ensure it sorted after store.write
   272   >     # zzz prefix to ensure it sorted after store.write
   273   >     tr.addfinalize('zzz-forcefails', fail)
   273   >     tr.addfinalize('zzz-forcefails', fail)
   274   >     return tr
   274   >     return tr
   275   > 
   275   > 
   276   > def abortwrapper(orig, self, *args, **kwargs):
   276   > def abortwrapper(orig, self, *args, **kwargs):
   277   >     raise util.Abort("forced transaction failure")
   277   >     raise error.Abort("forced transaction failure")
   278   > 
   278   > 
   279   > def uisetup(ui):
   279   > def uisetup(ui):
   280   >     wrapfunction(localrepo.localrepository, 'transaction', trwrapper)
   280   >     wrapfunction(localrepo.localrepository, 'transaction', trwrapper)
   281   >     wrapfunction(transaction.transaction, '_abort', abortwrapper)
   281   >     wrapfunction(transaction.transaction, '_abort', abortwrapper)
   282   > 
   282   >