Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.3, 2.0, and 2.0.1

stable thread: add many more exception handlers

try to closely follow the exception handling from Mercurial's dispatch routines.

Changeset 546b204cf558

Parent 964e21880db6

by Steve Borho

Changes to one file · Browse files at 546b204cf558 Showing diff from parent 964e21880db6 Diff from another changeset...

 
297
298
299
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
302
303
304
 
305
306
307
 
297
298
299
 
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
 
358
359
360
361
@@ -297,11 +297,65 @@
  else:   err = local._('SSL error: %s') % reason   ui.write_err(err + '\n') - except (Exception, OSError, IOError), e: + except error.AmbiguousCommand, inst: + ui.warn(local._("hg: command '%s' is ambiguous:\n %s\n") % + (inst.args[0], " ".join(inst.args[1]))) + except error.ParseError, inst: + if len(inst.args) > 1: + ui.warn(local._("hg: parse error at %s: %s\n") % + (inst.args[1], inst.args[0])) + else: + ui.warn(local._("hg: parse error: %s\n") % inst.args[0]) + except error.LockHeld, inst: + if inst.errno == errno.ETIMEDOUT: + reason = local._('timed out waiting for lock held by %s') % inst.locker + else: + reason = local._('lock held by %s') % inst.locker + ui.warn(local._("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) + except error.LockUnavailable, inst: + ui.warn(local._("abort: could not lock %s: %s\n") % + (inst.desc or inst.filename, inst.strerror)) + except error.RepoError, inst: + ui.warn(local._("abort: %s!\n") % inst) + except error.ResponseError, inst: + ui.warn(local._("abort: %s") % inst.args[0]) + if not isinstance(inst.args[1], basestring): + ui.warn(" %r\n" % (inst.args[1],)) + elif not inst.args[1]: + ui.warn(local._(" empty string\n")) + else: + ui.warn("\n%r\n" % util.ellipsis(inst.args[1])) + except error.RevlogError, inst: + ui.warn(local._("abort: %s!\n") % inst) + except IOError, inst: + if hasattr(inst, "code"): + ui.warn(local._("abort: %s\n") % inst) + elif hasattr(inst, "reason"): + try: # usually it is in the form (errno, strerror) + reason = inst.reason.args[1] + except: # it might be anything, for example a string + reason = inst.reason + ui.warn(local._("abort: error: %s\n") % reason) + elif hasattr(inst, "args") and inst.args[0] == errno.EPIPE: + if ui.debugflag: + ui.warn(local._("broken pipe\n")) + elif getattr(inst, "strerror", None): + if getattr(inst, "filename", None): + ui.warn(local._("abort: %s: %s\n") % (inst.strerror, inst.filename)) + else: + ui.warn(local._("abort: %s\n") % inst.strerror) + else: + raise + except OSError, inst: + if getattr(inst, "filename", None): + ui.warn(local._("abort: %s: %s\n") % (inst.strerror, inst.filename)) + else: + ui.warn(local._("abort: %s\n") % inst.strerror) + except Exception, inst:   if 'THGDEBUG' in os.environ:   import traceback   traceback.print_exc() - ui.write_err(str(e) + '\n') + ui.write_err(str(inst) + '\n')   except KeyboardInterrupt:   self.ret = -1