Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireproto.py @ 11592:26e0782b8380
protocol: unify client unbundle support
- introduce _callpush helper
- factor out differences in result handling into helpers
- unify
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 14 Jul 2010 17:12:18 -0500 |
parents | 0d9cb3f3b0a1 |
children | d054cc5c7737 |
line wrap: on
line diff
--- a/mercurial/wireproto.py Wed Jul 14 17:09:31 2010 -0500 +++ b/mercurial/wireproto.py Wed Jul 14 17:12:18 2010 -0500 @@ -103,6 +103,26 @@ return self._decompress(self._callstream("changegroupsubset", bases=bases, heads=heads)) + def unbundle(self, cg, heads, source): + '''Send cg (a readable file-like object representing the + changegroup to push, typically a chunkbuffer object) to the + remote server as a bundle. Return an integer indicating the + result of the push (see localrepository.addchangegroup()).''' + + ret, output = self._callpush("unbundle", cg, heads=' '.join(map(hex, heads))) + if ret == "": + raise error.ResponseError( + _('push failed:'), output) + try: + ret = int(ret) + except ValueError, err: + raise error.ResponseError( + _('push failed (unexpected response):'), ret) + + for l in output.splitlines(True): + self.ui.status(_('remote: '), l) + return ret + # server side def dispatch(repo, proto, command):