tests/test-revset.t
branchstable
changeset 21160 564f55b25122
parent 21024 7731a2281cf0
child 21870 dd716807fd23
--- a/tests/test-revset.t	Tue Apr 15 03:21:59 2014 +0900
+++ b/tests/test-revset.t	Thu Apr 17 19:36:17 2014 -0400
@@ -124,6 +124,7 @@
   [255]
   $ log -a-b-c- # succeeds with fallback
   4
+
   $ try -- -a-b-c--a # complains
   (minus
     (minus
@@ -140,6 +141,13 @@
   ('symbol', '\xc3\xa9')
   9
 
+no quoting needed
+
+  $ log ::a-b-c-
+  0
+  1
+  2
+
 quoting needed
 
   $ try '"-a-b-c-"-a'
@@ -347,10 +355,46 @@
   $ 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()'
@@ -367,6 +411,22 @@
   4
   $ log 'id(5)'
   2
+  $ log 'only(9)'
+  8
+  9
+  $ log 'only(8)'
+  8
+  $ log 'only(9, 5)'
+  2
+  4
+  8
+  9
+  $ log 'only(7 + 9, 5 + 2)'
+  4
+  6
+  7
+  8
+  9
   $ log 'outgoing()'
   8
   9
@@ -434,6 +494,138 @@
   $ log 'tag(tip)'
   9
 
+test sort revset
+--------------------------------------------
+
+test when adding two unordered revsets
+
+  $ log 'sort(keyword(issue) or modifies(b))'
+  4
+  6
+
+test when sorting a reversed collection in the same way it is
+
+  $ log 'sort(reverse(all()), -rev)'
+  9
+  8
+  7
+  6
+  5
+  4
+  3
+  2
+  1
+  0
+
+test when sorting a reversed collection
+
+  $ log 'sort(reverse(all()), rev)'
+  0
+  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+
+
+test sorting two sorted collections in different orders
+
+  $ log 'sort(outgoing() or reverse(removes(a)), rev)'
+  2
+  6
+  8
+  9
+
+test sorting two sorted collections in different orders backwards
+
+  $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
+  9
+  8
+  6
+  2
+
+test subtracting something from an addset
+
+  $ log '(outgoing() or removes(a)) - removes(a)'
+  8
+  9
+
+test intersecting something with an addset
+
+  $ log 'parents(outgoing() or removes(a))'
+  1
+  4
+  5
+  8
+
+check that conversion to _missingancestors works
+  $ try --optimize '::3 - ::1'
+  (minus
+    (dagrangepre
+      ('symbol', '3'))
+    (dagrangepre
+      ('symbol', '1')))
+  * optimized:
+  (func
+    ('symbol', '_missingancestors')
+    (list
+      ('symbol', '3')
+      ('symbol', '1')))
+  3
+  $ try --optimize 'ancestors(1) - ancestors(3)'
+  (minus
+    (func
+      ('symbol', 'ancestors')
+      ('symbol', '1'))
+    (func
+      ('symbol', 'ancestors')
+      ('symbol', '3')))
+  * optimized:
+  (func
+    ('symbol', '_missingancestors')
+    (list
+      ('symbol', '1')
+      ('symbol', '3')))
+  $ try --optimize 'not ::2 and ::6'
+  (and
+    (not
+      (dagrangepre
+        ('symbol', '2')))
+    (dagrangepre
+      ('symbol', '6')))
+  * optimized:
+  (func
+    ('symbol', '_missingancestors')
+    (list
+      ('symbol', '6')
+      ('symbol', '2')))
+  3
+  4
+  5
+  6
+  $ try --optimize 'ancestors(6) and not ancestors(4)'
+  (and
+    (func
+      ('symbol', 'ancestors')
+      ('symbol', '6'))
+    (not
+      (func
+        ('symbol', 'ancestors')
+        ('symbol', '4'))))
+  * optimized:
+  (func
+    ('symbol', '_missingancestors')
+    (list
+      ('symbol', '6')
+      ('symbol', '4')))
+  3
+  5
+  6
+
 we can use patterns when searching for tags
 
   $ log 'tag("1..*")'
@@ -568,6 +760,53 @@
   hg: parse error: ^ expects a number 0, 1, or 2
   [255]
 
+multiple revspecs
+
+  $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
+  8
+  9
+  4
+  5
+  6
+  7
+
+test usage in revpair (with "+")
+
+(real pair)
+
+  $ hg diff -r 'tip^^' -r 'tip'
+  diff -r 2326846efdab -r 24286f4ae135 .hgtags
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hgtags	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
+  $ hg diff -r 'tip^^::tip'
+  diff -r 2326846efdab -r 24286f4ae135 .hgtags
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hgtags	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
+
+(single rev)
+
+  $ hg diff -r 'tip^' -r 'tip^'
+  $ hg diff -r 'tip^::tip^ or tip^'
+
+(single rev that does not looks like a range)
+
+  $ hg diff -r 'tip^ or tip^'
+  diff -r d5d0dcbdc4d9 .hgtags
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/.hgtags	* (glob)
+  @@ -0,0 +1,1 @@
+  +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
+
+(no rev)
+
+  $ hg diff -r 'author("babar") or author("celeste")'
+  abort: empty revision range
+  [255]
+
 aliases:
 
   $ echo '[revsetalias]' >> .hg/hgrc