comparison mercurial/localrepo.py @ 24282:db8679812f84

hook: add a generic hook after transaction has been closed We are adding generic hooking for all transactions. We may have useful information about what happened during the transaction, user of the transaction should have filled the 'hookargs' dictionnary of the transaction. This hook is simple because it has no power to rollback the transaction.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 09 Mar 2015 22:36:56 -0700
parents e9ede9b4c2f8
children ff14b26fe5f4
comparison
equal deleted inserted replaced
24281:e9ede9b4c2f8 24282:db8679812f84
922 self.store.createmode) 922 self.store.createmode)
923 # note: writing the fncache only during finalize mean that the file is 923 # note: writing the fncache only during finalize mean that the file is
924 # outdated when running hooks. As fncache is used for streaming clone, 924 # outdated when running hooks. As fncache is used for streaming clone,
925 # this is not expected to break anything that happen during the hooks. 925 # this is not expected to break anything that happen during the hooks.
926 tr.addfinalize('flush-fncache', self.store.write) 926 tr.addfinalize('flush-fncache', self.store.write)
927 # we must avoid cyclic reference between repo and transaction.
928 reporef = weakref.ref(self)
929 def txnclosehook(tr2):
930 """To be run if transaction is successful, will schedule a hook run
931 """
932 def hook():
933 reporef().hook('txnclose', throw=False, txnname=desc,
934 **tr2.hookargs)
935 reporef()._afterlock(hook)
936 tr.addfinalize('txnclose-hook', txnclosehook)
927 self._transref = weakref.ref(tr) 937 self._transref = weakref.ref(tr)
928 return tr 938 return tr
929 939
930 def _journalfiles(self): 940 def _journalfiles(self):
931 return ((self.svfs, 'journal'), 941 return ((self.svfs, 'journal'),