# HG changeset patch # User Yuya Nishihara # Date 2020-10-09 10:19:10 # Node ID b90d7e7f39dbdff7f38fee80b45450efed409ea8 # Parent c694b1841a5ee60acf2d473b5ed0fc67cc33ef8d revset: fix sorting key of wdir revision It would go wrong on Python 2, and would crash on Python 3. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2287,13 +2287,13 @@ def roots(repo, subset, x): _sortkeyfuncs = { - b'rev': lambda c: c.rev(), + b'rev': scmutil.intrev, b'branch': lambda c: c.branch(), b'desc': lambda c: c.description(), b'user': lambda c: c.user(), b'author': lambda c: c.user(), b'date': lambda c: c.date()[0], - b'node': lambda c: c.node(), + b'node': scmutil.binnode, } diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -2899,6 +2899,29 @@ test sorting by multiple keys including 0 b12 m111 u112 111 10800 2 b111 m11 u12 111 3600 + sort including wdir (rev/-rev has fast path): + + $ hg log -r 'sort(. + wdir(), rev)' -T '{rev}\n' + 4 + 2147483647 + $ hg log -r 'sort(. + wdir(), -rev)' -T '{rev}\n' + 2147483647 + 4 + + $ hg log -r 'sort(. + wdir(), "branch rev")' -T '{rev}\n' + 4 + 2147483647 + $ hg log -r 'sort(. + wdir(), "branch -rev")' -T '{rev}\n' + 2147483647 + 4 + + $ hg log -r 'sort(. + wdir(), node)' -T '{node}\n' + ec7c1c90b589ade8603d5fb619dc6c25173a723f + ffffffffffffffffffffffffffffffffffffffff + $ hg log -r 'sort(. + wdir(), -node)' -T '{node}\n' + ffffffffffffffffffffffffffffffffffffffff + ec7c1c90b589ade8603d5fb619dc6c25173a723f + toposort prioritises graph branches $ hg up 2