Mercurial > hg
comparison mercurial/exchange.py @ 23222:6b7e60fb0b38
exchange: use the postclose API on transaction
As with changegroup, we should wait for the transaction to be really closed
before scheduling hook execution.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 28 Oct 2014 14:58:36 +0100 |
parents | 61cd79ac4b99 |
children | 6c1351352b6c |
comparison
equal
deleted
inserted
replaced
23221:cadc9a723d60 | 23222:6b7e60fb0b38 |
---|---|
855 if self._tr is not None: | 855 if self._tr is not None: |
856 repo = self.repo | 856 repo = self.repo |
857 p = lambda: self._tr.writepending() and repo.root or "" | 857 p = lambda: self._tr.writepending() and repo.root or "" |
858 repo.hook('b2x-pretransactionclose', throw=True, pending=p, | 858 repo.hook('b2x-pretransactionclose', throw=True, pending=p, |
859 **self._tr.hookargs) | 859 **self._tr.hookargs) |
860 self._tr.close() | |
861 hookargs = dict(self._tr.hookargs) | 860 hookargs = dict(self._tr.hookargs) |
862 def runhooks(): | 861 def runhooks(): |
863 repo.hook('b2x-transactionclose', **hookargs) | 862 repo.hook('b2x-transactionclose', **hookargs) |
864 repo._afterlock(runhooks) | 863 self._tr.addpostclose('b2x-hook-transactionclose', |
864 lambda: repo._afterlock(runhooks)) | |
865 self._tr.close() | |
865 | 866 |
866 def releasetransaction(self): | 867 def releasetransaction(self): |
867 """release transaction if created""" | 868 """release transaction if created""" |
868 if self._tr is not None: | 869 if self._tr is not None: |
869 self._tr.release() | 870 self._tr.release() |
1279 tr.hookargs['bundle2-exp'] = '1' | 1280 tr.hookargs['bundle2-exp'] = '1' |
1280 r = bundle2.processbundle(repo, cg, lambda: tr).reply | 1281 r = bundle2.processbundle(repo, cg, lambda: tr).reply |
1281 p = lambda: tr.writepending() and repo.root or "" | 1282 p = lambda: tr.writepending() and repo.root or "" |
1282 repo.hook('b2x-pretransactionclose', throw=True, pending=p, | 1283 repo.hook('b2x-pretransactionclose', throw=True, pending=p, |
1283 **tr.hookargs) | 1284 **tr.hookargs) |
1284 tr.close() | |
1285 hookargs = dict(tr.hookargs) | 1285 hookargs = dict(tr.hookargs) |
1286 def runhooks(): | 1286 def runhooks(): |
1287 repo.hook('b2x-transactionclose', **hookargs) | 1287 repo.hook('b2x-transactionclose', **hookargs) |
1288 repo._afterlock(runhooks) | 1288 tr.addpostclose('b2x-hook-transactionclose', |
1289 lambda: repo._afterlock(runhooks)) | |
1290 tr.close() | |
1289 except Exception, exc: | 1291 except Exception, exc: |
1290 exc.duringunbundle2 = True | 1292 exc.duringunbundle2 = True |
1291 raise | 1293 raise |
1292 else: | 1294 else: |
1293 r = changegroup.addchangegroup(repo, cg, source, url) | 1295 r = changegroup.addchangegroup(repo, cg, source, url) |