Patchwork [3,of,5] revset: always the `max` method of smartset in `max` revset

login
register
mail settings
Submitter Pierre-Yves David
Date March 21, 2014, 6:28 p.m.
Message ID <a2ee878b4dc367f62f94.1395426486@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4021/
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 1395426019 25200
#      Fri Mar 21 11:20:19 2014 -0700
# Node ID a2ee878b4dc367f62f9461761f3cd2ec33bd912c
# Parent  8ef733ec8279648ae80867ec085bd3bab9898629
revset: always the `max` method of smartset in `max` 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
@@ -1048,14 +1048,13 @@  def last(repo, subset, x):
 def maxrev(repo, subset, x):
     """``max(set)``
     Changeset with highest revision number in set.
     """
     os = getset(repo, spanset(repo), x)
-    if os:
-        m = os.max()
-        if m in subset:
-            return baseset([m])
+    m = os.max()
+    if m is not None and m in subset:
+        return baseset([m])
     return baseset([])
 
 def merge(repo, subset, x):
     """``merge()``
     Changeset is a merge changeset.
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -360,10 +360,24 @@  Testing min and max
 
 max: simple
 
   $ log 'max(contains(a))'
   5
+
+max: simple on unordered set)
+
+  $ log 'max((4+0+2+5+7) and contains(a))'
+  5
+
+max: no result
+
+  $ log 'max(contains(stringthatdoesnotappearanywhere))'
+
+max: no result on unordered set
+
+  $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
+
 min: simple
 
   $ log 'min(contains(a))'
   0