Patchwork D9978: hooks: forbid ':' in hook name

login
register
mail settings
Submitter phabricator
Date Feb. 10, 2021, 11:47 p.m.
Message ID <differential-rev-PHID-DREV-44ijot7rrjjoh2tioi23-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48293/
State Superseded
Headers show

Comments

phabricator - Feb. 10, 2021, 11:47 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D9978

AFFECTED FILES
  mercurial/configitems.py
  mercurial/hook.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -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)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1310,7 +1310,7 @@ 
 )
 coreconfigitem(
     b'hooks',
-    b'.*',
+    b'[^:]*',
     default=dynamicdefault,
     generic=True,
 )