diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -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): diff --git a/tests/test-acl.t b/tests/test-acl.t --- a/tests/test-acl.t +++ b/tests/test-acl.t @@ -120,7 +120,7 @@ bundle2-output-bundle: "HG20", 2 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-bundle: 1 parts total @@ -184,7 +184,7 @@ bundle2-output-bundle: "HG20", 2 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-bundle: 1 parts total @@ -259,7 +259,7 @@ bundle2-output-bundle: "HG20", 2 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-bundle: 1 parts total @@ -742,7 +742,7 @@ bundle2-output-bundle: "HG20", 2 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-bundle: 1 parts total @@ -1056,7 +1056,7 @@ bundle2-output-bundle: "HG20", 2 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-bundle: 1 parts total @@ -1141,7 +1141,7 @@ bundle2-output-bundle: "HG20", 2 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-bundle: 1 parts total @@ -1298,7 +1298,7 @@ bundle2-output-bundle: "HG20", 2 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-bundle: 1 parts total @@ -1502,7 +1502,7 @@ bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported @@ -1798,7 +1798,7 @@ bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported @@ -1891,7 +1891,7 @@ bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported @@ -2052,7 +2052,7 @@ bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload - bundle2-input-bundle: no-transaction + bundle2-input-bundle: with-transaction bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported