Patchwork D8523: py3: fix exception in pull when several things happen to a bookmark

login
register
mail settings
Submitter phabricator
Date May 14, 2020, 3 p.m.
Message ID <differential-rev-PHID-DREV-q2gty7rf4bwfpagxf4iw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46310/
State Superseded
Headers show

Comments

phabricator - May 14, 2020, 3 p.m.
valentin.gatienbaron created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Specifically, when `changes` is:
  
    [(b'@upstream-committed', None, <function ui.status>, b'updating bookmark @upstream-committed\n'),
     (b'@upstream-committed', binary-node, <function ui.warn>, b'divergent bookmark @ stored as @upstream-committed\n')]
  
  sorting the list raises:
  
    TypeError: '<' not supported between instances of 'bytes' and 'NoneType'

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bookmarks.py

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -754,7 +754,8 @@ 
     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)