Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bundle2.py @ 33693:5fc4ddfbe626
bundle2: load hookargs from bundleoperation into transaction when started one
When a transaction is started, we must load the hookargs from the
bundleoperation object to the transaction so that they can be used in the
transaction. Also this patch makes sure no more hookargs are added to the
bundleoperation object once the transaction starts.
This is a part of porting fb extension bundle2hooks to core.
Differential Revision: https://phab.mercurial-scm.org/D209
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 02 Aug 2017 03:23:06 +0530 |
parents | f3407d56a6e8 |
children | da7c285ec6da |
line wrap: on
line diff
--- a/mercurial/bundle2.py Wed Aug 02 03:08:42 2017 +0530 +++ b/mercurial/bundle2.py Wed Aug 02 03:23:06 2017 +0530 @@ -296,12 +296,31 @@ self.repo = repo self.ui = repo.ui self.records = unbundlerecords() - self.gettransaction = transactiongetter self.reply = None self.captureoutput = captureoutput self.hookargs = {} + self._gettransaction = transactiongetter + + def gettransaction(self): + transaction = self._gettransaction() + + if self.hookargs is not None: + # the ones added to the transaction supercede those added + # to the operation. + self.hookargs.update(transaction.hookargs) + transaction.hookargs = self.hookargs + + # mark the hookargs as flushed. further attempts to add to + # hookargs will result in an abort. + self.hookargs = None + + return transaction def addhookargs(self, hookargs): + if self.hookargs is None: + raise error.Abort( + _('attempted to add hooks to operation after transaction ' + 'started')) self.hookargs.update(hookargs) class TransactionUnavailable(RuntimeError):