comparison mercurial/exchange.py @ 23047:f10019d2ee0a

hook: schedule run "b2x-transactionclose" for after lock release Hooks that run after the transaction need to be able to touch the repository. So we need to run them after the lock release. This is similar to what the "changegroup" hook is doing in the `addchangegroup` function.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 17 Oct 2014 02:17:36 -0700
parents e4aeb14248ca
children e62c330a044f
comparison
equal deleted inserted replaced
23046:c1aede895072 23047:f10019d2ee0a
839 p = cl.writepending() and repo.root or "" 839 p = cl.writepending() and repo.root or ""
840 p = cl.writepending() and repo.root or "" 840 p = cl.writepending() and repo.root or ""
841 repo.hook('b2x-pretransactionclose', throw=True, pending=p, 841 repo.hook('b2x-pretransactionclose', throw=True, pending=p,
842 **self._tr.hookargs) 842 **self._tr.hookargs)
843 self._tr.close() 843 self._tr.close()
844 repo.hook('b2x-transactionclose', **self._tr.hookargs) 844 hookargs = dict(self._tr.hookargs)
845 def runhooks():
846 repo.hook('b2x-transactionclose', **hookargs)
847 repo._afterlock(runhooks)
845 848
846 def releasetransaction(self): 849 def releasetransaction(self):
847 """release transaction if created""" 850 """release transaction if created"""
848 if self._tr is not None: 851 if self._tr is not None:
849 self._tr.release() 852 self._tr.release()
1245 cl = repo.unfiltered().changelog 1248 cl = repo.unfiltered().changelog
1246 p = cl.writepending() and repo.root or "" 1249 p = cl.writepending() and repo.root or ""
1247 repo.hook('b2x-pretransactionclose', throw=True, pending=p, 1250 repo.hook('b2x-pretransactionclose', throw=True, pending=p,
1248 **tr.hookargs) 1251 **tr.hookargs)
1249 tr.close() 1252 tr.close()
1250 repo.hook('b2x-transactionclose', **tr.hookargs) 1253 hookargs = dict(tr.hookargs)
1254 def runhooks():
1255 repo.hook('b2x-transactionclose', **hookargs)
1256 repo._afterlock(runhooks)
1251 except Exception, exc: 1257 except Exception, exc:
1252 exc.duringunbundle2 = True 1258 exc.duringunbundle2 = True
1253 raise 1259 raise
1254 else: 1260 else:
1255 r = changegroup.addchangegroup(repo, cg, source, url) 1261 r = changegroup.addchangegroup(repo, cg, source, url)