changeset 11708:ba65d61f3158

revset: add min function
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Fri, 30 Jul 2010 10:07:46 +0900
parents 5fdf08b6b50c
children a2d45964f60c
files mercurial/help/revsets.txt mercurial/revset.py tests/test-revset tests/test-revset.out
diffstat 4 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/revsets.txt	Thu Jul 29 17:18:17 2010 +0900
+++ b/mercurial/help/revsets.txt	Fri Jul 30 10:07:46 2010 +0900
@@ -100,6 +100,9 @@
 ``max(set)``
   Changeset with highest revision number in set.
 
+``min(set)``
+  Changeset with lowest revision number in set.
+
 ``merge()``
   Changeset is a merge changeset.
 
--- a/mercurial/revset.py	Thu Jul 29 17:18:17 2010 +0900
+++ b/mercurial/revset.py	Fri Jul 30 10:07:46 2010 +0900
@@ -195,6 +195,14 @@
             return [m]
     return []
 
+def minrev(repo, subset, x):
+    s = getset(repo, subset, x)
+    if s:
+        m = min(s)
+        if m in subset:
+            return [m]
+    return []
+
 def limit(repo, subset, x):
     l = getargs(x, 2, 2, _("limit wants two arguments"))
     try:
@@ -466,6 +474,7 @@
     "keyword": keyword,
     "limit": limit,
     "max": maxrev,
+    "min": minrev,
     "merge": merge,
     "modifies": modifies,
     "outgoing": outgoing,
--- a/tests/test-revset	Thu Jul 29 17:18:17 2010 +0900
+++ b/tests/test-revset	Fri Jul 30 10:07:46 2010 +0900
@@ -110,6 +110,7 @@
 log 'keyword(issue)'
 log 'limit(head(), 1)'
 log 'max(contains(a))'
+log 'min(contains(a))'
 log 'merge()'
 log 'modifies(b)'
 log 'p1(merge())'
--- a/tests/test-revset.out	Thu Jul 29 17:18:17 2010 +0900
+++ b/tests/test-revset.out	Fri Jul 30 10:07:46 2010 +0900
@@ -152,6 +152,8 @@
 0
 % log 'max(contains(a))'
 5
+% log 'min(contains(a))'
+0
 % log 'merge()'
 6
 % log 'modifies(b)'