Mercurial > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
11591:0d9cb3f3b0a1 | 11592:26e0782b8380 |
---|---|
101 bases = " ".join(map(hex, bases)) | 101 bases = " ".join(map(hex, bases)) |
102 heads = " ".join(map(hex, heads)) | 102 heads = " ".join(map(hex, heads)) |
103 return self._decompress(self._callstream("changegroupsubset", | 103 return self._decompress(self._callstream("changegroupsubset", |
104 bases=bases, heads=heads)) | 104 bases=bases, heads=heads)) |
105 | 105 |
106 def unbundle(self, cg, heads, source): | |
107 '''Send cg (a readable file-like object representing the | |
108 changegroup to push, typically a chunkbuffer object) to the | |
109 remote server as a bundle. Return an integer indicating the | |
110 result of the push (see localrepository.addchangegroup()).''' | |
111 | |
112 ret, output = self._callpush("unbundle", cg, heads=' '.join(map(hex, heads))) | |
113 if ret == "": | |
114 raise error.ResponseError( | |
115 _('push failed:'), output) | |
116 try: | |
117 ret = int(ret) | |
118 except ValueError, err: | |
119 raise error.ResponseError( | |
120 _('push failed (unexpected response):'), ret) | |
121 | |
122 for l in output.splitlines(True): | |
123 self.ui.status(_('remote: '), l) | |
124 return ret | |
125 | |
106 # server side | 126 # server side |
107 | 127 |
108 def dispatch(repo, proto, command): | 128 def dispatch(repo, proto, command): |
109 if command not in commands: | 129 if command not in commands: |
110 return False | 130 return False |