changeset 46368:86b019899737 stable

hooks: forbid ':' in hook name The `:` character is a special separator in the config and it seems same do to the same for hooks. This is necessary to improve the experience around the HGPLAIN behavior change in 5.7. See next changesets for details. Differential Revision: https://phab.mercurial-scm.org/D9978
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 10 Feb 2021 21:05:05 +0100
parents fb6eca7b8c63
children 0760282995cf
files mercurial/configitems.py mercurial/hook.py
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Wed Feb 10 21:46:29 2021 +0100
+++ b/mercurial/configitems.py	Wed Feb 10 21:05:05 2021 +0100
@@ -1310,7 +1310,7 @@
 )
 coreconfigitem(
     b'hooks',
-    b'.*',
+    b'[^:]*',
     default=dynamicdefault,
     generic=True,
 )
--- a/mercurial/hook.py	Wed Feb 10 21:46:29 2021 +0100
+++ b/mercurial/hook.py	Wed Feb 10 21:05:05 2021 +0100
@@ -224,7 +224,11 @@
     """return all hooks items ready to be sorted"""
     hooks = {}
     for name, cmd in ui.configitems(b'hooks', untrusted=_untrusted):
-        if name.startswith(b'priority.') or name.startswith(b'tonative.'):
+        if (
+            name.startswith(b'priority.')
+            or name.startswith(b'tonative.')
+            or b':' in name
+        ):
             continue
 
         priority = ui.configint(b'hooks', b'priority.%s' % name, 0)