Show More
@@ -138,19 +138,7 b' class httprepository(wireproto.wirerepos' | |||||
138 | # if using keepalive, allow connection to be reused |
|
138 | # if using keepalive, allow connection to be reused | |
139 | fp.close() |
|
139 | fp.close() | |
140 |
|
140 | |||
141 | def _abort(self, exception): |
|
141 | def _callpush(self, cmd, cg, **args): | |
142 | raise exception |
|
|||
143 |
|
||||
144 | def _decompress(self, stream): |
|
|||
145 | return util.chunkbuffer(zgenerator(stream)) |
|
|||
146 |
|
||||
147 | def unbundle(self, cg, heads, source): |
|
|||
148 | '''Send cg (a readable file-like object representing the |
|
|||
149 | changegroup to push, typically a chunkbuffer object) to the |
|
|||
150 | remote server as a bundle. Return an integer response code: |
|
|||
151 | non-zero indicates a successful push (see |
|
|||
152 | localrepository.addchangegroup()), and zero indicates either |
|
|||
153 | error or nothing to push.''' |
|
|||
154 | # have to stream bundle to a temp file because we do not have |
|
142 | # have to stream bundle to a temp file because we do not have | |
155 | # http 1.1 chunked transfer. |
|
143 | # http 1.1 chunked transfer. | |
156 |
|
144 | |||
@@ -170,21 +158,12 b' class httprepository(wireproto.wirerepos' | |||||
170 |
|
158 | |||
171 | tempname = changegroup.writebundle(cg, None, type) |
|
159 | tempname = changegroup.writebundle(cg, None, type) | |
172 | fp = url.httpsendfile(tempname, "rb") |
|
160 | fp = url.httpsendfile(tempname, "rb") | |
|
161 | headers = {'Content-Type': 'application/mercurial-0.1'} | |||
|
162 | ||||
173 | try: |
|
163 | try: | |
174 | try: |
|
164 | try: | |
175 |
r |
|
165 | r = self._call(cmd, data=fp, headers=headers, **args) | |
176 | 'unbundle', data=fp, |
|
166 | return r.split('\n', 1) | |
177 | headers={'Content-Type': 'application/mercurial-0.1'}, |
|
|||
178 | heads=' '.join(map(hex, heads))) |
|
|||
179 | resp_code, output = resp.split('\n', 1) |
|
|||
180 | try: |
|
|||
181 | ret = int(resp_code) |
|
|||
182 | except ValueError, err: |
|
|||
183 | raise error.ResponseError( |
|
|||
184 | _('push failed (unexpected response):'), resp) |
|
|||
185 | for l in output.splitlines(True): |
|
|||
186 | self.ui.status(_('remote: '), l) |
|
|||
187 | return ret |
|
|||
188 | except socket.error, err: |
|
167 | except socket.error, err: | |
189 | if err.args[0] in (errno.ECONNRESET, errno.EPIPE): |
|
168 | if err.args[0] in (errno.ECONNRESET, errno.EPIPE): | |
190 | raise util.Abort(_('push failed: %s') % err.args[1]) |
|
169 | raise util.Abort(_('push failed: %s') % err.args[1]) | |
@@ -193,6 +172,12 b' class httprepository(wireproto.wirerepos' | |||||
193 | fp.close() |
|
172 | fp.close() | |
194 | os.unlink(tempname) |
|
173 | os.unlink(tempname) | |
195 |
|
174 | |||
|
175 | def _abort(self, exception): | |||
|
176 | raise exception | |||
|
177 | ||||
|
178 | def _decompress(self, stream): | |||
|
179 | return util.chunkbuffer(zgenerator(stream)) | |||
|
180 | ||||
196 | class httpsrepository(httprepository): |
|
181 | class httpsrepository(httprepository): | |
197 | def __init__(self, ui, path): |
|
182 | def __init__(self, ui, path): | |
198 | if not url.has_https: |
|
183 | if not url.has_https: |
@@ -128,6 +128,21 b' class sshrepository(wireproto.wirereposi' | |||||
128 | self._callstream(cmd, **args) |
|
128 | self._callstream(cmd, **args) | |
129 | return self._recv() |
|
129 | return self._recv() | |
130 |
|
130 | |||
|
131 | def _callpush(self, cmd, fp, **args): | |||
|
132 | r = self._call(cmd, **args) | |||
|
133 | if r: | |||
|
134 | return '', r | |||
|
135 | while 1: | |||
|
136 | d = fp.read(4096) | |||
|
137 | if not d: | |||
|
138 | break | |||
|
139 | self._send(d) | |||
|
140 | self._send("", flush=True) | |||
|
141 | r = self._recv() | |||
|
142 | if r: | |||
|
143 | return '', r | |||
|
144 | return self._recv(), '' | |||
|
145 | ||||
131 | def _decompress(self, stream): |
|
146 | def _decompress(self, stream): | |
132 | return stream |
|
147 | return stream | |
133 |
|
148 | |||
@@ -155,35 +170,6 b' class sshrepository(wireproto.wirereposi' | |||||
155 | def unlock(self): |
|
170 | def unlock(self): | |
156 | self._call("unlock") |
|
171 | self._call("unlock") | |
157 |
|
172 | |||
158 | def unbundle(self, cg, heads, source): |
|
|||
159 | '''Send cg (a readable file-like object representing the |
|
|||
160 | changegroup to push, typically a chunkbuffer object) to the |
|
|||
161 | remote server as a bundle. Return an integer indicating the |
|
|||
162 | result of the push (see localrepository.addchangegroup()).''' |
|
|||
163 | d = self._call("unbundle", heads=' '.join(map(hex, heads))) |
|
|||
164 | if d: |
|
|||
165 | # remote may send "unsynced changes" |
|
|||
166 | self._abort(error.RepoError(_("push refused: %s") % d)) |
|
|||
167 |
|
||||
168 | while 1: |
|
|||
169 | d = cg.read(4096) |
|
|||
170 | if not d: |
|
|||
171 | break |
|
|||
172 | self._send(d) |
|
|||
173 |
|
||||
174 | self._send("", flush=True) |
|
|||
175 |
|
||||
176 | r = self._recv() |
|
|||
177 | if r: |
|
|||
178 | # remote may send "unsynced changes" |
|
|||
179 | self._abort(error.RepoError(_("push failed: %s") % r)) |
|
|||
180 |
|
||||
181 | r = self._recv() |
|
|||
182 | try: |
|
|||
183 | return int(r) |
|
|||
184 | except: |
|
|||
185 | self._abort(error.ResponseError(_("unexpected response:"), r)) |
|
|||
186 |
|
||||
187 | def addchangegroup(self, cg, source, url): |
|
173 | def addchangegroup(self, cg, source, url): | |
188 | '''Send a changegroup to the remote server. Return an integer |
|
174 | '''Send a changegroup to the remote server. Return an integer | |
189 | similar to unbundle(). DEPRECATED, since it requires locking the |
|
175 | similar to unbundle(). DEPRECATED, since it requires locking the |
@@ -103,6 +103,26 b' class wirerepository(repo.repository):' | |||||
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): |
General Comments 0
You need to be logged in to leave comments.
Login now