Patchwork [2,of,5] revset: always the `min` method of smartset in `min` revset

login
register
mail settings
Submitter Pierre-Yves David
Date March 21, 2014, 6:28 p.m.
Message ID <8ef733ec8279648ae808.1395426485@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4018/
State Accepted
Headers show

Comments

Pierre-Yves David - March 21, 2014, 6:28 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1395425975 25200
#      Fri Mar 21 11:19:35 2014 -0700
# Node ID 8ef733ec8279648ae80867ec085bd3bab9898629
# Parent  ad232d545933fc511feaeceb85ba43c4cb1d5415
revset: always the `min` method of smartset in `min` revset

This is a bit simpler and make is easier to test that smart set have the proper
method defined.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1085,14 +1085,13 @@  def branchpoint(repo, subset, x):
 def minrev(repo, subset, x):
     """``min(set)``
     Changeset with lowest revision number in set.
     """
     os = getset(repo, spanset(repo), x)
-    if os:
-        m = os.min()
-        if m in subset:
-            return baseset([m])
+    m = os.min()
+    if m is not None and m in subset:
+        return baseset([m])
     return baseset([])
 
 def _missingancestors(repo, subset, x):
     # i18n: "_missingancestors" is a keyword
     revs, bases = getargs(x, 2, 2,
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -353,14 +353,36 @@  ancestor can accept 0 or more arguments
   $ log 'matching(6)'
   6
   $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
   6
   7
+
+Testing min and max
+
+max: simple
+
   $ log 'max(contains(a))'
   5
+min: simple
+
   $ log 'min(contains(a))'
   0
+
+min: simple on unordered set
+
+  $ log 'min((4+0+2+5+7) and contains(a))'
+  0
+
+min: empty
+
+  $ log 'min(contains(stringthatdoesnotappearanywhere))'
+
+min: empty on unordered set
+
+  $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
+
+
   $ log 'merge()'
   6
   $ log 'branchpoint()'
   1
   4