| 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 std::path::PathBuf; |
| 16 |
|
| 17 |
use test_case::test_case; |
| 18 |
use testutils::TestResult; |
| 19 |
|
| 20 |
use crate::common::CommandOutput; |
| 21 |
use crate::common::TestEnvironment; |
| 22 |
use crate::common::TestWorkDir; |
| 23 |
|
| 24 |
#[must_use] |
| 25 |
fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { |
| 26 |
let template = r#"separate(" ", change_id.short(), empty, local_bookmarks, description)"#; |
| 27 |
work_dir.run_jj(["log", "-T", template]) |
| 28 |
} |
| 29 |
|
| 30 |
#[must_use] |
| 31 |
fn get_log_with_summary(work_dir: &TestWorkDir) -> CommandOutput { |
| 32 |
let template = r#"separate(" ", change_id.short(), local_bookmarks, description)"#; |
| 33 |
work_dir.run_jj(["log", "-T", template, "--summary"]) |
| 34 |
} |
| 35 |
|
| 36 |
#[must_use] |
| 37 |
fn get_workspace_log_output(work_dir: &TestWorkDir) -> CommandOutput { |
| 38 |
let template = r#"separate(" ", change_id.short(), working_copies, description)"#; |
| 39 |
work_dir.run_jj(["log", "-T", template, "-r", "all()"]) |
| 40 |
} |
| 41 |
|
| 42 |
#[must_use] |
| 43 |
fn get_recorded_dates(work_dir: &TestWorkDir, revset: &str) -> CommandOutput { |
| 44 |
let template = r#"separate("\n", "Author date: " ++ author.timestamp(), "Committer date: " ++ committer.timestamp())"#; |
| 45 |
work_dir.run_jj(["log", "--no-graph", "-T", template, "-r", revset]) |
| 46 |
} |
| 47 |
|
| 48 |
#[test] |
| 49 |
fn test_split_by_paths() -> TestResult { |
| 50 |
let mut test_env = TestEnvironment::default(); |
| 51 |
let edit_script = test_env.set_up_fake_editor(); |
| 52 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 53 |
let work_dir = test_env.work_dir("repo"); |
| 54 |
|
| 55 |
work_dir.write_file("file1", "foo"); |
| 56 |
work_dir.write_file("file2", "foo"); |
| 57 |
work_dir.write_file("file3", "foo"); |
| 58 |
|
| 59 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 60 |
@ qpvuntsmwlqt false |
| 61 |
◆ zzzzzzzzzzzz true |
| 62 |
[EOF] |
| 63 |
"); |
| 64 |
insta::assert_snapshot!(get_recorded_dates(&work_dir, "@"), @" |
| 65 |
Author date: 2001-02-03 04:05:08.000 +07:00 |
| 66 |
Committer date: 2001-02-03 04:05:08.000 +07:00[EOF] |
| 67 |
"); |
| 68 |
|
| 69 |
std::fs::write( |
| 70 |
&edit_script, |
| 71 |
[ |
| 72 |
"dump editor0", |
| 73 |
"write\n", |
| 74 |
"next invocation\n", |
| 75 |
"dump editor1", |
| 76 |
] |
| 77 |
.join("\0"), |
| 78 |
)?; |
| 79 |
let output = work_dir.run_jj([ |
| 80 |
"split", |
| 81 |
"file2", |
| 82 |
r#"--config=templates.commit_trailers='"Trailer: value"'"#, |
| 83 |
]); |
| 84 |
insta::assert_snapshot!(output, @" |
| 85 |
------- stderr ------- |
| 86 |
Selected changes : qpvuntsm 6dbc7747 (no description set) |
| 87 |
Remaining changes: zsuskuln 42cbbc02 (no description set) |
| 88 |
Working copy (@) now at: zsuskuln 42cbbc02 (no description set) |
| 89 |
Parent commit (@-) : qpvuntsm 6dbc7747 (no description set) |
| 90 |
[EOF] |
| 91 |
"); |
| 92 |
// Trailers should be added to the editor template |
| 93 |
insta::assert_snapshot!( |
| 94 |
std::fs::read_to_string(test_env.env_root().join("editor0"))?, @r#" |
| 95 |
JJ: Enter a description for the selected changes. |
| 96 |
|
| 97 |
|
| 98 |
Trailer: value |
| 99 |
|
| 100 |
JJ: Change ID: qpvuntsm |
| 101 |
JJ: This commit contains the following changes: |
| 102 |
JJ: A file2 |
| 103 |
JJ: |
| 104 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 105 |
"#); |
| 106 |
assert!(!test_env.env_root().join("editor1").exists()); |
| 107 |
|
| 108 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 109 |
@ zsuskulnrvyr false |
| 110 |
○ qpvuntsmwlqt false |
| 111 |
◆ zzzzzzzzzzzz true |
| 112 |
[EOF] |
| 113 |
"); |
| 114 |
|
| 115 |
// The author dates of the new commits should be inherited from the commit being |
| 116 |
// split. The committer dates should be newer. |
| 117 |
insta::assert_snapshot!(get_recorded_dates(&work_dir, "@"), @" |
| 118 |
Author date: 2001-02-03 04:05:08.000 +07:00 |
| 119 |
Committer date: 2001-02-03 04:05:10.000 +07:00[EOF] |
| 120 |
"); |
| 121 |
insta::assert_snapshot!(get_recorded_dates(&work_dir, "@-"), @" |
| 122 |
Author date: 2001-02-03 04:05:08.000 +07:00 |
| 123 |
Committer date: 2001-02-03 04:05:10.000 +07:00[EOF] |
| 124 |
"); |
| 125 |
|
| 126 |
let output = work_dir.run_jj(["diff", "-s", "-r", "@-"]); |
| 127 |
insta::assert_snapshot!(output, @" |
| 128 |
A file2 |
| 129 |
[EOF] |
| 130 |
"); |
| 131 |
let output = work_dir.run_jj(["diff", "-s"]); |
| 132 |
insta::assert_snapshot!(output, @" |
| 133 |
A file1 |
| 134 |
A file3 |
| 135 |
[EOF] |
| 136 |
"); |
| 137 |
|
| 138 |
// Insert an empty commit after @- with "split ." |
| 139 |
std::fs::write(&edit_script, "")?; |
| 140 |
let output = work_dir.run_jj(["split", "-r", "@-", "."]); |
| 141 |
insta::assert_snapshot!(output, @r" |
| 142 |
------- stderr ------- |
| 143 |
Warning: All changes have been selected, so the original revision will become empty. |
| 144 |
Rebased 1 descendant commits. |
| 145 |
Selected changes : qpvuntsm 9fd1c9e1 (no description set) |
| 146 |
Remaining changes: znkkpsqq 41e0da21 (empty) (no description set) |
| 147 |
Working copy (@) now at: zsuskuln a06e40b8 (no description set) |
| 148 |
Parent commit (@-) : znkkpsqq 41e0da21 (empty) (no description set) |
| 149 |
[EOF] |
| 150 |
"); |
| 151 |
|
| 152 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 153 |
@ zsuskulnrvyr false |
| 154 |
○ znkkpsqqskkl true |
| 155 |
○ qpvuntsmwlqt false |
| 156 |
◆ zzzzzzzzzzzz true |
| 157 |
[EOF] |
| 158 |
"); |
| 159 |
|
| 160 |
let output = work_dir.run_jj(["diff", "-s", "-r", "@--"]); |
| 161 |
insta::assert_snapshot!(output, @" |
| 162 |
A file2 |
| 163 |
[EOF] |
| 164 |
"); |
| 165 |
|
| 166 |
// Remove newly created empty commit |
| 167 |
work_dir.run_jj(["abandon", "@-"]).success(); |
| 168 |
|
| 169 |
// Insert an empty commit before @- with "split nonexistent" |
| 170 |
std::fs::write(&edit_script, "")?; |
| 171 |
let output = work_dir.run_jj(["split", "-r", "@-", "nonexistent"]); |
| 172 |
insta::assert_snapshot!(output, @r" |
| 173 |
------- stderr ------- |
| 174 |
Warning: No matching entries for paths: nonexistent |
| 175 |
Warning: No changes have been selected, so the new revision will be empty. |
| 176 |
Rebased 1 descendant commits. |
| 177 |
Selected changes : qpvuntsm 49416632 (empty) (no description set) |
| 178 |
Remaining changes: lylxulpl 718afbf5 (no description set) |
| 179 |
Working copy (@) now at: zsuskuln 0ed53ee6 (no description set) |
| 180 |
Parent commit (@-) : lylxulpl 718afbf5 (no description set) |
| 181 |
[EOF] |
| 182 |
"); |
| 183 |
|
| 184 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 185 |
@ zsuskulnrvyr false |
| 186 |
○ lylxulplsnyw false |
| 187 |
○ qpvuntsmwlqt true |
| 188 |
◆ zzzzzzzzzzzz true |
| 189 |
[EOF] |
| 190 |
"); |
| 191 |
|
| 192 |
let output = work_dir.run_jj(["diff", "-s", "-r", "@-"]); |
| 193 |
insta::assert_snapshot!(output, @" |
| 194 |
A file2 |
| 195 |
[EOF] |
| 196 |
"); |
| 197 |
|
| 198 |
work_dir.run_jj(["new"]).success(); |
| 199 |
// Splitting a commit with deleted files should not show a warning. |
| 200 |
work_dir.remove_file("file1"); |
| 201 |
let output = work_dir.run_jj(["split", "file1"]); |
| 202 |
insta::assert_snapshot!(output, @r" |
| 203 |
------- stderr ------- |
| 204 |
Warning: All changes have been selected, so the original revision will become empty. |
| 205 |
Selected changes : uyznsvlq 971ccc0b (no description set) |
| 206 |
Remaining changes: xznxytkn a267cd96 (empty) (no description set) |
| 207 |
Working copy (@) now at: smwtzssm 6715dc2c (empty) (no description set) |
| 208 |
Parent commit (@-) : uyznsvlq 971ccc0b (no description set) |
| 209 |
[EOF] |
| 210 |
"); |
| 211 |
Ok(()) |
| 212 |
} |
| 213 |
|
| 214 |
#[test] |
| 215 |
fn test_split_with_non_empty_description() -> TestResult { |
| 216 |
let mut test_env = TestEnvironment::default(); |
| 217 |
let edit_script = test_env.set_up_fake_editor(); |
| 218 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 219 |
test_env.add_config(r#"template-aliases.default_commit_description = '"\n\nTESTED=TODO\n"'"#); |
| 220 |
let work_dir = test_env.work_dir("repo"); |
| 221 |
|
| 222 |
work_dir.write_file("file1", "foo\n"); |
| 223 |
work_dir.write_file("file2", "bar\n"); |
| 224 |
work_dir.run_jj(["describe", "-m", "test"]).success(); |
| 225 |
std::fs::write( |
| 226 |
edit_script, |
| 227 |
[ |
| 228 |
"dump editor1", |
| 229 |
"write\npart 1", |
| 230 |
"next invocation\n", |
| 231 |
"dump editor2", |
| 232 |
"write\npart 2", |
| 233 |
] |
| 234 |
.join("\0"), |
| 235 |
)?; |
| 236 |
let output = work_dir.run_jj(["split", "file1"]); |
| 237 |
insta::assert_snapshot!(output, @" |
| 238 |
------- stderr ------- |
| 239 |
Selected changes : qpvuntsm c7f7b14b part 1 |
| 240 |
Remaining changes: kkmpptxz ac33a5a9 part 2 |
| 241 |
Working copy (@) now at: kkmpptxz ac33a5a9 part 2 |
| 242 |
Parent commit (@-) : qpvuntsm c7f7b14b part 1 |
| 243 |
[EOF] |
| 244 |
"); |
| 245 |
|
| 246 |
insta::assert_snapshot!( |
| 247 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 248 |
JJ: Enter a description for the selected changes. |
| 249 |
test |
| 250 |
|
| 251 |
JJ: Change ID: qpvuntsm |
| 252 |
JJ: This commit contains the following changes: |
| 253 |
JJ: A file1 |
| 254 |
JJ: |
| 255 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 256 |
"#); |
| 257 |
insta::assert_snapshot!( |
| 258 |
std::fs::read_to_string(test_env.env_root().join("editor2"))?, @r#" |
| 259 |
JJ: Enter a description for the remaining changes. |
| 260 |
test |
| 261 |
|
| 262 |
JJ: Change ID: kkmpptxz |
| 263 |
JJ: This commit contains the following changes: |
| 264 |
JJ: A file2 |
| 265 |
JJ: |
| 266 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 267 |
"#); |
| 268 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 269 |
@ kkmpptxzrspx false part 2 |
| 270 |
○ qpvuntsmwlqt false part 1 |
| 271 |
◆ zzzzzzzzzzzz true |
| 272 |
[EOF] |
| 273 |
"); |
| 274 |
Ok(()) |
| 275 |
} |
| 276 |
|
| 277 |
#[test] |
| 278 |
fn test_split_with_default_description() -> TestResult { |
| 279 |
let mut test_env = TestEnvironment::default(); |
| 280 |
let edit_script = test_env.set_up_fake_editor(); |
| 281 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 282 |
test_env.add_config(r#"template-aliases.default_commit_description = '"\n\nTESTED=TODO\n"'"#); |
| 283 |
let work_dir = test_env.work_dir("repo"); |
| 284 |
|
| 285 |
work_dir.write_file("file1", "foo\n"); |
| 286 |
work_dir.write_file("file2", "bar\n"); |
| 287 |
|
| 288 |
std::fs::write( |
| 289 |
edit_script, |
| 290 |
["dump editor1", "next invocation\n", "dump editor2"].join("\0"), |
| 291 |
)?; |
| 292 |
let output = work_dir.run_jj(["split", "file1"]); |
| 293 |
insta::assert_snapshot!(output, @" |
| 294 |
------- stderr ------- |
| 295 |
Selected changes : qpvuntsm ff633dcc TESTED=TODO |
| 296 |
Remaining changes: rlvkpnrz b1d20b7e (no description set) |
| 297 |
Working copy (@) now at: rlvkpnrz b1d20b7e (no description set) |
| 298 |
Parent commit (@-) : qpvuntsm ff633dcc TESTED=TODO |
| 299 |
[EOF] |
| 300 |
"); |
| 301 |
|
| 302 |
// Since the commit being split has no description, the user will only be |
| 303 |
// prompted to add a description to the first commit, which will use the |
| 304 |
// default value we set. The second commit will inherit the empty |
| 305 |
// description from the commit being split. |
| 306 |
insta::assert_snapshot!( |
| 307 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 308 |
JJ: Enter a description for the selected changes. |
| 309 |
|
| 310 |
|
| 311 |
TESTED=TODO |
| 312 |
|
| 313 |
JJ: Change ID: qpvuntsm |
| 314 |
JJ: This commit contains the following changes: |
| 315 |
JJ: A file1 |
| 316 |
JJ: |
| 317 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 318 |
"#); |
| 319 |
assert!(!test_env.env_root().join("editor2").exists()); |
| 320 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 321 |
@ rlvkpnrzqnoo false |
| 322 |
○ qpvuntsmwlqt false TESTED=TODO |
| 323 |
◆ zzzzzzzzzzzz true |
| 324 |
[EOF] |
| 325 |
"); |
| 326 |
Ok(()) |
| 327 |
} |
| 328 |
|
| 329 |
#[test] |
| 330 |
fn test_split_with_descendants() -> TestResult { |
| 331 |
// Configure the environment and make the initial commits. |
| 332 |
let mut test_env = TestEnvironment::default(); |
| 333 |
let edit_script = test_env.set_up_fake_editor(); |
| 334 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 335 |
let work_dir = test_env.work_dir("repo"); |
| 336 |
|
| 337 |
// First commit. This is the one we will split later. |
| 338 |
work_dir.write_file("file1", "foo\n"); |
| 339 |
work_dir.write_file("file2", "bar\n"); |
| 340 |
work_dir |
| 341 |
.run_jj(["commit", "-m", "Add file1 & file2"]) |
| 342 |
.success(); |
| 343 |
// Second commit. |
| 344 |
work_dir.write_file("file3", "baz\n"); |
| 345 |
work_dir.run_jj(["commit", "-m", "Add file3"]).success(); |
| 346 |
// Third commit. |
| 347 |
work_dir.write_file("file4", "foobarbaz\n"); |
| 348 |
work_dir.run_jj(["describe", "-m", "Add file4"]).success(); |
| 349 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 350 |
@ kkmpptxzrspx false Add file4 |
| 351 |
○ rlvkpnrzqnoo false Add file3 |
| 352 |
○ qpvuntsmwlqt false Add file1 & file2 |
| 353 |
◆ zzzzzzzzzzzz true |
| 354 |
[EOF] |
| 355 |
"); |
| 356 |
|
| 357 |
// Set up the editor and do the split. |
| 358 |
std::fs::write( |
| 359 |
edit_script, |
| 360 |
[ |
| 361 |
"dump editor1", |
| 362 |
"write\nAdd file1", |
| 363 |
"next invocation\n", |
| 364 |
"dump editor2", |
| 365 |
"write\nAdd file2", |
| 366 |
] |
| 367 |
.join("\0"), |
| 368 |
)?; |
| 369 |
let output = work_dir.run_jj(["split", "file1", "-r", "qpvu"]); |
| 370 |
insta::assert_snapshot!(output, @r" |
| 371 |
------- stderr ------- |
| 372 |
Rebased 2 descendant commits. |
| 373 |
Selected changes : qpvuntsm 74306e35 Add file1 |
| 374 |
Remaining changes: royxmykx 0a37745e Add file2 |
| 375 |
Working copy (@) now at: kkmpptxz 7ee84812 Add file4 |
| 376 |
Parent commit (@-) : rlvkpnrz d335bd94 Add file3 |
| 377 |
[EOF] |
| 378 |
"); |
| 379 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 380 |
@ kkmpptxzrspx false Add file4 |
| 381 |
○ rlvkpnrzqnoo false Add file3 |
| 382 |
○ royxmykxtrkr false Add file2 |
| 383 |
○ qpvuntsmwlqt false Add file1 |
| 384 |
◆ zzzzzzzzzzzz true |
| 385 |
[EOF] |
| 386 |
"); |
| 387 |
|
| 388 |
// The commit we're splitting has a description, so the user will be |
| 389 |
// prompted to enter a description for each of the commits. |
| 390 |
insta::assert_snapshot!( |
| 391 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 392 |
JJ: Enter a description for the selected changes. |
| 393 |
Add file1 & file2 |
| 394 |
|
| 395 |
JJ: Change ID: qpvuntsm |
| 396 |
JJ: This commit contains the following changes: |
| 397 |
JJ: A file1 |
| 398 |
JJ: |
| 399 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 400 |
"#); |
| 401 |
insta::assert_snapshot!( |
| 402 |
std::fs::read_to_string(test_env.env_root().join("editor2"))?, @r#" |
| 403 |
JJ: Enter a description for the remaining changes. |
| 404 |
Add file1 & file2 |
| 405 |
|
| 406 |
JJ: Change ID: royxmykx |
| 407 |
JJ: This commit contains the following changes: |
| 408 |
JJ: A file2 |
| 409 |
JJ: |
| 410 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 411 |
"#); |
| 412 |
|
| 413 |
// Check the evolog for the first commit. It shows four entries: |
| 414 |
// - The initial empty commit. |
| 415 |
// - The rewritten commit from the snapshot after the files were added. |
| 416 |
// - The rewritten commit once the description is added during `jj commit`. |
| 417 |
// - The rewritten commit after the split. |
| 418 |
let evolog_1 = work_dir.run_jj(["evolog", "-r", "qpvun"]); |
| 419 |
insta::assert_snapshot!(evolog_1, @" |
| 420 |
○ qpvuntsm [email protected] 2001-02-03 08:05:12 74306e35 |
| 421 |
│ Add file1 |
| 422 |
│ -- operation 8da478b86b17 split commit 1d2499e72cefc8a2b87ebb47569140857b96189f |
| 423 |
○ qpvuntsm/1 [email protected] 2001-02-03 08:05:08 1d2499e7 (hidden) |
| 424 |
│ Add file1 & file2 |
| 425 |
│ -- operation 8f1bd50aa0bd commit f5700f8ef89e290e4e90ae6adc0908707e0d8c85 |
| 426 |
○ qpvuntsm/2 [email protected] 2001-02-03 08:05:08 f5700f8e (hidden) |
| 427 |
│ (no description set) |
| 428 |
│ -- operation f470eed642a6 snapshot working copy |
| 429 |
○ qpvuntsm/3 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden) |
| 430 |
(empty) (no description set) |
| 431 |
-- operation f63ee16f9553 add workspace 'default' |
| 432 |
[EOF] |
| 433 |
"); |
| 434 |
|
| 435 |
// The evolog for the second commit is the same, except that the change id |
| 436 |
// changes after the split. |
| 437 |
let evolog_2 = work_dir.run_jj(["evolog", "-r", "royxm"]); |
| 438 |
insta::assert_snapshot!(evolog_2, @" |
| 439 |
○ royxmykx [email protected] 2001-02-03 08:05:12 0a37745e |
| 440 |
│ Add file2 |
| 441 |
│ -- operation 8da478b86b17 split commit 1d2499e72cefc8a2b87ebb47569140857b96189f |
| 442 |
○ qpvuntsm/1 [email protected] 2001-02-03 08:05:08 1d2499e7 (hidden) |
| 443 |
│ Add file1 & file2 |
| 444 |
│ -- operation 8f1bd50aa0bd commit f5700f8ef89e290e4e90ae6adc0908707e0d8c85 |
| 445 |
○ qpvuntsm/2 [email protected] 2001-02-03 08:05:08 f5700f8e (hidden) |
| 446 |
│ (no description set) |
| 447 |
│ -- operation f470eed642a6 snapshot working copy |
| 448 |
○ qpvuntsm/3 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden) |
| 449 |
(empty) (no description set) |
| 450 |
-- operation f63ee16f9553 add workspace 'default' |
| 451 |
[EOF] |
| 452 |
"); |
| 453 |
Ok(()) |
| 454 |
} |
| 455 |
|
| 456 |
// This test makes sure that the children of the commit being split retain any |
| 457 |
// other parents which weren't involved in the split. |
| 458 |
#[test] |
| 459 |
fn test_split_with_merge_child() -> TestResult { |
| 460 |
let mut test_env = TestEnvironment::default(); |
| 461 |
let edit_script = test_env.set_up_fake_editor(); |
| 462 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 463 |
let work_dir = test_env.work_dir("repo"); |
| 464 |
work_dir.run_jj(["describe", "-m=1"]).success(); |
| 465 |
work_dir.run_jj(["new", "root()", "-m=a"]).success(); |
| 466 |
work_dir.write_file("file1", "foo\n"); |
| 467 |
work_dir.write_file("file2", "bar\n"); |
| 468 |
work_dir |
| 469 |
.run_jj(["new", "subject(1)", "subject(a)", "-m=2"]) |
| 470 |
.success(); |
| 471 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 472 |
@ zsuskulnrvyr true 2 |
| 473 |
├─╮ |
| 474 |
│ ○ kkmpptxzrspx false a |
| 475 |
○ │ qpvuntsmwlqt true 1 |
| 476 |
├─╯ |
| 477 |
◆ zzzzzzzzzzzz true |
| 478 |
[EOF] |
| 479 |
"); |
| 480 |
|
| 481 |
// Set up the editor and do the split. |
| 482 |
std::fs::write( |
| 483 |
edit_script, |
| 484 |
["write\nAdd file1", "next invocation\n", "write\nAdd file2"].join("\0"), |
| 485 |
)?; |
| 486 |
let output = work_dir.run_jj(["split", "-rsubject(a)", "file1"]); |
| 487 |
insta::assert_snapshot!(output, @r" |
| 488 |
------- stderr ------- |
| 489 |
Rebased 1 descendant commits. |
| 490 |
Selected changes : kkmpptxz cc199567 Add file1 |
| 491 |
Remaining changes: royxmykx e488409f Add file2 |
| 492 |
Working copy (@) now at: zsuskuln ace61421 (empty) 2 |
| 493 |
Parent commit (@-) : qpvuntsm 884fe9b9 (empty) 1 |
| 494 |
Parent commit (@-) : royxmykx e488409f Add file2 |
| 495 |
[EOF] |
| 496 |
"); |
| 497 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 498 |
@ zsuskulnrvyr true 2 |
| 499 |
├─╮ |
| 500 |
│ ○ royxmykxtrkr false Add file2 |
| 501 |
│ ○ kkmpptxzrspx false Add file1 |
| 502 |
○ │ qpvuntsmwlqt true 1 |
| 503 |
├─╯ |
| 504 |
◆ zzzzzzzzzzzz true |
| 505 |
[EOF] |
| 506 |
"); |
| 507 |
Ok(()) |
| 508 |
} |
| 509 |
|
| 510 |
#[test] |
| 511 |
// Split a commit with no descendants into siblings. Also tests that the default |
| 512 |
// description is set correctly on the first commit. |
| 513 |
fn test_split_parallel_no_descendants() -> TestResult { |
| 514 |
let mut test_env = TestEnvironment::default(); |
| 515 |
let edit_script = test_env.set_up_fake_editor(); |
| 516 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 517 |
test_env.add_config(r#"template-aliases.default_commit_description = '"\n\nTESTED=TODO\n"'"#); |
| 518 |
let work_dir = test_env.work_dir("repo"); |
| 519 |
|
| 520 |
work_dir.write_file("file1", "foo\n"); |
| 521 |
work_dir.write_file("file2", "bar\n"); |
| 522 |
|
| 523 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 524 |
@ qpvuntsmwlqt false |
| 525 |
◆ zzzzzzzzzzzz true |
| 526 |
[EOF] |
| 527 |
"); |
| 528 |
|
| 529 |
std::fs::write( |
| 530 |
edit_script, |
| 531 |
["dump editor1", "next invocation\n", "dump editor2"].join("\0"), |
| 532 |
)?; |
| 533 |
let output = work_dir.run_jj(["split", "--parallel", "file1"]); |
| 534 |
insta::assert_snapshot!(output, @" |
| 535 |
------- stderr ------- |
| 536 |
Selected changes : qpvuntsm 7bcd474c TESTED=TODO |
| 537 |
Remaining changes: kkmpptxz 431886f6 (no description set) |
| 538 |
Working copy (@) now at: kkmpptxz 431886f6 (no description set) |
| 539 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 540 |
Added 0 files, modified 0 files, removed 1 files |
| 541 |
[EOF] |
| 542 |
"); |
| 543 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 544 |
@ kkmpptxzrspx false |
| 545 |
│ ○ qpvuntsmwlqt false TESTED=TODO |
| 546 |
├─╯ |
| 547 |
◆ zzzzzzzzzzzz true |
| 548 |
[EOF] |
| 549 |
"); |
| 550 |
|
| 551 |
// Since the commit being split has no description, the user will only be |
| 552 |
// prompted to add a description to the first commit, which will use the |
| 553 |
// default value we set. The second commit will inherit the empty |
| 554 |
// description from the commit being split. |
| 555 |
insta::assert_snapshot!( |
| 556 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 557 |
JJ: Enter a description for the selected changes. |
| 558 |
|
| 559 |
|
| 560 |
TESTED=TODO |
| 561 |
|
| 562 |
JJ: Change ID: qpvuntsm |
| 563 |
JJ: This commit contains the following changes: |
| 564 |
JJ: A file1 |
| 565 |
JJ: |
| 566 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 567 |
"#); |
| 568 |
assert!(!test_env.env_root().join("editor2").exists()); |
| 569 |
|
| 570 |
// Check the evolog for the first commit. It shows three entries: |
| 571 |
// - The initial empty commit. |
| 572 |
// - The rewritten commit from the snapshot after the files were added. |
| 573 |
// - The rewritten commit after the split. |
| 574 |
let evolog_1 = work_dir.run_jj(["evolog", "-r", "qpvun"]); |
| 575 |
insta::assert_snapshot!(evolog_1, @" |
| 576 |
○ qpvuntsm [email protected] 2001-02-03 08:05:09 7bcd474c |
| 577 |
│ TESTED=TODO |
| 578 |
│ -- operation 46ec05e13358 split commit f5700f8ef89e290e4e90ae6adc0908707e0d8c85 |
| 579 |
○ qpvuntsm/1 [email protected] 2001-02-03 08:05:08 f5700f8e (hidden) |
| 580 |
│ (no description set) |
| 581 |
│ -- operation 9173705f4b2a snapshot working copy |
| 582 |
○ qpvuntsm/2 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden) |
| 583 |
(empty) (no description set) |
| 584 |
-- operation f63ee16f9553 add workspace 'default' |
| 585 |
[EOF] |
| 586 |
"); |
| 587 |
|
| 588 |
// The evolog for the second commit is the same, except that the change id |
| 589 |
// changes after the split. |
| 590 |
let evolog_2 = work_dir.run_jj(["evolog", "-r", "kkmpp"]); |
| 591 |
insta::assert_snapshot!(evolog_2, @" |
| 592 |
@ kkmpptxz [email protected] 2001-02-03 08:05:09 431886f6 |
| 593 |
│ (no description set) |
| 594 |
│ -- operation 46ec05e13358 split commit f5700f8ef89e290e4e90ae6adc0908707e0d8c85 |
| 595 |
○ qpvuntsm/1 [email protected] 2001-02-03 08:05:08 f5700f8e (hidden) |
| 596 |
│ (no description set) |
| 597 |
│ -- operation 9173705f4b2a snapshot working copy |
| 598 |
○ qpvuntsm/2 [email protected] 2001-02-03 08:05:07 e8849ae1 (hidden) |
| 599 |
(empty) (no description set) |
| 600 |
-- operation f63ee16f9553 add workspace 'default' |
| 601 |
[EOF] |
| 602 |
"); |
| 603 |
Ok(()) |
| 604 |
} |
| 605 |
|
| 606 |
#[test] |
| 607 |
fn test_split_parallel_with_descendants() -> TestResult { |
| 608 |
// Configure the environment and make the initial commits. |
| 609 |
let mut test_env = TestEnvironment::default(); |
| 610 |
let edit_script = test_env.set_up_fake_editor(); |
| 611 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 612 |
let work_dir = test_env.work_dir("repo"); |
| 613 |
|
| 614 |
// First commit. This is the one we will split later. |
| 615 |
work_dir.write_file("file1", "foo\n"); |
| 616 |
work_dir.write_file("file2", "bar\n"); |
| 617 |
work_dir |
| 618 |
.run_jj(["commit", "-m", "Add file1 & file2"]) |
| 619 |
.success(); |
| 620 |
// Second commit. This will be the child of the sibling commits after the split. |
| 621 |
work_dir.write_file("file3", "baz\n"); |
| 622 |
work_dir.run_jj(["commit", "-m", "Add file3"]).success(); |
| 623 |
// Third commit. |
| 624 |
work_dir.write_file("file4", "foobarbaz\n"); |
| 625 |
work_dir.run_jj(["describe", "-m", "Add file4"]).success(); |
| 626 |
// Move back to the previous commit so that we don't have to pass a revision |
| 627 |
// to the split command. |
| 628 |
work_dir.run_jj(["prev", "--edit"]).success(); |
| 629 |
work_dir.run_jj(["prev", "--edit"]).success(); |
| 630 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 631 |
○ kkmpptxzrspx false Add file4 |
| 632 |
○ rlvkpnrzqnoo false Add file3 |
| 633 |
@ qpvuntsmwlqt false Add file1 & file2 |
| 634 |
◆ zzzzzzzzzzzz true |
| 635 |
[EOF] |
| 636 |
"); |
| 637 |
|
| 638 |
// Set up the editor and do the split. |
| 639 |
std::fs::write( |
| 640 |
edit_script, |
| 641 |
[ |
| 642 |
"dump editor1", |
| 643 |
"write\nAdd file1", |
| 644 |
"next invocation\n", |
| 645 |
"dump editor2", |
| 646 |
"write\nAdd file2", |
| 647 |
] |
| 648 |
.join("\0"), |
| 649 |
)?; |
| 650 |
let output = work_dir.run_jj(["split", "--parallel", "file1"]); |
| 651 |
insta::assert_snapshot!(output, @r" |
| 652 |
------- stderr ------- |
| 653 |
Rebased 2 descendant commits. |
| 654 |
Selected changes : qpvuntsm 18c85f56 Add file1 |
| 655 |
Remaining changes: vruxwmqv cbdfd9cf Add file2 |
| 656 |
Working copy (@) now at: vruxwmqv cbdfd9cf Add file2 |
| 657 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 658 |
Added 0 files, modified 0 files, removed 1 files |
| 659 |
[EOF] |
| 660 |
"); |
| 661 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 662 |
○ kkmpptxzrspx false Add file4 |
| 663 |
○ rlvkpnrzqnoo false Add file3 |
| 664 |
├─╮ |
| 665 |
│ @ vruxwmqvtpmx false Add file2 |
| 666 |
○ │ qpvuntsmwlqt false Add file1 |
| 667 |
├─╯ |
| 668 |
◆ zzzzzzzzzzzz true |
| 669 |
[EOF] |
| 670 |
"); |
| 671 |
|
| 672 |
// The commit we're splitting has a description, so the user will be |
| 673 |
// prompted to enter a description for each of the sibling commits. |
| 674 |
insta::assert_snapshot!( |
| 675 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 676 |
JJ: Enter a description for the selected changes. |
| 677 |
Add file1 & file2 |
| 678 |
|
| 679 |
JJ: Change ID: qpvuntsm |
| 680 |
JJ: This commit contains the following changes: |
| 681 |
JJ: A file1 |
| 682 |
JJ: |
| 683 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 684 |
"#); |
| 685 |
insta::assert_snapshot!( |
| 686 |
std::fs::read_to_string(test_env.env_root().join("editor2"))?, @r#" |
| 687 |
JJ: Enter a description for the remaining changes. |
| 688 |
Add file1 & file2 |
| 689 |
|
| 690 |
JJ: Change ID: vruxwmqv |
| 691 |
JJ: This commit contains the following changes: |
| 692 |
JJ: A file2 |
| 693 |
JJ: |
| 694 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 695 |
"#); |
| 696 |
Ok(()) |
| 697 |
} |
| 698 |
|
| 699 |
// This test makes sure that the children of the commit being split retain any |
| 700 |
// other parents which weren't involved in the split. |
| 701 |
#[test] |
| 702 |
fn test_split_parallel_with_merge_child() -> TestResult { |
| 703 |
let mut test_env = TestEnvironment::default(); |
| 704 |
let edit_script = test_env.set_up_fake_editor(); |
| 705 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 706 |
let work_dir = test_env.work_dir("repo"); |
| 707 |
work_dir.run_jj(["describe", "-m=1"]).success(); |
| 708 |
work_dir.run_jj(["new", "root()", "-m=a"]).success(); |
| 709 |
work_dir.write_file("file1", "foo\n"); |
| 710 |
work_dir.write_file("file2", "bar\n"); |
| 711 |
work_dir |
| 712 |
.run_jj(["new", "subject(1)", "subject(a)", "-m=2"]) |
| 713 |
.success(); |
| 714 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 715 |
@ zsuskulnrvyr true 2 |
| 716 |
├─╮ |
| 717 |
│ ○ kkmpptxzrspx false a |
| 718 |
○ │ qpvuntsmwlqt true 1 |
| 719 |
├─╯ |
| 720 |
◆ zzzzzzzzzzzz true |
| 721 |
[EOF] |
| 722 |
"); |
| 723 |
|
| 724 |
// Set up the editor and do the split. |
| 725 |
std::fs::write( |
| 726 |
edit_script, |
| 727 |
["write\nAdd file1", "next invocation\n", "write\nAdd file2"].join("\0"), |
| 728 |
)?; |
| 729 |
let output = work_dir.run_jj(["split", "-rsubject(a)", "--parallel", "file1"]); |
| 730 |
insta::assert_snapshot!(output, @r" |
| 731 |
------- stderr ------- |
| 732 |
Rebased 1 descendant commits. |
| 733 |
Selected changes : kkmpptxz cc199567 Add file1 |
| 734 |
Remaining changes: royxmykx 82a5c527 Add file2 |
| 735 |
Working copy (@) now at: zsuskuln b7cdcdec (empty) 2 |
| 736 |
Parent commit (@-) : qpvuntsm 884fe9b9 (empty) 1 |
| 737 |
Parent commit (@-) : kkmpptxz cc199567 Add file1 |
| 738 |
Parent commit (@-) : royxmykx 82a5c527 Add file2 |
| 739 |
[EOF] |
| 740 |
"); |
| 741 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 742 |
@ zsuskulnrvyr true 2 |
| 743 |
├─┬─╮ |
| 744 |
│ │ ○ royxmykxtrkr false Add file2 |
| 745 |
│ ○ │ kkmpptxzrspx false Add file1 |
| 746 |
│ ├─╯ |
| 747 |
○ │ qpvuntsmwlqt true 1 |
| 748 |
├─╯ |
| 749 |
◆ zzzzzzzzzzzz true |
| 750 |
[EOF] |
| 751 |
"); |
| 752 |
Ok(()) |
| 753 |
} |
| 754 |
|
| 755 |
#[test] |
| 756 |
fn test_split_parallel_with_conflict() -> TestResult { |
| 757 |
let mut test_env = TestEnvironment::default(); |
| 758 |
let diff_editor = test_env.set_up_fake_diff_editor(); |
| 759 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 760 |
let work_dir = test_env.work_dir("repo"); |
| 761 |
|
| 762 |
work_dir.write_file("file", "line 1\nline 2\nline 3\n"); |
| 763 |
work_dir.run_jj(["new"]).success(); |
| 764 |
work_dir.write_file("file", "line 1\nline 2.1\nline 2.2\nline 3\n"); |
| 765 |
work_dir.run_jj(["new"]).success(); |
| 766 |
work_dir.write_file("file", "line 1\nline 3\n"); |
| 767 |
work_dir.run_jj(["prev", "--edit"]).success(); |
| 768 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 769 |
○ kkmpptxzrspx false |
| 770 |
@ rlvkpnrzqnoo false |
| 771 |
○ qpvuntsmwlqt false |
| 772 |
◆ zzzzzzzzzzzz true |
| 773 |
[EOF] |
| 774 |
"); |
| 775 |
|
| 776 |
// Create a conflict by splitting two consecutive lines into parallel commits. |
| 777 |
std::fs::write( |
| 778 |
diff_editor, |
| 779 |
["write file\nline 1\nline 2.1\nline 3\n"].join("\0"), |
| 780 |
)?; |
| 781 |
let output = work_dir.run_jj(["split", "--parallel", "-i", "-m="]); |
| 782 |
insta::assert_snapshot!(output, @r" |
| 783 |
------- stderr ------- |
| 784 |
Rebased 1 descendant commits. |
| 785 |
Selected changes : rlvkpnrz abe15fea (no description set) |
| 786 |
Remaining changes: royxmykx 4bbc5826 (conflict) (no description set) |
| 787 |
Working copy (@) now at: royxmykx 4bbc5826 (conflict) (no description set) |
| 788 |
Parent commit (@-) : qpvuntsm ee8e9376 (no description set) |
| 789 |
Added 0 files, modified 1 files, removed 0 files |
| 790 |
Warning: There are unresolved conflicts at these paths: |
| 791 |
file 2-sided conflict |
| 792 |
New conflicts appeared in 1 commits: |
| 793 |
royxmykx 4bbc5826 (conflict) (no description set) |
| 794 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 795 |
the conflicted commit: |
| 796 |
jj new royxmykx |
| 797 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 798 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 799 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 800 |
[EOF] |
| 801 |
"); |
| 802 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 803 |
○ kkmpptxzrspx false |
| 804 |
├─╮ |
| 805 |
│ @ royxmykxtrkr false |
| 806 |
○ │ rlvkpnrzqnoo false |
| 807 |
├─╯ |
| 808 |
○ qpvuntsmwlqt false |
| 809 |
◆ zzzzzzzzzzzz true |
| 810 |
[EOF] |
| 811 |
"); |
| 812 |
|
| 813 |
// The new commit should be conflicted. |
| 814 |
insta::assert_snapshot!(work_dir.read_file("file"), @r" |
| 815 |
line 1 |
| 816 |
<<<<<<< conflict 1 of 1 |
| 817 |
%%%%%%% diff from: selected changes for split (from rlvkpnrz 35382813) |
| 818 |
\\\\\\\ to: split revision (rlvkpnrz 35382813) |
| 819 |
line 2.1 |
| 820 |
+line 2.2 |
| 821 |
+++++++ qpvuntsm ee8e9376 (parents of split revision) |
| 822 |
line 2 |
| 823 |
>>>>>>> conflict 1 of 1 ends |
| 824 |
line 3 |
| 825 |
"); |
| 826 |
|
| 827 |
// The old commit shouldn't be conflicted, since it matches the selection from |
| 828 |
// the editor. |
| 829 |
insta::assert_snapshot!(work_dir.run_jj(["file", "show", "-r=@+-~@", "file"]), @" |
| 830 |
line 1 |
| 831 |
line 2.1 |
| 832 |
line 3 |
| 833 |
[EOF] |
| 834 |
"); |
| 835 |
|
| 836 |
// The child merge commit should keep the same contents. |
| 837 |
insta::assert_snapshot!(work_dir.run_jj(["file", "show", "-r=@+", "file"]), @" |
| 838 |
line 1 |
| 839 |
line 3 |
| 840 |
[EOF] |
| 841 |
"); |
| 842 |
Ok(()) |
| 843 |
} |
| 844 |
|
| 845 |
// Make sure `jj split` would refuse to split an empty commit. |
| 846 |
#[test] |
| 847 |
fn test_split_empty() -> TestResult { |
| 848 |
let mut test_env = TestEnvironment::default(); |
| 849 |
test_env.set_up_fake_editor(); |
| 850 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 851 |
let work_dir = test_env.work_dir("repo"); |
| 852 |
work_dir.run_jj(["describe", "--message", "abc"]).success(); |
| 853 |
|
| 854 |
let output = work_dir.run_jj(["split"]); |
| 855 |
insta::assert_snapshot!(output, @r" |
| 856 |
------- stderr ------- |
| 857 |
Hint: Using default editor ':builtin'; run `jj config set --user ui.diff-editor :builtin` to disable this message. |
| 858 |
Warning: Empty diff - won't run diff editor. |
| 859 |
Warning: All changes have been selected, so the original revision will become empty. |
| 860 |
Selected changes : qpvuntsm a8bcd860 (empty) abc |
| 861 |
Remaining changes: kkmpptxz 304fb14c (empty) abc |
| 862 |
Working copy (@) now at: kkmpptxz 304fb14c (empty) abc |
| 863 |
Parent commit (@-) : qpvuntsm a8bcd860 (empty) abc |
| 864 |
[EOF] |
| 865 |
"); |
| 866 |
|
| 867 |
// With path argument (user meant to pass revision) |
| 868 |
let output = work_dir.run_jj(["split", "@"]); |
| 869 |
insta::assert_snapshot!(output, @r" |
| 870 |
------- stderr ------- |
| 871 |
Warning: No matching entries for paths: @ |
| 872 |
Warning: All changes have been selected, so the original revision will become empty. |
| 873 |
Selected changes : kkmpptxz cd55fd14 (empty) abc |
| 874 |
Remaining changes: zsuskuln 49a292cc (empty) abc |
| 875 |
Working copy (@) now at: zsuskuln 49a292cc (empty) abc |
| 876 |
Parent commit (@-) : kkmpptxz cd55fd14 (empty) abc |
| 877 |
[EOF] |
| 878 |
"); |
| 879 |
Ok(()) |
| 880 |
} |
| 881 |
|
| 882 |
#[test] |
| 883 |
fn test_split_message_editor_avoids_unc() -> TestResult { |
| 884 |
let mut test_env = TestEnvironment::default(); |
| 885 |
let edit_script = test_env.set_up_fake_editor(); |
| 886 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 887 |
let work_dir = test_env.work_dir("repo"); |
| 888 |
|
| 889 |
work_dir.write_file("file1", "foo"); |
| 890 |
work_dir.write_file("file2", "foo"); |
| 891 |
|
| 892 |
std::fs::write(edit_script, "dump-path path")?; |
| 893 |
work_dir.run_jj(["split", "file2"]).success(); |
| 894 |
|
| 895 |
let edited_path = PathBuf::from(std::fs::read_to_string(test_env.env_root().join("path"))?); |
| 896 |
// While `assert!(!edited_path.starts_with("//?/"))` could work here in most |
| 897 |
// cases, it fails when it is not safe to strip the prefix, such as paths |
| 898 |
// over 260 chars. |
| 899 |
assert_eq!(edited_path, dunce::simplified(&edited_path)); |
| 900 |
Ok(()) |
| 901 |
} |
| 902 |
|
| 903 |
#[test] |
| 904 |
fn test_split_interactive() -> TestResult { |
| 905 |
let mut test_env = TestEnvironment::default(); |
| 906 |
let edit_script = test_env.set_up_fake_editor(); |
| 907 |
let diff_editor = test_env.set_up_fake_diff_editor(); |
| 908 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 909 |
let work_dir = test_env.work_dir("repo"); |
| 910 |
|
| 911 |
work_dir.write_file("file1", "foo\n"); |
| 912 |
work_dir.write_file("file2", "bar\n"); |
| 913 |
std::fs::write(edit_script, ["dump editor"].join("\0"))?; |
| 914 |
|
| 915 |
let diff_script = ["rm file2", "dump JJ-INSTRUCTIONS instrs"].join("\0"); |
| 916 |
std::fs::write(diff_editor, diff_script)?; |
| 917 |
|
| 918 |
// Split the working commit interactively and select only file1 |
| 919 |
let output = work_dir.run_jj(["split"]); |
| 920 |
insta::assert_snapshot!(output, @" |
| 921 |
------- stderr ------- |
| 922 |
Selected changes : qpvuntsm c664a51b (no description set) |
| 923 |
Remaining changes: rlvkpnrz 7e5d65b1 (no description set) |
| 924 |
Working copy (@) now at: rlvkpnrz 7e5d65b1 (no description set) |
| 925 |
Parent commit (@-) : qpvuntsm c664a51b (no description set) |
| 926 |
[EOF] |
| 927 |
"); |
| 928 |
|
| 929 |
insta::assert_snapshot!( |
| 930 |
std::fs::read_to_string(test_env.env_root().join("instrs"))?, @" |
| 931 |
You are splitting a commit into two: qpvuntsm f5700f8e (no description set) |
| 932 |
|
| 933 |
The diff initially shows the changes in the commit you're splitting. |
| 934 |
|
| 935 |
Adjust the right side until it shows the contents you want to split into the |
| 936 |
new commit. |
| 937 |
The changes that are not selected will replace the original commit. |
| 938 |
"); |
| 939 |
|
| 940 |
insta::assert_snapshot!( |
| 941 |
std::fs::read_to_string(test_env.env_root().join("editor"))?, @r#" |
| 942 |
JJ: Enter a description for the selected changes. |
| 943 |
|
| 944 |
|
| 945 |
JJ: Change ID: qpvuntsm |
| 946 |
JJ: This commit contains the following changes: |
| 947 |
JJ: A file1 |
| 948 |
JJ: |
| 949 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 950 |
"#); |
| 951 |
|
| 952 |
let output = work_dir.run_jj(["log", "--summary"]); |
| 953 |
insta::assert_snapshot!(output, @" |
| 954 |
@ rlvkpnrz [email protected] 2001-02-03 08:05:08 7e5d65b1 |
| 955 |
│ (no description set) |
| 956 |
│ A file2 |
| 957 |
○ qpvuntsm [email protected] 2001-02-03 08:05:08 c664a51b |
| 958 |
│ (no description set) |
| 959 |
│ A file1 |
| 960 |
◆ zzzzzzzz root() 00000000 |
| 961 |
[EOF] |
| 962 |
"); |
| 963 |
Ok(()) |
| 964 |
} |
| 965 |
|
| 966 |
#[test] |
| 967 |
fn test_split_interactive_with_paths() -> TestResult { |
| 968 |
let mut test_env = TestEnvironment::default(); |
| 969 |
let edit_script = test_env.set_up_fake_editor(); |
| 970 |
let diff_editor = test_env.set_up_fake_diff_editor(); |
| 971 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 972 |
let work_dir = test_env.work_dir("repo"); |
| 973 |
|
| 974 |
work_dir.write_file("file2", ""); |
| 975 |
work_dir.write_file("file3", ""); |
| 976 |
work_dir.run_jj(["new"]).success(); |
| 977 |
work_dir.write_file("file1", "foo\n"); |
| 978 |
work_dir.write_file("file2", "bar\n"); |
| 979 |
work_dir.write_file("file3", "baz\n"); |
| 980 |
|
| 981 |
std::fs::write(edit_script, ["dump editor"].join("\0"))?; |
| 982 |
// On the before side, file2 is empty. On the after side, it contains "bar". |
| 983 |
// The "reset file2" copies the empty version from the before side to the |
| 984 |
// after side, effectively "unselecting" the changes and leaving only the |
| 985 |
// changes made to file1. file3 doesn't appear on either side since it isn't |
| 986 |
// in the filesets passed to `jj split`. |
| 987 |
let diff_script = [ |
| 988 |
"files-before file2", |
| 989 |
"files-after JJ-INSTRUCTIONS file1 file2", |
| 990 |
"reset file2", |
| 991 |
] |
| 992 |
.join("\0"); |
| 993 |
std::fs::write(diff_editor, diff_script)?; |
| 994 |
|
| 995 |
// Select file1 and file2 by args, then select file1 interactively via the diff |
| 996 |
// script. |
| 997 |
let output = work_dir.run_jj(["split", "-i", "file1", "file2"]); |
| 998 |
insta::assert_snapshot!(output, @" |
| 999 |
------- stderr ------- |
| 1000 |
Selected changes : rlvkpnrz cdc9960a (no description set) |
| 1001 |
Remaining changes: kkmpptxz 7255f070 (no description set) |
| 1002 |
Working copy (@) now at: kkmpptxz 7255f070 (no description set) |
| 1003 |
Parent commit (@-) : rlvkpnrz cdc9960a (no description set) |
| 1004 |
[EOF] |
| 1005 |
"); |
| 1006 |
|
| 1007 |
insta::assert_snapshot!( |
| 1008 |
std::fs::read_to_string(test_env.env_root().join("editor"))?, @r#" |
| 1009 |
JJ: Enter a description for the selected changes. |
| 1010 |
|
| 1011 |
|
| 1012 |
JJ: Change ID: rlvkpnrz |
| 1013 |
JJ: This commit contains the following changes: |
| 1014 |
JJ: A file1 |
| 1015 |
JJ: |
| 1016 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1017 |
"#); |
| 1018 |
|
| 1019 |
let output = work_dir.run_jj(["log", "--summary"]); |
| 1020 |
insta::assert_snapshot!(output, @" |
| 1021 |
@ kkmpptxz [email protected] 2001-02-03 08:05:09 7255f070 |
| 1022 |
│ (no description set) |
| 1023 |
│ M file2 |
| 1024 |
│ M file3 |
| 1025 |
○ rlvkpnrz [email protected] 2001-02-03 08:05:09 cdc9960a |
| 1026 |
│ (no description set) |
| 1027 |
│ A file1 |
| 1028 |
○ qpvuntsm [email protected] 2001-02-03 08:05:08 ff687a2f |
| 1029 |
│ (no description set) |
| 1030 |
│ A file2 |
| 1031 |
│ A file3 |
| 1032 |
◆ zzzzzzzz root() 00000000 |
| 1033 |
[EOF] |
| 1034 |
"); |
| 1035 |
Ok(()) |
| 1036 |
} |
| 1037 |
|
| 1038 |
// When a commit is split, the second commit produced by the split becomes the |
| 1039 |
// working copy commit for all workspaces whose working copy commit was the |
| 1040 |
// target of the split. This test does a split where the target commit is the |
| 1041 |
// working copy commit for two different workspaces. |
| 1042 |
#[test] |
| 1043 |
fn test_split_with_multiple_workspaces_same_working_copy() -> TestResult { |
| 1044 |
let mut test_env = TestEnvironment::default(); |
| 1045 |
let edit_script = test_env.set_up_fake_editor(); |
| 1046 |
test_env.run_jj_in(".", ["git", "init", "main"]).success(); |
| 1047 |
let main_dir = test_env.work_dir("main"); |
| 1048 |
let secondary_dir = test_env.work_dir("secondary"); |
| 1049 |
|
| 1050 |
main_dir.run_jj(["desc", "-m", "first-commit"]).success(); |
| 1051 |
main_dir.write_file("file1", "foo"); |
| 1052 |
main_dir.write_file("file2", "foo"); |
| 1053 |
|
| 1054 |
// Create the second workspace and change its working copy commit to match |
| 1055 |
// the default workspace. |
| 1056 |
main_dir |
| 1057 |
.run_jj(["workspace", "add", "--name", "second", "../secondary"]) |
| 1058 |
.success(); |
| 1059 |
// Change the working copy in the second workspace. |
| 1060 |
secondary_dir |
| 1061 |
.run_jj(["edit", "-r", "subject(first-commit)"]) |
| 1062 |
.success(); |
| 1063 |
// Check the working-copy commit in each workspace in the log output. The "@" |
| 1064 |
// node in the graph indicates the current workspace's working-copy commit. |
| 1065 |
insta::assert_snapshot!(get_workspace_log_output(&main_dir), @" |
| 1066 |
@ qpvuntsmwlqt default@ second@ first-commit |
| 1067 |
◆ zzzzzzzzzzzz |
| 1068 |
[EOF] |
| 1069 |
"); |
| 1070 |
let setup_opid = main_dir.current_operation_id(); |
| 1071 |
|
| 1072 |
// Do the split in the default workspace. |
| 1073 |
std::fs::write( |
| 1074 |
&edit_script, |
| 1075 |
["", "next invocation\n", "write\nsecond-commit"].join("\0"), |
| 1076 |
)?; |
| 1077 |
main_dir.run_jj(["split", "file2"]).success(); |
| 1078 |
// The working copy for both workspaces will be the second split commit. |
| 1079 |
insta::assert_snapshot!(get_workspace_log_output(&main_dir), @" |
| 1080 |
@ royxmykxtrkr default@ second@ second-commit |
| 1081 |
○ qpvuntsmwlqt first-commit |
| 1082 |
◆ zzzzzzzzzzzz |
| 1083 |
[EOF] |
| 1084 |
"); |
| 1085 |
|
| 1086 |
// Test again with a --parallel split. |
| 1087 |
main_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1088 |
std::fs::write( |
| 1089 |
&edit_script, |
| 1090 |
["", "next invocation\n", "write\nsecond-commit"].join("\0"), |
| 1091 |
)?; |
| 1092 |
main_dir.run_jj(["split", "file2", "--parallel"]).success(); |
| 1093 |
insta::assert_snapshot!(get_workspace_log_output(&main_dir), @" |
| 1094 |
@ yostqsxwqrlt default@ second@ second-commit |
| 1095 |
│ ○ qpvuntsmwlqt first-commit |
| 1096 |
├─╯ |
| 1097 |
◆ zzzzzzzzzzzz |
| 1098 |
[EOF] |
| 1099 |
"); |
| 1100 |
Ok(()) |
| 1101 |
} |
| 1102 |
|
| 1103 |
// A workspace should only have its working copy commit updated if the target |
| 1104 |
// commit is the working copy commit. |
| 1105 |
#[test] |
| 1106 |
fn test_split_with_multiple_workspaces_different_working_copy() -> TestResult { |
| 1107 |
let mut test_env = TestEnvironment::default(); |
| 1108 |
let edit_script = test_env.set_up_fake_editor(); |
| 1109 |
test_env.run_jj_in(".", ["git", "init", "main"]).success(); |
| 1110 |
let main_dir = test_env.work_dir("main"); |
| 1111 |
|
| 1112 |
main_dir.run_jj(["desc", "-m", "first-commit"]).success(); |
| 1113 |
main_dir.write_file("file1", "foo"); |
| 1114 |
main_dir.write_file("file2", "foo"); |
| 1115 |
|
| 1116 |
// Create the second workspace with a different working copy commit. |
| 1117 |
main_dir |
| 1118 |
.run_jj(["workspace", "add", "--name", "second", "../secondary"]) |
| 1119 |
.success(); |
| 1120 |
// Check the working-copy commit in each workspace in the log output. The "@" |
| 1121 |
// node in the graph indicates the current workspace's working-copy commit. |
| 1122 |
insta::assert_snapshot!(get_workspace_log_output(&main_dir), @" |
| 1123 |
@ qpvuntsmwlqt default@ first-commit |
| 1124 |
│ ○ pmmvwywvzvvn second@ |
| 1125 |
├─╯ |
| 1126 |
◆ zzzzzzzzzzzz |
| 1127 |
[EOF] |
| 1128 |
"); |
| 1129 |
let setup_opid = main_dir.current_operation_id(); |
| 1130 |
|
| 1131 |
// Do the split in the default workspace. |
| 1132 |
std::fs::write( |
| 1133 |
&edit_script, |
| 1134 |
["", "next invocation\n", "write\nsecond-commit"].join("\0"), |
| 1135 |
)?; |
| 1136 |
main_dir.run_jj(["split", "file2"]).success(); |
| 1137 |
// Only the working copy commit for the default workspace changes. |
| 1138 |
insta::assert_snapshot!(get_workspace_log_output(&main_dir), @" |
| 1139 |
@ mzvwutvlkqwt default@ second-commit |
| 1140 |
○ qpvuntsmwlqt first-commit |
| 1141 |
│ ○ pmmvwywvzvvn second@ |
| 1142 |
├─╯ |
| 1143 |
◆ zzzzzzzzzzzz |
| 1144 |
[EOF] |
| 1145 |
"); |
| 1146 |
|
| 1147 |
// Test again with a --parallel split. |
| 1148 |
main_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1149 |
std::fs::write( |
| 1150 |
&edit_script, |
| 1151 |
["", "next invocation\n", "write\nsecond-commit"].join("\0"), |
| 1152 |
)?; |
| 1153 |
main_dir.run_jj(["split", "file2", "--parallel"]).success(); |
| 1154 |
insta::assert_snapshot!(get_workspace_log_output(&main_dir), @" |
| 1155 |
@ vruxwmqvtpmx default@ second-commit |
| 1156 |
│ ○ qpvuntsmwlqt first-commit |
| 1157 |
├─╯ |
| 1158 |
│ ○ pmmvwywvzvvn second@ |
| 1159 |
├─╯ |
| 1160 |
◆ zzzzzzzzzzzz |
| 1161 |
[EOF] |
| 1162 |
"); |
| 1163 |
Ok(()) |
| 1164 |
} |
| 1165 |
|
| 1166 |
#[test] |
| 1167 |
fn test_split_with_non_empty_description_and_trailers() -> TestResult { |
| 1168 |
let mut test_env = TestEnvironment::default(); |
| 1169 |
let edit_script = test_env.set_up_fake_editor(); |
| 1170 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1171 |
test_env.add_config(r#"template-aliases.default_commit_description = '"\n\nTESTED=TODO\n"'"#); |
| 1172 |
let work_dir = test_env.work_dir("repo"); |
| 1173 |
|
| 1174 |
work_dir.write_file("file1", "foo\n"); |
| 1175 |
work_dir.write_file("file2", "bar\n"); |
| 1176 |
work_dir.run_jj(["describe", "-m", "test"]).success(); |
| 1177 |
std::fs::write( |
| 1178 |
edit_script, |
| 1179 |
[ |
| 1180 |
"dump editor1", |
| 1181 |
"write\npart 1", |
| 1182 |
"next invocation\n", |
| 1183 |
"dump editor2", |
| 1184 |
"write\npart 2", |
| 1185 |
] |
| 1186 |
.join("\0"), |
| 1187 |
)?; |
| 1188 |
|
| 1189 |
test_env.add_config( |
| 1190 |
r#"[templates] |
| 1191 |
commit_trailers = '''"Signed-off-by: " ++ committer.email()'''"#, |
| 1192 |
); |
| 1193 |
let output = work_dir.run_jj(["split", "file1"]); |
| 1194 |
insta::assert_snapshot!(output, @" |
| 1195 |
------- stderr ------- |
| 1196 |
Selected changes : qpvuntsm c7f7b14b part 1 |
| 1197 |
Remaining changes: kkmpptxz ac33a5a9 part 2 |
| 1198 |
Working copy (@) now at: kkmpptxz ac33a5a9 part 2 |
| 1199 |
Parent commit (@-) : qpvuntsm c7f7b14b part 1 |
| 1200 |
[EOF] |
| 1201 |
"); |
| 1202 |
|
| 1203 |
insta::assert_snapshot!( |
| 1204 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 1205 |
JJ: Enter a description for the selected changes. |
| 1206 |
test |
| 1207 |
|
| 1208 |
Signed-off-by: [email protected] |
| 1209 |
|
| 1210 |
JJ: Change ID: qpvuntsm |
| 1211 |
JJ: This commit contains the following changes: |
| 1212 |
JJ: A file1 |
| 1213 |
JJ: |
| 1214 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1215 |
"#); |
| 1216 |
insta::assert_snapshot!( |
| 1217 |
std::fs::read_to_string(test_env.env_root().join("editor2"))?, @r#" |
| 1218 |
JJ: Enter a description for the remaining changes. |
| 1219 |
test |
| 1220 |
|
| 1221 |
Signed-off-by: [email protected] |
| 1222 |
|
| 1223 |
JJ: Change ID: kkmpptxz |
| 1224 |
JJ: This commit contains the following changes: |
| 1225 |
JJ: A file2 |
| 1226 |
JJ: |
| 1227 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1228 |
"#); |
| 1229 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1230 |
@ kkmpptxzrspx false part 2 |
| 1231 |
○ qpvuntsmwlqt false part 1 |
| 1232 |
◆ zzzzzzzzzzzz true |
| 1233 |
[EOF] |
| 1234 |
"); |
| 1235 |
Ok(()) |
| 1236 |
} |
| 1237 |
|
| 1238 |
#[test] |
| 1239 |
fn test_split_with_message() -> TestResult { |
| 1240 |
let test_env = TestEnvironment::default(); |
| 1241 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1242 |
let work_dir = test_env.work_dir("repo"); |
| 1243 |
|
| 1244 |
work_dir.write_file("file1", "foo\n"); |
| 1245 |
work_dir.write_file("file2", "bar\n"); |
| 1246 |
work_dir.run_jj(["describe", "-m", "my feature"]).success(); |
| 1247 |
let setup_opid = work_dir.current_operation_id(); |
| 1248 |
|
| 1249 |
let output = work_dir.run_jj(["split", "-m", "fix in file1", "file1"]); |
| 1250 |
insta::assert_snapshot!(output, @" |
| 1251 |
------- stderr ------- |
| 1252 |
Selected changes : qpvuntsm f2a70519 fix in file1 |
| 1253 |
Remaining changes: kkmpptxz cac11766 my feature |
| 1254 |
Working copy (@) now at: kkmpptxz cac11766 my feature |
| 1255 |
Parent commit (@-) : qpvuntsm f2a70519 fix in file1 |
| 1256 |
[EOF] |
| 1257 |
"); |
| 1258 |
|
| 1259 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1260 |
@ kkmpptxzrspx false my feature |
| 1261 |
○ qpvuntsmwlqt false fix in file1 |
| 1262 |
◆ zzzzzzzzzzzz true |
| 1263 |
[EOF] |
| 1264 |
"); |
| 1265 |
|
| 1266 |
// trailers should be added to the message |
| 1267 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1268 |
let output = work_dir.run_jj([ |
| 1269 |
"split", |
| 1270 |
"--config", |
| 1271 |
r#"templates.commit_trailers='"CC: " ++ committer.email()'"#, |
| 1272 |
"-m", |
| 1273 |
"fix in file1", |
| 1274 |
"file1", |
| 1275 |
]); |
| 1276 |
insta::assert_snapshot!(output, @" |
| 1277 |
------- stderr ------- |
| 1278 |
Selected changes : qpvuntsm d01cf12d fix in file1 |
| 1279 |
Remaining changes: royxmykx b1556ed9 my feature |
| 1280 |
Working copy (@) now at: royxmykx b1556ed9 my feature |
| 1281 |
Parent commit (@-) : qpvuntsm d01cf12d fix in file1 |
| 1282 |
[EOF] |
| 1283 |
"); |
| 1284 |
|
| 1285 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1286 |
@ royxmykxtrkr false my feature |
| 1287 |
○ qpvuntsmwlqt false fix in file1 |
| 1288 |
│ |
| 1289 |
│ CC: [email protected] |
| 1290 |
◆ zzzzzzzzzzzz true |
| 1291 |
[EOF] |
| 1292 |
"); |
| 1293 |
Ok(()) |
| 1294 |
} |
| 1295 |
|
| 1296 |
#[test] |
| 1297 |
fn test_split_move_first_commit() -> TestResult { |
| 1298 |
let test_env = TestEnvironment::default(); |
| 1299 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1300 |
let work_dir = test_env.work_dir("repo"); |
| 1301 |
|
| 1302 |
work_dir.write_file("file1", "foo\n"); |
| 1303 |
work_dir.write_file("file2", "bar\n"); |
| 1304 |
work_dir.run_jj(["commit", "-m", "file2"]).success(); |
| 1305 |
work_dir.write_file("file3", "bar\n"); |
| 1306 |
work_dir.run_jj(["commit", "-m", "file3"]).success(); |
| 1307 |
work_dir.write_file("file4", "bar\n"); |
| 1308 |
work_dir.run_jj(["commit", "-m", "file4"]).success(); |
| 1309 |
work_dir.run_jj(["new", "root()"]).success(); |
| 1310 |
work_dir.write_file("file5", "bar\n"); |
| 1311 |
work_dir.run_jj(["commit", "-m", "file5"]).success(); |
| 1312 |
|
| 1313 |
insta::assert_snapshot!(get_log_with_summary(&work_dir), @" |
| 1314 |
@ royxmykxtrkr |
| 1315 |
○ mzvwutvlkqwt file5 |
| 1316 |
│ A file5 |
| 1317 |
│ ○ kkmpptxzrspx file4 |
| 1318 |
│ │ A file4 |
| 1319 |
│ ○ rlvkpnrzqnoo file3 |
| 1320 |
│ │ A file3 |
| 1321 |
│ ○ qpvuntsmwlqt file2 |
| 1322 |
├─╯ A file1 |
| 1323 |
│ A file2 |
| 1324 |
◆ zzzzzzzzzzzz |
| 1325 |
[EOF] |
| 1326 |
"); |
| 1327 |
let setup_opid = work_dir.current_operation_id(); |
| 1328 |
|
| 1329 |
// insert the commit before the source commit |
| 1330 |
let output = work_dir.run_jj([ |
| 1331 |
"split", |
| 1332 |
"-m", |
| 1333 |
"file1", |
| 1334 |
"-r", |
| 1335 |
"qpvuntsmwlqt", |
| 1336 |
"--insert-before", |
| 1337 |
"qpvuntsmwlqt", |
| 1338 |
"file1", |
| 1339 |
]); |
| 1340 |
insta::assert_snapshot!(output, @r" |
| 1341 |
------- stderr ------- |
| 1342 |
Rebased 2 descendant commits. |
| 1343 |
Selected changes : vruxwmqv bf94c29a file1 |
| 1344 |
Remaining changes: qpvuntsm 66b1d4f1 file2 |
| 1345 |
[EOF] |
| 1346 |
"); |
| 1347 |
|
| 1348 |
insta::assert_snapshot!(get_log_with_summary(&work_dir), @" |
| 1349 |
@ royxmykxtrkr |
| 1350 |
○ mzvwutvlkqwt file5 |
| 1351 |
│ A file5 |
| 1352 |
│ ○ kkmpptxzrspx file4 |
| 1353 |
│ │ A file4 |
| 1354 |
│ ○ rlvkpnrzqnoo file3 |
| 1355 |
│ │ A file3 |
| 1356 |
│ ○ qpvuntsmwlqt file2 |
| 1357 |
│ │ A file2 |
| 1358 |
│ ○ vruxwmqvtpmx file1 |
| 1359 |
├─╯ A file1 |
| 1360 |
◆ zzzzzzzzzzzz |
| 1361 |
[EOF] |
| 1362 |
"); |
| 1363 |
|
| 1364 |
// insert the commit after the source commit |
| 1365 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1366 |
let output = work_dir.run_jj([ |
| 1367 |
"split", |
| 1368 |
"-m", |
| 1369 |
"file1", |
| 1370 |
"-r", |
| 1371 |
"qpvuntsmwlqt", |
| 1372 |
"--insert-after", |
| 1373 |
"qpvuntsmwlqt", |
| 1374 |
"file1", |
| 1375 |
]); |
| 1376 |
insta::assert_snapshot!(output, @r" |
| 1377 |
------- stderr ------- |
| 1378 |
Rebased 2 descendant commits. |
| 1379 |
Selected changes : kpqxywon 08294e90 file1 |
| 1380 |
Remaining changes: qpvuntsm 76ebcbb8 file2 |
| 1381 |
[EOF] |
| 1382 |
"); |
| 1383 |
|
| 1384 |
insta::assert_snapshot!(get_log_with_summary(&work_dir), @" |
| 1385 |
@ royxmykxtrkr |
| 1386 |
○ mzvwutvlkqwt file5 |
| 1387 |
│ A file5 |
| 1388 |
│ ○ kkmpptxzrspx file4 |
| 1389 |
│ │ A file4 |
| 1390 |
│ ○ rlvkpnrzqnoo file3 |
| 1391 |
│ │ A file3 |
| 1392 |
│ ○ kpqxywonksrl file1 |
| 1393 |
│ │ A file1 |
| 1394 |
│ ○ qpvuntsmwlqt file2 |
| 1395 |
├─╯ A file2 |
| 1396 |
◆ zzzzzzzzzzzz |
| 1397 |
[EOF] |
| 1398 |
"); |
| 1399 |
|
| 1400 |
// create a new branch anywhere in the tree |
| 1401 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1402 |
let output = work_dir.run_jj([ |
| 1403 |
"split", |
| 1404 |
"-m", |
| 1405 |
"file1", |
| 1406 |
"-r", |
| 1407 |
"qpvuntsmwlqt", |
| 1408 |
"--onto", |
| 1409 |
"rlvkpnrzqnoo", |
| 1410 |
"file1", |
| 1411 |
]); |
| 1412 |
insta::assert_snapshot!(output, @r" |
| 1413 |
------- stderr ------- |
| 1414 |
Rebased 2 descendant commits. |
| 1415 |
Selected changes : lylxulpl b42b2604 file1 |
| 1416 |
Remaining changes: qpvuntsm 0f76cbf0 file2 |
| 1417 |
[EOF] |
| 1418 |
"); |
| 1419 |
|
| 1420 |
insta::assert_snapshot!(get_log_with_summary(&work_dir), @" |
| 1421 |
@ royxmykxtrkr |
| 1422 |
○ mzvwutvlkqwt file5 |
| 1423 |
│ A file5 |
| 1424 |
│ ○ kkmpptxzrspx file4 |
| 1425 |
│ │ A file4 |
| 1426 |
│ │ ○ lylxulplsnyw file1 |
| 1427 |
│ ├─╯ A file1 |
| 1428 |
│ ○ rlvkpnrzqnoo file3 |
| 1429 |
│ │ A file3 |
| 1430 |
│ ○ qpvuntsmwlqt file2 |
| 1431 |
├─╯ A file2 |
| 1432 |
◆ zzzzzzzzzzzz |
| 1433 |
[EOF] |
| 1434 |
"); |
| 1435 |
|
| 1436 |
// create a bubble in the tree |
| 1437 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1438 |
let output = work_dir.run_jj([ |
| 1439 |
"split", |
| 1440 |
"-m", |
| 1441 |
"file1", |
| 1442 |
"-r", |
| 1443 |
"qpvuntsmwlqt", |
| 1444 |
"--insert-after", |
| 1445 |
"qpvuntsmwlqt", |
| 1446 |
"--insert-before", |
| 1447 |
"kkmpptxzrspx", |
| 1448 |
"file1", |
| 1449 |
]); |
| 1450 |
insta::assert_snapshot!(output, @r" |
| 1451 |
------- stderr ------- |
| 1452 |
Rebased 2 descendant commits. |
| 1453 |
Selected changes : uyznsvlq d0338445 file1 |
| 1454 |
Remaining changes: qpvuntsm 16d41320 file2 |
| 1455 |
[EOF] |
| 1456 |
"); |
| 1457 |
|
| 1458 |
insta::assert_snapshot!(get_log_with_summary(&work_dir), @" |
| 1459 |
@ royxmykxtrkr |
| 1460 |
○ mzvwutvlkqwt file5 |
| 1461 |
│ A file5 |
| 1462 |
│ ○ kkmpptxzrspx file4 |
| 1463 |
│ ├─╮ A file4 |
| 1464 |
│ │ ○ uyznsvlquzzm file1 |
| 1465 |
│ │ │ A file1 |
| 1466 |
│ ○ │ rlvkpnrzqnoo file3 |
| 1467 |
│ ├─╯ A file3 |
| 1468 |
│ ○ qpvuntsmwlqt file2 |
| 1469 |
├─╯ A file2 |
| 1470 |
◆ zzzzzzzzzzzz |
| 1471 |
[EOF] |
| 1472 |
"); |
| 1473 |
|
| 1474 |
// create a commit in another branch |
| 1475 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1476 |
let output = work_dir.run_jj([ |
| 1477 |
"split", |
| 1478 |
"-m", |
| 1479 |
"file1", |
| 1480 |
"-r", |
| 1481 |
"qpvuntsmwlqt", |
| 1482 |
"--before", |
| 1483 |
"@", |
| 1484 |
"file1", |
| 1485 |
]); |
| 1486 |
insta::assert_snapshot!(output, @r" |
| 1487 |
------- stderr ------- |
| 1488 |
Rebased 3 descendant commits. |
| 1489 |
Selected changes : nmzmmopx 72225233 file1 |
| 1490 |
Remaining changes: qpvuntsm 98b70782 file2 |
| 1491 |
Working copy (@) now at: royxmykx c3dd10b0 (empty) (no description set) |
| 1492 |
Parent commit (@-) : nmzmmopx 72225233 file1 |
| 1493 |
Added 1 files, modified 0 files, removed 0 files |
| 1494 |
[EOF] |
| 1495 |
"); |
| 1496 |
|
| 1497 |
insta::assert_snapshot!(get_log_with_summary(&work_dir), @" |
| 1498 |
@ royxmykxtrkr |
| 1499 |
○ nmzmmopxokps file1 |
| 1500 |
│ A file1 |
| 1501 |
○ mzvwutvlkqwt file5 |
| 1502 |
│ A file5 |
| 1503 |
│ ○ kkmpptxzrspx file4 |
| 1504 |
│ │ A file4 |
| 1505 |
│ ○ rlvkpnrzqnoo file3 |
| 1506 |
│ │ A file3 |
| 1507 |
│ ○ qpvuntsmwlqt file2 |
| 1508 |
├─╯ A file2 |
| 1509 |
◆ zzzzzzzzzzzz |
| 1510 |
[EOF] |
| 1511 |
"); |
| 1512 |
|
| 1513 |
// merge two branches with the new commit |
| 1514 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1515 |
let output = work_dir.run_jj([ |
| 1516 |
"split", |
| 1517 |
"-m", |
| 1518 |
"file1", |
| 1519 |
"-r", |
| 1520 |
"qpvuntsmwlqt", |
| 1521 |
"--after", |
| 1522 |
"mzvwutvlkqwt", |
| 1523 |
"--after", |
| 1524 |
"kkmpptxzrspx", |
| 1525 |
"file1", |
| 1526 |
]); |
| 1527 |
insta::assert_snapshot!(output, @r" |
| 1528 |
------- stderr ------- |
| 1529 |
Rebased 3 descendant commits. |
| 1530 |
Selected changes : nlrtlrxv 1b6975b0 file1 |
| 1531 |
Remaining changes: qpvuntsm 905586dd file2 |
| 1532 |
Working copy (@) now at: royxmykx 85be9860 (empty) (no description set) |
| 1533 |
Parent commit (@-) : nlrtlrxv 1b6975b0 file1 |
| 1534 |
Added 4 files, modified 0 files, removed 0 files |
| 1535 |
[EOF] |
| 1536 |
"); |
| 1537 |
|
| 1538 |
insta::assert_snapshot!(get_log_with_summary(&work_dir), @" |
| 1539 |
@ royxmykxtrkr |
| 1540 |
○ nlrtlrxvuusk file1 |
| 1541 |
├─╮ A file1 |
| 1542 |
│ ○ kkmpptxzrspx file4 |
| 1543 |
│ │ A file4 |
| 1544 |
│ ○ rlvkpnrzqnoo file3 |
| 1545 |
│ │ A file3 |
| 1546 |
│ ○ qpvuntsmwlqt file2 |
| 1547 |
│ │ A file2 |
| 1548 |
○ │ mzvwutvlkqwt file5 |
| 1549 |
├─╯ A file5 |
| 1550 |
◆ zzzzzzzzzzzz |
| 1551 |
[EOF] |
| 1552 |
"); |
| 1553 |
Ok(()) |
| 1554 |
} |
| 1555 |
|
| 1556 |
enum BookmarkBehavior { |
| 1557 |
Default, |
| 1558 |
MoveBookmarkToChild, |
| 1559 |
LeaveBookmarkWithTarget, |
| 1560 |
} |
| 1561 |
|
| 1562 |
// TODO: https://github.com/jj-vcs/jj/issues/3419 - Delete params when the config is removed. |
| 1563 |
#[test_case(BookmarkBehavior::Default; "default_behavior")] |
| 1564 |
#[test_case(BookmarkBehavior::MoveBookmarkToChild; "move_bookmark_to_child")] |
| 1565 |
#[test_case(BookmarkBehavior::LeaveBookmarkWithTarget; "leave_bookmark_with_target")] |
| 1566 |
fn test_split_with_bookmarks(bookmark_behavior: BookmarkBehavior) -> TestResult { |
| 1567 |
let mut test_env = TestEnvironment::default(); |
| 1568 |
let edit_script = test_env.set_up_fake_editor(); |
| 1569 |
test_env.run_jj_in(".", ["git", "init", "main"]).success(); |
| 1570 |
let main_dir = test_env.work_dir("main"); |
| 1571 |
|
| 1572 |
match bookmark_behavior { |
| 1573 |
BookmarkBehavior::LeaveBookmarkWithTarget => { |
| 1574 |
test_env.add_config("split.legacy-bookmark-behavior=false"); |
| 1575 |
} |
| 1576 |
BookmarkBehavior::MoveBookmarkToChild => { |
| 1577 |
test_env.add_config("split.legacy-bookmark-behavior=true"); |
| 1578 |
} |
| 1579 |
BookmarkBehavior::Default => (), |
| 1580 |
} |
| 1581 |
|
| 1582 |
// Setup. |
| 1583 |
main_dir.run_jj(["desc", "-m", "first-commit"]).success(); |
| 1584 |
main_dir.write_file("file1", "foo"); |
| 1585 |
main_dir.write_file("file2", "foo"); |
| 1586 |
main_dir |
| 1587 |
.run_jj(["bookmark", "set", "*le-signet*", "-r", "@"]) |
| 1588 |
.success(); |
| 1589 |
insta::allow_duplicates! { |
| 1590 |
insta::assert_snapshot!(get_log_output(&main_dir), @" |
| 1591 |
@ qpvuntsmwlqt false *le-signet* first-commit |
| 1592 |
◆ zzzzzzzzzzzz true |
| 1593 |
[EOF] |
| 1594 |
"); |
| 1595 |
} |
| 1596 |
let setup_opid = main_dir.current_operation_id(); |
| 1597 |
|
| 1598 |
// Do the split. |
| 1599 |
std::fs::write( |
| 1600 |
&edit_script, |
| 1601 |
["", "next invocation\n", "write\nsecond-commit"].join("\0"), |
| 1602 |
)?; |
| 1603 |
let output = main_dir.run_jj(["split", "file2"]); |
| 1604 |
match bookmark_behavior { |
| 1605 |
BookmarkBehavior::LeaveBookmarkWithTarget => { |
| 1606 |
insta::allow_duplicates! { |
| 1607 |
insta::assert_snapshot!(output, @" |
| 1608 |
------- stderr ------- |
| 1609 |
Selected changes : qpvuntsm a481fe8a *le-signet* | first-commit |
| 1610 |
Remaining changes: mzvwutvl 5f597a6e second-commit |
| 1611 |
Working copy (@) now at: mzvwutvl 5f597a6e second-commit |
| 1612 |
Parent commit (@-) : qpvuntsm a481fe8a *le-signet* | first-commit |
| 1613 |
[EOF] |
| 1614 |
"); |
| 1615 |
} |
| 1616 |
insta::allow_duplicates! { |
| 1617 |
insta::assert_snapshot!(get_log_output(&main_dir), @" |
| 1618 |
@ mzvwutvlkqwt false second-commit |
| 1619 |
○ qpvuntsmwlqt false *le-signet* first-commit |
| 1620 |
◆ zzzzzzzzzzzz true |
| 1621 |
[EOF] |
| 1622 |
"); |
| 1623 |
} |
| 1624 |
} |
| 1625 |
BookmarkBehavior::Default | BookmarkBehavior::MoveBookmarkToChild => { |
| 1626 |
insta::allow_duplicates! { |
| 1627 |
insta::assert_snapshot!(output, @" |
| 1628 |
------- stderr ------- |
| 1629 |
Selected changes : qpvuntsm a481fe8a first-commit |
| 1630 |
Remaining changes: mzvwutvl 5f597a6e *le-signet* | second-commit |
| 1631 |
Working copy (@) now at: mzvwutvl 5f597a6e *le-signet* | second-commit |
| 1632 |
Parent commit (@-) : qpvuntsm a481fe8a first-commit |
| 1633 |
[EOF] |
| 1634 |
"); |
| 1635 |
} |
| 1636 |
insta::allow_duplicates! { |
| 1637 |
insta::assert_snapshot!(get_log_output(&main_dir), @" |
| 1638 |
@ mzvwutvlkqwt false *le-signet* second-commit |
| 1639 |
○ qpvuntsmwlqt false first-commit |
| 1640 |
◆ zzzzzzzzzzzz true |
| 1641 |
[EOF] |
| 1642 |
"); |
| 1643 |
} |
| 1644 |
} |
| 1645 |
} |
| 1646 |
|
| 1647 |
// Test again with a --parallel split. |
| 1648 |
main_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1649 |
std::fs::write( |
| 1650 |
&edit_script, |
| 1651 |
["", "next invocation\n", "write\nsecond-commit"].join("\0"), |
| 1652 |
)?; |
| 1653 |
main_dir.run_jj(["split", "file2", "--parallel"]).success(); |
| 1654 |
match bookmark_behavior { |
| 1655 |
BookmarkBehavior::LeaveBookmarkWithTarget => { |
| 1656 |
insta::allow_duplicates! { |
| 1657 |
insta::assert_snapshot!(get_log_output(&main_dir), @" |
| 1658 |
@ vruxwmqvtpmx false second-commit |
| 1659 |
│ ○ qpvuntsmwlqt false *le-signet* first-commit |
| 1660 |
├─╯ |
| 1661 |
◆ zzzzzzzzzzzz true |
| 1662 |
[EOF] |
| 1663 |
"); |
| 1664 |
} |
| 1665 |
} |
| 1666 |
BookmarkBehavior::Default | BookmarkBehavior::MoveBookmarkToChild => { |
| 1667 |
insta::allow_duplicates! { |
| 1668 |
insta::assert_snapshot!(get_log_output(&main_dir), @" |
| 1669 |
@ vruxwmqvtpmx false *le-signet* second-commit |
| 1670 |
│ ○ qpvuntsmwlqt false first-commit |
| 1671 |
├─╯ |
| 1672 |
◆ zzzzzzzzzzzz true |
| 1673 |
[EOF] |
| 1674 |
"); |
| 1675 |
} |
| 1676 |
} |
| 1677 |
} |
| 1678 |
Ok(()) |
| 1679 |
} |
| 1680 |
|
| 1681 |
#[test] |
| 1682 |
fn test_split_with_editor_and_message_args() -> TestResult { |
| 1683 |
let mut test_env = TestEnvironment::default(); |
| 1684 |
let edit_script = test_env.set_up_fake_editor(); |
| 1685 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1686 |
let work_dir = test_env.work_dir("repo"); |
| 1687 |
|
| 1688 |
work_dir.write_file("file1", "foo\n"); |
| 1689 |
work_dir.write_file("file2", "bar\n"); |
| 1690 |
work_dir |
| 1691 |
.run_jj(["describe", "-m", "original description"]) |
| 1692 |
.success(); |
| 1693 |
|
| 1694 |
std::fs::write( |
| 1695 |
&edit_script, |
| 1696 |
[ |
| 1697 |
"dump editor1", |
| 1698 |
"write\nedited message 1", |
| 1699 |
"next invocation\n", |
| 1700 |
"dump editor2", |
| 1701 |
"write\nedited message 2", |
| 1702 |
] |
| 1703 |
.join("\0"), |
| 1704 |
)?; |
| 1705 |
work_dir |
| 1706 |
.run_jj([ |
| 1707 |
"split", |
| 1708 |
"-m", |
| 1709 |
"message from command line", |
| 1710 |
"--editor", |
| 1711 |
"file1", |
| 1712 |
]) |
| 1713 |
.success(); |
| 1714 |
|
| 1715 |
// Verify editor was opened for the first commit with message from command line |
| 1716 |
insta::assert_snapshot!( |
| 1717 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 1718 |
JJ: Enter a description for the selected changes. |
| 1719 |
message from command line |
| 1720 |
|
| 1721 |
JJ: Change ID: qpvuntsm |
| 1722 |
JJ: This commit contains the following changes: |
| 1723 |
JJ: A file1 |
| 1724 |
JJ: |
| 1725 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1726 |
"#); |
| 1727 |
|
| 1728 |
// Verify editor was opened for the second commit with the original description |
| 1729 |
insta::assert_snapshot!( |
| 1730 |
std::fs::read_to_string(test_env.env_root().join("editor2"))?, @r#" |
| 1731 |
JJ: Enter a description for the remaining changes. |
| 1732 |
original description |
| 1733 |
|
| 1734 |
JJ: Change ID: kkmpptxz |
| 1735 |
JJ: This commit contains the following changes: |
| 1736 |
JJ: A file2 |
| 1737 |
JJ: |
| 1738 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1739 |
"#); |
| 1740 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1741 |
@ kkmpptxzrspx false edited message 2 |
| 1742 |
○ qpvuntsmwlqt false edited message 1 |
| 1743 |
◆ zzzzzzzzzzzz true |
| 1744 |
[EOF] |
| 1745 |
"); |
| 1746 |
Ok(()) |
| 1747 |
} |
| 1748 |
|
| 1749 |
#[test] |
| 1750 |
fn test_split_with_editor_and_empty_message() -> TestResult { |
| 1751 |
let mut test_env = TestEnvironment::default(); |
| 1752 |
let edit_script = test_env.set_up_fake_editor(); |
| 1753 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1754 |
let work_dir = test_env.work_dir("repo"); |
| 1755 |
|
| 1756 |
work_dir.write_file("file1", "foo\n"); |
| 1757 |
work_dir.write_file("file2", "bar\n"); |
| 1758 |
work_dir |
| 1759 |
.run_jj(["describe", "-m", "original description"]) |
| 1760 |
.success(); |
| 1761 |
|
| 1762 |
// Use --editor with an empty message. The trailers should be added because |
| 1763 |
// the editor will be opened. |
| 1764 |
std::fs::write( |
| 1765 |
&edit_script, |
| 1766 |
[ |
| 1767 |
"dump editor1", |
| 1768 |
"write\nfirst commit", |
| 1769 |
"next invocation\n", |
| 1770 |
"dump editor2", |
| 1771 |
"write\nsecond commit", |
| 1772 |
] |
| 1773 |
.join("\0"), |
| 1774 |
)?; |
| 1775 |
work_dir |
| 1776 |
.run_jj([ |
| 1777 |
"split", |
| 1778 |
"-m", |
| 1779 |
"", |
| 1780 |
"--editor", |
| 1781 |
"--config", |
| 1782 |
r#"templates.commit_trailers='"Trailer: value"'"#, |
| 1783 |
"file1", |
| 1784 |
]) |
| 1785 |
.success(); |
| 1786 |
|
| 1787 |
// Verify editor was opened for the first commit with trailers added to the |
| 1788 |
// empty message |
| 1789 |
insta::assert_snapshot!( |
| 1790 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 1791 |
JJ: Enter a description for the selected changes. |
| 1792 |
|
| 1793 |
|
| 1794 |
Trailer: value |
| 1795 |
|
| 1796 |
JJ: Change ID: qpvuntsm |
| 1797 |
JJ: This commit contains the following changes: |
| 1798 |
JJ: A file1 |
| 1799 |
JJ: |
| 1800 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1801 |
"#); |
| 1802 |
// Verify editor was opened for the second commit with the original description |
| 1803 |
insta::assert_snapshot!( |
| 1804 |
std::fs::read_to_string(test_env.env_root().join("editor2"))?, @r#" |
| 1805 |
JJ: Enter a description for the remaining changes. |
| 1806 |
original description |
| 1807 |
|
| 1808 |
Trailer: value |
| 1809 |
|
| 1810 |
JJ: Change ID: kkmpptxz |
| 1811 |
JJ: This commit contains the following changes: |
| 1812 |
JJ: A file2 |
| 1813 |
JJ: |
| 1814 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1815 |
"#); |
| 1816 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1817 |
@ kkmpptxzrspx false second commit |
| 1818 |
○ qpvuntsmwlqt false first commit |
| 1819 |
◆ zzzzzzzzzzzz true |
| 1820 |
[EOF] |
| 1821 |
"); |
| 1822 |
Ok(()) |
| 1823 |
} |
| 1824 |
|
| 1825 |
#[test] |
| 1826 |
fn test_split_with_editor_without_message() -> TestResult { |
| 1827 |
let mut test_env = TestEnvironment::default(); |
| 1828 |
let edit_script = test_env.set_up_fake_editor(); |
| 1829 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1830 |
let work_dir = test_env.work_dir("repo"); |
| 1831 |
|
| 1832 |
work_dir.write_file("file1", "foo\n"); |
| 1833 |
work_dir.write_file("file2", "bar\n"); |
| 1834 |
work_dir |
| 1835 |
.run_jj(["describe", "-m", "original description"]) |
| 1836 |
.success(); |
| 1837 |
|
| 1838 |
// --editor without -m should behave the same as without --editor (normal flow) |
| 1839 |
std::fs::write( |
| 1840 |
&edit_script, |
| 1841 |
[ |
| 1842 |
"dump editor0", |
| 1843 |
"write\nfrom editor1", |
| 1844 |
"next invocation\n", |
| 1845 |
"dump editor1", |
| 1846 |
"write\nfrom editor2", |
| 1847 |
] |
| 1848 |
.join("\0"), |
| 1849 |
)?; |
| 1850 |
work_dir.run_jj(["split", "--editor", "file1"]).success(); |
| 1851 |
|
| 1852 |
// Verify editor was opened for the first commit |
| 1853 |
insta::assert_snapshot!( |
| 1854 |
std::fs::read_to_string(test_env.env_root().join("editor0"))?, @r#" |
| 1855 |
JJ: Enter a description for the selected changes. |
| 1856 |
original description |
| 1857 |
|
| 1858 |
JJ: Change ID: qpvuntsm |
| 1859 |
JJ: This commit contains the following changes: |
| 1860 |
JJ: A file1 |
| 1861 |
JJ: |
| 1862 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1863 |
"#); |
| 1864 |
// Verify editor was opened for the second commit |
| 1865 |
insta::assert_snapshot!( |
| 1866 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 1867 |
JJ: Enter a description for the remaining changes. |
| 1868 |
original description |
| 1869 |
|
| 1870 |
JJ: Change ID: kkmpptxz |
| 1871 |
JJ: This commit contains the following changes: |
| 1872 |
JJ: A file2 |
| 1873 |
JJ: |
| 1874 |
JJ: Lines starting with "JJ:" (like this one) will be removed. |
| 1875 |
"#); |
| 1876 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1877 |
@ kkmpptxzrspx false from editor2 |
| 1878 |
○ qpvuntsmwlqt false from editor1 |
| 1879 |
◆ zzzzzzzzzzzz true |
| 1880 |
[EOF] |
| 1881 |
"); |
| 1882 |
Ok(()) |
| 1883 |
} |