# HG changeset patch # User Pierre-Yves David # Date 1397594970 14400 # Node ID 19b9f23a8c6fa34e0677d21419ffdf6d0b7b92a8 # Parent 408877d491fbe83748d1f36c66ba9b2b105c9db2 bundle2: return a bundle20 object from exchanges.unbundle When a bundle2 is pushed we return a bundle instead of an integer. We use to return a binary stream. We now return a `bundle20` bundler to make the life of wireprotocol implementation simpler. diff -r 408877d491fb -r 19b9f23a8c6f mercurial/exchange.py --- a/mercurial/exchange.py Tue Apr 15 16:42:52 2014 -0400 +++ b/mercurial/exchange.py Tue Apr 15 16:49:30 2014 -0400 @@ -694,10 +694,8 @@ # push can proceed if util.safehasattr(cg, 'params'): tr = repo.transaction('unbundle') - ret = bundle2.processbundle(repo, cg, lambda: tr) + r = bundle2.processbundle(repo, cg, lambda: tr).reply tr.close() - stream = util.chunkbuffer(ret.reply.getchunks()) - r = bundle2.unbundle20(repo.ui, stream) else: r = changegroup.addchangegroup(repo, cg, source, url) finally: diff -r 408877d491fb -r 19b9f23a8c6f mercurial/localrepo.py --- a/mercurial/localrepo.py Tue Apr 15 16:42:52 2014 -0400 +++ b/mercurial/localrepo.py Tue Apr 15 16:49:30 2014 -0400 @@ -124,7 +124,14 @@ This function handles the repo locking itself.""" try: cg = exchange.readbundle(self.ui, cg, None) - return exchange.unbundle(self._repo, cg, heads, 'push', url) + ret = exchange.unbundle(self._repo, cg, heads, 'push', url) + if util.safehasattr(ret, 'getchunks'): + # This is a bundle20 object, turn it into an unbundler. + # This little dance should be dropped eventually when the API + # is finally improved. + stream = util.chunkbuffer(ret.getchunks()) + ret = bundle2.unbundle20(self.ui, stream) + return ret except exchange.PushRaced, exc: raise error.ResponseError(_('push failed:'), exc.message)