Show More
@@ -0,0 +1,253 | |||||
|
1 | ||||
|
2 | This test test the low-level definition of stack, agnostic from all formatting | |||
|
3 | ||||
|
4 | Initial setup | |||
|
5 | ||||
|
6 | $ cat << EOF >> $HGRCPATH | |||
|
7 | > [ui] | |||
|
8 | > logtemplate = {rev} {branch} {phase} {desc|firstline}\n | |||
|
9 | > [extensions] | |||
|
10 | > rebase= | |||
|
11 | > [experimental] | |||
|
12 | > evolution=createmarkers,exchange,allowunstable | |||
|
13 | > EOF | |||
|
14 | ||||
|
15 | $ hg init main | |||
|
16 | $ cd main | |||
|
17 | $ hg branch other | |||
|
18 | marked working directory as branch other | |||
|
19 | (branches are permanent and global, did you want a bookmark?) | |||
|
20 | $ echo aaa > aaa | |||
|
21 | $ hg add aaa | |||
|
22 | $ hg commit -m c_a | |||
|
23 | $ echo aaa > bbb | |||
|
24 | $ hg add bbb | |||
|
25 | $ hg commit -m c_b | |||
|
26 | $ hg branch foo | |||
|
27 | marked working directory as branch foo | |||
|
28 | $ echo aaa > ccc | |||
|
29 | $ hg add ccc | |||
|
30 | $ hg commit -m c_c | |||
|
31 | $ echo aaa > ddd | |||
|
32 | $ hg add ddd | |||
|
33 | $ hg commit -m c_d | |||
|
34 | $ echo aaa > eee | |||
|
35 | $ hg add eee | |||
|
36 | $ hg commit -m c_e | |||
|
37 | $ echo aaa > fff | |||
|
38 | $ hg add fff | |||
|
39 | $ hg commit -m c_f | |||
|
40 | $ hg log -G | |||
|
41 | @ 5 foo draft c_f | |||
|
42 | | | |||
|
43 | o 4 foo draft c_e | |||
|
44 | | | |||
|
45 | o 3 foo draft c_d | |||
|
46 | | | |||
|
47 | o 2 foo draft c_c | |||
|
48 | | | |||
|
49 | o 1 other draft c_b | |||
|
50 | | | |||
|
51 | o 0 other draft c_a | |||
|
52 | ||||
|
53 | ||||
|
54 | Check that stack doesn't include public changesets | |||
|
55 | -------------------------------------------------- | |||
|
56 | ||||
|
57 | $ hg up other | |||
|
58 | 0 files updated, 0 files merged, 4 files removed, 0 files unresolved | |||
|
59 | $ hg log -G -r "stack()" | |||
|
60 | @ 1 other draft c_b | |||
|
61 | | | |||
|
62 | o 0 other draft c_a | |||
|
63 | ||||
|
64 | $ hg phase --public 'branch("other")' | |||
|
65 | $ hg log -G -r "stack()" | |||
|
66 | $ hg up foo | |||
|
67 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
68 | ||||
|
69 | Simple test | |||
|
70 | ----------- | |||
|
71 | ||||
|
72 | 'stack()' list all changeset in the branch | |||
|
73 | ||||
|
74 | $ hg branch | |||
|
75 | foo | |||
|
76 | $ hg log -G -r "stack()" | |||
|
77 | @ 5 foo draft c_f | |||
|
78 | | | |||
|
79 | o 4 foo draft c_e | |||
|
80 | | | |||
|
81 | o 3 foo draft c_d | |||
|
82 | | | |||
|
83 | o 2 foo draft c_c | |||
|
84 | | | |||
|
85 | ~ | |||
|
86 | ||||
|
87 | Case with some of the branch unstable | |||
|
88 | ------------------------------------ | |||
|
89 | ||||
|
90 | $ hg up 3 | |||
|
91 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |||
|
92 | $ echo bbb > ddd | |||
|
93 | $ hg commit --amend | |||
|
94 | 2 new orphan changesets | |||
|
95 | $ hg log -G | |||
|
96 | @ 6 foo draft c_d | |||
|
97 | | | |||
|
98 | | * 5 foo draft c_f | |||
|
99 | | | | |||
|
100 | | * 4 foo draft c_e | |||
|
101 | | | | |||
|
102 | | x 3 foo draft c_d | |||
|
103 | |/ | |||
|
104 | o 2 foo draft c_c | |||
|
105 | | | |||
|
106 | o 1 other public c_b | |||
|
107 | | | |||
|
108 | o 0 other public c_a | |||
|
109 | ||||
|
110 | $ hg log -G -r "stack()" | |||
|
111 | @ 6 foo draft c_d | |||
|
112 | | | |||
|
113 | ~ | |||
|
114 | $ hg up -r "desc(c_e)" | |||
|
115 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
116 | $ hg log -G -r "stack()" | |||
|
117 | @ 4 foo draft c_e | |||
|
118 | | | |||
|
119 | x 3 foo draft c_d | |||
|
120 | | | |||
|
121 | ~ | |||
|
122 | $ hg up -r "desc(c_d)" | |||
|
123 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
124 | ||||
|
125 | $ hg log -G -r "stack()" | |||
|
126 | @ 6 foo draft c_d | |||
|
127 | | | |||
|
128 | ~ | |||
|
129 | ||||
|
130 | Case with multiple topological heads | |||
|
131 | ------------------------------------ | |||
|
132 | ||||
|
133 | Make things linear again | |||
|
134 | ||||
|
135 | $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()' | |||
|
136 | rebasing 4:4f2a69f6d380 "c_e" | |||
|
137 | rebasing 5:913c298d8b0a "c_f" | |||
|
138 | $ hg log -G | |||
|
139 | o 8 foo draft c_f | |||
|
140 | | | |||
|
141 | o 7 foo draft c_e | |||
|
142 | | | |||
|
143 | @ 6 foo draft c_d | |||
|
144 | | | |||
|
145 | o 2 foo draft c_c | |||
|
146 | | | |||
|
147 | o 1 other public c_b | |||
|
148 | | | |||
|
149 | o 0 other public c_a | |||
|
150 | ||||
|
151 | ||||
|
152 | Create the second branch | |||
|
153 | ||||
|
154 | $ hg up 'desc(c_d)' | |||
|
155 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
156 | $ echo aaa > ggg | |||
|
157 | $ hg add ggg | |||
|
158 | $ hg commit -m c_g | |||
|
159 | created new head | |||
|
160 | $ echo aaa > hhh | |||
|
161 | $ hg add hhh | |||
|
162 | $ hg commit -m c_h | |||
|
163 | $ hg log -G | |||
|
164 | @ 10 foo draft c_h | |||
|
165 | | | |||
|
166 | o 9 foo draft c_g | |||
|
167 | | | |||
|
168 | | o 8 foo draft c_f | |||
|
169 | | | | |||
|
170 | | o 7 foo draft c_e | |||
|
171 | |/ | |||
|
172 | o 6 foo draft c_d | |||
|
173 | | | |||
|
174 | o 2 foo draft c_c | |||
|
175 | | | |||
|
176 | o 1 other public c_b | |||
|
177 | | | |||
|
178 | o 0 other public c_a | |||
|
179 | ||||
|
180 | ||||
|
181 | Test output | |||
|
182 | ||||
|
183 | $ hg log -G -r "stack(10)" | |||
|
184 | @ 10 foo draft c_h | |||
|
185 | | | |||
|
186 | o 9 foo draft c_g | |||
|
187 | | | |||
|
188 | ~ | |||
|
189 | $ hg log -G -r "stack(8)" | |||
|
190 | o 8 foo draft c_f | |||
|
191 | | | |||
|
192 | o 7 foo draft c_e | |||
|
193 | | | |||
|
194 | ~ | |||
|
195 | $ hg log -G -r "stack(head())" | |||
|
196 | @ 10 foo draft c_h | |||
|
197 | | | |||
|
198 | o 9 foo draft c_g | |||
|
199 | | | |||
|
200 | ~ | |||
|
201 | o 8 foo draft c_f | |||
|
202 | | | |||
|
203 | o 7 foo draft c_e | |||
|
204 | | | |||
|
205 | ~ | |||
|
206 | Check the stack order | |||
|
207 | $ hg log -r "first(stack())" | |||
|
208 | 10 foo draft c_h | |||
|
209 | $ hg log -r "first(stack(10))" | |||
|
210 | 10 foo draft c_h | |||
|
211 | $ hg log -r "first(stack(8))" | |||
|
212 | 8 foo draft c_f | |||
|
213 | $ hg log -r "first(stack(head()))" | |||
|
214 | 8 foo draft c_f | |||
|
215 | ||||
|
216 | Case with multiple heads with unstability involved | |||
|
217 | -------------------------------------------------- | |||
|
218 | ||||
|
219 | We amend the message to make sure the display base pick the right changeset | |||
|
220 | ||||
|
221 | $ hg up 'desc(c_d)' | |||
|
222 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |||
|
223 | $ echo ccc > ddd | |||
|
224 | $ hg commit --amend -m 'c_D' | |||
|
225 | 4 new orphan changesets | |||
|
226 | $ hg rebase -d . -s 'desc(c_g)' | |||
|
227 | rebasing 9:2ebb6e48ab8a "c_g" | |||
|
228 | rebasing 10:634f38e27a1d "c_h" | |||
|
229 | $ hg log -G | |||
|
230 | o 13 foo draft c_h | |||
|
231 | | | |||
|
232 | o 12 foo draft c_g | |||
|
233 | | | |||
|
234 | @ 11 foo draft c_D | |||
|
235 | | | |||
|
236 | | * 8 foo draft c_f | |||
|
237 | | | | |||
|
238 | | * 7 foo draft c_e | |||
|
239 | | | | |||
|
240 | | x 6 foo draft c_d | |||
|
241 | |/ | |||
|
242 | o 2 foo draft c_c | |||
|
243 | | | |||
|
244 | o 1 other public c_b | |||
|
245 | | | |||
|
246 | o 0 other public c_a | |||
|
247 | ||||
|
248 | ||||
|
249 | We should improve stack definition to also show 12 and 13 here | |||
|
250 | $ hg log -G -r "stack()" | |||
|
251 | @ 11 foo draft c_D | |||
|
252 | | | |||
|
253 | ~ |
@@ -28,6 +28,7 from . import ( | |||||
28 | revsetlang, |
|
28 | revsetlang, | |
29 | scmutil, |
|
29 | scmutil, | |
30 | smartset, |
|
30 | smartset, | |
|
31 | stack, | |||
31 | util, |
|
32 | util, | |
32 | ) |
|
33 | ) | |
33 | from .utils import dateutil |
|
34 | from .utils import dateutil | |
@@ -1532,6 +1533,21 def secret(repo, subset, x): | |||||
1532 | target = phases.secret |
|
1533 | target = phases.secret | |
1533 | return _phase(repo, subset, target) |
|
1534 | return _phase(repo, subset, target) | |
1534 |
|
1535 | |||
|
1536 | @predicate('stack([revs])', safe=True) | |||
|
1537 | def _stack(repo, subset, x): | |||
|
1538 | # experimental revset for the stack of changesets or working directory | |||
|
1539 | # parent | |||
|
1540 | if x is None: | |||
|
1541 | stacks = stack.getstack(repo, x) | |||
|
1542 | else: | |||
|
1543 | stacks = smartset.baseset([]) | |||
|
1544 | for revision in getset(repo, fullreposet(repo), x): | |||
|
1545 | currentstack = stack.getstack(repo, revision) | |||
|
1546 | stacks = stacks + currentstack | |||
|
1547 | ||||
|
1548 | # Force to use the order of the stacks instead of the subset one | |||
|
1549 | return stacks & subset | |||
|
1550 | ||||
1535 | def parentspec(repo, subset, x, n, order): |
|
1551 | def parentspec(repo, subset, x, n, order): | |
1536 | """``set^0`` |
|
1552 | """``set^0`` | |
1537 | The set. |
|
1553 | The set. |
General Comments 0
You need to be logged in to leave comments.
Login now