[PATCH V2] extdata: show debug message if external command exits with non-zero status
Yuya Nishihara
yuya at tcha.org
Wed Oct 4 14:12:47 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1506856910 -3600
# Sun Oct 01 12:21:50 2017 +0100
# Node ID 82606a8703b6f3b297fd0ed6d3e45e43ecd548de
# Parent b3a36705720f5ed1e7cc5129b27450ca59c7952b
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.
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1065,6 +1065,10 @@ def extdatasource(repo, source):
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()
diff --git a/tests/test-extdata.t b/tests/test-extdata.t
--- a/tests/test-extdata.t
+++ b/tests/test-extdata.t
@@ -12,6 +12,7 @@ test revset support
> 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 @@ test weight of extdata() revset
(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()"
More information about the Mercurial-devel
mailing list