Mercurial > hg
changeset 28427:969a4615c4c4
revset: add inspection data to max() and min() functions
We are likely to be interested in how these functions build a result set.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 16 Feb 2016 21:44:13 +0900 |
parents | 3d39ac06af9a |
children | 6a4a4ca21907 |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 42 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Tue Feb 16 21:43:51 2016 +0900 +++ b/mercurial/revset.py Tue Feb 16 21:44:13 2016 +0900 @@ -1325,12 +1325,12 @@ 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): @@ -1370,12 +1370,12 @@ 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):
--- a/tests/test-revset.t Tue Feb 16 21:43:51 2016 +0900 +++ b/tests/test-revset.t Tue Feb 16 21:44:13 2016 +0900 @@ -1727,7 +1727,10 @@ ('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 @@ <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