[Request] [+ ] D8526: py3: change default priority and length used for sorting hooks to be compatible with python 3

charlesetc (Charles Chamberlain) phabricator at mercurial-scm.org
Fri May 15 03:18:58 UTC 2020


charlesetc created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/hook.py

CHANGE DETAILS

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -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
 
 



To: charlesetc, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200515/d77f5a18/attachment-0001.html>


More information about the Mercurial-patches mailing list