Patchwork [6,of,7] procutil: make explainexit() simply return a message (API)

login
register
mail settings
Submitter Yuya Nishihara
Date April 7, 2018, 1:39 p.m.
Message ID <f3b7b60041c2e3663151.1523108382@mimosa>
Download mbox | patch
Permalink /patch/30547/
State Accepted
Headers show

Comments

Yuya Nishihara - April 7, 2018, 1:39 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1523103822 -32400
#      Sat Apr 07 21:23:42 2018 +0900
# Node ID f3b7b60041c2e3663151d5609645dda52d3fad9d
# Parent  f7f7e44d201d897123122c01b86580c19e46142b
procutil: make explainexit() simply return a message (API)

Almost all callers want it.

Patch

diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
--- a/hgext/bugzilla.py
+++ b/hgext/bugzilla.py
@@ -534,7 +534,7 @@  class bzmysql(bzaccess):
             if ret:
                 self.ui.warn(out)
                 raise error.Abort(_('bugzilla notify command %s') %
-                                  procutil.explainexit(ret)[0])
+                                  procutil.explainexit(ret))
         self.ui.status(_('done\n'))
 
     def get_user_id(self, user):
diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -440,7 +440,7 @@  class commandline(object):
             if output:
                 self.ui.warn(_('%s error:\n') % self.command)
                 self.ui.warn(output)
-            msg = procutil.explainexit(status)[0]
+            msg = procutil.explainexit(status)
             raise error.Abort('%s %s' % (self.command, msg))
 
     def run0(self, cmd, *args, **kwargs):
diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -154,7 +154,7 @@  def _exthook(ui, repo, htype, name, cmd,
     ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
            name, cmd, duration)
     if r:
-        desc, r = procutil.explainexit(r)
+        desc = procutil.explainexit(r)
         if throw:
             raise error.HookAbort(_('%s hook %s') % (name, desc))
         ui.warn(_('warning: %s hook %s\n') % (name, desc))
diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -150,7 +150,7 @@  def _sendmail(ui, sender, recipients, ms
     if ret:
         raise error.Abort('%s %s' % (
             os.path.basename(program.split(None, 1)[0]),
-            procutil.explainexit(ret)[0]))
+            procutil.explainexit(ret)))
 
 def _mbox(mbox, sender, recipients, msg):
     '''write mails to mbox'''
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2133,7 +2133,7 @@  def _externalpatch(ui, repo, patcher, pa
     code = fp.close()
     if code:
         raise PatchError(_("patch command failed: %s") %
-                         procutil.explainexit(code)[0])
+                         procutil.explainexit(code))
     return fuzz
 
 def patchbackend(ui, backend, patchobj, strip, prefix, files=None,
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1173,7 +1173,7 @@  def extdatasource(repo, source):
             src.close()
     if proc and proc.returncode != 0:
         raise error.Abort(_("extdata command '%s' failed: %s")
-                          % (cmd, procutil.explainexit(proc.returncode)[0]))
+                          % (cmd, procutil.explainexit(proc.returncode)))
 
     return data
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1501,7 +1501,7 @@  class ui(object):
             rc = self._runsystem(cmd, environ=environ, cwd=cwd, out=out)
         if rc and onerr:
             errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]),
-                                procutil.explainexit(rc)[0])
+                                procutil.explainexit(rc))
             if errprefix:
                 errmsg = '%s: %s' % (errprefix, errmsg)
             raise onerr(errmsg)
diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -79,11 +79,11 @@  except AttributeError:
 closefds = pycompat.isposix
 
 def explainexit(code):
-    """return a 2-tuple (desc, code) describing a subprocess status
+    """return a message describing a subprocess status
     (codes from kill are negative - not os.system/wait encoding)"""
     if code >= 0:
-        return _("exited with status %d") % code, code
-    return _("killed by signal %d") % -code, code
+        return _("exited with status %d") % code
+    return _("killed by signal %d") % -code
 
 class _pfile(object):
     """File-like wrapper for a stream opened by subprocess.Popen()"""
@@ -179,7 +179,7 @@  def tempfilter(s, cmd):
             code = 0
         if code:
             raise error.Abort(_("command '%s' failed: %s") %
-                              (cmd, explainexit(code)[0]))
+                              (cmd, explainexit(code)))
         with open(outname, 'rb') as fp:
             return fp.read()
     finally: