procutil: fix error message of tempfile filter
authorYuya Nishihara <yuya@tcha.org>
Sat, 07 Apr 2018 21:17:50 +0900
changeset 37461 538353b80676
parent 37460 a6c6b7beb025
child 37462 c0d0fd87ba7c
procutil: fix error message of tempfile filter First, we need to use procutil.system() to get an exit code compatible with explainexit(). Second, explainexit() returns (msg, code) tuple.
mercurial/utils/procutil.py
tests/test-encode.t
--- a/mercurial/utils/procutil.py	Sat Apr 07 21:14:16 2018 +0900
+++ b/mercurial/utils/procutil.py	Sat Apr 07 21:17:50 2018 +0900
@@ -174,12 +174,12 @@
         os.close(outfd)
         cmd = cmd.replace('INFILE', inname)
         cmd = cmd.replace('OUTFILE', outname)
-        code = os.system(cmd)
+        code = system(cmd)
         if pycompat.sysplatform == 'OpenVMS' and code & 1:
             code = 0
         if code:
             raise error.Abort(_("command '%s' failed: %s") %
-                              (cmd, explainexit(code)))
+                              (cmd, explainexit(code)[0]))
         with open(outname, 'rb') as fp:
             return fp.read()
     finally:
--- a/tests/test-encode.t	Sat Apr 07 21:14:16 2018 +0900
+++ b/tests/test-encode.t	Sat Apr 07 21:17:50 2018 +0900
@@ -59,5 +59,14 @@
   this is a test
   $ hg -R .. cat --decode ../a.gz | gunzip
   this is a test
+  $ cd ..
+
+check tempfile filter
+
+  $ hg cat a.gz --decode --config 'decode.*.gz=tempfile:gzip -c INFILE > OUTFILE' | gunzip
+  this is a test
+  $ hg cat a.gz --decode --config 'decode.*.gz=tempfile:sh -c "exit 1"'
+  abort: command '*' failed: exited with status 1 (glob)
+  [255]
 
   $ cd ..