Patchwork tests: do not use system hg if it does not have "files" command

login
register
mail settings
Submitter Jun Wu
Date June 28, 2017, 8:47 p.m.
Message ID <6aeb5921fb15ebfe5437.1498682821@x1c>
Download mbox | patch
Permalink /patch/21806/
State Accepted
Headers show

Comments

Jun Wu - June 28, 2017, 8:47 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1498682751 25200
#      Wed Jun 28 13:45:51 2017 -0700
# Node ID 6aeb5921fb15ebfe54375d3a2dfa973b32e33efc
# Parent  6ef5f0c95d643d114262f8c6689a6fc02adb0da7
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 6aeb5921fb15
tests: do not use system hg if it does not have "files" command

Ancient hg does not have "hg files" so test-check-*.t will fail with
"unknown command 'files'":

  $ hg files
  hg: unknown command 'files'
  $ hg --version
  Mercurial Distributed SCM (version 2.6.2)

Test "hg files" and give up using syshg if it does not have "files" command.
Augie Fackler - June 28, 2017, 9:45 p.m.
On Wed, Jun 28, 2017 at 01:47:01PM -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1498682751 25200
> #      Wed Jun 28 13:45:51 2017 -0700
> # Node ID 6aeb5921fb15ebfe54375d3a2dfa973b32e33efc
> # Parent  6ef5f0c95d643d114262f8c6689a6fc02adb0da7
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 6aeb5921fb15
> tests: do not use system hg if it does not have "files" command

queued, thanks

Patch

diff --git a/tests/helpers-testrepo.sh b/tests/helpers-testrepo.sh
--- a/tests/helpers-testrepo.sh
+++ b/tests/helpers-testrepo.sh
@@ -26,2 +26,15 @@  syshgenv () {
     export HGPLAIN
 }
+
+# Most test-check-* sourcing this file run "hg files", which is not available
+# in ancient versions of hg. So we double check if "syshg files" works and
+# fallback to hg bundled in the repo.
+syshg files -h >/dev/null 2>/dev/null
+if [ $? -ne 0 ]; then
+    syshg() {
+        hg "$@"
+    }
+    syshgenv() {
+        :
+    }
+fi