diff mercurial/utils/procutil.py @ 37460:a6c6b7beb025

procutil: unify platform.explainexit() Since 4368f582c806 "use subprocess instead of os.system", posix.explainexit() is the superset of Windows implementation.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 07 Apr 2018 21:14:16 +0900
parents 90c5ca718781
children 538353b80676
line wrap: on
line diff
--- a/mercurial/utils/procutil.py	Sat Apr 07 21:09:21 2018 +0900
+++ b/mercurial/utils/procutil.py	Sat Apr 07 21:14:16 2018 +0900
@@ -52,7 +52,6 @@
 else:
     from .. import posix as platform
 
-explainexit = platform.explainexit
 findexe = platform.findexe
 _gethgcmd = platform.gethgcmd
 getuser = platform.getuser
@@ -79,6 +78,13 @@
 
 closefds = pycompat.isposix
 
+def explainexit(code):
+    """return a 2-tuple (desc, code) 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
+
 class _pfile(object):
     """File-like wrapper for a stream opened by subprocess.Popen()"""