comparison mercurial/wireproto.py @ 15017:f4522df38c65

wireproto: add out-of-band error class to allow remote repo to report errors Older clients will still print the provided error message and not much else: over ssh, this will be each line prefixed with 'remote: ' in addition to an "abort: unexpected response: '\n'"; over http, this will be the '---%<---' banners in addition to the 'does not appear to be a repository' message. Currently, clients with this patch will display 'abort: remote error:\n' and the provided error text, but it is trivial to style the error text however is deemed appropriate.
author Andrew Pritchard <andrewp@fogcreek.com>
date Tue, 02 Aug 2011 15:21:10 -0400
parents 592e45b7d43e
children 42d0d4f63bf0
comparison
equal deleted inserted replaced
15016:871c77e78f5d 15017:f4522df38c65
333 333
334 class pusherr(object): 334 class pusherr(object):
335 def __init__(self, res): 335 def __init__(self, res):
336 self.res = res 336 self.res = res
337 337
338 class ooberror(object):
339 def __init__(self, message):
340 self.message = message
341
338 def dispatch(repo, proto, command): 342 def dispatch(repo, proto, command):
339 func, spec = commands[command] 343 func, spec = commands[command]
340 args = proto.getargs(spec) 344 args = proto.getargs(spec)
341 return func(repo, proto, *args) 345 return func(repo, proto, *args)
342 346
374 else: 378 else:
375 data[k] = vals[k] 379 data[k] = vals[k]
376 result = func(repo, proto, *[data[k] for k in keys]) 380 result = func(repo, proto, *[data[k] for k in keys])
377 else: 381 else:
378 result = func(repo, proto) 382 result = func(repo, proto)
383 if isinstance(result, ooberror):
384 return result
379 res.append(escapearg(result)) 385 res.append(escapearg(result))
380 return ';'.join(res) 386 return ';'.join(res)
381 387
382 def between(repo, proto, pairs): 388 def between(repo, proto, pairs):
383 pairs = [decodelist(p, '-') for p in pairs.split(" ")] 389 pairs = [decodelist(p, '-') for p in pairs.split(" ")]