diff tests/test-topic.t @ 4322:41f38bf15b4c

topic: make revsets like 'foo#stack[0]' work 'stack' relation subscript function is another way to refer to s0, s1, etc. But instead of aborting in many cases it will simply return an empty set.
author Anton Shestakov <av6@dwimlabs.net>
date Sun, 16 Dec 2018 11:22:04 +0800
parents 78700a59192a
children 482992803db6
line wrap: on
line diff
--- a/tests/test-topic.t	Sat Dec 22 01:29:59 2018 -0500
+++ b/tests/test-topic.t	Sun Dec 16 11:22:04 2018 +0800
@@ -823,6 +823,86 @@
 
   $ cd ..
 
+Stack relation subscript in revsets
+===================================
+
+  $ hg init more-than-one-commit-per-topic
+  $ cd more-than-one-commit-per-topic
+  $ cat > .hg/hgrc << EOF
+  > [phases]
+  > publish=false
+  > EOF
+
+  $ echo 0 > foo
+  $ hg ci -qAm 0
+  $ hg topic featureA
+  marked working directory as topic: featureA
+  $ echo 1 > foo
+  $ hg ci -qm 1
+  $ echo 2 > foo
+  $ hg ci -qm 2
+  $ echo 3 > foo
+  $ hg ci -qm 3
+  $ hg topic --clear
+  $ echo 4 > foo
+  $ hg ci -qm 4
+
+  $ tlog 'all()'
+  0: 
+  1: featureA
+  2: featureA
+  3: featureA
+  4: 
+
+  $ hg stack
+  ### target: default (branch)
+  s2@ 4 (current)
+    ^ 3
+  s1: 0
+
+  $ tlog 'tip#stack[0]'
+  $ tlog 'tip#stack[1]'
+  0: 
+  $ tlog 'tip#stack[2]'
+  4: 
+
+  $ hg stack featureA
+  ### topic: featureA
+  ### target: default (branch), 3 behind
+  s3: 3
+  s2: 2
+  s1: 1
+  s0^ 0 (base)
+
+  $ tlog 'featureA#s[0]'
+  0: 
+  $ tlog 'featureA#s[1]'
+  1: featureA
+  $ tlog 'featureA#s[2]'
+  2: featureA
+  $ tlog 'featureA#s[3]'
+  3: featureA
+
+  $ tlog 'all()#s[-1]'
+  $ tlog 'all()#s[0]'
+  0: 
+  $ tlog 'all()#s[1]'
+  0: 
+  1: featureA
+  $ tlog 'all()#s[9999]'
+
+  $ hg topic featureB
+  marked working directory as topic: featureB
+  $ hg stack
+  ### topic: featureB
+  ### target: default (branch)
+  (stack is empty)
+  s0^ 4 (base current)
+  $ tlog 'wdir()#s[0]'
+  4: 
+
+  $ cd ..
+
 Testing the new config knob to forbid untopiced commit
 ======================================================