Patchwork revset: add a `node` key for sorting

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 9, 2020, 7:11 a.m.
Message ID <187528344585900e0915.1602227469@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/47415/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 9, 2020, 7:11 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1602166446 -7200
#      Thu Oct 08 16:14:06 2020 +0200
# Node ID 187528344585900e0915965a14baf968f175fbbd
# Parent  66cb7ad3787ca10558ef747036e5417c4f352707
# EXP-Topic node-sorting
# Available At https://foss.heptapod.net/octobus/mercurial-devel/
#              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r 187528344585
revset: add a `node` key for sorting

Sorting by node give an arbitrary, but stable order which is useful for
sampling.
Yuya Nishihara - Oct. 9, 2020, 9:52 a.m.
On Fri, 09 Oct 2020 09:11:09 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1602166446 -7200
> #      Thu Oct 08 16:14:06 2020 +0200
> # Node ID 187528344585900e0915965a14baf968f175fbbd
> # Parent  66cb7ad3787ca10558ef747036e5417c4f352707
> # EXP-Topic node-sorting
> # Available At https://foss.heptapod.net/octobus/mercurial-devel/
> #              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r 187528344585
> revset: add a `node` key for sorting

Queued, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2293,6 +2293,7 @@  def roots(repo, subset, x):
     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(),
 }
 
 
@@ -2356,6 +2357,7 @@  def sort(repo, subset, x, order):
     - ``user`` for user name (``author`` can be used as an alias),
     - ``date`` for the commit date
     - ``topo`` for a reverse topographical sort
+    - ``node`` the nodeid of the revision
 
     The ``topo`` sort order cannot be combined with other sort keys. This sort
     takes one optional argument, ``topo.firstbranch``, which takes a revset that
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -2885,7 +2885,7 @@  test sorting by multiple keys including 
   3 b112 m111 u11  120 0
   0 b12  m111 u112 111 10800
 
-  $ hg log -r 'sort(all(), "-desc -date")'
+  $ hg log -r 'sort(all(), "-desc -node")'
   1 b11  m12  u111 112 7200
   4 b111 m112 u111 110 14400
   3 b112 m111 u11  120 0