comparison tests/test-stack-branch.t @ 6376:5c8196a550b6

topic: make hg stack work for branches with double slashes in them Other commands are likely affected as well. Things to note: we're using FQBN-formatted branch instead of full branch//namespace/topic in the workingctx.dirty() check because otherwise, if you had no topic active and were trying to update to a topic, wdir would be considered to be dirty and update would abort (same with unset topic namespace and trying to update to a changeset with topic namespace set). With just a bare branch, this doesn't happen, because you can't deactivate a branch. This is caught by test-topic.t.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 15 Dec 2022 15:44:39 +0400
parents c4097632a1a3
children c5848d8b664d
comparison
equal deleted inserted replaced
6375:fcbca44dd0df 6376:5c8196a550b6
10 > evolution=createmarkers,exchange,allowunstable 10 > evolution=createmarkers,exchange,allowunstable
11 > EOF 11 > EOF
12 12
13 $ hg init main 13 $ hg init main
14 $ cd main 14 $ cd main
15 $ hg branch other 15 $ hg branch double//slash
16 marked working directory as branch other 16 marked working directory as branch double//slash
17 (branches are permanent and global, did you want a bookmark?) 17 (branches are permanent and global, did you want a bookmark?)
18 $ echo aaa > aaa 18 $ echo aaa > aaa
19 $ hg add aaa 19 $ hg add aaa
20 $ hg commit -m c_a 20 $ hg commit -m c_a
21 $ echo aaa > bbb 21 $ echo aaa > bbb
22 $ hg add bbb 22 $ hg add bbb
23 $ hg commit -m c_b 23 $ hg commit -m c_b
24 $ hg branch foo 24 $ hg branch foo//bar
25 marked working directory as branch foo 25 marked working directory as branch foo//bar
26 $ echo aaa > ccc 26 $ echo aaa > ccc
27 $ hg add ccc 27 $ hg add ccc
28 $ hg commit -m c_c 28 $ hg commit -m c_c
29 $ echo aaa > ddd 29 $ echo aaa > ddd
30 $ hg add ddd 30 $ hg add ddd
34 $ hg commit -m c_e 34 $ hg commit -m c_e
35 $ echo aaa > fff 35 $ echo aaa > fff
36 $ hg add fff 36 $ hg add fff
37 $ hg commit -m c_f 37 $ hg commit -m c_f
38 $ hg log -G 38 $ hg log -G
39 @ 5 foo {} draft c_f 39 @ 5 foo//bar {} draft c_f
40 | 40 |
41 o 4 foo {} draft c_e 41 o 4 foo//bar {} draft c_e
42 | 42 |
43 o 3 foo {} draft c_d 43 o 3 foo//bar {} draft c_d
44 | 44 |
45 o 2 foo {} draft c_c 45 o 2 foo//bar {} draft c_c
46 | 46 |
47 o 1 other {} draft c_b 47 o 1 double//slash {} draft c_b
48 | 48 |
49 o 0 other {} draft c_a 49 o 0 double//slash {} draft c_a
50 50
51 51
52 Check that topic without any parent does not crash --list 52 Check that topic without any parent does not crash --list
53 --------------------------------------------------------- 53 ---------------------------------------------------------
54 54
55 $ hg up other 55 $ hg up double//slash//
56 0 files updated, 0 files merged, 4 files removed, 0 files unresolved 56 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
57 $ hg stack 57 $ hg stack
58 ### target: other (branch) 58 ### target: double//slash (branch)
59 s2@ c_b (current) 59 s2@ c_b (current)
60 s1: c_a 60 s1: c_a
61 $ hg phase --public 'branch("other")' 61 $ hg phase --public 'branch("double//slash//")'
62 $ hg up foo 62 $ hg up foo//bar//
63 4 files updated, 0 files merged, 0 files removed, 0 files unresolved 63 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 64
65 Simple test 65 Simple test
66 ----------- 66 -----------
67 67
68 'hg stack' list all changeset in the topic 68 'hg stack' list all changeset in the topic
69 69
70 $ hg branch 70 $ hg branch
71 foo 71 foo//bar
72 $ hg stack 72 $ hg stack
73 ### target: foo (branch) 73 ### target: foo//bar (branch)
74 s4@ c_f (current) 74 s4@ c_f (current)
75 s3: c_e 75 s3: c_e
76 s2: c_d 76 s2: c_d
77 s1: c_c 77 s1: c_c
78 s0^ c_b (base) 78 s0^ c_b (base)
79 $ hg stack -v 79 $ hg stack -v
80 ### target: foo (branch) 80 ### target: foo//bar (branch)
81 s4(913c298d8b0a)@ c_f (current) 81 s4(18b3ff044de9)@ c_f (current)
82 s3(4f2a69f6d380): c_e 82 s3(b1913e064ca1): c_e
83 s2(f61adbacd17a): c_d 83 s2(8fad7e98adf6): c_d
84 s1(3e9313bc4b71): c_c 84 s1(da14ac95d156): c_c
85 s0(4a04f1104a27)^ c_b (base) 85 s0(2450a061c0f0)^ c_b (base)
86 86
87 Test "t#" reference 87 Test "t#" reference
88 ------------------- 88 -------------------
89 89
90 $ hg up s2 90 $ hg up s2
91 0 files updated, 0 files merged, 2 files removed, 0 files unresolved 91 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
92 $ hg up foo 92 $ hg up foo//bar//
93 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 93 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
94 $ hg up s42 94 $ hg up s42
95 abort: cannot resolve "s42": branch "foo" has only 4 non-public changesets 95 abort: cannot resolve "s42": branch "foo//bar//" has only 4 non-public changesets
96 [255] 96 [255]
97 $ hg up s2 97 $ hg up s2
98 0 files updated, 0 files merged, 2 files removed, 0 files unresolved 98 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
99 $ hg summary 99 $ hg summary
100 parent: 3:f61adbacd17a 100 parent: 3:8fad7e98adf6
101 c_d 101 c_d
102 branch: foo 102 branch: foo//bar//
103 commit: (clean) 103 commit: (clean)
104 update: 2 new changesets (update) 104 update: 2 new changesets (update)
105 phases: 4 draft 105 phases: 4 draft
106 106
107 Case with some of the branch unstable 107 Case with some of the branch unstable
109 109
110 $ echo bbb > ddd 110 $ echo bbb > ddd
111 $ hg commit --amend 111 $ hg commit --amend
112 2 new orphan changesets 112 2 new orphan changesets
113 $ hg log -G 113 $ hg log -G
114 @ 6 foo {} draft c_d 114 @ 6 foo//bar {} draft c_d
115 | 115 |
116 | * 5 foo {} draft c_f 116 | * 5 foo//bar {} draft c_f
117 | | 117 | |
118 | * 4 foo {} draft c_e 118 | * 4 foo//bar {} draft c_e
119 | | 119 | |
120 | x 3 foo {} draft c_d 120 | x 3 foo//bar {} draft c_d
121 |/ 121 |/
122 o 2 foo {} draft c_c 122 o 2 foo//bar {} draft c_c
123 | 123 |
124 o 1 other {} public c_b 124 o 1 double//slash {} public c_b
125 | 125 |
126 o 0 other {} public c_a 126 o 0 double//slash {} public c_a
127 127
128 $ hg stack 128 $ hg stack
129 ### target: foo (branch) 129 ### target: foo//bar (branch)
130 s4$ c_f (orphan) 130 s4$ c_f (orphan)
131 s3$ c_e (orphan) 131 s3$ c_e (orphan)
132 s2@ c_d (current) 132 s2@ c_d (current)
133 s1: c_c 133 s1: c_c
134 s0^ c_b (base) 134 s0^ c_b (base)
135 $ hg up s3 135 $ hg up s3
136 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 136 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
137 $ hg stack 137 $ hg stack
138 ### target: foo (branch) 138 ### target: foo//bar (branch)
139 s4$ c_f (orphan) 139 s4$ c_f (orphan)
140 s3@ c_e (current orphan) 140 s3@ c_e (current orphan)
141 s2: c_d 141 s2: c_d
142 s1: c_c 142 s1: c_c
143 s0^ c_b (base) 143 s0^ c_b (base)
145 1 files updated, 0 files merged, 1 files removed, 0 files unresolved 145 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
146 146
147 Also test the revset: 147 Also test the revset:
148 148
149 $ hg log -r 'stack()' 149 $ hg log -r 'stack()'
150 2 foo {} draft c_c 150 2 foo//bar {} draft c_c
151 6 foo {} draft c_d 151 6 foo//bar {} draft c_d
152 4 foo {} draft c_e 152 4 foo//bar {} draft c_e
153 5 foo {} draft c_f 153 5 foo//bar {} draft c_f
154 154
155 Case with multiple heads on the topic 155 Case with multiple heads on the topic
156 ------------------------------------- 156 -------------------------------------
157 157
158 Make things linear again 158 Make things linear again
159 159
160 $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()' 160 $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()'
161 rebasing 4:4f2a69f6d380 "c_e" 161 rebasing 4:b1913e064ca1 "c_e"
162 rebasing 5:913c298d8b0a "c_f" 162 rebasing 5:18b3ff044de9 "c_f"
163 $ hg log -G 163 $ hg log -G
164 o 8 foo {} draft c_f 164 o 8 foo//bar {} draft c_f
165 | 165 |
166 o 7 foo {} draft c_e 166 o 7 foo//bar {} draft c_e
167 | 167 |
168 @ 6 foo {} draft c_d 168 @ 6 foo//bar {} draft c_d
169 | 169 |
170 o 2 foo {} draft c_c 170 o 2 foo//bar {} draft c_c
171 | 171 |
172 o 1 other {} public c_b 172 o 1 double//slash {} public c_b
173 | 173 |
174 o 0 other {} public c_a 174 o 0 double//slash {} public c_a
175 175
176 176
177 Create the second branch 177 Create the second branch
178 178
179 $ hg up 'desc(c_d)' 179 $ hg up 'desc(c_d)'
185 (consider using topic for lightweight branches. See 'hg help topic') 185 (consider using topic for lightweight branches. See 'hg help topic')
186 $ echo aaa > hhh 186 $ echo aaa > hhh
187 $ hg add hhh 187 $ hg add hhh
188 $ hg commit -m c_h 188 $ hg commit -m c_h
189 $ hg log -G 189 $ hg log -G
190 @ 10 foo {} draft c_h 190 @ 10 foo//bar {} draft c_h
191 | 191 |
192 o 9 foo {} draft c_g 192 o 9 foo//bar {} draft c_g
193 | 193 |
194 | o 8 foo {} draft c_f 194 | o 8 foo//bar {} draft c_f
195 | | 195 | |
196 | o 7 foo {} draft c_e 196 | o 7 foo//bar {} draft c_e
197 |/ 197 |/
198 o 6 foo {} draft c_d 198 o 6 foo//bar {} draft c_d
199 | 199 |
200 o 2 foo {} draft c_c 200 o 2 foo//bar {} draft c_c
201 | 201 |
202 o 1 other {} public c_b 202 o 1 double//slash {} public c_b
203 | 203 |
204 o 0 other {} public c_a 204 o 0 double//slash {} public c_a
205 205
206 206
207 Test output 207 Test output
208 208
209 $ hg stack 209 $ hg stack
210 ### target: foo (branch) (2 heads) 210 ### target: foo//bar (branch) (2 heads)
211 s6@ c_h (current) 211 s6@ c_h (current)
212 s5: c_g 212 s5: c_g
213 s2^ c_d (base) 213 s2^ c_d (base)
214 s4: c_f 214 s4: c_f
215 s3: c_e 215 s3: c_e
226 0 files updated, 0 files merged, 2 files removed, 0 files unresolved 226 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
227 $ echo ccc > ddd 227 $ echo ccc > ddd
228 $ hg commit --amend -m 'c_D' 228 $ hg commit --amend -m 'c_D'
229 4 new orphan changesets 229 4 new orphan changesets
230 $ hg rebase -d . -s 'desc(c_g)' 230 $ hg rebase -d . -s 'desc(c_g)'
231 rebasing 9:2ebb6e48ab8a "c_g" 231 rebasing 9:8c1819a4441f "c_g"
232 rebasing 10:634f38e27a1d "c_h" 232 rebasing 10:e255b784f0e9 "c_h"
233 $ hg log -G 233 $ hg log -G
234 o 13 foo {} draft c_h 234 o 13 foo//bar {} draft c_h
235 | 235 |
236 o 12 foo {} draft c_g 236 o 12 foo//bar {} draft c_g
237 | 237 |
238 @ 11 foo {} draft c_D 238 @ 11 foo//bar {} draft c_D
239 | 239 |
240 | * 8 foo {} draft c_f 240 | * 8 foo//bar {} draft c_f
241 | | 241 | |
242 | * 7 foo {} draft c_e 242 | * 7 foo//bar {} draft c_e
243 | | 243 | |
244 | x 6 foo {} draft c_d 244 | x 6 foo//bar {} draft c_d
245 |/ 245 |/
246 o 2 foo {} draft c_c 246 o 2 foo//bar {} draft c_c
247 | 247 |
248 o 1 other {} public c_b 248 o 1 double//slash {} public c_b
249 | 249 |
250 o 0 other {} public c_a 250 o 0 double//slash {} public c_a
251 251
252 252
253 $ hg stack 253 $ hg stack
254 ### target: foo (branch) (2 heads) 254 ### target: foo//bar (branch) (2 heads)
255 s6: c_h 255 s6: c_h
256 s5: c_g 256 s5: c_g
257 s2^ c_D (base current) 257 s2^ c_D (base current)
258 s4$ c_f (orphan) 258 s4$ c_f (orphan)
259 s3$ c_e (orphan) 259 s3$ c_e (orphan)
263 263
264 Check that stack doesn't show draft changesets on a branch 264 Check that stack doesn't show draft changesets on a branch
265 ---------------------------------------------------------- 265 ----------------------------------------------------------
266 266
267 $ hg log --graph 267 $ hg log --graph
268 o 13 foo {} draft c_h 268 o 13 foo//bar {} draft c_h
269 | 269 |
270 o 12 foo {} draft c_g 270 o 12 foo//bar {} draft c_g
271 | 271 |
272 @ 11 foo {} draft c_D 272 @ 11 foo//bar {} draft c_D
273 | 273 |
274 | * 8 foo {} draft c_f 274 | * 8 foo//bar {} draft c_f
275 | | 275 | |
276 | * 7 foo {} draft c_e 276 | * 7 foo//bar {} draft c_e
277 | | 277 | |
278 | x 6 foo {} draft c_d 278 | x 6 foo//bar {} draft c_d
279 |/ 279 |/
280 o 2 foo {} draft c_c 280 o 2 foo//bar {} draft c_c
281 | 281 |
282 o 1 other {} public c_b 282 o 1 double//slash {} public c_b
283 | 283 |
284 o 0 other {} public c_a 284 o 0 double//slash {} public c_a
285 285
286 286
287 $ hg stack 287 $ hg stack
288 ### target: foo (branch) (2 heads) 288 ### target: foo//bar (branch) (2 heads)
289 s6: c_h 289 s6: c_h
290 s5: c_g 290 s5: c_g
291 s2^ c_D (base current) 291 s2^ c_D (base current)
292 s4$ c_f (orphan) 292 s4$ c_f (orphan)
293 s3$ c_e (orphan) 293 s3$ c_e (orphan)
294 s2@ c_D (current) 294 s2@ c_D (current)
295 s1: c_c 295 s1: c_c
296 s0^ c_b (base) 296 s0^ c_b (base)
297 $ hg phase --public s1 297 $ hg phase --public s1
298 $ hg stack 298 $ hg stack
299 ### target: foo (branch) (2 heads) 299 ### target: foo//bar (branch) (2 heads)
300 s5: c_h 300 s5: c_h
301 s4: c_g 301 s4: c_g
302 s1^ c_D (base current) 302 s1^ c_D (base current)
303 s3$ c_f (orphan) 303 s3$ c_f (orphan)
304 s2$ c_e (orphan) 304 s2$ c_e (orphan)
309 ---------------------------------------------------- 309 ----------------------------------------------------
310 310
311 $ hg topic --rev s4::s5 sometopic 311 $ hg topic --rev s4::s5 sometopic
312 changed topic on 2 changesets to "sometopic" 312 changed topic on 2 changesets to "sometopic"
313 $ hg stack 313 $ hg stack
314 ### target: foo (branch) 314 ### target: foo//bar (branch)
315 s3$ c_f (orphan) 315 s3$ c_f (orphan)
316 s2$ c_e (orphan) 316 s2$ c_e (orphan)
317 s1@ c_D (current) 317 s1@ c_D (current)
318 s0^ c_c (base) 318 s0^ c_c (base)