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
--- 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