extdata: show debug message if external command exits with non-zero status
authorYuya Nishihara <yuya@tcha.org>
Sun, 01 Oct 2017 12:21:50 +0100
changeset 34542 153e4e05e9b3
parent 34541 0a0a72c043ac
child 34543 6fad8059a970
extdata: show debug message if external command exits with non-zero status This isn't fatal because it's quite common for grep to exit with 1. Thanks to Foozy for spotting this.
mercurial/scmutil.py
tests/test-extdata.t
--- a/mercurial/scmutil.py	Sat Sep 30 08:57:50 2017 +0100
+++ b/mercurial/scmutil.py	Sun Oct 01 12:21:50 2017 +0100
@@ -1065,6 +1065,10 @@
     finally:
         if proc:
             proc.communicate()
+            if proc.returncode != 0:
+                # not an error so 'cmd | grep' can be empty
+                repo.ui.debug("extdata command '%s' %s\n"
+                              % (cmd, util.explainexit(proc.returncode)[0]))
         if src:
             src.close()
 
--- a/tests/test-extdata.t	Sat Sep 30 08:57:50 2017 +0100
+++ b/tests/test-extdata.t	Sun Oct 01 12:21:50 2017 +0100
@@ -12,6 +12,7 @@
   > filedata = file:extdata.txt
   > notes = notes.txt
   > shelldata = shell:cat extdata.txt | grep 2
+  > emptygrep = shell:cat extdata.txt | grep empty
   > EOF
   $ cat <<'EOF' > extdata.txt
   > 2 another comment on 2
@@ -42,6 +43,12 @@
     (symbol '3'))
   3
 
+test non-zero exit of shell command
+
+  $ hg log -qr "extdata(emptygrep)"
+  $ hg log -qr "extdata(emptygrep)" --debug
+  extdata command 'cat extdata.txt | grep empty' exited with status * (glob)
+
 test bad extdata() revset source
 
   $ hg log -qr "extdata()"