changeset 28426:3d39ac06af9a

revset: add inspection data to limit() and last() functions We are likely to be interested in how these functions calculate a result set.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 16 Feb 2016 21:43:51 +0900
parents 02d7faaf455c
children 969a4615c4c4
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 42 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Tue Feb 16 21:32:00 2016 +0900
+++ b/mercurial/revset.py	Tue Feb 16 21:43:51 2016 +0900
@@ -1288,7 +1288,8 @@
             break
         elif y in subset:
             result.append(y)
-    return baseset(result)
+    return baseset(result, datarepr=('<limit n=%d, offset=%d, %r, %r>',
+                                     lim, ofs, subset, os))
 
 @predicate('last(set, [n])', safe=True)
 def last(repo, subset, x):
@@ -1314,7 +1315,7 @@
             break
         elif y in subset:
             result.append(y)
-    return baseset(result)
+    return baseset(result, datarepr=('<last n=%d, %r, %r>', lim, subset, os))
 
 @predicate('max(set)', safe=True)
 def maxrev(repo, subset, x):
--- a/tests/test-revset.t	Tue Feb 16 21:32:00 2016 +0900
+++ b/tests/test-revset.t	Tue Feb 16 21:43:51 2016 +0900
@@ -1984,11 +1984,48 @@
 
 issue2549 - correct optimizations
 
-  $ log 'limit(1 or 2 or 3, 2) and not 2'
+  $ try 'limit(1 or 2 or 3, 2) and not 2'
+  (and
+    (func
+      ('symbol', 'limit')
+      (list
+        (or
+          ('symbol', '1')
+          ('symbol', '2')
+          ('symbol', '3'))
+        ('symbol', '2')))
+    (not
+      ('symbol', '2')))
+  * set:
+  <filteredset
+    <baseset
+      <limit n=2, offset=0,
+        <fullreposet+ 0:9>,
+        <baseset [1, 2, 3]>>>,
+    <not
+      <baseset [2]>>>
   1
   $ log 'max(1 or 2) and not 2'
   $ log 'min(1 or 2) and not 1'
-  $ log 'last(1 or 2, 1) and not 2'
+  $ try 'last(1 or 2, 1) and not 2'
+  (and
+    (func
+      ('symbol', 'last')
+      (list
+        (or
+          ('symbol', '1')
+          ('symbol', '2'))
+        ('symbol', '1')))
+    (not
+      ('symbol', '2')))
+  * set:
+  <filteredset
+    <baseset
+      <last n=1,
+        <fullreposet+ 0:9>,
+        <baseset [2, 1]>>>,
+    <not
+      <baseset [2]>>>
 
 issue4289 - ordering of built-ins
   $ hg log -M -q -r 3:2