hook: disable the shell to native command translation by default
There are other things I want to add like ~ expansion and translating single to
double quotes for cmd.exe. So off by default is safer.
I'm having second thoughts about the name, but I don't have any better ideas.
--- a/mercurial/help/config.txt Mon Jul 16 17:47:58 2018 -0700
+++ b/mercurial/help/config.txt Sun Jul 15 23:46:09 2018 -0400
@@ -891,16 +891,17 @@
.. container:: windows
- Some basic Unix syntax is supported for portability, including ``$VAR``
+ Some basic Unix syntax can be enabled for portability, including ``$VAR``
and ``${VAR}`` style variables. To use a literal ``$``, it must be
- escaped with a back slash or inside of a strong quote. This can be
- disabled by adding a prefix of ``tonative.`` to the hook name on a new
- line, and setting it to ``False``. For example::
+ escaped with a back slash or inside of a strong quote.
+
+ This feature is enabled by adding a prefix of ``tonative.`` to the hook
+ name on a new line, and setting it to ``True``. For example::
[hooks]
incoming.autobuild = /my/build/hook
- # disable translation to cmd.exe syntax for autobuild hook
- tonative.incoming.autobuild = False
+ # enable translation to cmd.exe syntax for autobuild hook
+ tonative.incoming.autobuild = True
``changegroup``
Run after a changegroup has been added via push, pull or unbundle. The ID of
--- a/mercurial/hook.py Mon Jul 16 17:47:58 2018 -0700
+++ b/mercurial/hook.py Sun Jul 15 23:46:09 2018 -0400
@@ -139,7 +139,7 @@
v = stringutil.pprint(v)
env['HG_' + k.upper()] = v
- if ui.configbool('hooks', 'tonative.%s' % name, pycompat.iswindows):
+ if ui.configbool('hooks', 'tonative.%s' % name, False):
ui.note(_('converting hook "%s" to native\n') % name)
cmd = procutil.shelltonative(cmd, env)
--- a/tests/test-bookmarks-pushpull.t Mon Jul 16 17:47:58 2018 -0700
+++ b/tests/test-bookmarks-pushpull.t Sun Jul 15 23:46:09 2018 -0400
@@ -194,7 +194,6 @@
bundle2-input: part header size: 0
bundle2-input: end of bundle2 stream
bundle2-input-bundle: 3 parts total
- converting hook "txnclose-bookmark.test" to native (windows !)
running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
bundle2-output-bundle: "HG20", 1 parts total
@@ -309,7 +308,6 @@
bundle2-input: part header size: 0
bundle2-input: end of bundle2 stream
bundle2-input-bundle: 3 parts total
- converting hook "txnclose-bookmark.test" to native (windows !)
running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
bundle2-output-bundle: "HG20", 0 parts total
--- a/tests/test-commit-amend.t Mon Jul 16 17:47:58 2018 -0700
+++ b/tests/test-commit-amend.t Sun Jul 15 23:46:09 2018 -0400
@@ -205,7 +205,6 @@
a
committing manifest
committing changelog
- converting hook "pretxncommit.test-saving-last-message" to native (windows !)
running hook pretxncommit.test-saving-last-message: false
transaction abort!
rollback completed
@@ -231,7 +230,6 @@
a
committing manifest
committing changelog
- converting hook "pretxncommit.test-saving-last-message" to native (windows !)
running hook pretxncommit.test-saving-last-message: false
transaction abort!
rollback completed
--- a/tests/test-histedit-fold.t Mon Jul 16 17:47:58 2018 -0700
+++ b/tests/test-histedit-fold.t Sun Jul 15 23:46:09 2018 -0400
@@ -478,7 +478,8 @@
1:199b6bb90248 b
0:6c795aa153cb a
- $ hg histedit 6c795aa153cb --config hooks.commit='echo commit $HG_NODE' --commands - 2>&1 << EOF | fixbundle
+ $ hg histedit 6c795aa153cb --config hooks.commit='echo commit $HG_NODE' --config hooks.tonative.commit=True \
+ > --commands - 2>&1 << EOF | fixbundle
> pick 199b6bb90248 b
> fold a1a953ffb4b0 c
> pick 6c795aa153cb a
@@ -494,8 +495,8 @@
$ cat > $TESTTMP/tmp.hgrc <<'EOF'
> [hooks]
> pre-add = echo no variables
- > tonative.pre-add = False
> post-add = echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT
+ > tonative.post-add = True
> EOF
TODO: Windows should output double quotes around "also $non-var"
--- a/tests/test-keyword.t Mon Jul 16 17:47:58 2018 -0700
+++ b/tests/test-keyword.t Sun Jul 15 23:46:09 2018 -0400
@@ -183,7 +183,6 @@
overwriting a expanding keywords
updating the branch cache
committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
- converting hook "commit.test" to native (windows !)
running hook commit.test: cp a hooktest
$ hg status
? hooktest
--- a/tests/test-push-http.t Mon Jul 16 17:47:58 2018 -0700
+++ b/tests/test-push-http.t Sun Jul 15 23:46:09 2018 -0400
@@ -90,13 +90,10 @@
remote: adding a revisions
remote: added 1 changesets with 1 changes to 1 files
remote: updating the branch cache
- remote: converting hook "txnclose-phase.test" to native (windows !)
remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
- remote: converting hook "txnclose-phase.test" to native (windows !)
remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
- remote: converting hook "changegroup" to native (windows !)
remote: running hook changegroup: sh -c "printenv.py changegroup 0"
remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
% serve errors
@@ -113,13 +110,10 @@
remote: adding a revisions
remote: added 1 changesets with 1 changes to 1 files
remote: updating the branch cache
- remote: converting hook "txnclose-phase.test" to native (windows !)
remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
- remote: converting hook "txnclose-phase.test" to native (windows !)
remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
- remote: converting hook "changegroup" to native (windows !)
remote: running hook changegroup: sh -c "printenv.py changegroup 0"
remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
% serve errors
--- a/tests/test-rebase-interruptions.t Mon Jul 16 17:47:58 2018 -0700
+++ b/tests/test-rebase-interruptions.t Sun Jul 15 23:46:09 2018 -0400
@@ -333,7 +333,8 @@
$ cp -R a3 hook-pretxncommit
$ cd hook-pretxncommit
- $ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.pretxncommit=hg log -r $HG_NODE | grep "summary: C"'
+ $ hg rebase --source 2 --dest 5 --tool internal:other \
+ > --config 'hooks.tonative.pretxncommit=True' --config 'hooks.pretxncommit=hg log -r $HG_NODE | grep "summary: C"'
rebasing 2:965c486023db "C"
summary: C
rebasing 6:a0b2430ebfb8 "F" (tip)