# HG changeset patch # User Charles Chamberlain # Date 1589512464 14400 # Node ID 50416d3d4b651d93e74e892587ad40107462569f # Parent f445a4f7e8a7ace1c75bdd6c9d107e9c24a4d350 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', )]`, 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 diff -r f445a4f7e8a7 -r 50416d3d4b65 mercurial/hook.py --- 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