# HG changeset patch # User Anton Shestakov # Date 1589465998 -28800 # Node ID 6ea05c9744de2dd098c3fb68d49857d72590b884 # Parent c2eea89b3f74ca7e1f26d6abcfaaae9f63682c8e obslog: make obslog --no-origin -f work with multiple successor sets When trying to sort multiple successor sets, this block of code used to fail with: - TypeError: '<' not supported between instances of 'dict' and 'dict' (on py3) - TypeError: cannot compare sets using cmp() (on py2) So for sorted() to work properly, we need to remove dicts and sets from the data. diff -r c2eea89b3f74 -r 6ea05c9744de hgext3rd/evolve/obshistory.py --- a/hgext3rd/evolve/obshistory.py Sat May 09 22:19:09 2020 +0800 +++ b/hgext3rd/evolve/obshistory.py Thu May 14 22:19:58 2020 +0800 @@ -219,9 +219,14 @@ r = obsutil.successorsandmarkers(repo, ctx) if r is None: r = [] - for succset in sorted(r): - if succset[b'markers']: - yield (succset[b'successors'], succset[b'markers']) + # replacing dicts and sets, they can't be compared + data = [ + (succset[b'successors'], tuple(sorted(succset[b'markers']))) + for succset in r + ] + for (nodes, markers) in sorted(data): + if markers: + yield (nodes, markers) else: markers = successors.get(ctx.node(), ()) for marker in sorted(markers): diff -r c2eea89b3f74 -r 6ea05c9744de tests/test-evolve-obshistory-content-divergent.t --- a/tests/test-evolve-obshistory-content-divergent.t Sat May 09 22:19:09 2020 +0800 +++ b/tests/test-evolve-obshistory-content-divergent.t Thu May 14 22:19:58 2020 +0800 @@ -98,6 +98,11 @@ +A1 + $ hg obslog --hidden 'desc(A0)' --no-origin -f + x 471f378eab4c (1) A0 + reworded(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) + reworded(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) + Check that with all option, every changeset is shown $ hg obslog --hidden --all 471f378eab4c --patch @@ -123,6 +128,15 @@ | x 471f378eab4c (1) A0 + $ hg obslog --hidden --all 'desc(A0)' --no-origin -f + @ 65b757b745b9 (3) A2 + | + | * fdf9bde5129a (2) A1 + |/ + x 471f378eab4c (1) A0 + reworded(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) + reworded(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) + $ hg obslog --hidden 471f378eab4c --no-graph --no-origin -Tjson | python -m json.tool [ {