Mercurial > public > mercurial-scm > hg-stable
diff mercurial/exchange.py @ 23439:743736fc7c41
bundle2-push: provide transaction to reply unbundler
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.
This diff adds an experimental config option "bundle2.pushback" which provides
a transaction to the reply unbundler during a push operation. This behavior is
opt-in because of potential security issues: the response can contain any part
type that has a handler defined, allowing the server to make arbitrary changes
to the local repository.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Fri, 21 Nov 2014 15:50:38 -0800 |
parents | 94e2862dbcfb |
children | 4dd8a6a1240d |
line wrap: on
line diff
--- a/mercurial/exchange.py Mon Nov 24 16:04:44 2014 -0800 +++ b/mercurial/exchange.py Fri Nov 21 15:50:38 2014 -0800 @@ -572,8 +572,12 @@ The only currently supported type of data is changegroup but this will evolve in the future.""" bundler = bundle2.bundle20(pushop.ui, bundle2.bundle2caps(pushop.remote)) + pushback = (pushop.trmanager + and pushop.ui.configbool('experimental', 'bundle2.pushback')) + # create reply capability - capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo)) + capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo, + allowpushback=pushback)) bundler.newpart('b2x:replycaps', data=capsblob) replyhandlers = [] for partgenname in b2partsgenorder: @@ -590,7 +594,10 @@ except error.BundleValueError, exc: raise util.Abort('missing support for %s' % exc) try: - op = bundle2.processbundle(pushop.repo, reply) + trgetter = None + if pushback: + trgetter = pushop.trmanager.transaction + op = bundle2.processbundle(pushop.repo, reply, trgetter) except error.BundleValueError, exc: raise util.Abort('missing support for %s' % exc) for rephand in replyhandlers: