# HG changeset patch # User Valentin Gatien-Baron # Date 2020-05-14 14:24:52 # Node ID f189c5280d48853f09a5b04fd5fe8c3c0adbf505 # Parent edffab2cf0ead5140fdaa391c1c827ddc53dfe35 py3: fix exception in pull when several things happen to a bookmark Specifically, when `changes` is: [(b'@upstream-committed', None, , b'updating bookmark @upstream-committed\n'), (b'@upstream-committed', binary-node, , b'divergent bookmark @ stored as @upstream-committed\n')] sorting the list raises: TypeError: '<' not supported between instances of 'bytes' and 'NoneType' Differential Revision: https://phab.mercurial-scm.org/D8523 diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -754,7 +754,8 @@ def updatefromremote(ui, repo, remotemar if changed: tr = trfunc() changes = [] - for b, node, writer, msg in sorted(changed): + key = lambda t: (t[0], t[1] or b'') + for b, node, writer, msg in sorted(changed, key=key): changes.append((b, node)) writer(msg) localmarks.applychanges(repo, tr, changes)