# HG changeset patch
# User Yuya Nishihara
# Date 1506856910 -3600
# Sun Oct 01 12:21:50 2017 +0100
# Node ID 6ef72e8546b2c86b7ca4ba190fe1affcaa3a440c
# Parent b963750b125f6e342a0e2148535b7c7d0bc50e3b
extdata: abort if external command exits with non-zero status (BC)
Per the last discussion, this is more reliable and consistent way than
suppressing an error. For grep, erroring out might be inconvenient, but
for curl, non-zero exit status should be detected. The latter wouldn't be
possible if non-zero status is ignored.
https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-October/105727.html
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1100,12 +1100,11 @@ 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()
+if proc and proc.returncode != 0:
+raise error.Abort(_("extdata command '%s' failed: %s")
+ % (cmd, util.explainexit(proc.returncode)[0]))
return data
diff --git a/tests/test-extdata.t b/tests/test-extdata.t
--- a/tests/test-extdata.t
+++ b/tests/test-extdata.t
@@ -46,8 +46,8 @@ test weight of extdata() revset
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)
+ abort: extdata command 'cat extdata.txt | grep empty' failed: exited with
status 1
+ [255]
test bad extdata() revset source
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel