# HG changeset patch # User Pierre-Yves David # Date 1612994634 -3600 # Node ID b910be772eb9bc0b62bd3bc421a2084d3ac72c9f # Parent 7289eac777eca454dbc08f2c0cbe1b368b1b2ae1 hooks: add a `auto` value for `hooks.*run-with-plain` That setting restore the behavior pre-5.6. The current HGPLAIN value is simply passed to the hooks. This allow user who needs it to fully mitigate the behavior change introduced in Mercurial 5.7 by restoring the older behavior. Differential Revision: https://phab.mercurial-scm.org/D9982 diff -r 7289eac777ec -r b910be772eb9 mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt Wed Feb 10 23:21:21 2021 +0100 +++ b/mercurial/helptext/config.txt Wed Feb 10 23:03:54 2021 +0100 @@ -1032,6 +1032,8 @@ incoming.autobuild:run-with-plain = yes # HGPLAIN never set incoming.autobuild:run-with-plain = no + # HGPLAIN inherited from environment (default before Mercurila 5.7) + incoming.autobuild:run-with-plain = auto Most hooks are run with environment variables set that give useful additional information. For each hook below, the environment variables diff -r 7289eac777ec -r b910be772eb9 mercurial/hook.py --- a/mercurial/hook.py Wed Feb 10 23:21:21 2021 +0100 +++ b/mercurial/hook.py Wed Feb 10 23:03:54 2021 +0100 @@ -158,7 +158,10 @@ env[b'HG_HOOKTYPE'] = htype env[b'HG_HOOKNAME'] = name - plain = ui.configbool(b'hooks', b'%s:run-with-plain' % name) + if ui.config(b'hooks', b'%s:run-with-plain' % name) == b'auto': + plain = ui.plain() + else: + plain = ui.configbool(b'hooks', b'%s:run-with-plain' % name) if plain: env[b'HGPLAIN'] = b'1' else: diff -r 7289eac777ec -r b910be772eb9 tests/test-hook.t --- a/tests/test-hook.t Wed Feb 10 23:21:21 2021 +0100 +++ b/tests/test-hook.t Wed Feb 10 23:03:54 2021 +0100 @@ -1412,16 +1412,20 @@ > pre-version.testing-yes:run-with-plain=yes > pre-version.testing-no=echo '### no ########' plain: \${HGPLAIN:-''} > pre-version.testing-no:run-with-plain=no + > pre-version.testing-auto=echo '### auto ######' plain: \${HGPLAIN:-''} + > pre-version.testing-auto:run-with-plain=auto > EOF $ (unset HGPLAIN; hg version --quiet) ### default ### plain: 1 ### yes ####### plain: 1 ### no ######## plain: + ### auto ###### plain: Mercurial Distributed SCM (*) (glob) $ HGPLAIN=1 hg version --quiet ### default ### plain: 1 ### yes ####### plain: 1 ### no ######## plain: + ### auto ###### plain: 1 Mercurial Distributed SCM (*) (glob)