just playing with tangled
1// Copyright 2024 The Jujutsu Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::common::CommandOutput;
16use crate::common::TestEnvironment;
17use crate::common::TestWorkDir;
18
19#[test]
20fn test_parallelize_no_descendants() {
21 let test_env = TestEnvironment::default();
22 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
23 let work_dir = test_env.work_dir("repo");
24
25 for n in 1..6 {
26 work_dir.run_jj(["commit", &format!("-m{n}")]).success();
27 }
28 work_dir.run_jj(["describe", "-m=6"]).success();
29 insta::assert_snapshot!(get_log_output(&work_dir), @r"
30 @ 02b7709cc4e9 6 parents: 5
31 ○ 1b2f08d76b66 5 parents: 4
32 ○ e5c4cf44e237 4 parents: 3
33 ○ 4cd999dfaac0 3 parents: 2
34 ○ d3902619fade 2 parents: 1
35 ○ 8b64ddff700d 1 parents:
36 ◆ 000000000000 parents:
37 [EOF]
38 ");
39
40 work_dir
41 .run_jj(["parallelize", "description(1)::"])
42 .success();
43 insta::assert_snapshot!(get_log_output(&work_dir), @r"
44 @ 4850b4629edb 6 parents:
45 │ ○ 87627fbb7d29 5 parents:
46 ├─╯
47 │ ○ 5b9815e28fae 4 parents:
48 ├─╯
49 │ ○ bb1bb465ccc2 3 parents:
50 ├─╯
51 │ ○ 337eca1ef3a8 2 parents:
52 ├─╯
53 │ ○ 8b64ddff700d 1 parents:
54 ├─╯
55 ◆ 000000000000 parents:
56 [EOF]
57 ");
58}
59
60// Only the head commit has descendants.
61#[test]
62fn test_parallelize_with_descendants_simple() {
63 let test_env = TestEnvironment::default();
64 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
65 let work_dir = test_env.work_dir("repo");
66
67 for n in 1..6 {
68 work_dir.run_jj(["commit", &format!("-m{n}")]).success();
69 }
70 work_dir.run_jj(["describe", "-m=6"]).success();
71 insta::assert_snapshot!(get_log_output(&work_dir), @r"
72 @ 02b7709cc4e9 6 parents: 5
73 ○ 1b2f08d76b66 5 parents: 4
74 ○ e5c4cf44e237 4 parents: 3
75 ○ 4cd999dfaac0 3 parents: 2
76 ○ d3902619fade 2 parents: 1
77 ○ 8b64ddff700d 1 parents:
78 ◆ 000000000000 parents:
79 [EOF]
80 ");
81
82 work_dir
83 .run_jj(["parallelize", "description(1)::description(4)"])
84 .success();
85 insta::assert_snapshot!(get_log_output(&work_dir), @r"
86 @ 9bc057f8b6e3 6 parents: 5
87 ○ 9e36a8afe793 5 parents: 1 2 3 4
88 ├─┬─┬─╮
89 │ │ │ ○ 5b9815e28fae 4 parents:
90 │ │ ○ │ bb1bb465ccc2 3 parents:
91 │ │ ├─╯
92 │ ○ │ 337eca1ef3a8 2 parents:
93 │ ├─╯
94 ○ │ 8b64ddff700d 1 parents:
95 ├─╯
96 ◆ 000000000000 parents:
97 [EOF]
98 ");
99}
100
101// One of the commits being parallelized has a child that isn't being
102// parallelized. That child will become a merge of any ancestors which are being
103// parallelized.
104#[test]
105fn test_parallelize_where_interior_has_non_target_children() {
106 let test_env = TestEnvironment::default();
107 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
108 let work_dir = test_env.work_dir("repo");
109
110 for n in 1..6 {
111 work_dir.run_jj(["commit", &format!("-m{n}")]).success();
112 }
113 work_dir
114 .run_jj(["new", "description(2)", "-m=2c"])
115 .success();
116 work_dir.run_jj(["new", "description(5)", "-m=6"]).success();
117 insta::assert_snapshot!(get_log_output(&work_dir), @r"
118 @ 2508ea92308a 6 parents: 5
119 ○ 1b2f08d76b66 5 parents: 4
120 ○ e5c4cf44e237 4 parents: 3
121 ○ 4cd999dfaac0 3 parents: 2
122 │ ○ 3e7571e62c87 2c parents: 2
123 ├─╯
124 ○ d3902619fade 2 parents: 1
125 ○ 8b64ddff700d 1 parents:
126 ◆ 000000000000 parents:
127 [EOF]
128 ");
129
130 work_dir
131 .run_jj(["parallelize", "description(1)::description(4)"])
132 .success();
133 insta::assert_snapshot!(get_log_output(&work_dir), @r"
134 @ c9525dff9d03 6 parents: 5
135 ○ b3ad09518546 5 parents: 1 2 3 4
136 ├─┬─┬─╮
137 │ │ │ ○ 3b125ed6a683 4 parents:
138 │ │ ○ │ 1ed8c0c5be30 3 parents:
139 │ │ ├─╯
140 │ │ │ ○ c01d8e85ea96 2c parents: 1 2
141 ╭─┬───╯
142 │ ○ │ 7efea6c89b60 2 parents:
143 │ ├─╯
144 ○ │ 8b64ddff700d 1 parents:
145 ├─╯
146 ◆ 000000000000 parents:
147 [EOF]
148 ");
149}
150
151#[test]
152fn test_parallelize_where_root_has_non_target_children() {
153 let test_env = TestEnvironment::default();
154 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
155 let work_dir = test_env.work_dir("repo");
156
157 for n in 1..4 {
158 work_dir.run_jj(["commit", &format!("-m{n}")]).success();
159 }
160 work_dir
161 .run_jj(["new", "description(1)", "-m=1c"])
162 .success();
163 work_dir.run_jj(["new", "description(3)", "-m=4"]).success();
164 insta::assert_snapshot!(get_log_output(&work_dir), @r"
165 @ 9132691e6256 4 parents: 3
166 ○ 4cd999dfaac0 3 parents: 2
167 ○ d3902619fade 2 parents: 1
168 │ ○ 6c64110df0a5 1c parents: 1
169 ├─╯
170 ○ 8b64ddff700d 1 parents:
171 ◆ 000000000000 parents:
172 [EOF]
173 ");
174 work_dir
175 .run_jj(["parallelize", "description(1)::description(3)"])
176 .success();
177 insta::assert_snapshot!(get_log_output(&work_dir), @r"
178 @ 3397916989e7 4 parents: 1 2 3
179 ├─┬─╮
180 │ │ ○ 1f768c1bc591 3 parents:
181 │ ○ │ 12ef12b4640e 2 parents:
182 │ ├─╯
183 │ │ ○ 6c64110df0a5 1c parents: 1
184 ├───╯
185 ○ │ 8b64ddff700d 1 parents:
186 ├─╯
187 ◆ 000000000000 parents:
188 [EOF]
189 ");
190}
191
192// One of the commits being parallelized has a child that is a merge commit.
193#[test]
194fn test_parallelize_with_merge_commit_child() {
195 let test_env = TestEnvironment::default();
196 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
197 let work_dir = test_env.work_dir("repo");
198
199 work_dir.run_jj(["commit", "-m", "1"]).success();
200 for n in 2..4 {
201 work_dir.run_jj(["commit", "-m", &n.to_string()]).success();
202 }
203 work_dir.run_jj(["new", "root()", "-m", "a"]).success();
204 work_dir
205 .run_jj(["new", "description(2)", "description(a)", "-m", "2a-c"])
206 .success();
207 work_dir
208 .run_jj(["new", "description(3)", "-m", "4"])
209 .success();
210 insta::assert_snapshot!(get_log_output(&work_dir), @r"
211 @ 99ffaf5b3984 4 parents: 3
212 ○ 4cd999dfaac0 3 parents: 2
213 │ ○ 4313cc3b476f 2a-c parents: 2 a
214 ╭─┤
215 │ ○ 1eb902150bb9 a parents:
216 ○ │ d3902619fade 2 parents: 1
217 ○ │ 8b64ddff700d 1 parents:
218 ├─╯
219 ◆ 000000000000 parents:
220 [EOF]
221 ");
222
223 // After this finishes, child-2a will have three parents: "1", "2", and "a".
224 work_dir
225 .run_jj(["parallelize", "description(1)::description(3)"])
226 .success();
227 insta::assert_snapshot!(get_log_output(&work_dir), @r"
228 @ 3ee9279847a6 4 parents: 1 2 3
229 ├─┬─╮
230 │ │ ○ bb1bb465ccc2 3 parents:
231 │ │ │ ○ c70ee196514b 2a-c parents: 1 2 a
232 ╭─┬───┤
233 │ │ │ ○ 1eb902150bb9 a parents:
234 │ │ ├─╯
235 │ ○ │ 337eca1ef3a8 2 parents:
236 │ ├─╯
237 ○ │ 8b64ddff700d 1 parents:
238 ├─╯
239 ◆ 000000000000 parents:
240 [EOF]
241 ");
242}
243
244#[test]
245fn test_parallelize_disconnected_target_commits() {
246 let test_env = TestEnvironment::default();
247 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
248 let work_dir = test_env.work_dir("repo");
249
250 for n in 1..3 {
251 work_dir.run_jj(["commit", &format!("-m{n}")]).success();
252 }
253 work_dir.run_jj(["describe", "-m=3"]).success();
254 insta::assert_snapshot!(get_log_output(&work_dir), @r"
255 @ 4cd999dfaac0 3 parents: 2
256 ○ d3902619fade 2 parents: 1
257 ○ 8b64ddff700d 1 parents:
258 ◆ 000000000000 parents:
259 [EOF]
260 ");
261
262 let output = work_dir.run_jj(["parallelize", "description(1)", "description(3)"]);
263 insta::assert_snapshot!(output, @r"
264 ------- stderr -------
265 Nothing changed.
266 [EOF]
267 ");
268 insta::assert_snapshot!(get_log_output(&work_dir), @r"
269 @ 4cd999dfaac0 3 parents: 2
270 ○ d3902619fade 2 parents: 1
271 ○ 8b64ddff700d 1 parents:
272 ◆ 000000000000 parents:
273 [EOF]
274 ");
275}
276
277#[test]
278fn test_parallelize_head_is_a_merge() {
279 let test_env = TestEnvironment::default();
280 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
281 let work_dir = test_env.work_dir("repo");
282 work_dir.run_jj(["commit", "-m=0"]).success();
283 work_dir.run_jj(["commit", "-m=1"]).success();
284 work_dir.run_jj(["commit", "-m=2"]).success();
285 work_dir.run_jj(["new", "root()"]).success();
286 work_dir.run_jj(["commit", "-m=a"]).success();
287 work_dir.run_jj(["commit", "-m=b"]).success();
288 work_dir
289 .run_jj(["new", "description(2)", "description(b)", "-m=merged-head"])
290 .success();
291 insta::assert_snapshot!(get_log_output(&work_dir), @r"
292 @ 1fb53c45237e merged-head parents: 2 b
293 ├─╮
294 │ ○ a7bf5001cfd8 b parents: a
295 │ ○ 6ca0450a05f5 a parents:
296 ○ │ 1f81bd465ed0 2 parents: 1
297 ○ │ 0c058af014a6 1 parents: 0
298 ○ │ 745bea8029c1 0 parents:
299 ├─╯
300 ◆ 000000000000 parents:
301 [EOF]
302 ");
303
304 work_dir
305 .run_jj(["parallelize", "description(1)::"])
306 .success();
307 insta::assert_snapshot!(get_log_output(&work_dir), @r"
308 @ 82131a679769 merged-head parents: 0 b
309 ├─╮
310 │ ○ a7bf5001cfd8 b parents: a
311 │ ○ 6ca0450a05f5 a parents:
312 │ │ ○ daef04bc3fae 2 parents: 0
313 ├───╯
314 │ │ ○ 0c058af014a6 1 parents: 0
315 ├───╯
316 ○ │ 745bea8029c1 0 parents:
317 ├─╯
318 ◆ 000000000000 parents:
319 [EOF]
320 ");
321}
322
323#[test]
324fn test_parallelize_interior_target_is_a_merge() {
325 let test_env = TestEnvironment::default();
326 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
327 let work_dir = test_env.work_dir("repo");
328 work_dir.run_jj(["commit", "-m=0"]).success();
329 work_dir.run_jj(["describe", "-m=1"]).success();
330 work_dir.run_jj(["new", "root()", "-m=a"]).success();
331 work_dir
332 .run_jj(["new", "description(1)", "description(a)", "-m=2"])
333 .success();
334 work_dir.run_jj(["new", "-m=3"]).success();
335 insta::assert_snapshot!(get_log_output(&work_dir), @r"
336 @ 9b77792c77ac 3 parents: 2
337 ○ 1e29145c95fd 2 parents: 1 a
338 ├─╮
339 │ ○ 427890ea3f2b a parents:
340 ○ │ 0c058af014a6 1 parents: 0
341 ○ │ 745bea8029c1 0 parents:
342 ├─╯
343 ◆ 000000000000 parents:
344 [EOF]
345 ");
346
347 work_dir
348 .run_jj(["parallelize", "description(1)::"])
349 .success();
350 insta::assert_snapshot!(get_log_output(&work_dir), @r"
351 @ 042fc3f4315c 3 parents: 0 a
352 ├─╮
353 │ │ ○ 80603361bb48 2 parents: 0 a
354 ╭─┬─╯
355 │ ○ 427890ea3f2b a parents:
356 │ │ ○ 0c058af014a6 1 parents: 0
357 ├───╯
358 ○ │ 745bea8029c1 0 parents:
359 ├─╯
360 ◆ 000000000000 parents:
361 [EOF]
362 ");
363}
364
365#[test]
366fn test_parallelize_root_is_a_merge() {
367 let test_env = TestEnvironment::default();
368 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
369 let work_dir = test_env.work_dir("repo");
370 work_dir.run_jj(["describe", "-m=y"]).success();
371 work_dir.run_jj(["new", "root()", "-m=x"]).success();
372 work_dir
373 .run_jj(["new", "description(y)", "description(x)", "-m=1"])
374 .success();
375 work_dir.run_jj(["new", "-m=2"]).success();
376 work_dir.run_jj(["new", "-m=3"]).success();
377 insta::assert_snapshot!(get_log_output(&work_dir), @r"
378 @ cc239b744d01 3 parents: 2
379 ○ 2bf00c2ad44c 2 parents: 1
380 ○ 1c6853121f3c 1 parents: y x
381 ├─╮
382 │ ○ 4035b23c8f72 x parents:
383 ○ │ ca57511e158f y parents:
384 ├─╯
385 ◆ 000000000000 parents:
386 [EOF]
387 ");
388
389 work_dir
390 .run_jj(["parallelize", "description(1)::description(2)"])
391 .success();
392 insta::assert_snapshot!(get_log_output(&work_dir), @r"
393 @ 2c7fdfa00b38 3 parents: 1 2
394 ├─╮
395 │ ○ 3acbd32944d6 2 parents: y x
396 │ ├─╮
397 ○ │ │ 1c6853121f3c 1 parents: y x
398 ╰─┬─╮
399 │ ○ 4035b23c8f72 x parents:
400 ○ │ ca57511e158f y parents:
401 ├─╯
402 ◆ 000000000000 parents:
403 [EOF]
404 ");
405}
406
407#[test]
408fn test_parallelize_multiple_heads() {
409 let test_env = TestEnvironment::default();
410 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
411 let work_dir = test_env.work_dir("repo");
412 work_dir.run_jj(["commit", "-m=0"]).success();
413 work_dir.run_jj(["describe", "-m=1"]).success();
414 work_dir.run_jj(["new", "description(0)", "-m=2"]).success();
415 insta::assert_snapshot!(get_log_output(&work_dir), @r"
416 @ 97d7522f40e8 2 parents: 0
417 │ ○ 0c058af014a6 1 parents: 0
418 ├─╯
419 ○ 745bea8029c1 0 parents:
420 ◆ 000000000000 parents:
421 [EOF]
422 ");
423
424 work_dir
425 .run_jj(["parallelize", "description(0)::"])
426 .success();
427 insta::assert_snapshot!(get_log_output(&work_dir), @r"
428 @ e84481c26195 2 parents:
429 │ ○ 6270540ee067 1 parents:
430 ├─╯
431 │ ○ 745bea8029c1 0 parents:
432 ├─╯
433 ◆ 000000000000 parents:
434 [EOF]
435 ");
436}
437
438// All heads must have the same children as the other heads, but only if they
439// have children. In this test only one head has children, so the command
440// succeeds.
441#[test]
442fn test_parallelize_multiple_heads_with_and_without_children() {
443 let test_env = TestEnvironment::default();
444 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
445 let work_dir = test_env.work_dir("repo");
446 work_dir.run_jj(["commit", "-m=0"]).success();
447 work_dir.run_jj(["describe", "-m=1"]).success();
448 work_dir.run_jj(["new", "description(0)", "-m=2"]).success();
449 insta::assert_snapshot!(get_log_output(&work_dir), @r"
450 @ 97d7522f40e8 2 parents: 0
451 │ ○ 0c058af014a6 1 parents: 0
452 ├─╯
453 ○ 745bea8029c1 0 parents:
454 ◆ 000000000000 parents:
455 [EOF]
456 ");
457
458 work_dir
459 .run_jj(["parallelize", "description(0)", "description(1)"])
460 .success();
461 insta::assert_snapshot!(get_log_output(&work_dir), @r"
462 @ 97d7522f40e8 2 parents: 0
463 ○ 745bea8029c1 0 parents:
464 │ ○ 6270540ee067 1 parents:
465 ├─╯
466 ◆ 000000000000 parents:
467 [EOF]
468 ");
469}
470
471#[test]
472fn test_parallelize_multiple_roots() {
473 let test_env = TestEnvironment::default();
474 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
475 let work_dir = test_env.work_dir("repo");
476 work_dir.run_jj(["describe", "-m=1"]).success();
477 work_dir.run_jj(["new", "root()", "-m=a"]).success();
478 work_dir
479 .run_jj(["new", "description(1)", "description(a)", "-m=2"])
480 .success();
481 work_dir.run_jj(["new", "-m=3"]).success();
482 insta::assert_snapshot!(get_log_output(&work_dir), @r"
483 @ 34da938ad94a 3 parents: 2
484 ○ 85d5043b881d 2 parents: 1 a
485 ├─╮
486 │ ○ 6d37472c632c a parents:
487 ○ │ 8b64ddff700d 1 parents:
488 ├─╯
489 ◆ 000000000000 parents:
490 [EOF]
491 ");
492
493 // Succeeds because the roots have the same parents.
494 work_dir.run_jj(["parallelize", "root().."]).success();
495 insta::assert_snapshot!(get_log_output(&work_dir), @r"
496 @ 3c90598481cd 3 parents:
497 │ ○ b96aa55582e5 2 parents:
498 ├─╯
499 │ ○ 6d37472c632c a parents:
500 ├─╯
501 │ ○ 8b64ddff700d 1 parents:
502 ├─╯
503 ◆ 000000000000 parents:
504 [EOF]
505 ");
506}
507
508#[test]
509fn test_parallelize_multiple_heads_with_different_children() {
510 let test_env = TestEnvironment::default();
511 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
512 let work_dir = test_env.work_dir("repo");
513 work_dir.run_jj(["commit", "-m=1"]).success();
514 work_dir.run_jj(["commit", "-m=2"]).success();
515 work_dir.run_jj(["commit", "-m=3"]).success();
516 work_dir.run_jj(["new", "root()"]).success();
517 work_dir.run_jj(["commit", "-m=a"]).success();
518 work_dir.run_jj(["commit", "-m=b"]).success();
519 work_dir.run_jj(["commit", "-m=c"]).success();
520 insta::assert_snapshot!(get_log_output(&work_dir), @r"
521 @ 4bc4dace0e65 parents: c
522 ○ 63b0da9212c0 c parents: b
523 ○ a7bf5001cfd8 b parents: a
524 ○ 6ca0450a05f5 a parents:
525 │ ○ 4cd999dfaac0 3 parents: 2
526 │ ○ d3902619fade 2 parents: 1
527 │ ○ 8b64ddff700d 1 parents:
528 ├─╯
529 ◆ 000000000000 parents:
530 [EOF]
531 ");
532
533 work_dir
534 .run_jj([
535 "parallelize",
536 "description(1)::description(2)",
537 "description(a)::description(b)",
538 ])
539 .success();
540 insta::assert_snapshot!(get_log_output(&work_dir), @r"
541 @ f6c9d9ee3db8 parents: c
542 ○ 62661d5f0c77 c parents: a b
543 ├─╮
544 │ ○ c9ea9058f5c7 b parents:
545 ○ │ 6ca0450a05f5 a parents:
546 ├─╯
547 │ ○ dac1be696563 3 parents: 1 2
548 │ ├─╮
549 │ │ ○ 7efea6c89b60 2 parents:
550 ├───╯
551 │ ○ 8b64ddff700d 1 parents:
552 ├─╯
553 ◆ 000000000000 parents:
554 [EOF]
555 ");
556}
557
558#[test]
559fn test_parallelize_multiple_roots_with_different_parents() {
560 let test_env = TestEnvironment::default();
561 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
562 let work_dir = test_env.work_dir("repo");
563 work_dir.run_jj(["commit", "-m=1"]).success();
564 work_dir.run_jj(["commit", "-m=2"]).success();
565 work_dir.run_jj(["new", "root()"]).success();
566 work_dir.run_jj(["commit", "-m=a"]).success();
567 work_dir.run_jj(["commit", "-m=b"]).success();
568 work_dir
569 .run_jj(["new", "description(2)", "description(b)", "-m=merged-head"])
570 .success();
571 insta::assert_snapshot!(get_log_output(&work_dir), @r"
572 @ ba4297d53c1a merged-head parents: 2 b
573 ├─╮
574 │ ○ 6577defaca2d b parents: a
575 │ ○ 1eb902150bb9 a parents:
576 ○ │ d3902619fade 2 parents: 1
577 ○ │ 8b64ddff700d 1 parents:
578 ├─╯
579 ◆ 000000000000 parents:
580 [EOF]
581 ");
582
583 work_dir
584 .run_jj(["parallelize", "description(2)::", "description(b)::"])
585 .success();
586 insta::assert_snapshot!(get_log_output(&work_dir), @r"
587 @ 0943ed52b3ed merged-head parents: 1 a
588 ├─╮
589 │ │ ○ 6577defaca2d b parents: a
590 │ ├─╯
591 │ ○ 1eb902150bb9 a parents:
592 │ │ ○ d3902619fade 2 parents: 1
593 ├───╯
594 ○ │ 8b64ddff700d 1 parents:
595 ├─╯
596 ◆ 000000000000 parents:
597 [EOF]
598 ");
599}
600
601#[test]
602fn test_parallelize_complex_nonlinear_target() {
603 let test_env = TestEnvironment::default();
604 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
605 let work_dir = test_env.work_dir("repo");
606 work_dir.run_jj(["new", "-m=0", "root()"]).success();
607 work_dir.run_jj(["new", "-m=1", "description(0)"]).success();
608 work_dir.run_jj(["new", "-m=2", "description(0)"]).success();
609 work_dir.run_jj(["new", "-m=3", "description(0)"]).success();
610 work_dir.run_jj(["new", "-m=4", "all:heads(..)"]).success();
611 work_dir
612 .run_jj(["new", "-m=1c", "description(1)"])
613 .success();
614 work_dir
615 .run_jj(["new", "-m=2c", "description(2)"])
616 .success();
617 work_dir
618 .run_jj(["new", "-m=3c", "description(3)"])
619 .success();
620 insta::assert_snapshot!(get_log_output(&work_dir), @r"
621 @ b043eb81416c 3c parents: 3
622 │ ○ 48277ee9afe0 4 parents: 3 2 1
623 ╭─┼─╮
624 ○ │ │ 944922f0c69f 3 parents: 0
625 │ │ │ ○ 9d28e8e38435 2c parents: 2
626 │ ├───╯
627 │ ○ │ 97d7522f40e8 2 parents: 0
628 ├─╯ │
629 │ ○ │ 6c82c22a5e35 1c parents: 1
630 │ ├─╯
631 │ ○ 0c058af014a6 1 parents: 0
632 ├─╯
633 ○ 745bea8029c1 0 parents:
634 ◆ 000000000000 parents:
635 [EOF]
636 ");
637
638 let output = work_dir.run_jj(["parallelize", "description(0)::description(4)"]);
639 insta::assert_snapshot!(output, @r"
640 ------- stderr -------
641 Working copy (@) now at: yostqsxw 59a216e5 (empty) 3c
642 Parent commit (@-) : rlvkpnrz 745bea80 (empty) 0
643 Parent commit (@-) : mzvwutvl cb944786 (empty) 3
644 [EOF]
645 ");
646 insta::assert_snapshot!(get_log_output(&work_dir), @r"
647 @ 59a216e537c4 3c parents: 0 3
648 ├─╮
649 │ ○ cb9447869bf0 3 parents:
650 │ │ ○ 248ce1ffd76b 2c parents: 0 2
651 ╭───┤
652 │ │ ○ 8f4b8ef68676 2 parents:
653 │ ├─╯
654 │ │ ○ 55c626d090e2 1c parents: 0 1
655 ╭───┤
656 │ │ ○ 82918d78c984 1 parents:
657 │ ├─╯
658 ○ │ 745bea8029c1 0 parents:
659 ├─╯
660 │ ○ 14ca4df576b3 4 parents:
661 ├─╯
662 ◆ 000000000000 parents:
663 [EOF]
664 ");
665}
666
667#[must_use]
668fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput {
669 let template = r#"
670 separate(" ",
671 commit_id.short(),
672 description.first_line(),
673 "parents:",
674 parents.map(|c|c.description().first_line())
675 )"#;
676 work_dir.run_jj(["log", "-T", template])
677}