##// END OF EJS Templates
procutil: make explainexit() simply return a message (API)...
Yuya Nishihara -
r37481:bbd240f8 default
parent child Browse files
Show More
@@ -534,7 +534,7 b' class bzmysql(bzaccess):'
534 if ret:
534 if ret:
535 self.ui.warn(out)
535 self.ui.warn(out)
536 raise error.Abort(_('bugzilla notify command %s') %
536 raise error.Abort(_('bugzilla notify command %s') %
537 procutil.explainexit(ret)[0])
537 procutil.explainexit(ret))
538 self.ui.status(_('done\n'))
538 self.ui.status(_('done\n'))
539
539
540 def get_user_id(self, user):
540 def get_user_id(self, user):
@@ -440,7 +440,7 b' class commandline(object):'
440 if output:
440 if output:
441 self.ui.warn(_('%s error:\n') % self.command)
441 self.ui.warn(_('%s error:\n') % self.command)
442 self.ui.warn(output)
442 self.ui.warn(output)
443 msg = procutil.explainexit(status)[0]
443 msg = procutil.explainexit(status)
444 raise error.Abort('%s %s' % (self.command, msg))
444 raise error.Abort('%s %s' % (self.command, msg))
445
445
446 def run0(self, cmd, *args, **kwargs):
446 def run0(self, cmd, *args, **kwargs):
@@ -154,7 +154,7 b' def _exthook(ui, repo, htype, name, cmd,'
154 ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
154 ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
155 name, cmd, duration)
155 name, cmd, duration)
156 if r:
156 if r:
157 desc, r = procutil.explainexit(r)
157 desc = procutil.explainexit(r)
158 if throw:
158 if throw:
159 raise error.HookAbort(_('%s hook %s') % (name, desc))
159 raise error.HookAbort(_('%s hook %s') % (name, desc))
160 ui.warn(_('warning: %s hook %s\n') % (name, desc))
160 ui.warn(_('warning: %s hook %s\n') % (name, desc))
@@ -150,7 +150,7 b' def _sendmail(ui, sender, recipients, ms'
150 if ret:
150 if ret:
151 raise error.Abort('%s %s' % (
151 raise error.Abort('%s %s' % (
152 os.path.basename(program.split(None, 1)[0]),
152 os.path.basename(program.split(None, 1)[0]),
153 procutil.explainexit(ret)[0]))
153 procutil.explainexit(ret)))
154
154
155 def _mbox(mbox, sender, recipients, msg):
155 def _mbox(mbox, sender, recipients, msg):
156 '''write mails to mbox'''
156 '''write mails to mbox'''
@@ -2133,7 +2133,7 b' def _externalpatch(ui, repo, patcher, pa'
2133 code = fp.close()
2133 code = fp.close()
2134 if code:
2134 if code:
2135 raise PatchError(_("patch command failed: %s") %
2135 raise PatchError(_("patch command failed: %s") %
2136 procutil.explainexit(code)[0])
2136 procutil.explainexit(code))
2137 return fuzz
2137 return fuzz
2138
2138
2139 def patchbackend(ui, backend, patchobj, strip, prefix, files=None,
2139 def patchbackend(ui, backend, patchobj, strip, prefix, files=None,
@@ -1173,7 +1173,7 b' def extdatasource(repo, source):'
1173 src.close()
1173 src.close()
1174 if proc and proc.returncode != 0:
1174 if proc and proc.returncode != 0:
1175 raise error.Abort(_("extdata command '%s' failed: %s")
1175 raise error.Abort(_("extdata command '%s' failed: %s")
1176 % (cmd, procutil.explainexit(proc.returncode)[0]))
1176 % (cmd, procutil.explainexit(proc.returncode)))
1177
1177
1178 return data
1178 return data
1179
1179
@@ -1501,7 +1501,7 b' class ui(object):'
1501 rc = self._runsystem(cmd, environ=environ, cwd=cwd, out=out)
1501 rc = self._runsystem(cmd, environ=environ, cwd=cwd, out=out)
1502 if rc and onerr:
1502 if rc and onerr:
1503 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]),
1503 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]),
1504 procutil.explainexit(rc)[0])
1504 procutil.explainexit(rc))
1505 if errprefix:
1505 if errprefix:
1506 errmsg = '%s: %s' % (errprefix, errmsg)
1506 errmsg = '%s: %s' % (errprefix, errmsg)
1507 raise onerr(errmsg)
1507 raise onerr(errmsg)
@@ -79,11 +79,11 b' except AttributeError:'
79 closefds = pycompat.isposix
79 closefds = pycompat.isposix
80
80
81 def explainexit(code):
81 def explainexit(code):
82 """return a 2-tuple (desc, code) describing a subprocess status
82 """return a message describing a subprocess status
83 (codes from kill are negative - not os.system/wait encoding)"""
83 (codes from kill are negative - not os.system/wait encoding)"""
84 if code >= 0:
84 if code >= 0:
85 return _("exited with status %d") % code, code
85 return _("exited with status %d") % code
86 return _("killed by signal %d") % -code, code
86 return _("killed by signal %d") % -code
87
87
88 class _pfile(object):
88 class _pfile(object):
89 """File-like wrapper for a stream opened by subprocess.Popen()"""
89 """File-like wrapper for a stream opened by subprocess.Popen()"""
@@ -179,7 +179,7 b' def tempfilter(s, cmd):'
179 code = 0
179 code = 0
180 if code:
180 if code:
181 raise error.Abort(_("command '%s' failed: %s") %
181 raise error.Abort(_("command '%s' failed: %s") %
182 (cmd, explainexit(code)[0]))
182 (cmd, explainexit(code)))
183 with open(outname, 'rb') as fp:
183 with open(outname, 'rb') as fp:
184 return fp.read()
184 return fp.read()
185 finally:
185 finally:
General Comments 0
You need to be logged in to leave comments. Login now