[PATCH 7 of 7] revset: add inspection data to max() and min() functions
Yuya Nishihara
yuya at tcha.org
Sat Feb 27 14:38:21 UTC 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1455626653 -32400
# Tue Feb 16 21:44:13 2016 +0900
# Node ID 717ebc96e95b19467bdae3cca68e9920aa1c7d26
# Parent ca5471aaa2a27b79e8a99406a66d661612505bc4
revset: add inspection data to max() and min() functions
We are likely to be interested in how these functions build a result set.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1354,12 +1354,12 @@ def maxrev(repo, subset, x):
try:
m = os.max()
if m in subset:
- return baseset([m])
+ return baseset([m], datarepr=('<max %r, %r>', subset, os))
except ValueError:
# os.max() throws a ValueError when the collection is empty.
# Same as python's max().
pass
- return baseset()
+ return baseset(datarepr=('<max %r, %r>', subset, os))
@predicate('merge()', safe=True)
def merge(repo, subset, x):
@@ -1399,12 +1399,12 @@ def minrev(repo, subset, x):
try:
m = os.min()
if m in subset:
- return baseset([m])
+ return baseset([m], datarepr=('<min %r, %r>', subset, os))
except ValueError:
# os.min() throws a ValueError when the collection is empty.
# Same as python's min().
pass
- return baseset()
+ return baseset(datarepr=('<min %r, %r>', subset, os))
@predicate('modifies(pattern)', safe=True)
def modifies(repo, subset, x):
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1727,7 +1727,10 @@ test nesting and variable passing
('symbol', '2')
('symbol', '5')))
* set:
- <baseset [5]>
+ <baseset
+ <max
+ <fullreposet+ 0:9>,
+ <spanset+ 2:5>>>
5
test chained `or` operations are flattened at parsing phase
@@ -2005,8 +2008,40 @@ issue2549 - correct optimizations
<not
<baseset [2]>>>
1
- $ log 'max(1 or 2) and not 2'
- $ log 'min(1 or 2) and not 1'
+ $ try 'max(1 or 2) and not 2'
+ (and
+ (func
+ ('symbol', 'max')
+ (or
+ ('symbol', '1')
+ ('symbol', '2')))
+ (not
+ ('symbol', '2')))
+ * set:
+ <filteredset
+ <baseset
+ <max
+ <fullreposet+ 0:9>,
+ <baseset [1, 2]>>>,
+ <not
+ <baseset [2]>>>
+ $ try 'min(1 or 2) and not 1'
+ (and
+ (func
+ ('symbol', 'min')
+ (or
+ ('symbol', '1')
+ ('symbol', '2')))
+ (not
+ ('symbol', '1')))
+ * set:
+ <filteredset
+ <baseset
+ <min
+ <fullreposet+ 0:9>,
+ <baseset [1, 2]>>>,
+ <not
+ <baseset [1]>>>
$ try 'last(1 or 2, 1) and not 2'
(and
(func
More information about the Mercurial-devel
mailing list