Show More
@@ -111,7 +111,7 b' def _runcatch(ui, args):' | |||||
111 | ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
|
111 | ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) | |
112 | else: |
|
112 | else: | |
113 | ui.warn(_("abort: %s\n") % inst.strerror) |
|
113 | ui.warn(_("abort: %s\n") % inst.strerror) | |
114 | except util.UnexpectedOutput, inst: |
|
114 | except error.ResponseError, inst: | |
115 | ui.warn(_("abort: %s") % inst.args[0]) |
|
115 | ui.warn(_("abort: %s") % inst.args[0]) | |
116 | if not isinstance(inst.args[1], basestring): |
|
116 | if not isinstance(inst.args[1], basestring): | |
117 | ui.warn(" %r\n" % (inst.args[1],)) |
|
117 | ui.warn(" %r\n" % (inst.args[1],)) |
@@ -46,3 +46,7 b' class LockHeld(LockError):' | |||||
46 |
|
46 | |||
47 | class LockUnavailable(LockError): |
|
47 | class LockUnavailable(LockError): | |
48 | pass |
|
48 | pass | |
|
49 | ||||
|
50 | class ResponseError(Exception): | |||
|
51 | """Raised to print an error with part of output and exit.""" | |||
|
52 |
@@ -135,7 +135,7 b' class httprepository(repo.repository):' | |||||
135 | try: |
|
135 | try: | |
136 | return map(bin, d[:-1].split(" ")) |
|
136 | return map(bin, d[:-1].split(" ")) | |
137 | except: |
|
137 | except: | |
138 |
raise |
|
138 | raise error.ResponseError(_("unexpected response:"), d) | |
139 |
|
139 | |||
140 | def branches(self, nodes): |
|
140 | def branches(self, nodes): | |
141 | n = " ".join(map(hex, nodes)) |
|
141 | n = " ".join(map(hex, nodes)) | |
@@ -144,7 +144,7 b' class httprepository(repo.repository):' | |||||
144 | br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] |
|
144 | br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] | |
145 | return br |
|
145 | return br | |
146 | except: |
|
146 | except: | |
147 |
raise |
|
147 | raise error.ResponseError(_("unexpected response:"), d) | |
148 |
|
148 | |||
149 | def between(self, pairs): |
|
149 | def between(self, pairs): | |
150 | batch = 8 # avoid giant requests |
|
150 | batch = 8 # avoid giant requests | |
@@ -155,7 +155,7 b' class httprepository(repo.repository):' | |||||
155 | try: |
|
155 | try: | |
156 | r += [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] |
|
156 | r += [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] | |
157 | except: |
|
157 | except: | |
158 |
raise |
|
158 | raise error.ResponseError(_("unexpected response:"), d) | |
159 | return r |
|
159 | return r | |
160 |
|
160 | |||
161 | def changegroup(self, nodes, kind): |
|
161 | def changegroup(self, nodes, kind): | |
@@ -200,7 +200,7 b' class httprepository(repo.repository):' | |||||
200 | try: |
|
200 | try: | |
201 | ret = int(resp_code) |
|
201 | ret = int(resp_code) | |
202 | except ValueError, err: |
|
202 | except ValueError, err: | |
203 |
raise |
|
203 | raise error.ResponseError( | |
204 | _('push failed (unexpected response):'), resp) |
|
204 | _('push failed (unexpected response):'), resp) | |
205 | self.ui.write(output) |
|
205 | self.ui.write(output) | |
206 | return ret |
|
206 | return ret |
@@ -2076,7 +2076,7 b' class localrepository(repo.repository):' | |||||
2076 | try: |
|
2076 | try: | |
2077 | resp = int(l) |
|
2077 | resp = int(l) | |
2078 | except ValueError: |
|
2078 | except ValueError: | |
2079 | raise util.UnexpectedOutput( |
|
2079 | raise error.ResponseError( | |
2080 | _('Unexpected response from remote server:'), l) |
|
2080 | _('Unexpected response from remote server:'), l) | |
2081 | if resp == 1: |
|
2081 | if resp == 1: | |
2082 | raise util.Abort(_('operation forbidden by server')) |
|
2082 | raise util.Abort(_('operation forbidden by server')) | |
@@ -2089,7 +2089,7 b' class localrepository(repo.repository):' | |||||
2089 | try: |
|
2089 | try: | |
2090 | total_files, total_bytes = map(int, l.split(' ', 1)) |
|
2090 | total_files, total_bytes = map(int, l.split(' ', 1)) | |
2091 | except (ValueError, TypeError): |
|
2091 | except (ValueError, TypeError): | |
2092 | raise util.UnexpectedOutput( |
|
2092 | raise error.ResponseError( | |
2093 | _('Unexpected response from remote server:'), l) |
|
2093 | _('Unexpected response from remote server:'), l) | |
2094 | self.ui.status(_('%d files to transfer, %s of data\n') % |
|
2094 | self.ui.status(_('%d files to transfer, %s of data\n') % | |
2095 | (total_files, util.bytecount(total_bytes))) |
|
2095 | (total_files, util.bytecount(total_bytes))) | |
@@ -2101,7 +2101,7 b' class localrepository(repo.repository):' | |||||
2101 | name, size = l.split('\0', 1) |
|
2101 | name, size = l.split('\0', 1) | |
2102 | size = int(size) |
|
2102 | size = int(size) | |
2103 | except (ValueError, TypeError): |
|
2103 | except (ValueError, TypeError): | |
2104 |
raise |
|
2104 | raise error.ResponseError( | |
2105 | _('Unexpected response from remote server:'), l) |
|
2105 | _('Unexpected response from remote server:'), l) | |
2106 | self.ui.debug(_('adding %s (%s)\n') % (name, util.bytecount(size))) |
|
2106 | self.ui.debug(_('adding %s (%s)\n') % (name, util.bytecount(size))) | |
2107 | ofp = self.sopener(name, 'w') |
|
2107 | ofp = self.sopener(name, 'w') |
@@ -132,7 +132,7 b' class sshrepository(repo.repository):' | |||||
132 | try: |
|
132 | try: | |
133 | l = int(l) |
|
133 | l = int(l) | |
134 | except: |
|
134 | except: | |
135 |
self.raise_( |
|
135 | self.raise_(error.ResponseError(_("unexpected response:"), l)) | |
136 | return self.pipei.read(l) |
|
136 | return self.pipei.read(l) | |
137 |
|
137 | |||
138 | def _send(self, data, flush=False): |
|
138 | def _send(self, data, flush=False): | |
@@ -164,7 +164,7 b' class sshrepository(repo.repository):' | |||||
164 | try: |
|
164 | try: | |
165 | return map(bin, d[:-1].split(" ")) |
|
165 | return map(bin, d[:-1].split(" ")) | |
166 | except: |
|
166 | except: | |
167 |
self.raise_( |
|
167 | self.raise_(error.ResponseError(_("unexpected response:"), d)) | |
168 |
|
168 | |||
169 | def branches(self, nodes): |
|
169 | def branches(self, nodes): | |
170 | n = " ".join(map(hex, nodes)) |
|
170 | n = " ".join(map(hex, nodes)) | |
@@ -173,7 +173,7 b' class sshrepository(repo.repository):' | |||||
173 | br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] |
|
173 | br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] | |
174 | return br |
|
174 | return br | |
175 | except: |
|
175 | except: | |
176 |
self.raise_( |
|
176 | self.raise_(error.ResponseError(_("unexpected response:"), d)) | |
177 |
|
177 | |||
178 | def between(self, pairs): |
|
178 | def between(self, pairs): | |
179 | n = " ".join(["-".join(map(hex, p)) for p in pairs]) |
|
179 | n = " ".join(["-".join(map(hex, p)) for p in pairs]) | |
@@ -182,7 +182,7 b' class sshrepository(repo.repository):' | |||||
182 | p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] |
|
182 | p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] | |
183 | return p |
|
183 | return p | |
184 | except: |
|
184 | except: | |
185 |
self.raise_( |
|
185 | self.raise_(error.ResponseError(_("unexpected response:"), d)) | |
186 |
|
186 | |||
187 | def changegroup(self, nodes, kind): |
|
187 | def changegroup(self, nodes, kind): | |
188 | n = " ".join(map(hex, nodes)) |
|
188 | n = " ".join(map(hex, nodes)) | |
@@ -217,7 +217,7 b' class sshrepository(repo.repository):' | |||||
217 | try: |
|
217 | try: | |
218 | return int(r) |
|
218 | return int(r) | |
219 | except: |
|
219 | except: | |
220 |
self.raise_( |
|
220 | self.raise_(error.ResponseError(_("unexpected response:"), r)) | |
221 |
|
221 | |||
222 | def addchangegroup(self, cg, source, url): |
|
222 | def addchangegroup(self, cg, source, url): | |
223 | d = self.call("addchangegroup") |
|
223 | d = self.call("addchangegroup") | |
@@ -239,7 +239,7 b' class sshrepository(repo.repository):' | |||||
239 | try: |
|
239 | try: | |
240 | return int(r) |
|
240 | return int(r) | |
241 | except: |
|
241 | except: | |
242 |
self.raise_( |
|
242 | self.raise_(error.ResponseError(_("unexpected response:"), r)) | |
243 |
|
243 | |||
244 | def stream_out(self): |
|
244 | def stream_out(self): | |
245 | return self.do_cmd('stream_out') |
|
245 | return self.do_cmd('stream_out') |
@@ -335,9 +335,6 b' def increasingchunks(source, min=1024, m' | |||||
335 | class Abort(Exception): |
|
335 | class Abort(Exception): | |
336 | """Raised if a command needs to print an error and exit.""" |
|
336 | """Raised if a command needs to print an error and exit.""" | |
337 |
|
337 | |||
338 | class UnexpectedOutput(Abort): |
|
|||
339 | """Raised to print an error with part of output and exit.""" |
|
|||
340 |
|
||||
341 | def always(fn): return True |
|
338 | def always(fn): return True | |
342 | def never(fn): return False |
|
339 | def never(fn): return False | |
343 |
|
340 |
General Comments 0
You need to be logged in to leave comments.
Login now