diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1338,6 +1338,12 @@ generic=True, ) coreconfigitem( + b'hooks', + b'.*:run-with-plain', + default=True, + generic=True, +) +coreconfigitem( b'hgweb-paths', b'.*', default=list, diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -1027,6 +1027,11 @@ incoming.autobuild = /my/build/hook # force autobuild hook to run before other incoming hooks priority.incoming.autobuild = 1 + ### control HGPLAIN setting when running autobuild hook + # HGPLAIN always set (default from Mercurial 5.7) + incoming.autobuild:run-with-plain = yes + # HGPLAIN never set + incoming.autobuild:run-with-plain = no Most hooks are run with environment variables set that give useful additional information. For each hook below, the environment variables diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -157,7 +157,12 @@ env[b'HG_PENDING'] = repo.root env[b'HG_HOOKTYPE'] = htype env[b'HG_HOOKNAME'] = name - env[b'HGPLAIN'] = b'1' + + plain = ui.configbool(b'hooks', b'%s:run-with-plain' % name) + if plain: + env[b'HGPLAIN'] = b'1' + else: + env[b'HGPLAIN'] = b'' for k, v in pycompat.iteritems(args): # transaction changes can accumulate MBs of data, so skip it diff --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -1407,13 +1407,21 @@ $ cat << EOF >> .hg/hgrc > [hooks] - > pre-version.testing-default=echo '### default ###' plain: \$HGPLAIN + > pre-version.testing-default=echo '### default ###' plain: \${HGPLAIN:-''} + > pre-version.testing-yes=echo '### yes #######' plain: \${HGPLAIN:-''} + > pre-version.testing-yes:run-with-plain=yes + > pre-version.testing-no=echo '### no ########' plain: \${HGPLAIN:-''} + > pre-version.testing-no:run-with-plain=no > EOF $ (unset HGPLAIN; hg version --quiet) ### default ### plain: 1 + ### yes ####### plain: 1 + ### no ######## plain: Mercurial Distributed SCM (*) (glob) $ HGPLAIN=1 hg version --quiet ### default ### plain: 1 + ### yes ####### plain: 1 + ### no ######## plain: Mercurial Distributed SCM (*) (glob)