mercurial/dispatch.py
changeset 7474 b2cbced7bb50
parent 7388 5751631246de
child 7632 9626819b2e3d
equal deleted inserted replaced
7473:5185a24ce04e 7474:b2cbced7bb50
    88                 if ui.debugflag:
    88                 if ui.debugflag:
    89                     ui.warn(_("\nbroken pipe\n"))
    89                     ui.warn(_("\nbroken pipe\n"))
    90             else:
    90             else:
    91                 raise
    91                 raise
    92     except socket.error, inst:
    92     except socket.error, inst:
    93         ui.warn(_("abort: %s\n") % inst[-1])
    93         ui.warn(_("abort: %s\n") % inst.args[-1])
    94     except IOError, inst:
    94     except IOError, inst:
    95         if hasattr(inst, "code"):
    95         if hasattr(inst, "code"):
    96             ui.warn(_("abort: %s\n") % inst)
    96             ui.warn(_("abort: %s\n") % inst)
    97         elif hasattr(inst, "reason"):
    97         elif hasattr(inst, "reason"):
    98             try: # usually it is in the form (errno, strerror)
    98             try: # usually it is in the form (errno, strerror)
    99                 reason = inst.reason.args[1]
    99                 reason = inst.reason.args[1]
   100             except: # it might be anything, for example a string
   100             except: # it might be anything, for example a string
   101                 reason = inst.reason
   101                 reason = inst.reason
   102             ui.warn(_("abort: error: %s\n") % reason)
   102             ui.warn(_("abort: error: %s\n") % reason)
   103         elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
   103         elif hasattr(inst, "args") and inst.args[0] == errno.EPIPE:
   104             if ui.debugflag:
   104             if ui.debugflag:
   105                 ui.warn(_("broken pipe\n"))
   105                 ui.warn(_("broken pipe\n"))
   106         elif getattr(inst, "strerror", None):
   106         elif getattr(inst, "strerror", None):
   107             if getattr(inst, "filename", None):
   107             if getattr(inst, "filename", None):
   108                 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
   108                 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
   114         if getattr(inst, "filename", None):
   114         if getattr(inst, "filename", None):
   115             ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
   115             ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
   116         else:
   116         else:
   117             ui.warn(_("abort: %s\n") % inst.strerror)
   117             ui.warn(_("abort: %s\n") % inst.strerror)
   118     except util.UnexpectedOutput, inst:
   118     except util.UnexpectedOutput, inst:
   119         ui.warn(_("abort: %s") % inst[0])
   119         ui.warn(_("abort: %s") % inst.args[0])
   120         if not isinstance(inst[1], basestring):
   120         if not isinstance(inst.args[1], basestring):
   121             ui.warn(" %r\n" % (inst[1],))
   121             ui.warn(" %r\n" % (inst.args[1],))
   122         elif not inst[1]:
   122         elif not inst.args[1]:
   123             ui.warn(_(" empty string\n"))
   123             ui.warn(_(" empty string\n"))
   124         else:
   124         else:
   125             ui.warn("\n%r\n" % util.ellipsis(inst[1]))
   125             ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
   126     except ImportError, inst:
   126     except ImportError, inst:
   127         m = str(inst).split()[-1]
   127         m = str(inst).split()[-1]
   128         ui.warn(_("abort: could not import module %s!\n") % m)
   128         ui.warn(_("abort: could not import module %s!\n") % m)
   129         if m in "mpatch bdiff".split():
   129         if m in "mpatch bdiff".split():
   130             ui.warn(_("(did you forget to compile extensions?)\n"))
   130             ui.warn(_("(did you forget to compile extensions?)\n"))