revset: add min function
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Fri, 30 Jul 2010 10:07:46 +0900
changeset 11708 ba65d61f3158
parent 11706 5fdf08b6b50c
child 11711 a2d45964f60c
revset: add min function
mercurial/help/revsets.txt
mercurial/revset.py
tests/test-revset
tests/test-revset.out
--- 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)'