[prev in list] [next in list] [prev in thread] [next in thread]
List: mercurial-devel
Subject: [PATCH 2 of 2 V3] revset: raise ValueError when calling min or max on empty smartset
From: pierre-yves.david () ens-lyon ! org
Date: 2014-03-31 18:39:09
Message-ID: 35a21b04c019e3993a66.1396291149 () marginatus ! alto ! octopoid ! net
[Download RAW message or body]
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1396051213 25200
# Fri Mar 28 17:00:13 2014 -0700
# Node ID 35a21b04c019e3993a6679b612cd28d108be92b1
# Parent c49f6dae96445ee65830f21dc76466d9384c659d
revset: raise ValueError when calling min or max on empty smartset
min([]) raise a ValueError, we do the same thing in smartset.min() and
smartset.max() for the sake of consistency.
The min/amax test are greatly improved in the process to prevent this familly
of regression
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2285,11 +2285,11 @@ class _orderedsetmixin(object):
def _first(self):
"""return the first revision in the set"""
for r in self:
return r
- return None
+ raise ValueError('arg is an empty sequence')
def _last(self):
"""return the last revision in the set"""
self.reverse()
m = self._first()
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,50 @@ 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
+
+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
+
+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
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@selenic.com
http://selenic.com/mailman/listinfo/mercurial-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic