Mercurial > hg
changeset 44828:50416d3d4b65 stable
py3: change default priority and length used for sorting hooks to be compatible with python 3
The call to `sorted(hooks.values())` can on line 213 of hooks.py can raise when using
python 3. For instance, when hooks.values is `[(0, 2, b'post-commit.check-status', b''),
(None, None, b'changegroup.app-hooks', <object object at 0x7f5279885590>)]`, the error is
`TypeError: '<' not supported between instances of 'NoneType' and 'int'`
This fix keeps the same order that was used in python 2 without relying on comparison with
None.
Differential Revision: https://phab.mercurial-scm.org/D8527
author | Charles Chamberlain <cchamberlain@janestreet.com> |
---|---|
date | Thu, 14 May 2020 23:14:24 -0400 |
parents | f445a4f7e8a7 |
children | 017cc5ee537f |
files | mercurial/hook.py |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hook.py Mon May 18 08:31:32 2020 -0700 +++ b/mercurial/hook.py Thu May 14 23:14:24 2020 -0400 @@ -206,7 +206,7 @@ # in that section uses "_fromuntrusted" as its command. untrustedhooks = _hookitems(ui, _untrusted=True) for name, value in untrustedhooks.items(): - trustedvalue = hooks.get(name, (None, None, name, _fromuntrusted)) + trustedvalue = hooks.get(name, ((), (), name, _fromuntrusted)) if value != trustedvalue: (lp, lo, lk, lv) = trustedvalue hooks[name] = (lp, lo, lk, _fromuntrusted) @@ -222,7 +222,7 @@ continue priority = ui.configint(b'hooks', b'priority.%s' % name, 0) - hooks[name] = (-priority, len(hooks), name, cmd) + hooks[name] = ((-priority,), (len(hooks),), name, cmd) return hooks