Mercurial > evolve
changeset 5323:6ea05c9744de stable
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 14 May 2020 22:19:58 +0800 |
parents | c2eea89b3f74 |
children | f3d6b43e8b82 |
files | hgext3rd/evolve/obshistory.py tests/test-evolve-obshistory-content-divergent.t |
diffstat | 2 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- 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 [ {