Debian Codegraph @

cli/tests/test_evolog_command.rs

raw
1 // Copyright 2022 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
15 use crate::common::TestEnvironment;
16 use crate::common::to_toml_value;
17
18 #[test]
19 fn test_evolog_with_or_without_diff() {
20 let test_env = TestEnvironment::default();
21 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
22 let work_dir = test_env.work_dir("repo");
23
24 work_dir.write_file("file1", "foo\n");
25 work_dir.run_jj(["new", "-m", "my description"]).success();
26 work_dir.write_file("file1", "foo\nbar\n");
27 work_dir.write_file("file2", "foo\n");
28 work_dir
29 .run_jj(["rebase", "-r", "@", "-o", "root()"])
30 .success();
31 work_dir.write_file("file1", "resolved\n");
32
33 let output = work_dir.run_jj(["evolog"]);
34 insta::assert_snapshot!(output, @"
35 @ rlvkpnrz [email protected] 2001-02-03 08:05:10 33c10ace
36 │ my description
37 │ -- operation b78459d9d126 snapshot working copy
38 × rlvkpnrz/1 [email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
39 │ my description
40 │ -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
41 ○ rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 51e08f95 (hidden)
42 │ my description
43 │ -- operation 8c72466647e6 snapshot working copy
44 ○ rlvkpnrz/3 [email protected] 2001-02-03 08:05:08 b955b72e (hidden)
45 (empty) my description
46 -- operation 390d0e261e11 new empty commit
47 [EOF]
48 ");
49
50 // Color
51 let output = work_dir.run_jj(["--color=always", "evolog"]);
52 insta::assert_snapshot!(output, @"
53 @ rlvkpnrz [38;5;[email protected] 2001-02-03 08:05:10 33c10ace
54 │ my description
55 │ -- operation b78459d9d126 snapshot working copy
56 × rlvkpnrz/1 [38;5;[email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
57 │ my description
58 │ -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
59 ○ rlvkpnrz/2 [38;5;[email protected] 2001-02-03 08:05:09 51e08f95 (hidden)
60 │ my description
61 │ -- operation 8c72466647e6 snapshot working copy
62 ○ rlvkpnrz/3 [38;5;[email protected] 2001-02-03 08:05:08 b955b72e (hidden)
63 (empty) my description
64 -- operation 390d0e261e11 new empty commit
65 [EOF]
66 ");
67
68 // There should be no diff caused by the rebase because it was a pure rebase
69 // (even even though it resulted in a conflict).
70 let output = work_dir.run_jj(["evolog", "-p"]);
71 insta::assert_snapshot!(output, @r#"
72 @ rlvkpnrz [email protected] 2001-02-03 08:05:10 33c10ace
73 │ my description
74 │ -- operation b78459d9d126 snapshot working copy
75 │ Resolved conflict in file1:
76 │ 1 : <<<<<<< conflict 1 of 1
77 │ 2 : %%%%%%% diff from: qpvuntsm c664a51b (parents of rebased revision)
78 │ 3 : \\\\\\\ to: zzzzzzzz 00000000 (rebase destination)
79 │ 4 : -foo
80 │ 5 : +++++++ rlvkpnrz 51e08f95 "my description" (rebased revision)
81 │ 6 : foo
82 │ 7 : bar
83 │ 8 : >>>>>>> conflict 1 of 1 ends
84 │ 1: resolved
85 × rlvkpnrz/1 [email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
86 │ my description
87 │ -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
88 ○ rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 51e08f95 (hidden)
89 │ my description
90 │ -- operation 8c72466647e6 snapshot working copy
91 │ Modified regular file file1:
92 │ 1 1: foo
93 │ 2: bar
94 │ Added regular file file2:
95 │ 1: foo
96 ○ rlvkpnrz/3 [email protected] 2001-02-03 08:05:08 b955b72e (hidden)
97 (empty) my description
98 -- operation 390d0e261e11 new empty commit
99 Modified commit description:
100 1: my description
101 [EOF]
102 "#);
103
104 // Multiple starting revisions
105 let output = work_dir.run_jj(["evolog", "-r.."]);
106 insta::assert_snapshot!(output, @"
107 @ rlvkpnrz [email protected] 2001-02-03 08:05:10 33c10ace
108 │ my description
109 │ -- operation b78459d9d126 snapshot working copy
110 × rlvkpnrz/1 [email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
111 │ my description
112 │ -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
113 ○ rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 51e08f95 (hidden)
114 │ my description
115 │ -- operation 8c72466647e6 snapshot working copy
116 ○ rlvkpnrz/3 [email protected] 2001-02-03 08:05:08 b955b72e (hidden)
117 (empty) my description
118 -- operation 390d0e261e11 new empty commit
119 ○ qpvuntsm [email protected] 2001-02-03 08:05:08 c664a51b
120 │ (no description set)
121 │ -- operation 919afc102de5 snapshot working copy
122 ○ qpvuntsm/1 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
123 (empty) (no description set)
124 -- operation f63ee16f9553 add workspace 'default'
125 [EOF]
126 ");
127
128 // Test `--limit`
129 let output = work_dir.run_jj(["evolog", "--limit=2"]);
130 insta::assert_snapshot!(output, @"
131 @ rlvkpnrz [email protected] 2001-02-03 08:05:10 33c10ace
132 │ my description
133 │ -- operation b78459d9d126 snapshot working copy
134 × rlvkpnrz/1 [email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
135 │ my description
136 │ -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
137 [EOF]
138 ");
139
140 // Test `--no-graph`
141 let output = work_dir.run_jj(["evolog", "--no-graph"]);
142 insta::assert_snapshot!(output, @"
143 rlvkpnrz [email protected] 2001-02-03 08:05:10 33c10ace
144 my description
145 -- operation b78459d9d126 snapshot working copy
146 rlvkpnrz/1 [email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
147 my description
148 -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
149 rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 51e08f95 (hidden)
150 my description
151 -- operation 8c72466647e6 snapshot working copy
152 rlvkpnrz/3 [email protected] 2001-02-03 08:05:08 b955b72e (hidden)
153 (empty) my description
154 -- operation 390d0e261e11 new empty commit
155 [EOF]
156 ");
157
158 // Test `--git` format, and that it implies `-p`
159 let output = work_dir.run_jj(["evolog", "--no-graph", "--git"]);
160 insta::assert_snapshot!(output, @r#"
161 rlvkpnrz [email protected] 2001-02-03 08:05:10 33c10ace
162 my description
163 -- operation b78459d9d126 snapshot working copy
164 diff --git a/file1 b/file1
165 index 0000000000..2ab19ae607 100644
166 --- a/file1
167 +++ b/file1
168 @@ -1,8 +1,1 @@
169 -<<<<<<< conflict 1 of 1
170 -%%%%%%% diff from: qpvuntsm c664a51b (parents of rebased revision)
171 -\\\\\\\ to: zzzzzzzz 00000000 (rebase destination)
172 --foo
173 -+++++++ rlvkpnrz 51e08f95 "my description" (rebased revision)
174 -foo
175 -bar
176 ->>>>>>> conflict 1 of 1 ends
177 +resolved
178 rlvkpnrz/1 [email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
179 my description
180 -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
181 rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 51e08f95 (hidden)
182 my description
183 -- operation 8c72466647e6 snapshot working copy
184 diff --git a/file1 b/file1
185 index 257cc5642c..3bd1f0e297 100644
186 --- a/file1
187 +++ b/file1
188 @@ -1,1 +1,2 @@
189 foo
190 +bar
191 diff --git a/file2 b/file2
192 new file mode 100644
193 index 0000000000..257cc5642c
194 --- /dev/null
195 +++ b/file2
196 @@ -0,0 +1,1 @@
197 +foo
198 rlvkpnrz/3 [email protected] 2001-02-03 08:05:08 b955b72e (hidden)
199 (empty) my description
200 -- operation 390d0e261e11 new empty commit
201 diff --git a/JJ-COMMIT-DESCRIPTION b/JJ-COMMIT-DESCRIPTION
202 --- JJ-COMMIT-DESCRIPTION
203 +++ JJ-COMMIT-DESCRIPTION
204 @@ -0,0 +1,1 @@
205 +my description
206 [EOF]
207 "#);
208 }
209
210 #[test]
211 fn test_evolog_template() {
212 let test_env = TestEnvironment::default();
213
214 test_env
215 .run_jj_in(".", ["git", "init", "--colocate", "origin"])
216 .success();
217 let origin_dir = test_env.work_dir("origin");
218 origin_dir
219 .run_jj(["bookmark", "set", "-r@", "main"])
220 .success();
221
222 test_env
223 .run_jj_in(".", ["git", "clone", "origin", "local"])
224 .success();
225 let work_dir = test_env.work_dir("local");
226
227 // default template with operation
228 let output = work_dir.run_jj(["evolog", "-r@"]);
229 insta::assert_snapshot!(output, @"
230 @ kkmpptxz [email protected] 2001-02-03 08:05:09 2b17ac71
231 (empty) (no description set)
232 -- operation 378fe523fc0a add workspace 'default'
233 [EOF]
234 ");
235 let output = work_dir.run_jj(["evolog", "-r@", "--color=debug"]);
236 insta::assert_snapshot!(output, @"
237 <<evolog commit node working_copy mutable::@>> <<evolog working_copy mutable commit change_id shortest prefix::k>><<evolog working_copy mutable commit change_id shortest rest::kmpptxz>><<evolog working_copy mutable:: >><<evolog working_copy mutable commit author email local::test.user>><<evolog working_copy mutable commit author email::@>><<evolog working_copy mutable commit author email domain::example.com>><<evolog working_copy mutable:: >><<evolog working_copy mutable commit committer timestamp local format::2001-02-03 08:05:09>><<evolog working_copy mutable:: >><<evolog working_copy mutable commit commit_id shortest prefix::2>><<evolog working_copy mutable commit commit_id shortest rest::b17ac71>><<evolog working_copy mutable::>>
238 <<evolog working_copy mutable empty::(empty)>><<evolog working_copy mutable:: >><<evolog working_copy mutable empty description placeholder::(no description set)>><<evolog working_copy mutable::>>
239 <<evolog separator::-->><<evolog:: operation >><<evolog operation id short::378fe523fc0a>><<evolog:: >><<evolog operation description first_line::add workspace 'default'>><<evolog::>>
240 [EOF]
241 ");
242
243 // default template without operation
244 let output = work_dir.run_jj(["evolog", "-rmain@origin"]);
245 insta::assert_snapshot!(output, @"
246 ◆ qpvuntsm [email protected] 2001-02-03 08:05:07 main@origin e8849ae1
247 (empty) (no description set)
248 [EOF]
249 ");
250 let output = work_dir.run_jj(["evolog", "-rmain@origin", "--color=debug"]);
251 insta::assert_snapshot!(output, @"
252 <<evolog commit node immutable::◆>> <<evolog immutable commit change_id shortest prefix::q>><<evolog immutable commit change_id shortest rest::pvuntsm>><<evolog immutable:: >><<evolog immutable commit author email local::test.user>><<evolog immutable commit author email::@>><<evolog immutable commit author email domain::example.com>><<evolog immutable:: >><<evolog immutable commit committer timestamp local format::2001-02-03 08:05:07>><<evolog immutable:: >><<evolog immutable commit bookmarks name::main>><<evolog immutable commit bookmarks::@>><<evolog immutable commit bookmarks remote::origin>><<evolog immutable:: >><<evolog immutable commit commit_id shortest prefix::e>><<evolog immutable commit commit_id shortest rest::8849ae1>><<evolog immutable::>>
253 <<evolog immutable empty::(empty)>><<evolog immutable:: >><<evolog immutable empty description placeholder::(no description set)>><<evolog immutable::>>
254 [EOF]
255 ");
256
257 // default template with root commit
258 let output = work_dir.run_jj(["evolog", "-rroot()"]);
259 insta::assert_snapshot!(output, @"
260 ◆ zzzzzzzz root() 00000000
261 [EOF]
262 ");
263 let output = work_dir.run_jj(["evolog", "-rroot()", "--color=debug"]);
264 insta::assert_snapshot!(output, @"
265 <<evolog commit node immutable::◆>> <<evolog immutable commit change_id shortest prefix::z>><<evolog immutable commit change_id shortest rest::zzzzzzz>><<evolog immutable:: >><<evolog immutable root::root()>><<evolog immutable:: >><<evolog immutable commit commit_id shortest prefix::0>><<evolog immutable commit commit_id shortest rest::0000000>><<evolog immutable::>>
266 [EOF]
267 ");
268
269 // JSON output with operation
270 let output = work_dir.run_jj(["evolog", "-r@", "-Tjson(self)", "--no-graph"]);
271 insta::assert_snapshot!(output, @r#"{"commit":{"commit_id":"2b17ac719c7db025e2514f5708d2b0328fc6b268","parents":["0000000000000000000000000000000000000000"],"change_id":"kkmpptxzrspxrzommnulwmwkkqwworpl","description":"","author":{"name":"Test User","email":"[email protected]","timestamp":"2001-02-03T04:05:09+07:00"},"committer":{"name":"Test User","email":"[email protected]","timestamp":"2001-02-03T04:05:09+07:00"}},"operation":{"id":"378fe523fc0ae9ac17af7eee7ce6a8d87f23cb97ecdb27ca0c75892948f1ccd979d48c3dbb201c360328ce0f92bcf3ca5c8d64da61d49543403086da315bd54f","parents":["00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"],"time":{"start":"2001-02-03T04:05:09+07:00","end":"2001-02-03T04:05:09+07:00"},"description":"add workspace 'default'","hostname":"host.example.com","username":"test-username","is_snapshot":false,"workspace_name":null,"attributes":{}}}[EOF]"#);
272
273 // JSON output without operation
274 let output = work_dir.run_jj(["evolog", "-rmain@origin", "-Tjson(self)", "--no-graph"]);
275 insta::assert_snapshot!(output, @r#"{"commit":{"commit_id":"e8849ae12c709f2321908879bc724fdb2ab8a781","parents":["0000000000000000000000000000000000000000"],"change_id":"qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu","description":"","author":{"name":"Test User","email":"[email protected]","timestamp":"2001-02-03T04:05:07+07:00"},"committer":{"name":"Test User","email":"[email protected]","timestamp":"2001-02-03T04:05:07+07:00"}},"operation":null}[EOF]"#);
276 }
277
278 #[test]
279 fn test_evolog_with_custom_symbols() {
280 let test_env = TestEnvironment::default();
281 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
282 let work_dir = test_env.work_dir("repo");
283
284 work_dir.write_file("file1", "foo\n");
285 work_dir.run_jj(["new", "-m", "my description"]).success();
286 work_dir.write_file("file1", "foo\nbar\n");
287 work_dir.write_file("file2", "foo\n");
288 work_dir
289 .run_jj(["rebase", "-r", "@", "-o", "root()"])
290 .success();
291 work_dir.write_file("file1", "resolved\n");
292
293 let config = "templates.log_node='if(current_working_copy, \"$\", \"┝\")'";
294 let output = work_dir.run_jj(["evolog", "--config", config]);
295
296 insta::assert_snapshot!(output, @"
297 $ rlvkpnrz [email protected] 2001-02-03 08:05:10 33c10ace
298 │ my description
299 │ -- operation 68c3f8867818 snapshot working copy
300 ┝ rlvkpnrz/1 [email protected] 2001-02-03 08:05:09 cdf175ef (hidden) (conflict)
301 │ my description
302 │ -- operation b2a0c4f0aa5d rebase commit 51e08f95160c897080d035d330aead3ee6ed5588
303 ┝ rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 51e08f95 (hidden)
304 │ my description
305 │ -- operation 8c72466647e6 snapshot working copy
306 ┝ rlvkpnrz/3 [email protected] 2001-02-03 08:05:08 b955b72e (hidden)
307 (empty) my description
308 -- operation 390d0e261e11 new empty commit
309 [EOF]
310 ");
311 }
312
313 #[test]
314 fn test_evolog_word_wrap() {
315 let test_env = TestEnvironment::default();
316 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
317 let work_dir = test_env.work_dir("repo");
318 let render = |args: &[&str], columns: u32, word_wrap: bool| {
319 let word_wrap = to_toml_value(word_wrap);
320 work_dir.run_jj_with(|cmd| {
321 cmd.args(args)
322 .arg(format!("--config=ui.log-word-wrap={word_wrap}"))
323 .env("COLUMNS", columns.to_string())
324 })
325 };
326
327 work_dir.run_jj(["describe", "-m", "first"]).success();
328
329 // ui.log-word-wrap option applies to both graph/no-graph outputs
330 insta::assert_snapshot!(render(&["evolog"], 40, false), @"
331 @ qpvuntsm [email protected] 2001-02-03 08:05:08 68a50538
332 │ (empty) first
333 │ -- operation 1e1a8ca9529a describe commit e8849ae12c709f2321908879bc724fdb2ab8a781
334 ○ qpvuntsm/1 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
335 (empty) (no description set)
336 -- operation f63ee16f9553 add workspace 'default'
337 [EOF]
338 ");
339 insta::assert_snapshot!(render(&["evolog"], 40, true), @"
340 @ qpvuntsm [email protected]
341 │ 2001-02-03 08:05:08 68a50538
342 │ (empty) first
343 │ -- operation 1e1a8ca9529a describe
344 │ commit
345 │ e8849ae12c709f2321908879bc724fdb2ab8a781
346 ○ qpvuntsm/1 [email protected]
347 2001-02-03 08:05:07 e8849ae1 (hidden)
348 (empty) (no description set)
349 -- operation f63ee16f9553 add
350 workspace 'default'
351 [EOF]
352 ");
353 insta::assert_snapshot!(render(&["evolog", "--no-graph"], 40, false), @"
354 qpvuntsm [email protected] 2001-02-03 08:05:08 68a50538
355 (empty) first
356 -- operation 1e1a8ca9529a describe commit e8849ae12c709f2321908879bc724fdb2ab8a781
357 qpvuntsm/1 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
358 (empty) (no description set)
359 -- operation f63ee16f9553 add workspace 'default'
360 [EOF]
361 ");
362 insta::assert_snapshot!(render(&["evolog", "--no-graph"], 40, true), @"
363 qpvuntsm [email protected]
364 2001-02-03 08:05:08 68a50538
365 (empty) first
366 -- operation 1e1a8ca9529a describe
367 commit
368 e8849ae12c709f2321908879bc724fdb2ab8a781
369 qpvuntsm/1 [email protected]
370 2001-02-03 08:05:07 e8849ae1 (hidden)
371 (empty) (no description set)
372 -- operation f63ee16f9553 add workspace
373 'default'
374 [EOF]
375 ");
376 }
377
378 #[test]
379 fn test_evolog_squash() {
380 let test_env = TestEnvironment::default();
381 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
382 let work_dir = test_env.work_dir("repo");
383
384 work_dir.run_jj(["describe", "-m", "first"]).success();
385 work_dir.write_file("file1", "foo\n");
386 work_dir.run_jj(["new", "-m", "second"]).success();
387 work_dir.write_file("file1", "foo\nbar\n");
388
389 // not partial
390 work_dir.run_jj(["squash", "-m", "squashed 1"]).success();
391
392 work_dir.run_jj(["describe", "-m", "third"]).success();
393 work_dir.write_file("file1", "foo\nbar\nbaz\n");
394 work_dir.write_file("file2", "foo2\n");
395 work_dir.write_file("file3", "foo3\n");
396
397 // partial
398 work_dir
399 .run_jj(["squash", "-m", "squashed 2", "file1"])
400 .success();
401
402 work_dir.run_jj(["new", "-m", "fourth"]).success();
403 work_dir.write_file("file4", "foo4\n");
404
405 work_dir.run_jj(["new", "-m", "fifth"]).success();
406 work_dir.write_file("file5", "foo5\n");
407
408 // multiple sources
409 work_dir
410 .run_jj([
411 "squash",
412 "-msquashed 3",
413 "--from=subject(fourth)|subject(fifth)",
414 "--into=subject(squash*)",
415 ])
416 .success();
417
418 let output = work_dir.run_jj(["evolog", "-p", "-rsubject(squash*)"]);
419 insta::assert_snapshot!(output, @r"
420 ○ qpvuntsm [email protected] 2001-02-03 08:05:15 5f3281c6
421 ├─┬─╮ squashed 3
422 │ │ │ -- operation ce2492756a0d squash commits into 5ec0619af5cb4f7707a556a71a6f96af0bc294d2
423 │ │ │ Modified commit description:
424 │ │ │ 1 : <<<<<<< conflict 1 of 1
425 │ │ │ 2 : +++++++ side #1
426 │ │ │ 3 : squashed 2
427 │ │ │ 4 : %%%%%%% diff from: base #1
428 │ │ │ 5 : \\\\\\\ to: side #2
429 │ │ │ 6 : +fourth
430 │ │ │ 7 : %%%%%%% diff from: base #2
431 │ │ │ 8 : \\\\\\\ to: side #3
432 │ │ │ 9 : +fifth
433 │ │ │ 10 : >>>>>>> conflict 1 of 1 ends
434 │ │ │ 1: squashed 3
435 │ │ ○ vruxwmqv/0 [email protected] 2001-02-03 08:05:15 770795d0 (hidden)
436 │ │ │ fifth
437 │ │ │ -- operation ac8d9eefabd0 snapshot working copy
438 │ │ │ Added regular file file5:
439 │ │ │ 1: foo5
440 │ │ ○ vruxwmqv/1 [email protected] 2001-02-03 08:05:14 2e0123d1 (hidden)
441 │ │ (empty) fifth
442 │ │ -- operation 3906ce22eb5a new empty commit
443 │ │ Modified commit description:
444 │ │ 1: fifth
445 │ ○ yqosqzyt/0 [email protected] 2001-02-03 08:05:14 ea8161b6 (hidden)
446 │ │ fourth
447 │ │ -- operation 57bb636dabb8 snapshot working copy
448 │ │ Added regular file file4:
449 │ │ 1: foo4
450 │ ○ yqosqzyt/1 [email protected] 2001-02-03 08:05:13 1de5fdb6 (hidden)
451 │ (empty) fourth
452 │ -- operation 899b98063159 new empty commit
453 │ Modified commit description:
454 │ 1: fourth
455 ○ qpvuntsm/1 [email protected] 2001-02-03 08:05:12 5ec0619a (hidden)
456 ├─╮ squashed 2
457 │ │ -- operation 6fdaa0b09c18 squash commits into 690858846504af0e42fde980fdacf9851559ebb8
458 │ │ Modified commit description:
459 │ │ 1 : <<<<<<< conflict 1 of 1
460 │ │ 2 : +++++++ side #1
461 │ │ 3 : squashed 1
462 │ │ 4 : %%%%%%% diff from: base
463 │ │ 5 : \\\\\\\ to: side #2
464 │ │ 6 : +third
465 │ │ 7 : >>>>>>> conflict 1 of 1 ends
466 │ │ 1: squashed 2
467 │ │ Removed regular file file2:
468 │ │ 1 : foo2
469 │ │ Removed regular file file3:
470 │ │ 1 : foo3
471 │ ○ zsuskuln/3 [email protected] 2001-02-03 08:05:12 cce957f1 (hidden)
472 │ │ third
473 │ │ -- operation d4dd3f693233 snapshot working copy
474 │ │ Modified regular file file1:
475 │ │ 1 1: foo
476 │ │ 2 2: bar
477 │ │ 3: baz
478 │ │ Added regular file file2:
479 │ │ 1: foo2
480 │ │ Added regular file file3:
481 │ │ 1: foo3
482 │ ○ zsuskuln/4 [email protected] 2001-02-03 08:05:11 3a2a4253 (hidden)
483 │ │ (empty) third
484 │ │ -- operation 33e1d3ed9731 describe commit ebec10f449ad7ab92c7293efab5e3db2d8e9fea1
485 │ │ Modified commit description:
486 │ │ 1: third
487 │ ○ zsuskuln/5 [email protected] 2001-02-03 08:05:10 ebec10f4 (hidden)
488 │ (empty) (no description set)
489 │ -- operation 5e3953f66df8 squash commits into 5878cbe03cdf599c9353e5a1a52a01f4c5e0e0fa
490 ○ qpvuntsm/2 [email protected] 2001-02-03 08:05:10 69085884 (hidden)
491 ├─╮ squashed 1
492 │ │ -- operation 5e3953f66df8 squash commits into 5878cbe03cdf599c9353e5a1a52a01f4c5e0e0fa
493 │ │ Modified commit description:
494 │ │ 1 : <<<<<<< conflict 1 of 1
495 │ │ 2 : %%%%%%% diff from: base
496 │ │ 3 : \\\\\\\ to: side #1
497 │ │ 4 : +first
498 │ │ 5 : +++++++ side #2
499 │ │ 6 : second
500 │ │ 7 : >>>>>>> conflict 1 of 1 ends
501 │ │ 1: squashed 1
502 │ ○ kkmpptxz/0 [email protected] 2001-02-03 08:05:10 a3759c9d (hidden)
503 │ │ second
504 │ │ -- operation 41aaffdd1249 snapshot working copy
505 │ │ Modified regular file file1:
506 │ │ 1 1: foo
507 │ │ 2: bar
508 │ ○ kkmpptxz/1 [email protected] 2001-02-03 08:05:09 a5b2f625 (hidden)
509 │ (empty) second
510 │ -- operation 624750bb3872 new empty commit
511 │ Modified commit description:
512 │ 1: second
513 ○ qpvuntsm/3 [email protected] 2001-02-03 08:05:09 5878cbe0 (hidden)
514 │ first
515 │ -- operation 6959849352e5 snapshot working copy
516 │ Added regular file file1:
517 │ 1: foo
518 ○ qpvuntsm/4 [email protected] 2001-02-03 08:05:08 68a50538 (hidden)
519 │ (empty) first
520 │ -- operation 1e1a8ca9529a describe commit e8849ae12c709f2321908879bc724fdb2ab8a781
521 │ Modified commit description:
522 │ 1: first
523 ○ qpvuntsm/5 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
524 (empty) (no description set)
525 -- operation f63ee16f9553 add workspace 'default'
526 [EOF]
527 ");
528 }
529
530 #[test]
531 fn test_evolog_abandoned_op() {
532 let test_env = TestEnvironment::default();
533 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
534 let work_dir = test_env.work_dir("repo");
535
536 work_dir.write_file("file1", "");
537 work_dir.run_jj(["describe", "-mfile1"]).success();
538 work_dir.write_file("file2", "");
539 work_dir.run_jj(["describe", "-mfile2"]).success();
540
541 insta::assert_snapshot!(work_dir.run_jj(["evolog", "--summary"]), @"
542 @ qpvuntsm [email protected] 2001-02-03 08:05:09 e1869e5d
543 │ file2
544 │ -- operation d8b6fd24ba81 describe commit 32cabcfa05c604a36074d74ae59964e4e5eb18e9
545 ○ qpvuntsm/1 [email protected] 2001-02-03 08:05:09 32cabcfa (hidden)
546 │ file1
547 │ -- operation 8d538c10fa39 snapshot working copy
548 │ A file2
549 ○ qpvuntsm/2 [email protected] 2001-02-03 08:05:08 cb5ebdc6 (hidden)
550 │ file1
551 │ -- operation 7f39e29a02f6 describe commit 093c3c9624b6cfe22b310586f5638792aa80e6d7
552 ○ qpvuntsm/3 [email protected] 2001-02-03 08:05:08 093c3c96 (hidden)
553 │ (no description set)
554 │ -- operation c2b5918d8499 snapshot working copy
555 │ A file1
556 ○ qpvuntsm/4 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
557 (empty) (no description set)
558 -- operation f63ee16f9553 add workspace 'default'
559 [EOF]
560 ");
561
562 // Truncate up to the last "describe -mfile2" operation
563 work_dir.run_jj(["op", "abandon", "..@-"]).success();
564
565 // Unreachable predecessors are omitted, therefore the bottom commit shows
566 // diffs from the empty tree.
567 insta::assert_snapshot!(work_dir.run_jj(["evolog", "--summary"]), @"
568 @ qpvuntsm [email protected] 2001-02-03 08:05:09 e1869e5d
569 │ file2
570 │ -- operation 942cfd389e43 describe commit 32cabcfa05c604a36074d74ae59964e4e5eb18e9
571 ○ qpvuntsm/1 [email protected] 2001-02-03 08:05:09 32cabcfa (hidden)
572 file1
573 A file1
574 A file2
575 [EOF]
576 ");
577 }
578
579 #[test]
580 fn test_evolog_with_no_template() {
581 let test_env = TestEnvironment::default();
582 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
583 let work_dir = test_env.work_dir("repo");
584
585 let output = work_dir.run_jj(["evolog", "-T"]);
586 insta::assert_snapshot!(output, @"
587 ------- stderr -------
588 error: a value is required for '--template <TEMPLATE>' but none was supplied
589
590 For more information, try '--help'.
591 Hint: The following template aliases are defined:
592 - builtin_config_list
593 - builtin_config_list_detailed
594 - builtin_draft_commit_description
595 - builtin_draft_commit_description_with_diff
596 - builtin_evolog_compact
597 - builtin_log_comfortable
598 - builtin_log_compact
599 - builtin_log_compact_full_description
600 - builtin_log_detailed
601 - builtin_log_node
602 - builtin_log_node_ascii
603 - builtin_log_oneline
604 - builtin_log_redacted
605 - builtin_op_log_comfortable
606 - builtin_op_log_compact
607 - builtin_op_log_node
608 - builtin_op_log_node_ascii
609 - builtin_op_log_oneline
610 - builtin_op_log_redacted
611 - builtin_workspace_list
612 - commit_summary_separator
613 - default_commit_description
614 - description_placeholder
615 - email_placeholder
616 - empty_commit_marker
617 - git_format_patch_email_headers
618 - name_placeholder
619 [EOF]
620 [exit status: 2]
621 ");
622 }
623
624 #[test]
625 fn test_evolog_reversed_no_graph() {
626 let test_env = TestEnvironment::default();
627 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
628 let work_dir = test_env.work_dir("repo");
629
630 work_dir.run_jj(["describe", "-m", "a"]).success();
631 work_dir.run_jj(["describe", "-m", "b"]).success();
632 work_dir.run_jj(["describe", "-m", "c"]).success();
633 let output = work_dir.run_jj(["evolog", "--reversed", "--no-graph"]);
634 insta::assert_snapshot!(output, @"
635 qpvuntsm/3 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
636 (empty) (no description set)
637 -- operation f63ee16f9553 add workspace 'default'
638 qpvuntsm/2 [email protected] 2001-02-03 08:05:08 b86e28cd (hidden)
639 (empty) a
640 -- operation d3f27026b8a8 describe commit e8849ae12c709f2321908879bc724fdb2ab8a781
641 qpvuntsm/1 [email protected] 2001-02-03 08:05:09 9f43967b (hidden)
642 (empty) b
643 -- operation 33dc6bc64b41 describe commit b86e28cd6862624ad77e1aaf31e34b2c7545bebd
644 qpvuntsm [email protected] 2001-02-03 08:05:10 b28cda4b
645 (empty) c
646 -- operation a87d22b54fb2 describe commit 9f43967b1cdbce4ab322cb7b4636fc0362c38373
647 [EOF]
648 ");
649
650 let output = work_dir.run_jj(["evolog", "--limit=2", "--reversed", "--no-graph"]);
651 insta::assert_snapshot!(output, @"
652 qpvuntsm/1 [email protected] 2001-02-03 08:05:09 9f43967b (hidden)
653 (empty) b
654 -- operation 33dc6bc64b41 describe commit b86e28cd6862624ad77e1aaf31e34b2c7545bebd
655 qpvuntsm [email protected] 2001-02-03 08:05:10 b28cda4b
656 (empty) c
657 -- operation a87d22b54fb2 describe commit 9f43967b1cdbce4ab322cb7b4636fc0362c38373
658 [EOF]
659 ");
660 }
661
662 #[test]
663 fn test_evolog_reverse_with_graph() {
664 let test_env = TestEnvironment::default();
665 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
666 let work_dir = test_env.work_dir("repo");
667
668 work_dir.run_jj(["describe", "-m", "a"]).success();
669 work_dir.run_jj(["describe", "-m", "b"]).success();
670 work_dir.run_jj(["describe", "-m", "c"]).success();
671 work_dir
672 .run_jj(["new", "-r", "subject(c)", "-m", "d"])
673 .success();
674 work_dir
675 .run_jj(["new", "-r", "subject(c)", "-m", "e"])
676 .success();
677 work_dir
678 .run_jj([
679 "squash",
680 "--from=subject(d)|subject(e)",
681 "--to=subject(c)",
682 "-m",
683 "c+d+e",
684 ])
685 .success();
686 let output = work_dir.run_jj(["evolog", "-r", "subject(c+d+e)", "--reversed"]);
687 insta::assert_snapshot!(output, @"
688 ○ qpvuntsm/4 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
689 │ (empty) (no description set)
690 │ -- operation f63ee16f9553 add workspace 'default'
691 ○ qpvuntsm/3 [email protected] 2001-02-03 08:05:08 b86e28cd (hidden)
692 │ (empty) a
693 │ -- operation d3f27026b8a8 describe commit e8849ae12c709f2321908879bc724fdb2ab8a781
694 ○ qpvuntsm/2 [email protected] 2001-02-03 08:05:09 9f43967b (hidden)
695 │ (empty) b
696 │ -- operation 33dc6bc64b41 describe commit b86e28cd6862624ad77e1aaf31e34b2c7545bebd
697 ○ qpvuntsm/1 [email protected] 2001-02-03 08:05:10 b28cda4b (hidden)
698 │ (empty) c
699 │ -- operation a87d22b54fb2 describe commit 9f43967b1cdbce4ab322cb7b4636fc0362c38373
700 │ ○ mzvwutvl/0 [email protected] 2001-02-03 08:05:11 6a4ff8aa (hidden)
701 ├─╯ (empty) d
702 │ -- operation 8baeb4813719 new empty commit
703 │ ○ royxmykx/0 [email protected] 2001-02-03 08:05:12 7dea2d1d (hidden)
704 ├─╯ (empty) e
705 │ -- operation 9bdd877c3495 new empty commit
706 ○ qpvuntsm [email protected] 2001-02-03 08:05:13 78fdd026
707 (empty) c+d+e
708 -- operation e91587b8968e squash commits into b28cda4b118fc50495ca34a24f030abc078d032e
709 [EOF]
710 ");
711
712 let output = work_dir.run_jj(["evolog", "-rsubject(c+d+e)", "--limit=3", "--reversed"]);
713 insta::assert_snapshot!(output, @"
714 ○ mzvwutvl/0 [email protected] 2001-02-03 08:05:11 6a4ff8aa (hidden)
715 │ (empty) d
716 │ -- operation 8baeb4813719 new empty commit
717 │ ○ royxmykx/0 [email protected] 2001-02-03 08:05:12 7dea2d1d (hidden)
718 ├─╯ (empty) e
719 │ -- operation 9bdd877c3495 new empty commit
720 ○ qpvuntsm [email protected] 2001-02-03 08:05:13 78fdd026
721 (empty) c+d+e
722 -- operation e91587b8968e squash commits into b28cda4b118fc50495ca34a24f030abc078d032e
723 [EOF]
724 ");
725 }
726
727 #[test]
728 fn test_evolog_template_predecessors_and_inter_diff() {
729 let test_env = TestEnvironment::default();
730 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
731 let work_dir = test_env.work_dir("repo");
732
733 // Base change "c".
734 work_dir.run_jj(["describe", "-m", "c"]).success();
735
736 // Two sibling changes to be squashed into "c".
737 work_dir
738 .run_jj(["new", "-r", "subject(c)", "-m", "d"])
739 .success();
740 work_dir.write_file("file1", "d\n");
741 work_dir.write_file("file2", "d\n");
742
743 // Test inter_diff with fileset argument before squash.
744 let output = work_dir
745 .run_jj([
746 "evolog",
747 "-r@",
748 r#"-T=builtin_evolog_compact ++ self.inter_diff("file1").git()"#,
749 ])
750 .success();
751 insta::assert_snapshot!(output, @"
752 @ kkmpptxz [email protected] 2001-02-03 08:05:10 c6106cde
753 │ d
754 │ -- operation 6561c201f04a snapshot working copy
755 │ diff --git a/file1 b/file1
756 │ new file mode 100644
757 │ index 0000000000..4bcfe98e64
758 │ --- /dev/null
759 │ +++ b/file1
760 │ @@ -0,0 +1,1 @@
761 │ +d
762 ○ kkmpptxz/1 [email protected] 2001-02-03 08:05:09 780d27be (hidden)
763 (empty) d
764 -- operation f0e828390851 new empty commit
765 [EOF]
766 ");
767
768 work_dir
769 .run_jj(["new", "-r", "subject(c)", "-m", "e"])
770 .success();
771 work_dir.write_file("file3", "e\n");
772
773 // Squash both changes into "c". This should record multiple predecessors
774 // for the rewritten commit (previous version of "c" + squashed commits).
775 work_dir
776 .run_jj([
777 "squash",
778 "--from=subject(d)|subject(e)",
779 "--to=subject(c)",
780 "-m",
781 "c+d+e",
782 ])
783 .success();
784
785 // The rewritten commit has multiple predecessors. `inter_diff()` should be
786 // empty because it's computed against predecessor trees rebased onto the
787 // destination parents.
788 let output = work_dir
789 .run_jj([
790 "evolog",
791 "-rsubject(c+d+e)",
792 r#"-T=builtin_evolog_compact ++ separate("\n", "predecessors: " ++ predecessors.map(|c| c.commit_id().shortest(8)).join(","), inter_diff.summary())"#,
793 ])
794 .success();
795 insta::assert_snapshot!(output, @"
796 ○ qpvuntsm [email protected] 2001-02-03 08:05:12 92850c35
797 ├─┬─╮ c+d+e
798 │ │ │ -- operation e306add442b0 squash commits into e3ce68f48b53d16111a1310c7f417a39c2934931
799 │ │ │ predecessors: e3ce68f4,c6106cde,870e49d7
800 │ │ ○ mzvwutvl/0 [email protected] 2001-02-03 08:05:12 870e49d7 (hidden)
801 │ │ │ e
802 │ │ │ -- operation cf23ca301b6e snapshot working copy
803 │ │ │ predecessors: 3345e308
804 │ │ │ A file3
805 │ │ ○ mzvwutvl/1 [email protected] 2001-02-03 08:05:11 3345e308 (hidden)
806 │ │ (empty) e
807 │ │ -- operation f4ef2c58934a new empty commit
808 │ │ predecessors:
809 │ ○ kkmpptxz/0 [email protected] 2001-02-03 08:05:10 c6106cde (hidden)
810 │ │ d
811 │ │ -- operation 6561c201f04a snapshot working copy
812 │ │ predecessors: 780d27be
813 │ │ A file1
814 │ │ A file2
815 │ ○ kkmpptxz/1 [email protected] 2001-02-03 08:05:09 780d27be (hidden)
816 │ (empty) d
817 │ -- operation f0e828390851 new empty commit
818 │ predecessors:
819 ○ qpvuntsm/1 [email protected] 2001-02-03 08:05:08 e3ce68f4 (hidden)
820 │ (empty) c
821 │ -- operation 6859b8912238 describe commit e8849ae12c709f2321908879bc724fdb2ab8a781
822 │ predecessors: e8849ae1
823 ○ qpvuntsm/2 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden)
824 (empty) (no description set)
825 -- operation f63ee16f9553 add workspace 'default'
826 predecessors:
827 [EOF]
828 ");
829 }