| 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::Path; |
| 16 |
|
| 17 |
use indoc::indoc; |
| 18 |
use testutils::TestResult; |
| 19 |
|
| 20 |
use crate::common::CommandOutput; |
| 21 |
use crate::common::TestEnvironment; |
| 22 |
use crate::common::TestWorkDir; |
| 23 |
use crate::common::create_commit_with_files; |
| 24 |
|
| 25 |
#[must_use] |
| 26 |
fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { |
| 27 |
work_dir.run_jj(["log", "-T", "bookmarks"]) |
| 28 |
} |
| 29 |
|
| 30 |
#[test] |
| 31 |
fn test_resolution() -> TestResult { |
| 32 |
let mut test_env = TestEnvironment::default(); |
| 33 |
let editor_script = test_env.set_up_fake_editor(); |
| 34 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 35 |
let work_dir = test_env.work_dir("repo"); |
| 36 |
|
| 37 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); |
| 38 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); |
| 39 |
create_commit_with_files(&work_dir, "b", &["base"], &[("file", "b\n")]); |
| 40 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 41 |
// Test the setup |
| 42 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 43 |
@ conflict |
| 44 |
├─╮ |
| 45 |
│ ○ b |
| 46 |
○ │ a |
| 47 |
├─╯ |
| 48 |
○ base |
| 49 |
◆ |
| 50 |
[EOF] |
| 51 |
"); |
| 52 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 53 |
file 2-sided conflict |
| 54 |
[EOF] |
| 55 |
"); |
| 56 |
insta::assert_snapshot!(work_dir.read_file("file"), @r#" |
| 57 |
<<<<<<< conflict 1 of 1 |
| 58 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 59 |
\\\\\\\ to: zsuskuln 45537d53 "a" |
| 60 |
-base |
| 61 |
+a |
| 62 |
+++++++ royxmykx 89d1b299 "b" |
| 63 |
b |
| 64 |
>>>>>>> conflict 1 of 1 ends |
| 65 |
"#); |
| 66 |
let setup_opid = work_dir.current_operation_id(); |
| 67 |
|
| 68 |
// Check that output file starts out empty and resolve the conflict |
| 69 |
std::fs::write( |
| 70 |
&editor_script, |
| 71 |
["dump editor0", "write\nresolution\n"].join("\0"), |
| 72 |
)?; |
| 73 |
let output = work_dir.run_jj(["resolve"]); |
| 74 |
insta::assert_snapshot!(output, @" |
| 75 |
------- stderr ------- |
| 76 |
Resolving conflicts in: file |
| 77 |
Working copy (@) now at: vruxwmqv 741263c9 conflict | conflict |
| 78 |
Parent commit (@-) : zsuskuln 45537d53 a | a |
| 79 |
Parent commit (@-) : royxmykx 89d1b299 b | b |
| 80 |
Added 0 files, modified 1 files, removed 0 files |
| 81 |
[EOF] |
| 82 |
"); |
| 83 |
insta::assert_snapshot!( |
| 84 |
std::fs::read_to_string(test_env.env_root().join("editor0"))?, @""); |
| 85 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 86 |
diff --git a/file b/file |
| 87 |
index 0000000000..88425ec521 100644 |
| 88 |
--- a/file |
| 89 |
+++ b/file |
| 90 |
@@ -1,8 +1,1 @@ |
| 91 |
-<<<<<<< conflict 1 of 1 |
| 92 |
-%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 93 |
-\\\\\\\ to: zsuskuln 45537d53 "a" |
| 94 |
--base |
| 95 |
-+a |
| 96 |
-+++++++ royxmykx 89d1b299 "b" |
| 97 |
-b |
| 98 |
->>>>>>> conflict 1 of 1 ends |
| 99 |
+resolution |
| 100 |
[EOF] |
| 101 |
"#); |
| 102 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 103 |
------- stderr ------- |
| 104 |
Error: No conflicts found at this revision |
| 105 |
[EOF] |
| 106 |
[exit status: 2] |
| 107 |
"); |
| 108 |
|
| 109 |
// Try again with --tool=<name> |
| 110 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 111 |
std::fs::write(&editor_script, "write\nresolution\n")?; |
| 112 |
let output = work_dir.run_jj([ |
| 113 |
"resolve", |
| 114 |
"--config=ui.merge-editor='false'", |
| 115 |
"--tool=fake-editor", |
| 116 |
]); |
| 117 |
insta::assert_snapshot!(output, @" |
| 118 |
------- stderr ------- |
| 119 |
Resolving conflicts in: file |
| 120 |
Working copy (@) now at: vruxwmqv 1f8a36f7 conflict | conflict |
| 121 |
Parent commit (@-) : zsuskuln 45537d53 a | a |
| 122 |
Parent commit (@-) : royxmykx 89d1b299 b | b |
| 123 |
Added 0 files, modified 1 files, removed 0 files |
| 124 |
[EOF] |
| 125 |
"); |
| 126 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 127 |
diff --git a/file b/file |
| 128 |
index 0000000000..88425ec521 100644 |
| 129 |
--- a/file |
| 130 |
+++ b/file |
| 131 |
@@ -1,8 +1,1 @@ |
| 132 |
-<<<<<<< conflict 1 of 1 |
| 133 |
-%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 134 |
-\\\\\\\ to: zsuskuln 45537d53 "a" |
| 135 |
--base |
| 136 |
-+a |
| 137 |
-+++++++ royxmykx 89d1b299 "b" |
| 138 |
-b |
| 139 |
->>>>>>> conflict 1 of 1 ends |
| 140 |
+resolution |
| 141 |
[EOF] |
| 142 |
"#); |
| 143 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 144 |
------- stderr ------- |
| 145 |
Error: No conflicts found at this revision |
| 146 |
[EOF] |
| 147 |
[exit status: 2] |
| 148 |
"); |
| 149 |
|
| 150 |
// Check that the output file starts with conflict markers if |
| 151 |
// `merge-tool-edits-conflict-markers=true` |
| 152 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 153 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 154 |
std::fs::write( |
| 155 |
&editor_script, |
| 156 |
["dump editor1", "write\nresolution\n"].join("\0"), |
| 157 |
)?; |
| 158 |
work_dir |
| 159 |
.run_jj([ |
| 160 |
"resolve", |
| 161 |
"--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", |
| 162 |
]) |
| 163 |
.success(); |
| 164 |
insta::assert_snapshot!( |
| 165 |
std::fs::read_to_string(test_env.env_root().join("editor1"))?, @r#" |
| 166 |
<<<<<<< conflict 1 of 1 |
| 167 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 168 |
\\\\\\\ to: zsuskuln 45537d53 "a" |
| 169 |
-base |
| 170 |
+a |
| 171 |
+++++++ royxmykx 89d1b299 "b" |
| 172 |
b |
| 173 |
>>>>>>> conflict 1 of 1 ends |
| 174 |
"#); |
| 175 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 176 |
diff --git a/file b/file |
| 177 |
index 0000000000..88425ec521 100644 |
| 178 |
--- a/file |
| 179 |
+++ b/file |
| 180 |
@@ -1,8 +1,1 @@ |
| 181 |
-<<<<<<< conflict 1 of 1 |
| 182 |
-%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 183 |
-\\\\\\\ to: zsuskuln 45537d53 "a" |
| 184 |
--base |
| 185 |
-+a |
| 186 |
-+++++++ royxmykx 89d1b299 "b" |
| 187 |
-b |
| 188 |
->>>>>>> conflict 1 of 1 ends |
| 189 |
+resolution |
| 190 |
[EOF] |
| 191 |
"#); |
| 192 |
|
| 193 |
// Check that if merge tool leaves conflict markers in output file and |
| 194 |
// `merge-tool-edits-conflict-markers=true`, these markers are properly parsed. |
| 195 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 196 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 197 |
std::fs::write( |
| 198 |
&editor_script, |
| 199 |
[ |
| 200 |
"dump editor2", |
| 201 |
indoc! {" |
| 202 |
write |
| 203 |
<<<<<<< |
| 204 |
%%%%%%% |
| 205 |
-some |
| 206 |
+fake |
| 207 |
+++++++ |
| 208 |
conflict |
| 209 |
>>>>>>> |
| 210 |
"}, |
| 211 |
] |
| 212 |
.join("\0"), |
| 213 |
)?; |
| 214 |
let output = work_dir.run_jj([ |
| 215 |
"resolve", |
| 216 |
"--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", |
| 217 |
]); |
| 218 |
insta::assert_snapshot!(output, @" |
| 219 |
------- stderr ------- |
| 220 |
Resolving conflicts in: file |
| 221 |
Working copy (@) now at: vruxwmqv a9cb79b1 conflict | (conflict) conflict |
| 222 |
Parent commit (@-) : zsuskuln 45537d53 a | a |
| 223 |
Parent commit (@-) : royxmykx 89d1b299 b | b |
| 224 |
Added 0 files, modified 1 files, removed 0 files |
| 225 |
Warning: There are unresolved conflicts at these paths: |
| 226 |
file 2-sided conflict |
| 227 |
New conflicts appeared in 1 commits: |
| 228 |
vruxwmqv a9cb79b1 conflict | (conflict) conflict |
| 229 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 230 |
the conflicted commit: |
| 231 |
jj new vruxwmqv |
| 232 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 233 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 234 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 235 |
[EOF] |
| 236 |
"); |
| 237 |
insta::assert_snapshot!( |
| 238 |
std::fs::read_to_string(test_env.env_root().join("editor2"))?, @r#" |
| 239 |
<<<<<<< conflict 1 of 1 |
| 240 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 241 |
\\\\\\\ to: zsuskuln 45537d53 "a" |
| 242 |
-base |
| 243 |
+a |
| 244 |
+++++++ royxmykx 89d1b299 "b" |
| 245 |
b |
| 246 |
>>>>>>> conflict 1 of 1 ends |
| 247 |
"#); |
| 248 |
// Note the "Modified" below |
| 249 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 250 |
diff --git a/file b/file |
| 251 |
--- a/file |
| 252 |
+++ b/file |
| 253 |
@@ -1,8 +1,8 @@ |
| 254 |
<<<<<<< conflict 1 of 1 |
| 255 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 256 |
\\\\\\\ to: zsuskuln 45537d53 "a" |
| 257 |
--base |
| 258 |
-+a |
| 259 |
+-some |
| 260 |
++fake |
| 261 |
+++++++ royxmykx 89d1b299 "b" |
| 262 |
-b |
| 263 |
+conflict |
| 264 |
>>>>>>> conflict 1 of 1 ends |
| 265 |
[EOF] |
| 266 |
"#); |
| 267 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 268 |
file 2-sided conflict |
| 269 |
[EOF] |
| 270 |
"); |
| 271 |
|
| 272 |
// Check that if merge tool leaves conflict markers in output file but |
| 273 |
// `merge-tool-edits-conflict-markers=false` or is not specified, |
| 274 |
// `jj` considers the conflict resolved. |
| 275 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 276 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 277 |
std::fs::write( |
| 278 |
&editor_script, |
| 279 |
[ |
| 280 |
"dump editor3", |
| 281 |
indoc! {" |
| 282 |
write |
| 283 |
<<<<<<< |
| 284 |
%%%%%%% |
| 285 |
-some |
| 286 |
+fake |
| 287 |
+++++++ |
| 288 |
conflict |
| 289 |
>>>>>>> |
| 290 |
"}, |
| 291 |
] |
| 292 |
.join("\0"), |
| 293 |
)?; |
| 294 |
let output = work_dir.run_jj(["resolve"]); |
| 295 |
insta::assert_snapshot!(output, @" |
| 296 |
------- stderr ------- |
| 297 |
Resolving conflicts in: file |
| 298 |
Working copy (@) now at: vruxwmqv 2cc7f5e3 conflict | conflict |
| 299 |
Parent commit (@-) : zsuskuln 45537d53 a | a |
| 300 |
Parent commit (@-) : royxmykx 89d1b299 b | b |
| 301 |
Added 0 files, modified 1 files, removed 0 files |
| 302 |
[EOF] |
| 303 |
"); |
| 304 |
insta::assert_snapshot!( |
| 305 |
std::fs::read_to_string(test_env.env_root().join("editor3"))?, @""); |
| 306 |
// Note the "Resolved" below |
| 307 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 308 |
diff --git a/file b/file |
| 309 |
index 0000000000..0610716cc1 100644 |
| 310 |
--- a/file |
| 311 |
+++ b/file |
| 312 |
@@ -1,8 +1,7 @@ |
| 313 |
-<<<<<<< conflict 1 of 1 |
| 314 |
-%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 315 |
-\\\\\\\ to: zsuskuln 45537d53 "a" |
| 316 |
--base |
| 317 |
-+a |
| 318 |
-+++++++ royxmykx 89d1b299 "b" |
| 319 |
-b |
| 320 |
->>>>>>> conflict 1 of 1 ends |
| 321 |
+<<<<<<< |
| 322 |
+%%%%%%% |
| 323 |
+-some |
| 324 |
++fake |
| 325 |
++++++++ |
| 326 |
+conflict |
| 327 |
+>>>>>>> |
| 328 |
[EOF] |
| 329 |
"#); |
| 330 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 331 |
------- stderr ------- |
| 332 |
Error: No conflicts found at this revision |
| 333 |
[EOF] |
| 334 |
[exit status: 2] |
| 335 |
"); |
| 336 |
|
| 337 |
// Check that merge tool can override conflict marker style setting, and that |
| 338 |
// the merge tool can output Git-style conflict markers |
| 339 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 340 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 341 |
std::fs::write( |
| 342 |
&editor_script, |
| 343 |
[ |
| 344 |
"dump editor4", |
| 345 |
indoc! {" |
| 346 |
write |
| 347 |
<<<<<<< |
| 348 |
some |
| 349 |
||||||| |
| 350 |
fake |
| 351 |
======= |
| 352 |
conflict |
| 353 |
>>>>>>> |
| 354 |
"}, |
| 355 |
] |
| 356 |
.join("\0"), |
| 357 |
)?; |
| 358 |
let output = work_dir.run_jj([ |
| 359 |
"resolve", |
| 360 |
"--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", |
| 361 |
"--config=merge-tools.fake-editor.conflict-marker-style=git", |
| 362 |
]); |
| 363 |
insta::assert_snapshot!(output, @" |
| 364 |
------- stderr ------- |
| 365 |
Resolving conflicts in: file |
| 366 |
Working copy (@) now at: vruxwmqv cd45e3c2 conflict | (conflict) conflict |
| 367 |
Parent commit (@-) : zsuskuln 45537d53 a | a |
| 368 |
Parent commit (@-) : royxmykx 89d1b299 b | b |
| 369 |
Added 0 files, modified 1 files, removed 0 files |
| 370 |
Warning: There are unresolved conflicts at these paths: |
| 371 |
file 2-sided conflict |
| 372 |
New conflicts appeared in 1 commits: |
| 373 |
vruxwmqv cd45e3c2 conflict | (conflict) conflict |
| 374 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 375 |
the conflicted commit: |
| 376 |
jj new vruxwmqv |
| 377 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 378 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 379 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 380 |
[EOF] |
| 381 |
"); |
| 382 |
insta::assert_snapshot!( |
| 383 |
std::fs::read_to_string(test_env.env_root().join("editor4"))?, @r#" |
| 384 |
<<<<<<< zsuskuln 45537d53 "a" |
| 385 |
a |
| 386 |
||||||| rlvkpnrz 1792382a "base" |
| 387 |
base |
| 388 |
======= |
| 389 |
b |
| 390 |
>>>>>>> royxmykx 89d1b299 "b" |
| 391 |
"#); |
| 392 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 393 |
diff --git a/file b/file |
| 394 |
--- a/file |
| 395 |
+++ b/file |
| 396 |
@@ -1,8 +1,8 @@ |
| 397 |
<<<<<<< conflict 1 of 1 |
| 398 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 399 |
\\\\\\\ to: zsuskuln 45537d53 "a" |
| 400 |
--base |
| 401 |
-+a |
| 402 |
+-fake |
| 403 |
++some |
| 404 |
+++++++ royxmykx 89d1b299 "b" |
| 405 |
-b |
| 406 |
+conflict |
| 407 |
>>>>>>> conflict 1 of 1 ends |
| 408 |
[EOF] |
| 409 |
"#); |
| 410 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 411 |
file 2-sided conflict |
| 412 |
[EOF] |
| 413 |
"); |
| 414 |
|
| 415 |
// Check that merge tool can leave conflict markers by returning exit code 1 |
| 416 |
// when using `merge-conflict-exit-codes = [1]`. The Git "diff3" conflict |
| 417 |
// markers should also be parsed correctly. |
| 418 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 419 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 420 |
std::fs::write( |
| 421 |
&editor_script, |
| 422 |
[ |
| 423 |
"dump editor5", |
| 424 |
indoc! {" |
| 425 |
write |
| 426 |
<<<<<<< |
| 427 |
some |
| 428 |
||||||| |
| 429 |
fake |
| 430 |
======= |
| 431 |
conflict |
| 432 |
>>>>>>> |
| 433 |
"}, |
| 434 |
"fail", |
| 435 |
] |
| 436 |
.join("\0"), |
| 437 |
)?; |
| 438 |
let output = work_dir.run_jj([ |
| 439 |
"resolve", |
| 440 |
"--config=merge-tools.fake-editor.merge-conflict-exit-codes=[1]", |
| 441 |
]); |
| 442 |
insta::assert_snapshot!(output, @" |
| 443 |
------- stderr ------- |
| 444 |
Resolving conflicts in: file |
| 445 |
Working copy (@) now at: vruxwmqv 097d6249 conflict | (conflict) conflict |
| 446 |
Parent commit (@-) : zsuskuln 45537d53 a | a |
| 447 |
Parent commit (@-) : royxmykx 89d1b299 b | b |
| 448 |
Added 0 files, modified 1 files, removed 0 files |
| 449 |
Warning: There are unresolved conflicts at these paths: |
| 450 |
file 2-sided conflict |
| 451 |
New conflicts appeared in 1 commits: |
| 452 |
vruxwmqv 097d6249 conflict | (conflict) conflict |
| 453 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 454 |
the conflicted commit: |
| 455 |
jj new vruxwmqv |
| 456 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 457 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 458 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 459 |
[EOF] |
| 460 |
"); |
| 461 |
insta::assert_snapshot!( |
| 462 |
std::fs::read_to_string(test_env.env_root().join("editor5"))?, @""); |
| 463 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 464 |
diff --git a/file b/file |
| 465 |
--- a/file |
| 466 |
+++ b/file |
| 467 |
@@ -1,8 +1,8 @@ |
| 468 |
<<<<<<< conflict 1 of 1 |
| 469 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 470 |
\\\\\\\ to: zsuskuln 45537d53 "a" |
| 471 |
--base |
| 472 |
-+a |
| 473 |
+-fake |
| 474 |
++some |
| 475 |
+++++++ royxmykx 89d1b299 "b" |
| 476 |
-b |
| 477 |
+conflict |
| 478 |
>>>>>>> conflict 1 of 1 ends |
| 479 |
[EOF] |
| 480 |
"#); |
| 481 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 482 |
file 2-sided conflict |
| 483 |
[EOF] |
| 484 |
"); |
| 485 |
|
| 486 |
// Check that an error is reported if a merge tool indicated it would leave |
| 487 |
// conflict markers, but the output file didn't contain valid conflict markers. |
| 488 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 489 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 490 |
std::fs::write( |
| 491 |
&editor_script, |
| 492 |
[ |
| 493 |
indoc! {" |
| 494 |
write |
| 495 |
<<<<<<< this isn't diff3 style! |
| 496 |
some |
| 497 |
======= |
| 498 |
conflict |
| 499 |
>>>>>>> |
| 500 |
"}, |
| 501 |
"fail", |
| 502 |
] |
| 503 |
.join("\0"), |
| 504 |
)?; |
| 505 |
let output = work_dir.run_jj([ |
| 506 |
"resolve", |
| 507 |
"--config=merge-tools.fake-editor.merge-conflict-exit-codes=[1]", |
| 508 |
]); |
| 509 |
insta::assert_snapshot!(output.normalize_stderr_exit_status(), @" |
| 510 |
------- stderr ------- |
| 511 |
Resolving conflicts in: file |
| 512 |
Error: Failed to resolve conflicts |
| 513 |
Caused by: Tool exited with exit status: 1, but did not produce valid conflict markers (run with --debug to see the exact invocation) |
| 514 |
[EOF] |
| 515 |
[exit status: 1] |
| 516 |
"); |
| 517 |
Ok(()) |
| 518 |
} |
| 519 |
|
| 520 |
#[test] |
| 521 |
fn test_files_still_have_conflicts() -> TestResult { |
| 522 |
let mut test_env = TestEnvironment::default(); |
| 523 |
let editor_script = test_env.set_up_fake_editor(); |
| 524 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 525 |
let work_dir = test_env.work_dir("repo"); |
| 526 |
|
| 527 |
// set up the commit graph |
| 528 |
create_commit_with_files( |
| 529 |
&work_dir, |
| 530 |
"base", |
| 531 |
&[], |
| 532 |
&[("file1", "base\n"), ("file2", "base\n")], |
| 533 |
); |
| 534 |
create_commit_with_files( |
| 535 |
&work_dir, |
| 536 |
"a", |
| 537 |
&["base"], |
| 538 |
&[("file1", "a\n"), ("file2", "a\n")], |
| 539 |
); |
| 540 |
create_commit_with_files( |
| 541 |
&work_dir, |
| 542 |
"b", |
| 543 |
&["base"], |
| 544 |
&[("file1", "b\n"), ("file2", "b\n")], |
| 545 |
); |
| 546 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 547 |
create_commit_with_files(&work_dir, "c", &["conflict"], &[]); |
| 548 |
create_commit_with_files(&work_dir, "d", &["base"], &[]); |
| 549 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 550 |
@ d |
| 551 |
│ × c |
| 552 |
│ × conflict |
| 553 |
│ ├─╮ |
| 554 |
│ │ ○ b |
| 555 |
├───╯ |
| 556 |
│ ○ a |
| 557 |
├─╯ |
| 558 |
○ base |
| 559 |
◆ |
| 560 |
[EOF] |
| 561 |
"); |
| 562 |
let setup_opid = work_dir.current_operation_id(); |
| 563 |
|
| 564 |
// partially resolve the conflict from an unaffected sibling |
| 565 |
std::fs::write(&editor_script, "write\nresolution\n")?; |
| 566 |
let output = work_dir.run_jj([ |
| 567 |
"resolve", |
| 568 |
"-r", |
| 569 |
"conflict", |
| 570 |
"file1", |
| 571 |
"--config", |
| 572 |
"hints.resolving-conflicts=false", |
| 573 |
]); |
| 574 |
insta::assert_snapshot!(output, @r" |
| 575 |
------- stderr ------- |
| 576 |
Resolving conflicts in: file1 |
| 577 |
Rebased 1 descendant commits. |
| 578 |
New conflicts appeared in 1 commits: |
| 579 |
vruxwmqv b7972990 conflict | (conflict) conflict |
| 580 |
Warning: After this operation, some files at this revision still have conflicts: |
| 581 |
file2 2-sided conflict |
| 582 |
[EOF] |
| 583 |
"); |
| 584 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 585 |
|
| 586 |
// partially resolve the conflict from a descendant |
| 587 |
work_dir.run_jj(["edit", "c"]).success(); |
| 588 |
let output = work_dir.run_jj([ |
| 589 |
"resolve", |
| 590 |
"-r", |
| 591 |
"conflict", |
| 592 |
"file1", |
| 593 |
"--config", |
| 594 |
"hints.resolving-conflicts=false", |
| 595 |
]); |
| 596 |
insta::assert_snapshot!(output, @r" |
| 597 |
------- stderr ------- |
| 598 |
Resolving conflicts in: file1 |
| 599 |
Rebased 1 descendant commits. |
| 600 |
Working copy (@) now at: znkkpsqq b97a283e c | (conflict) (empty) c |
| 601 |
Parent commit (@-) : vruxwmqv e97ef12c conflict | (conflict) conflict |
| 602 |
Added 0 files, modified 1 files, removed 0 files |
| 603 |
Warning: There are unresolved conflicts at these paths: |
| 604 |
file2 2-sided conflict |
| 605 |
New conflicts appeared in 1 commits: |
| 606 |
vruxwmqv e97ef12c conflict | (conflict) conflict |
| 607 |
Warning: After this operation, some files at this revision still have conflicts: |
| 608 |
file2 2-sided conflict |
| 609 |
[EOF] |
| 610 |
"); |
| 611 |
Ok(()) |
| 612 |
} |
| 613 |
|
| 614 |
fn check_resolve_produces_input_file( |
| 615 |
test_env: &mut TestEnvironment, |
| 616 |
root: impl AsRef<Path>, |
| 617 |
filename: &str, |
| 618 |
role: &str, |
| 619 |
expected_content: &str, |
| 620 |
) { |
| 621 |
let editor_script = test_env.set_up_fake_editor(); |
| 622 |
let work_dir = test_env.work_dir(root); |
| 623 |
std::fs::write(editor_script, format!("expect\n{expected_content}")).unwrap(); |
| 624 |
|
| 625 |
let merge_arg_config = format!(r#"merge-tools.fake-editor.merge-args=["${role}"]"#); |
| 626 |
// This error means that fake-editor exited successfully but did not modify the |
| 627 |
// output file. |
| 628 |
let output = work_dir.run_jj(["resolve", "--config", &merge_arg_config, filename]); |
| 629 |
insta::allow_duplicates! { |
| 630 |
insta::assert_snapshot!( |
| 631 |
output.normalize_stderr_with(|s| s.replacen(filename, "$FILENAME", 1)), @" |
| 632 |
------- stderr ------- |
| 633 |
Resolving conflicts in: $FILENAME |
| 634 |
Error: Failed to resolve conflicts |
| 635 |
Caused by: The output file is either unchanged or empty after the editor quit (run with --debug to see the exact invocation). |
| 636 |
[EOF] |
| 637 |
[exit status: 1] |
| 638 |
"); |
| 639 |
} |
| 640 |
} |
| 641 |
|
| 642 |
#[test] |
| 643 |
fn test_normal_conflict_input_files() -> TestResult { |
| 644 |
let mut test_env = TestEnvironment::default(); |
| 645 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 646 |
let work_dir = test_env.work_dir("repo"); |
| 647 |
|
| 648 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); |
| 649 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); |
| 650 |
create_commit_with_files(&work_dir, "b", &["base"], &[("file", "b\n")]); |
| 651 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 652 |
// Test the setup |
| 653 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 654 |
@ conflict |
| 655 |
├─╮ |
| 656 |
│ ○ b |
| 657 |
○ │ a |
| 658 |
├─╯ |
| 659 |
○ base |
| 660 |
◆ |
| 661 |
[EOF] |
| 662 |
"); |
| 663 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 664 |
file 2-sided conflict |
| 665 |
[EOF] |
| 666 |
"); |
| 667 |
insta::assert_snapshot!(work_dir.read_file("file"), @r#" |
| 668 |
<<<<<<< conflict 1 of 1 |
| 669 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 670 |
\\\\\\\ to: zsuskuln 45537d53 "a" |
| 671 |
-base |
| 672 |
+a |
| 673 |
+++++++ royxmykx 89d1b299 "b" |
| 674 |
b |
| 675 |
>>>>>>> conflict 1 of 1 ends |
| 676 |
"#); |
| 677 |
|
| 678 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "base", "base\n"); |
| 679 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "left", "a\n"); |
| 680 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "right", "b\n"); |
| 681 |
Ok(()) |
| 682 |
} |
| 683 |
|
| 684 |
#[test] |
| 685 |
fn test_baseless_conflict_input_files() -> TestResult { |
| 686 |
let mut test_env = TestEnvironment::default(); |
| 687 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 688 |
let work_dir = test_env.work_dir("repo"); |
| 689 |
|
| 690 |
create_commit_with_files(&work_dir, "base", &[], &[]); |
| 691 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); |
| 692 |
create_commit_with_files(&work_dir, "b", &["base"], &[("file", "b\n")]); |
| 693 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 694 |
// Test the setup |
| 695 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 696 |
@ conflict |
| 697 |
├─╮ |
| 698 |
│ ○ b |
| 699 |
○ │ a |
| 700 |
├─╯ |
| 701 |
○ base |
| 702 |
◆ |
| 703 |
[EOF] |
| 704 |
"); |
| 705 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 706 |
file 2-sided conflict |
| 707 |
[EOF] |
| 708 |
"); |
| 709 |
insta::assert_snapshot!(work_dir.read_file("file"), @r#" |
| 710 |
<<<<<<< conflict 1 of 1 |
| 711 |
%%%%%%% diff from: rlvkpnrz 2308e5a2 "base" |
| 712 |
\\\\\\\ to: zsuskuln e3c7222d "a" |
| 713 |
+a |
| 714 |
+++++++ royxmykx 1f2c13ec "b" |
| 715 |
b |
| 716 |
>>>>>>> conflict 1 of 1 ends |
| 717 |
"#); |
| 718 |
|
| 719 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "base", ""); |
| 720 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "left", "a\n"); |
| 721 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "right", "b\n"); |
| 722 |
Ok(()) |
| 723 |
} |
| 724 |
|
| 725 |
#[test] |
| 726 |
fn test_too_many_parents() -> TestResult { |
| 727 |
let test_env = TestEnvironment::default(); |
| 728 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 729 |
let work_dir = test_env.work_dir("repo"); |
| 730 |
|
| 731 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); |
| 732 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); |
| 733 |
create_commit_with_files(&work_dir, "b", &["base"], &[("file", "b\n")]); |
| 734 |
create_commit_with_files(&work_dir, "c", &["base"], &[("file", "c\n")]); |
| 735 |
create_commit_with_files(&work_dir, "conflict", &["a", "b", "c"], &[]); |
| 736 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 737 |
file 3-sided conflict |
| 738 |
[EOF] |
| 739 |
"); |
| 740 |
// Test warning color |
| 741 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list", "--color=always"]), @" |
| 742 |
file [38;5;1m3-sided[38;5;3m conflict[39m |
| 743 |
[EOF] |
| 744 |
"); |
| 745 |
|
| 746 |
let output = work_dir.run_jj(["resolve"]); |
| 747 |
insta::assert_snapshot!(output, @r#" |
| 748 |
------- stderr ------- |
| 749 |
Hint: Using default editor ':builtin'; run `jj config set --user ui.merge-editor :builtin` to disable this message. |
| 750 |
Error: Failed to resolve conflicts |
| 751 |
Caused by: The conflict at "file" has 3 sides. At most 2 sides are supported. |
| 752 |
Hint: Edit the conflict markers manually to resolve this. |
| 753 |
[EOF] |
| 754 |
[exit status: 1] |
| 755 |
"#); |
| 756 |
Ok(()) |
| 757 |
} |
| 758 |
|
| 759 |
#[test] |
| 760 |
fn test_simplify_conflict_sides() -> TestResult { |
| 761 |
let mut test_env = TestEnvironment::default(); |
| 762 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 763 |
let work_dir = test_env.work_dir("repo"); |
| 764 |
|
| 765 |
// Creates a 4-sided conflict, with fileA and fileB having different conflicts: |
| 766 |
// fileA: A - B + C - B + B - B + B |
| 767 |
// fileB: A - A + A - A + B - C + D |
| 768 |
create_commit_with_files( |
| 769 |
&work_dir, |
| 770 |
"base", |
| 771 |
&[], |
| 772 |
&[("fileA", "base\n"), ("fileB", "base\n")], |
| 773 |
); |
| 774 |
create_commit_with_files(&work_dir, "a1", &["base"], &[("fileA", "1\n")]); |
| 775 |
create_commit_with_files(&work_dir, "a2", &["base"], &[("fileA", "2\n")]); |
| 776 |
create_commit_with_files(&work_dir, "b1", &["base"], &[("fileB", "1\n")]); |
| 777 |
create_commit_with_files(&work_dir, "b2", &["base"], &[("fileB", "2\n")]); |
| 778 |
create_commit_with_files(&work_dir, "conflictA", &["a1", "a2"], &[]); |
| 779 |
create_commit_with_files(&work_dir, "conflictB", &["b1", "b2"], &[]); |
| 780 |
create_commit_with_files(&work_dir, "conflict", &["conflictA", "conflictB"], &[]); |
| 781 |
|
| 782 |
// Even though the tree-level conflict is a 4-sided conflict, each file is |
| 783 |
// materialized as a 2-sided conflict. |
| 784 |
insta::assert_snapshot!(work_dir.run_jj(["debug", "tree"]), @r#" |
| 785 |
fileA: Ok(Conflicted([Some(File { id: FileId("d00491fd7e5bb6fa28c517a0bb32b8b506539d4d"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("0cfbf08886fca9a91cb753ec8734c84fcbe52c9f"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") })])) |
| 786 |
fileB: Ok(Conflicted([Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("d00491fd7e5bb6fa28c517a0bb32b8b506539d4d"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false, copy_id: CopyId("") }), Some(File { id: FileId("0cfbf08886fca9a91cb753ec8734c84fcbe52c9f"), executable: false, copy_id: CopyId("") })])) |
| 787 |
[EOF] |
| 788 |
"#); |
| 789 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 790 |
fileA 2-sided conflict |
| 791 |
fileB 2-sided conflict |
| 792 |
[EOF] |
| 793 |
"); |
| 794 |
insta::assert_snapshot!(work_dir.read_file("fileA"), @r#" |
| 795 |
<<<<<<< conflict 1 of 1 |
| 796 |
%%%%%%% diff from: rlvkpnrz ca4643d3 "base" |
| 797 |
\\\\\\\ to: zsuskuln f302fbd1 "a1" |
| 798 |
-base |
| 799 |
+1 |
| 800 |
+++++++ royxmykx 128a2559 "a2" |
| 801 |
2 |
| 802 |
>>>>>>> conflict 1 of 1 ends |
| 803 |
"#); |
| 804 |
insta::assert_snapshot!(work_dir.read_file("fileB"), @r#" |
| 805 |
<<<<<<< conflict 1 of 1 |
| 806 |
%%%%%%% diff from: rlvkpnrz ca4643d3 "base" |
| 807 |
\\\\\\\ to: vruxwmqv 5be2d37a "b1" |
| 808 |
-base |
| 809 |
+1 |
| 810 |
+++++++ znkkpsqq bd8e6328 "b2" |
| 811 |
2 |
| 812 |
>>>>>>> conflict 1 of 1 ends |
| 813 |
"#); |
| 814 |
|
| 815 |
// Conflict should be simplified before being handled by external merge tool. |
| 816 |
check_resolve_produces_input_file(&mut test_env, "repo", "fileA", "base", "base\n"); |
| 817 |
check_resolve_produces_input_file(&mut test_env, "repo", "fileA", "left", "1\n"); |
| 818 |
check_resolve_produces_input_file(&mut test_env, "repo", "fileA", "right", "2\n"); |
| 819 |
check_resolve_produces_input_file(&mut test_env, "repo", "fileB", "base", "base\n"); |
| 820 |
check_resolve_produces_input_file(&mut test_env, "repo", "fileB", "left", "1\n"); |
| 821 |
check_resolve_produces_input_file(&mut test_env, "repo", "fileB", "right", "2\n"); |
| 822 |
|
| 823 |
// Check that simplified conflicts are still parsed as conflicts after editing |
| 824 |
// when `merge-tool-edits-conflict-markers=true`. |
| 825 |
let editor_script = test_env.set_up_fake_editor(); |
| 826 |
std::fs::write( |
| 827 |
editor_script, |
| 828 |
indoc! {" |
| 829 |
write |
| 830 |
<<<<<<< conflict 1 of 1 |
| 831 |
%%%%%%% diff from base to side #1 |
| 832 |
-base_edited |
| 833 |
+1_edited |
| 834 |
+++++++ side #2 |
| 835 |
2_edited |
| 836 |
>>>>>>> conflict 1 of 1 ends |
| 837 |
"}, |
| 838 |
)?; |
| 839 |
let work_dir = test_env.work_dir("repo"); |
| 840 |
let output = work_dir.run_jj([ |
| 841 |
"resolve", |
| 842 |
"--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", |
| 843 |
"fileB", |
| 844 |
]); |
| 845 |
insta::assert_snapshot!(output, @" |
| 846 |
------- stderr ------- |
| 847 |
Resolving conflicts in: fileB |
| 848 |
Working copy (@) now at: nkmrtpmo e3edd72f conflict | (conflict) conflict |
| 849 |
Parent commit (@-) : kmkuslsw fb05b298 conflictA | (conflict) (empty) conflictA |
| 850 |
Parent commit (@-) : lylxulpl c680c6d6 conflictB | (conflict) (empty) conflictB |
| 851 |
Added 0 files, modified 1 files, removed 0 files |
| 852 |
Warning: There are unresolved conflicts at these paths: |
| 853 |
fileA 2-sided conflict |
| 854 |
fileB 2-sided conflict |
| 855 |
New conflicts appeared in 1 commits: |
| 856 |
nkmrtpmo e3edd72f conflict | (conflict) conflict |
| 857 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 858 |
the conflicted commit: |
| 859 |
jj new nkmrtpmo |
| 860 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 861 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 862 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 863 |
[EOF] |
| 864 |
"); |
| 865 |
insta::assert_snapshot!(work_dir.read_file("fileB"), @r#" |
| 866 |
<<<<<<< conflict 1 of 1 |
| 867 |
%%%%%%% diff from: rlvkpnrz ca4643d3 "base" |
| 868 |
\\\\\\\ to: vruxwmqv 5be2d37a "b1" |
| 869 |
-base_edited |
| 870 |
+1_edited |
| 871 |
+++++++ znkkpsqq bd8e6328 "b2" |
| 872 |
2_edited |
| 873 |
>>>>>>> conflict 1 of 1 ends |
| 874 |
"#); |
| 875 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 876 |
fileA 2-sided conflict |
| 877 |
fileB 2-sided conflict |
| 878 |
[EOF] |
| 879 |
"); |
| 880 |
Ok(()) |
| 881 |
} |
| 882 |
|
| 883 |
#[test] |
| 884 |
fn test_edit_delete_conflict_input_files() -> TestResult { |
| 885 |
let mut test_env = TestEnvironment::default(); |
| 886 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 887 |
let work_dir = test_env.work_dir("repo"); |
| 888 |
|
| 889 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); |
| 890 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); |
| 891 |
create_commit_with_files(&work_dir, "b", &["base"], &[]); |
| 892 |
work_dir.remove_file("file"); |
| 893 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 894 |
// Test the setup |
| 895 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 896 |
@ conflict |
| 897 |
├─╮ |
| 898 |
│ ○ b |
| 899 |
○ │ a |
| 900 |
├─╯ |
| 901 |
○ base |
| 902 |
◆ |
| 903 |
[EOF] |
| 904 |
"); |
| 905 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 906 |
file 2-sided conflict including 1 deletion |
| 907 |
[EOF] |
| 908 |
"); |
| 909 |
insta::assert_snapshot!(work_dir.read_file("file"), @r#" |
| 910 |
<<<<<<< conflict 1 of 1 |
| 911 |
+++++++ zsuskuln 45537d53 "a" |
| 912 |
a |
| 913 |
%%%%%%% diff from: rlvkpnrz 1792382a "base" |
| 914 |
\\\\\\\ to: royxmykx d213fd81 "b" |
| 915 |
-base |
| 916 |
>>>>>>> conflict 1 of 1 ends |
| 917 |
"#); |
| 918 |
|
| 919 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "base", "base\n"); |
| 920 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "left", "a\n"); |
| 921 |
check_resolve_produces_input_file(&mut test_env, "repo", "file", "right", ""); |
| 922 |
Ok(()) |
| 923 |
} |
| 924 |
|
| 925 |
#[test] |
| 926 |
fn test_file_vs_dir() -> TestResult { |
| 927 |
let test_env = TestEnvironment::default(); |
| 928 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 929 |
let work_dir = test_env.work_dir("repo"); |
| 930 |
|
| 931 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); |
| 932 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); |
| 933 |
create_commit_with_files(&work_dir, "b", &["base"], &[]); |
| 934 |
work_dir.remove_file("file"); |
| 935 |
work_dir.create_dir("file"); |
| 936 |
// Without a placeholder file, `jj` ignores an empty directory |
| 937 |
work_dir.write_file("file/placeholder", ""); |
| 938 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 939 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 940 |
@ conflict |
| 941 |
├─╮ |
| 942 |
│ ○ b |
| 943 |
○ │ a |
| 944 |
├─╯ |
| 945 |
○ base |
| 946 |
◆ |
| 947 |
[EOF] |
| 948 |
"); |
| 949 |
|
| 950 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 951 |
file 2-sided conflict including a directory |
| 952 |
[EOF] |
| 953 |
"); |
| 954 |
let output = work_dir.run_jj(["resolve"]); |
| 955 |
insta::assert_snapshot!(output, @r#" |
| 956 |
------- stderr ------- |
| 957 |
Hint: Using default editor ':builtin'; run `jj config set --user ui.merge-editor :builtin` to disable this message. |
| 958 |
Error: Failed to resolve conflicts |
| 959 |
Caused by: Only conflicts that involve normal files (not symlinks, etc.) are supported. Conflict summary for "file": |
| 960 |
Conflict: |
| 961 |
Removing file with id df967b96a579e45a18b8251732d16804b2e56a55 (rlvkpnrz 1792382a "base") |
| 962 |
Adding file with id 78981922613b2afb6025042ff6bd878ac1994e85 (zsuskuln 45537d53 "a") |
| 963 |
Adding tree with id 133bb38fc4e4bf6b551f1f04db7e48f04cac2877 (royxmykx 0950b959 "b") |
| 964 |
[EOF] |
| 965 |
[exit status: 1] |
| 966 |
"#); |
| 967 |
Ok(()) |
| 968 |
} |
| 969 |
|
| 970 |
#[test] |
| 971 |
fn test_description_with_dir_and_deletion() -> TestResult { |
| 972 |
let test_env = TestEnvironment::default(); |
| 973 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 974 |
let work_dir = test_env.work_dir("repo"); |
| 975 |
|
| 976 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); |
| 977 |
create_commit_with_files(&work_dir, "edit", &["base"], &[("file", "b\n")]); |
| 978 |
create_commit_with_files(&work_dir, "dir", &["base"], &[]); |
| 979 |
work_dir.remove_file("file"); |
| 980 |
work_dir.create_dir("file"); |
| 981 |
// Without a placeholder file, `jj` ignores an empty directory |
| 982 |
work_dir.write_file("file/placeholder", ""); |
| 983 |
create_commit_with_files(&work_dir, "del", &["base"], &[]); |
| 984 |
work_dir.remove_file("file"); |
| 985 |
create_commit_with_files(&work_dir, "conflict", &["edit", "dir", "del"], &[]); |
| 986 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 987 |
@ conflict |
| 988 |
├─┬─╮ |
| 989 |
│ │ ○ del |
| 990 |
│ ○ │ dir |
| 991 |
│ ├─╯ |
| 992 |
○ │ edit |
| 993 |
├─╯ |
| 994 |
○ base |
| 995 |
◆ |
| 996 |
[EOF] |
| 997 |
"); |
| 998 |
|
| 999 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1000 |
file 3-sided conflict including 1 deletion and a directory |
| 1001 |
[EOF] |
| 1002 |
"); |
| 1003 |
// Test warning color. The deletion is fine, so it's not highlighted |
| 1004 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list", "--color=always"]), @" |
| 1005 |
file [38;5;1m3-sided[38;5;3m conflict including 1 deletion and [38;5;1ma directory[39m |
| 1006 |
[EOF] |
| 1007 |
"); |
| 1008 |
let output = work_dir.run_jj(["resolve"]); |
| 1009 |
insta::assert_snapshot!(output, @r#" |
| 1010 |
------- stderr ------- |
| 1011 |
Hint: Using default editor ':builtin'; run `jj config set --user ui.merge-editor :builtin` to disable this message. |
| 1012 |
Error: Failed to resolve conflicts |
| 1013 |
Caused by: Only conflicts that involve normal files (not symlinks, etc.) are supported. Conflict summary for "file": |
| 1014 |
Conflict: |
| 1015 |
Removing file with id df967b96a579e45a18b8251732d16804b2e56a55 (rlvkpnrz 1792382a "base") |
| 1016 |
Removing file with id df967b96a579e45a18b8251732d16804b2e56a55 (rlvkpnrz 1792382a "base") |
| 1017 |
Adding file with id 61780798228d17af2d34fce4cfbdf35556832472 (zsuskuln 6c74ed1d "edit") |
| 1018 |
Adding tree with id 133bb38fc4e4bf6b551f1f04db7e48f04cac2877 (royxmykx 09c02334 "dir") |
| 1019 |
[EOF] |
| 1020 |
[exit status: 1] |
| 1021 |
"#); |
| 1022 |
Ok(()) |
| 1023 |
} |
| 1024 |
|
| 1025 |
#[test] |
| 1026 |
fn test_resolve_conflicts_with_executable() -> TestResult { |
| 1027 |
let mut test_env = TestEnvironment::default(); |
| 1028 |
let editor_script = test_env.set_up_fake_editor(); |
| 1029 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1030 |
let work_dir = test_env.work_dir("repo"); |
| 1031 |
|
| 1032 |
// Create a conflict in "file1" where all 3 terms are executables, and create a |
| 1033 |
// conflict in "file2" where one side set the executable bit. |
| 1034 |
create_commit_with_files( |
| 1035 |
&work_dir, |
| 1036 |
"base", |
| 1037 |
&[], |
| 1038 |
&[("file1", "base1\n"), ("file2", "base2\n")], |
| 1039 |
); |
| 1040 |
work_dir.run_jj(["file", "chmod", "x", "file1"]).success(); |
| 1041 |
create_commit_with_files( |
| 1042 |
&work_dir, |
| 1043 |
"a", |
| 1044 |
&["base"], |
| 1045 |
&[("file1", "a1\n"), ("file2", "a2\n")], |
| 1046 |
); |
| 1047 |
create_commit_with_files( |
| 1048 |
&work_dir, |
| 1049 |
"b", |
| 1050 |
&["base"], |
| 1051 |
&[("file1", "b1\n"), ("file2", "b2\n")], |
| 1052 |
); |
| 1053 |
work_dir.run_jj(["file", "chmod", "x", "file2"]).success(); |
| 1054 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 1055 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1056 |
file1 2-sided conflict including an executable |
| 1057 |
file2 2-sided conflict including an executable |
| 1058 |
[EOF] |
| 1059 |
"); |
| 1060 |
insta::assert_snapshot!(work_dir.read_file("file1"), @r#" |
| 1061 |
<<<<<<< conflict 1 of 1 |
| 1062 |
%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1063 |
\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1064 |
-base1 |
| 1065 |
+a1 |
| 1066 |
+++++++ yqosqzyt 36361412 "b" |
| 1067 |
b1 |
| 1068 |
>>>>>>> conflict 1 of 1 ends |
| 1069 |
"# |
| 1070 |
); |
| 1071 |
insta::assert_snapshot!(work_dir.read_file("file2"), @r#" |
| 1072 |
<<<<<<< conflict 1 of 1 |
| 1073 |
%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1074 |
\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1075 |
-base2 |
| 1076 |
+a2 |
| 1077 |
+++++++ yqosqzyt 36361412 "b" |
| 1078 |
b2 |
| 1079 |
>>>>>>> conflict 1 of 1 ends |
| 1080 |
"# |
| 1081 |
); |
| 1082 |
let setup_opid = work_dir.current_operation_id(); |
| 1083 |
|
| 1084 |
// Test resolving the conflict in "file1", which should produce an executable |
| 1085 |
std::fs::write(&editor_script, b"write\nresolution1\n")?; |
| 1086 |
let output = work_dir.run_jj(["resolve", "file1"]); |
| 1087 |
insta::assert_snapshot!(output, @" |
| 1088 |
------- stderr ------- |
| 1089 |
Resolving conflicts in: file1 |
| 1090 |
Working copy (@) now at: znkkpsqq 59e1d672 conflict | (conflict) conflict |
| 1091 |
Parent commit (@-) : mzvwutvl 86f7f0e3 a | a |
| 1092 |
Parent commit (@-) : yqosqzyt 36361412 b | b |
| 1093 |
Added 0 files, modified 1 files, removed 0 files |
| 1094 |
Warning: There are unresolved conflicts at these paths: |
| 1095 |
file2 2-sided conflict including an executable |
| 1096 |
New conflicts appeared in 1 commits: |
| 1097 |
znkkpsqq 59e1d672 conflict | (conflict) conflict |
| 1098 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 1099 |
the conflicted commit: |
| 1100 |
jj new znkkpsqq |
| 1101 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 1102 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 1103 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 1104 |
[EOF] |
| 1105 |
"); |
| 1106 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1107 |
diff --git a/file1 b/file1 |
| 1108 |
index 0000000000..95cc18629d 100755 |
| 1109 |
--- a/file1 |
| 1110 |
+++ b/file1 |
| 1111 |
@@ -1,8 +1,1 @@ |
| 1112 |
-<<<<<<< conflict 1 of 1 |
| 1113 |
-%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1114 |
-\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1115 |
--base1 |
| 1116 |
-+a1 |
| 1117 |
-+++++++ yqosqzyt 36361412 "b" |
| 1118 |
-b1 |
| 1119 |
->>>>>>> conflict 1 of 1 ends |
| 1120 |
+resolution1 |
| 1121 |
[EOF] |
| 1122 |
"#); |
| 1123 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1124 |
file2 2-sided conflict including an executable |
| 1125 |
[EOF] |
| 1126 |
"); |
| 1127 |
|
| 1128 |
// Test resolving the conflict in "file2", which should produce an executable |
| 1129 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1130 |
std::fs::write(&editor_script, b"write\nresolution2\n")?; |
| 1131 |
let output = work_dir.run_jj(["resolve", "file2"]); |
| 1132 |
insta::assert_snapshot!(output, @" |
| 1133 |
------- stderr ------- |
| 1134 |
Resolving conflicts in: file2 |
| 1135 |
Working copy (@) now at: znkkpsqq d3f09ac5 conflict | (conflict) conflict |
| 1136 |
Parent commit (@-) : mzvwutvl 86f7f0e3 a | a |
| 1137 |
Parent commit (@-) : yqosqzyt 36361412 b | b |
| 1138 |
Added 0 files, modified 1 files, removed 0 files |
| 1139 |
Warning: There are unresolved conflicts at these paths: |
| 1140 |
file1 2-sided conflict including an executable |
| 1141 |
New conflicts appeared in 1 commits: |
| 1142 |
znkkpsqq d3f09ac5 conflict | (conflict) conflict |
| 1143 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 1144 |
the conflicted commit: |
| 1145 |
jj new znkkpsqq |
| 1146 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 1147 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 1148 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 1149 |
[EOF] |
| 1150 |
"); |
| 1151 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1152 |
diff --git a/file2 b/file2 |
| 1153 |
index 0000000000..775f078581 100755 |
| 1154 |
--- a/file2 |
| 1155 |
+++ b/file2 |
| 1156 |
@@ -1,8 +1,1 @@ |
| 1157 |
-<<<<<<< conflict 1 of 1 |
| 1158 |
-%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1159 |
-\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1160 |
--base2 |
| 1161 |
-+a2 |
| 1162 |
-+++++++ yqosqzyt 36361412 "b" |
| 1163 |
-b2 |
| 1164 |
->>>>>>> conflict 1 of 1 ends |
| 1165 |
+resolution2 |
| 1166 |
[EOF] |
| 1167 |
"#); |
| 1168 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1169 |
file1 2-sided conflict including an executable |
| 1170 |
[EOF] |
| 1171 |
"); |
| 1172 |
|
| 1173 |
// Pick "our" contents, but merges executable bits |
| 1174 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1175 |
let output = work_dir.run_jj(["resolve", "--tool=:ours"]); |
| 1176 |
insta::assert_snapshot!(output, @" |
| 1177 |
------- stderr ------- |
| 1178 |
Working copy (@) now at: znkkpsqq d902c14b conflict | conflict |
| 1179 |
Parent commit (@-) : mzvwutvl 86f7f0e3 a | a |
| 1180 |
Parent commit (@-) : yqosqzyt 36361412 b | b |
| 1181 |
Added 0 files, modified 2 files, removed 0 files |
| 1182 |
[EOF] |
| 1183 |
"); |
| 1184 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1185 |
diff --git a/file1 b/file1 |
| 1186 |
index 0000000000..da0f8ed91a 100755 |
| 1187 |
--- a/file1 |
| 1188 |
+++ b/file1 |
| 1189 |
@@ -1,8 +1,1 @@ |
| 1190 |
-<<<<<<< conflict 1 of 1 |
| 1191 |
-%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1192 |
-\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1193 |
--base1 |
| 1194 |
-+a1 |
| 1195 |
-+++++++ yqosqzyt 36361412 "b" |
| 1196 |
-b1 |
| 1197 |
->>>>>>> conflict 1 of 1 ends |
| 1198 |
+a1 |
| 1199 |
diff --git a/file2 b/file2 |
| 1200 |
index 0000000000..c1827f07e1 100755 |
| 1201 |
--- a/file2 |
| 1202 |
+++ b/file2 |
| 1203 |
@@ -1,8 +1,1 @@ |
| 1204 |
-<<<<<<< conflict 1 of 1 |
| 1205 |
-%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1206 |
-\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1207 |
--base2 |
| 1208 |
-+a2 |
| 1209 |
-+++++++ yqosqzyt 36361412 "b" |
| 1210 |
-b2 |
| 1211 |
->>>>>>> conflict 1 of 1 ends |
| 1212 |
+a2 |
| 1213 |
[EOF] |
| 1214 |
"#); |
| 1215 |
|
| 1216 |
// Pick "their" contents, but merges executable bits |
| 1217 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1218 |
let output = work_dir.run_jj(["resolve", "--tool=:theirs"]); |
| 1219 |
insta::assert_snapshot!(output, @" |
| 1220 |
------- stderr ------- |
| 1221 |
Working copy (@) now at: znkkpsqq a340ca5f conflict | conflict |
| 1222 |
Parent commit (@-) : mzvwutvl 86f7f0e3 a | a |
| 1223 |
Parent commit (@-) : yqosqzyt 36361412 b | b |
| 1224 |
Added 0 files, modified 2 files, removed 0 files |
| 1225 |
[EOF] |
| 1226 |
"); |
| 1227 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1228 |
diff --git a/file1 b/file1 |
| 1229 |
index 0000000000..c9c6af7f78 100755 |
| 1230 |
--- a/file1 |
| 1231 |
+++ b/file1 |
| 1232 |
@@ -1,8 +1,1 @@ |
| 1233 |
-<<<<<<< conflict 1 of 1 |
| 1234 |
-%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1235 |
-\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1236 |
--base1 |
| 1237 |
-+a1 |
| 1238 |
-+++++++ yqosqzyt 36361412 "b" |
| 1239 |
b1 |
| 1240 |
->>>>>>> conflict 1 of 1 ends |
| 1241 |
diff --git a/file2 b/file2 |
| 1242 |
index 0000000000..e6bfff5c1d 100755 |
| 1243 |
--- a/file2 |
| 1244 |
+++ b/file2 |
| 1245 |
@@ -1,8 +1,1 @@ |
| 1246 |
-<<<<<<< conflict 1 of 1 |
| 1247 |
-%%%%%%% diff from: rlvkpnrz b90abfa7 "base" |
| 1248 |
-\\\\\\\ to: mzvwutvl 86f7f0e3 "a" |
| 1249 |
--base2 |
| 1250 |
-+a2 |
| 1251 |
-+++++++ yqosqzyt 36361412 "b" |
| 1252 |
b2 |
| 1253 |
->>>>>>> conflict 1 of 1 ends |
| 1254 |
[EOF] |
| 1255 |
"#); |
| 1256 |
Ok(()) |
| 1257 |
} |
| 1258 |
|
| 1259 |
#[test] |
| 1260 |
fn test_resolve_change_delete_executable() -> TestResult { |
| 1261 |
let mut test_env = TestEnvironment::default(); |
| 1262 |
let editor_script = test_env.set_up_fake_editor(); |
| 1263 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1264 |
let work_dir = test_env.work_dir("repo"); |
| 1265 |
|
| 1266 |
let file_template = |
| 1267 |
r#"separate(' ', path, if(conflict, "c", "-"), if(executable, "x", "-")) ++ "\n""#; |
| 1268 |
let file_list = |path: &str| work_dir.run_jj(["file", "list", "-T", file_template, path]); |
| 1269 |
|
| 1270 |
// base a b |
| 1271 |
// file1: normal -> { exec, absent } |
| 1272 |
// file2: exec -> { absent, normal } (with content change) |
| 1273 |
// file3: absent -> { normal, exec } |
| 1274 |
// file4: normal -> { normal, absent } (with content change) |
| 1275 |
// file5: exec -> { absent, exec } (with content change) |
| 1276 |
create_commit_with_files( |
| 1277 |
&work_dir, |
| 1278 |
"base", |
| 1279 |
&[], |
| 1280 |
&[("file1", ""), ("file2", ""), ("file4", ""), ("file5", "")], |
| 1281 |
); |
| 1282 |
work_dir |
| 1283 |
.run_jj(["file", "chmod", "x", "file2", "file5"]) |
| 1284 |
.success(); |
| 1285 |
create_commit_with_files( |
| 1286 |
&work_dir, |
| 1287 |
"a", |
| 1288 |
&["base"], |
| 1289 |
&[("file1", ""), ("file3", ""), ("file4", "a4\n")], |
| 1290 |
); |
| 1291 |
work_dir.remove_file("file2"); |
| 1292 |
work_dir.remove_file("file5"); |
| 1293 |
work_dir.run_jj(["file", "chmod", "x", "file1"]).success(); |
| 1294 |
create_commit_with_files( |
| 1295 |
&work_dir, |
| 1296 |
"b", |
| 1297 |
&["base"], |
| 1298 |
&[("file2", "b2\n"), ("file3", ""), ("file5", "b5\n")], |
| 1299 |
); |
| 1300 |
work_dir.remove_file("file1"); |
| 1301 |
work_dir.remove_file("file4"); |
| 1302 |
work_dir.run_jj(["file", "chmod", "n", "file2"]).success(); |
| 1303 |
work_dir.run_jj(["file", "chmod", "x", "file3"]).success(); |
| 1304 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 1305 |
|
| 1306 |
// Test the setup |
| 1307 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1308 |
file1 2-sided conflict including 1 deletion and an executable |
| 1309 |
file2 2-sided conflict including 1 deletion and an executable |
| 1310 |
file3 2-sided conflict including an executable |
| 1311 |
file4 2-sided conflict including 1 deletion |
| 1312 |
file5 2-sided conflict including 1 deletion and an executable |
| 1313 |
[EOF] |
| 1314 |
"); |
| 1315 |
insta::assert_snapshot!(file_list("all()"), @" |
| 1316 |
file1 c - |
| 1317 |
file2 c - |
| 1318 |
file3 c - |
| 1319 |
file4 c - |
| 1320 |
file5 c x |
| 1321 |
[EOF] |
| 1322 |
"); |
| 1323 |
insta::assert_snapshot!(work_dir.run_jj(["log", "--git"]), @" |
| 1324 |
@ kmkuslsw [email protected] 2001-02-03 08:05:18 conflict 1196e800 (conflict) |
| 1325 |
├─╮ (empty) conflict |
| 1326 |
│ ○ vruxwmqv [email protected] 2001-02-03 08:05:17 b 888b6cc3 |
| 1327 |
│ │ b |
| 1328 |
│ │ diff --git a/file1 b/file1 |
| 1329 |
│ │ deleted file mode 100644 |
| 1330 |
│ │ index e69de29bb2..0000000000 |
| 1331 |
│ │ diff --git a/file2 b/file2 |
| 1332 |
│ │ old mode 100755 |
| 1333 |
│ │ new mode 100644 |
| 1334 |
│ │ index e69de29bb2..e6bfff5c1d |
| 1335 |
│ │ --- a/file2 |
| 1336 |
│ │ +++ b/file2 |
| 1337 |
│ │ @@ -0,0 +1,1 @@ |
| 1338 |
│ │ +b2 |
| 1339 |
│ │ diff --git a/file3 b/file3 |
| 1340 |
│ │ new file mode 100755 |
| 1341 |
│ │ index 0000000000..e69de29bb2 |
| 1342 |
│ │ diff --git a/file4 b/file4 |
| 1343 |
│ │ deleted file mode 100644 |
| 1344 |
│ │ index e69de29bb2..0000000000 |
| 1345 |
│ │ diff --git a/file5 b/file5 |
| 1346 |
│ │ index e69de29bb2..90a5159bf0 100755 |
| 1347 |
│ │ --- a/file5 |
| 1348 |
│ │ +++ b/file5 |
| 1349 |
│ │ @@ -0,0 +1,1 @@ |
| 1350 |
│ │ +b5 |
| 1351 |
○ │ mzvwutvl [email protected] 2001-02-03 08:05:13 a e2d3924b |
| 1352 |
├─╯ a |
| 1353 |
│ diff --git a/file1 b/file1 |
| 1354 |
│ old mode 100644 |
| 1355 |
│ new mode 100755 |
| 1356 |
│ diff --git a/file2 b/file2 |
| 1357 |
│ deleted file mode 100755 |
| 1358 |
│ index e69de29bb2..0000000000 |
| 1359 |
│ diff --git a/file3 b/file3 |
| 1360 |
│ new file mode 100644 |
| 1361 |
│ index 0000000000..e69de29bb2 |
| 1362 |
│ diff --git a/file4 b/file4 |
| 1363 |
│ index e69de29bb2..88ba23dca8 100644 |
| 1364 |
│ --- a/file4 |
| 1365 |
│ +++ b/file4 |
| 1366 |
│ @@ -0,0 +1,1 @@ |
| 1367 |
│ +a4 |
| 1368 |
│ diff --git a/file5 b/file5 |
| 1369 |
│ deleted file mode 100755 |
| 1370 |
│ index e69de29bb2..0000000000 |
| 1371 |
○ rlvkpnrz [email protected] 2001-02-03 08:05:10 base f747aa1f |
| 1372 |
│ base |
| 1373 |
│ diff --git a/file1 b/file1 |
| 1374 |
│ new file mode 100644 |
| 1375 |
│ index 0000000000..e69de29bb2 |
| 1376 |
│ diff --git a/file2 b/file2 |
| 1377 |
│ new file mode 100755 |
| 1378 |
│ index 0000000000..e69de29bb2 |
| 1379 |
│ diff --git a/file4 b/file4 |
| 1380 |
│ new file mode 100644 |
| 1381 |
│ index 0000000000..e69de29bb2 |
| 1382 |
│ diff --git a/file5 b/file5 |
| 1383 |
│ new file mode 100755 |
| 1384 |
│ index 0000000000..e69de29bb2 |
| 1385 |
◆ zzzzzzzz root() 00000000 |
| 1386 |
[EOF] |
| 1387 |
"); |
| 1388 |
|
| 1389 |
// Exec bit conflict can be resolved by chmod |
| 1390 |
let output = work_dir.run_jj(["resolve", "file1"]); |
| 1391 |
insta::assert_snapshot!(output, @r#" |
| 1392 |
------- stderr ------- |
| 1393 |
Error: Failed to resolve conflicts |
| 1394 |
Caused by: "file1" has conflicts in executable bit |
| 1395 |
Conflict: |
| 1396 |
Removing file with id e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 (rlvkpnrz f747aa1f "base") |
| 1397 |
Adding executable file with id e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 (mzvwutvl e2d3924b "a") |
| 1398 |
Hint: Use `jj file chmod` to update the executable bit. |
| 1399 |
[EOF] |
| 1400 |
[exit status: 1] |
| 1401 |
"#); |
| 1402 |
let output = work_dir.run_jj(["file", "chmod", "--quiet", "x", "file1"]); |
| 1403 |
insta::assert_snapshot!(output, @""); |
| 1404 |
|
| 1405 |
// Exec bit conflict can be resolved by chmod, then content conflict |
| 1406 |
let output = work_dir.run_jj(["resolve", "file2"]); |
| 1407 |
insta::assert_snapshot!(output, @r#" |
| 1408 |
------- stderr ------- |
| 1409 |
Error: Failed to resolve conflicts |
| 1410 |
Caused by: "file2" has conflicts in executable bit |
| 1411 |
Conflict: |
| 1412 |
Removing executable file with id e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 (rlvkpnrz f747aa1f "base") |
| 1413 |
Adding file with id e6bfff5c1d0f0ecd501552b43a1e13d8008abc31 (vruxwmqv 888b6cc3 "b") |
| 1414 |
Hint: Use `jj file chmod` to update the executable bit. |
| 1415 |
[EOF] |
| 1416 |
[exit status: 1] |
| 1417 |
"#); |
| 1418 |
let output = work_dir.run_jj(["file", "chmod", "--quiet", "n", "file2"]); |
| 1419 |
insta::assert_snapshot!(output, @""); |
| 1420 |
std::fs::write(&editor_script, "write\nresolved\n")?; |
| 1421 |
let output = work_dir.run_jj(["resolve", "file2"]); |
| 1422 |
insta::assert_snapshot!(output, @" |
| 1423 |
------- stderr ------- |
| 1424 |
Resolving conflicts in: file2 |
| 1425 |
Working copy (@) now at: kmkuslsw 3f8814ba conflict | (conflict) conflict |
| 1426 |
Parent commit (@-) : mzvwutvl e2d3924b a | a |
| 1427 |
Parent commit (@-) : vruxwmqv 888b6cc3 b | b |
| 1428 |
Added 0 files, modified 1 files, removed 0 files |
| 1429 |
Warning: There are unresolved conflicts at these paths: |
| 1430 |
file3 2-sided conflict including an executable |
| 1431 |
file4 2-sided conflict including 1 deletion |
| 1432 |
file5 2-sided conflict including 1 deletion and an executable |
| 1433 |
[EOF] |
| 1434 |
"); |
| 1435 |
|
| 1436 |
// Exec bit conflict can be resolved by chmod |
| 1437 |
let output = work_dir.run_jj(["resolve", "file3"]); |
| 1438 |
insta::assert_snapshot!(output, @r#" |
| 1439 |
------- stderr ------- |
| 1440 |
Error: Failed to resolve conflicts |
| 1441 |
Caused by: "file3" has conflicts in executable bit |
| 1442 |
Conflict: |
| 1443 |
Adding file with id e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 (mzvwutvl e2d3924b "a") |
| 1444 |
Adding executable file with id e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 (vruxwmqv 888b6cc3 "b") |
| 1445 |
Hint: Use `jj file chmod` to update the executable bit. |
| 1446 |
[EOF] |
| 1447 |
[exit status: 1] |
| 1448 |
"#); |
| 1449 |
let output = work_dir.run_jj(["file", "chmod", "--quiet", "x", "file3"]); |
| 1450 |
insta::assert_snapshot!(output, @""); |
| 1451 |
|
| 1452 |
// Take modified content, the executable bit should be kept as "-" |
| 1453 |
let output = work_dir.run_jj(["resolve", "file4", "--tool=:ours"]); |
| 1454 |
insta::assert_snapshot!(output, @" |
| 1455 |
------- stderr ------- |
| 1456 |
Working copy (@) now at: kmkuslsw 0810a8d2 conflict | (conflict) conflict |
| 1457 |
Parent commit (@-) : mzvwutvl e2d3924b a | a |
| 1458 |
Parent commit (@-) : vruxwmqv 888b6cc3 b | b |
| 1459 |
Added 0 files, modified 1 files, removed 0 files |
| 1460 |
Warning: There are unresolved conflicts at these paths: |
| 1461 |
file5 2-sided conflict including 1 deletion and an executable |
| 1462 |
[EOF] |
| 1463 |
"); |
| 1464 |
|
| 1465 |
// Take modified content, the executable bit should be kept as "x" |
| 1466 |
let output = work_dir.run_jj(["resolve", "file5", "--tool=:theirs"]); |
| 1467 |
insta::assert_snapshot!(output, @r" |
| 1468 |
------- stderr ------- |
| 1469 |
Working copy (@) now at: kmkuslsw 7337267a conflict | conflict |
| 1470 |
Parent commit (@-) : mzvwutvl e2d3924b a | a |
| 1471 |
Parent commit (@-) : vruxwmqv 888b6cc3 b | b |
| 1472 |
Added 0 files, modified 1 files, removed 0 files |
| 1473 |
Existing conflicts were resolved or abandoned from 1 commits. |
| 1474 |
[EOF] |
| 1475 |
"); |
| 1476 |
|
| 1477 |
insta::assert_snapshot!(file_list("all()"), @" |
| 1478 |
file2 - - |
| 1479 |
file3 - x |
| 1480 |
file4 - - |
| 1481 |
file5 - x |
| 1482 |
[EOF] |
| 1483 |
"); |
| 1484 |
Ok(()) |
| 1485 |
} |
| 1486 |
|
| 1487 |
#[test] |
| 1488 |
fn test_pass_path_argument() -> TestResult { |
| 1489 |
let mut test_env = TestEnvironment::default(); |
| 1490 |
let editor_script = test_env.set_up_fake_editor(); |
| 1491 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1492 |
let work_dir = test_env.work_dir("repo"); |
| 1493 |
|
| 1494 |
// Makes it easier to read the diffs between conflicts |
| 1495 |
test_env.add_config("ui.conflict-marker-style = 'snapshot'"); |
| 1496 |
|
| 1497 |
// Create a conflict |
| 1498 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); |
| 1499 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); |
| 1500 |
create_commit_with_files(&work_dir, "b", &["base"], &[("file", "b\n")]); |
| 1501 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 1502 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1503 |
file 2-sided conflict |
| 1504 |
[EOF] |
| 1505 |
"); |
| 1506 |
insta::assert_snapshot!(work_dir.read_file("file"), @r#" |
| 1507 |
<<<<<<< conflict 1 of 1 |
| 1508 |
+++++++ zsuskuln 45537d53 "a" |
| 1509 |
a |
| 1510 |
------- rlvkpnrz 1792382a "base" |
| 1511 |
base |
| 1512 |
+++++++ royxmykx 89d1b299 "b" |
| 1513 |
b |
| 1514 |
>>>>>>> conflict 1 of 1 ends |
| 1515 |
"# |
| 1516 |
); |
| 1517 |
|
| 1518 |
// If the merge tool accepts the "$path" argument, then it should be passed |
| 1519 |
std::fs::write( |
| 1520 |
&editor_script, |
| 1521 |
indoc! {b" |
| 1522 |
expect-arg 0 |
| 1523 |
file\0write |
| 1524 |
resolution |
| 1525 |
\0"}, |
| 1526 |
)?; |
| 1527 |
let output = work_dir.run_jj([ |
| 1528 |
"resolve", |
| 1529 |
"file", |
| 1530 |
r#"--config=merge-tools.fake-editor.merge-args=["$output", "$path"]"#, |
| 1531 |
]); |
| 1532 |
insta::assert_snapshot!(output, @" |
| 1533 |
------- stderr ------- |
| 1534 |
Resolving conflicts in: file |
| 1535 |
Working copy (@) now at: vruxwmqv 682816de conflict | conflict |
| 1536 |
Parent commit (@-) : zsuskuln 45537d53 a | a |
| 1537 |
Parent commit (@-) : royxmykx 89d1b299 b | b |
| 1538 |
Added 0 files, modified 1 files, removed 0 files |
| 1539 |
[EOF] |
| 1540 |
"); |
| 1541 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1542 |
diff --git a/file b/file |
| 1543 |
index 0000000000..88425ec521 100644 |
| 1544 |
--- a/file |
| 1545 |
+++ b/file |
| 1546 |
@@ -1,8 +1,1 @@ |
| 1547 |
-<<<<<<< conflict 1 of 1 |
| 1548 |
-+++++++ zsuskuln 45537d53 "a" |
| 1549 |
-a |
| 1550 |
-------- rlvkpnrz 1792382a "base" |
| 1551 |
-base |
| 1552 |
-+++++++ royxmykx 89d1b299 "b" |
| 1553 |
-b |
| 1554 |
->>>>>>> conflict 1 of 1 ends |
| 1555 |
+resolution |
| 1556 |
[EOF] |
| 1557 |
"#); |
| 1558 |
|
| 1559 |
// The output filtered to a non-existent file should display a warning. |
| 1560 |
let output = work_dir.run_jj([ |
| 1561 |
"resolve", |
| 1562 |
"nonexistent", |
| 1563 |
"file", |
| 1564 |
r#"--config=merge-tools.fake-editor.merge-args=["$output", "$path"]"#, |
| 1565 |
]); |
| 1566 |
insta::assert_snapshot!(output, @" |
| 1567 |
------- stderr ------- |
| 1568 |
Warning: No matching entries for paths: nonexistent |
| 1569 |
Error: No conflicts found at the given path(s) |
| 1570 |
[EOF] |
| 1571 |
[exit status: 2] |
| 1572 |
"); |
| 1573 |
Ok(()) |
| 1574 |
} |
| 1575 |
|
| 1576 |
#[test] |
| 1577 |
fn test_resolve_long_conflict_markers() -> TestResult { |
| 1578 |
let mut test_env = TestEnvironment::default(); |
| 1579 |
let editor_script = test_env.set_up_fake_editor(); |
| 1580 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1581 |
let work_dir = test_env.work_dir("repo"); |
| 1582 |
|
| 1583 |
// Makes it easier to read the diffs between conflicts |
| 1584 |
test_env.add_config("ui.conflict-marker-style = 'snapshot'"); |
| 1585 |
|
| 1586 |
// Create a conflict which requires long conflict markers to be materialized |
| 1587 |
create_commit_with_files(&work_dir, "base", &[], &[("file", "======= base\n")]); |
| 1588 |
create_commit_with_files(&work_dir, "a", &["base"], &[("file", "<<<<<<< a\n")]); |
| 1589 |
create_commit_with_files(&work_dir, "b", &["base"], &[("file", ">>>>>>> b\n")]); |
| 1590 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 1591 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1592 |
file 2-sided conflict |
| 1593 |
[EOF] |
| 1594 |
"); |
| 1595 |
insta::assert_snapshot!(work_dir.read_file("file"), @r#" |
| 1596 |
<<<<<<<<<<< conflict 1 of 1 |
| 1597 |
+++++++++++ zsuskuln 10d994ef "a" |
| 1598 |
<<<<<<< a |
| 1599 |
----------- rlvkpnrz 04dceede "base" |
| 1600 |
======= base |
| 1601 |
+++++++++++ royxmykx 7f215575 "b" |
| 1602 |
>>>>>>> b |
| 1603 |
>>>>>>>>>>> conflict 1 of 1 ends |
| 1604 |
"# |
| 1605 |
); |
| 1606 |
let setup_opid = work_dir.current_operation_id(); |
| 1607 |
// Allow signaling that conflict markers were produced even if not editing |
| 1608 |
// conflict markers materialized in the output file |
| 1609 |
test_env.add_config("merge-tools.fake-editor.merge-conflict-exit-codes = [1]"); |
| 1610 |
|
| 1611 |
// By default, conflict markers of length 7 or longer are parsed for |
| 1612 |
// compatibility with Git merge tools |
| 1613 |
std::fs::write( |
| 1614 |
&editor_script, |
| 1615 |
indoc! {b" |
| 1616 |
write |
| 1617 |
<<<<<<< |
| 1618 |
A |
| 1619 |
||||||| |
| 1620 |
BASE |
| 1621 |
======= |
| 1622 |
B |
| 1623 |
>>>>>>> |
| 1624 |
\0fail |
| 1625 |
"}, |
| 1626 |
)?; |
| 1627 |
let output = work_dir.run_jj(["resolve"]); |
| 1628 |
insta::assert_snapshot!(output, @" |
| 1629 |
------- stderr ------- |
| 1630 |
Resolving conflicts in: file |
| 1631 |
Working copy (@) now at: vruxwmqv ad16cc38 conflict | (conflict) conflict |
| 1632 |
Parent commit (@-) : zsuskuln 10d994ef a | a |
| 1633 |
Parent commit (@-) : royxmykx 7f215575 b | b |
| 1634 |
Added 0 files, modified 1 files, removed 0 files |
| 1635 |
Warning: There are unresolved conflicts at these paths: |
| 1636 |
file 2-sided conflict |
| 1637 |
New conflicts appeared in 1 commits: |
| 1638 |
vruxwmqv ad16cc38 conflict | (conflict) conflict |
| 1639 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 1640 |
the conflicted commit: |
| 1641 |
jj new vruxwmqv |
| 1642 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 1643 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 1644 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 1645 |
[EOF] |
| 1646 |
"); |
| 1647 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1648 |
diff --git a/file b/file |
| 1649 |
--- a/file |
| 1650 |
+++ b/file |
| 1651 |
@@ -1,8 +1,8 @@ |
| 1652 |
-<<<<<<<<<<< conflict 1 of 1 |
| 1653 |
-+++++++++++ zsuskuln 10d994ef "a" |
| 1654 |
-<<<<<<< a |
| 1655 |
------------ rlvkpnrz 04dceede "base" |
| 1656 |
-======= base |
| 1657 |
-+++++++++++ royxmykx 7f215575 "b" |
| 1658 |
->>>>>>> b |
| 1659 |
->>>>>>>>>>> conflict 1 of 1 ends |
| 1660 |
+<<<<<<< conflict 1 of 1 |
| 1661 |
++++++++ zsuskuln 10d994ef "a" |
| 1662 |
+A |
| 1663 |
+------- rlvkpnrz 04dceede "base" |
| 1664 |
+BASE |
| 1665 |
++++++++ royxmykx 7f215575 "b" |
| 1666 |
+B |
| 1667 |
+>>>>>>> conflict 1 of 1 ends |
| 1668 |
[EOF] |
| 1669 |
"#); |
| 1670 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1671 |
file 2-sided conflict |
| 1672 |
[EOF] |
| 1673 |
"); |
| 1674 |
|
| 1675 |
// If the merge tool edits the output file with materialized markers, the |
| 1676 |
// markers must match the length of the materialized markers to be parsed |
| 1677 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1678 |
std::fs::write( |
| 1679 |
&editor_script, |
| 1680 |
indoc! {b" |
| 1681 |
dump editor |
| 1682 |
\0write |
| 1683 |
<<<<<<<<<<< |
| 1684 |
<<<<<<< A |
| 1685 |
||||||||||| |
| 1686 |
======= BASE |
| 1687 |
=========== |
| 1688 |
>>>>>>> B |
| 1689 |
>>>>>>>>>>> |
| 1690 |
\0fail |
| 1691 |
"}, |
| 1692 |
)?; |
| 1693 |
let output = work_dir.run_jj([ |
| 1694 |
"resolve", |
| 1695 |
"--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", |
| 1696 |
]); |
| 1697 |
insta::assert_snapshot!(output, @" |
| 1698 |
------- stderr ------- |
| 1699 |
Resolving conflicts in: file |
| 1700 |
Working copy (@) now at: vruxwmqv bbbee812 conflict | (conflict) conflict |
| 1701 |
Parent commit (@-) : zsuskuln 10d994ef a | a |
| 1702 |
Parent commit (@-) : royxmykx 7f215575 b | b |
| 1703 |
Added 0 files, modified 1 files, removed 0 files |
| 1704 |
Warning: There are unresolved conflicts at these paths: |
| 1705 |
file 2-sided conflict |
| 1706 |
New conflicts appeared in 1 commits: |
| 1707 |
vruxwmqv bbbee812 conflict | (conflict) conflict |
| 1708 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 1709 |
the conflicted commit: |
| 1710 |
jj new vruxwmqv |
| 1711 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 1712 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 1713 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 1714 |
[EOF] |
| 1715 |
"); |
| 1716 |
insta::assert_snapshot!( |
| 1717 |
std::fs::read_to_string(test_env.env_root().join("editor"))?, @r#" |
| 1718 |
<<<<<<<<<<< conflict 1 of 1 |
| 1719 |
+++++++++++ zsuskuln 10d994ef "a" |
| 1720 |
<<<<<<< a |
| 1721 |
----------- rlvkpnrz 04dceede "base" |
| 1722 |
======= base |
| 1723 |
+++++++++++ royxmykx 7f215575 "b" |
| 1724 |
>>>>>>> b |
| 1725 |
>>>>>>>>>>> conflict 1 of 1 ends |
| 1726 |
"#); |
| 1727 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1728 |
diff --git a/file b/file |
| 1729 |
--- a/file |
| 1730 |
+++ b/file |
| 1731 |
@@ -1,8 +1,8 @@ |
| 1732 |
<<<<<<<<<<< conflict 1 of 1 |
| 1733 |
+++++++++++ zsuskuln 10d994ef "a" |
| 1734 |
-<<<<<<< a |
| 1735 |
+<<<<<<< A |
| 1736 |
----------- rlvkpnrz 04dceede "base" |
| 1737 |
-======= base |
| 1738 |
+======= BASE |
| 1739 |
+++++++++++ royxmykx 7f215575 "b" |
| 1740 |
->>>>>>> b |
| 1741 |
+>>>>>>> B |
| 1742 |
>>>>>>>>>>> conflict 1 of 1 ends |
| 1743 |
[EOF] |
| 1744 |
"#); |
| 1745 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1746 |
file 2-sided conflict |
| 1747 |
[EOF] |
| 1748 |
"); |
| 1749 |
|
| 1750 |
// If the merge tool accepts the marker length as an argument, then the conflict |
| 1751 |
// markers should be at least as long as "$marker_length" |
| 1752 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1753 |
std::fs::write( |
| 1754 |
&editor_script, |
| 1755 |
indoc! {b" |
| 1756 |
expect-arg 0 |
| 1757 |
11\0write |
| 1758 |
<<<<<<<<<<< |
| 1759 |
<<<<<<< A |
| 1760 |
||||||||||| |
| 1761 |
======= BASE |
| 1762 |
=========== |
| 1763 |
>>>>>>> B |
| 1764 |
>>>>>>>>>>> |
| 1765 |
\0fail |
| 1766 |
"}, |
| 1767 |
)?; |
| 1768 |
let output = work_dir.run_jj([ |
| 1769 |
"resolve", |
| 1770 |
r#"--config=merge-tools.fake-editor.merge-args=["$output", "$marker_length"]"#, |
| 1771 |
]); |
| 1772 |
insta::assert_snapshot!(output, @" |
| 1773 |
------- stderr ------- |
| 1774 |
Resolving conflicts in: file |
| 1775 |
Working copy (@) now at: vruxwmqv 4405a045 conflict | (conflict) conflict |
| 1776 |
Parent commit (@-) : zsuskuln 10d994ef a | a |
| 1777 |
Parent commit (@-) : royxmykx 7f215575 b | b |
| 1778 |
Added 0 files, modified 1 files, removed 0 files |
| 1779 |
Warning: There are unresolved conflicts at these paths: |
| 1780 |
file 2-sided conflict |
| 1781 |
New conflicts appeared in 1 commits: |
| 1782 |
vruxwmqv 4405a045 conflict | (conflict) conflict |
| 1783 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 1784 |
the conflicted commit: |
| 1785 |
jj new vruxwmqv |
| 1786 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 1787 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 1788 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 1789 |
[EOF] |
| 1790 |
"); |
| 1791 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1792 |
diff --git a/file b/file |
| 1793 |
--- a/file |
| 1794 |
+++ b/file |
| 1795 |
@@ -1,8 +1,8 @@ |
| 1796 |
<<<<<<<<<<< conflict 1 of 1 |
| 1797 |
+++++++++++ zsuskuln 10d994ef "a" |
| 1798 |
-<<<<<<< a |
| 1799 |
+<<<<<<< A |
| 1800 |
----------- rlvkpnrz 04dceede "base" |
| 1801 |
-======= base |
| 1802 |
+======= BASE |
| 1803 |
+++++++++++ royxmykx 7f215575 "b" |
| 1804 |
->>>>>>> b |
| 1805 |
+>>>>>>> B |
| 1806 |
>>>>>>>>>>> conflict 1 of 1 ends |
| 1807 |
[EOF] |
| 1808 |
"#); |
| 1809 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1810 |
file 2-sided conflict |
| 1811 |
[EOF] |
| 1812 |
"); |
| 1813 |
Ok(()) |
| 1814 |
} |
| 1815 |
|
| 1816 |
#[test] |
| 1817 |
fn test_multiple_conflicts() -> TestResult { |
| 1818 |
let mut test_env = TestEnvironment::default(); |
| 1819 |
let editor_script = test_env.set_up_fake_editor(); |
| 1820 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1821 |
let work_dir = test_env.work_dir("repo"); |
| 1822 |
|
| 1823 |
create_commit_with_files( |
| 1824 |
&work_dir, |
| 1825 |
"base", |
| 1826 |
&[], |
| 1827 |
&[ |
| 1828 |
( |
| 1829 |
"this_file_has_a_very_long_name_to_test_padding", |
| 1830 |
"first base\n", |
| 1831 |
), |
| 1832 |
("another_file", "second base\n"), |
| 1833 |
], |
| 1834 |
); |
| 1835 |
create_commit_with_files( |
| 1836 |
&work_dir, |
| 1837 |
"a", |
| 1838 |
&["base"], |
| 1839 |
&[ |
| 1840 |
( |
| 1841 |
"this_file_has_a_very_long_name_to_test_padding", |
| 1842 |
"first a\n", |
| 1843 |
), |
| 1844 |
("another_file", "second a\n"), |
| 1845 |
], |
| 1846 |
); |
| 1847 |
create_commit_with_files( |
| 1848 |
&work_dir, |
| 1849 |
"b", |
| 1850 |
&["base"], |
| 1851 |
&[ |
| 1852 |
( |
| 1853 |
"this_file_has_a_very_long_name_to_test_padding", |
| 1854 |
"first b\n", |
| 1855 |
), |
| 1856 |
("another_file", "second b\n"), |
| 1857 |
], |
| 1858 |
); |
| 1859 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 1860 |
// Test the setup |
| 1861 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1862 |
@ conflict |
| 1863 |
├─╮ |
| 1864 |
│ ○ b |
| 1865 |
○ │ a |
| 1866 |
├─╯ |
| 1867 |
○ base |
| 1868 |
◆ |
| 1869 |
[EOF] |
| 1870 |
"); |
| 1871 |
insta::assert_snapshot!( |
| 1872 |
work_dir.read_file("this_file_has_a_very_long_name_to_test_padding"), @r#" |
| 1873 |
<<<<<<< conflict 1 of 1 |
| 1874 |
%%%%%%% diff from: rlvkpnrz fa081b8c "base" |
| 1875 |
\\\\\\\ to: zsuskuln 2c821f70 "a" |
| 1876 |
-first base |
| 1877 |
+first a |
| 1878 |
+++++++ royxmykx 4c2029de "b" |
| 1879 |
first b |
| 1880 |
>>>>>>> conflict 1 of 1 ends |
| 1881 |
"#); |
| 1882 |
insta::assert_snapshot!(work_dir.read_file("another_file"), @r#" |
| 1883 |
<<<<<<< conflict 1 of 1 |
| 1884 |
%%%%%%% diff from: rlvkpnrz fa081b8c "base" |
| 1885 |
\\\\\\\ to: zsuskuln 2c821f70 "a" |
| 1886 |
-second base |
| 1887 |
+second a |
| 1888 |
+++++++ royxmykx 4c2029de "b" |
| 1889 |
second b |
| 1890 |
>>>>>>> conflict 1 of 1 ends |
| 1891 |
"#); |
| 1892 |
let setup_opid = work_dir.current_operation_id(); |
| 1893 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1894 |
another_file 2-sided conflict |
| 1895 |
this_file_has_a_very_long_name_to_test_padding 2-sided conflict |
| 1896 |
[EOF] |
| 1897 |
"); |
| 1898 |
// Test colors |
| 1899 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list", "--color=always"]), @" |
| 1900 |
another_file [38;5;3m2-sided conflict[39m |
| 1901 |
this_file_has_a_very_long_name_to_test_padding [38;5;3m2-sided conflict[39m |
| 1902 |
[EOF] |
| 1903 |
"); |
| 1904 |
|
| 1905 |
// Check that we can manually pick which of the conflicts to resolve first |
| 1906 |
std::fs::write(&editor_script, "expect\n\0write\nresolution another_file\n")?; |
| 1907 |
let output = work_dir.run_jj(["resolve", "another_file"]); |
| 1908 |
insta::assert_snapshot!(output, @" |
| 1909 |
------- stderr ------- |
| 1910 |
Resolving conflicts in: another_file |
| 1911 |
Working copy (@) now at: vruxwmqv 90639b66 conflict | (conflict) conflict |
| 1912 |
Parent commit (@-) : zsuskuln 2c821f70 a | a |
| 1913 |
Parent commit (@-) : royxmykx 4c2029de b | b |
| 1914 |
Added 0 files, modified 1 files, removed 0 files |
| 1915 |
Warning: There are unresolved conflicts at these paths: |
| 1916 |
this_file_has_a_very_long_name_to_test_padding 2-sided conflict |
| 1917 |
New conflicts appeared in 1 commits: |
| 1918 |
vruxwmqv 90639b66 conflict | (conflict) conflict |
| 1919 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 1920 |
the conflicted commit: |
| 1921 |
jj new vruxwmqv |
| 1922 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 1923 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 1924 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 1925 |
[EOF] |
| 1926 |
"); |
| 1927 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1928 |
diff --git a/another_file b/another_file |
| 1929 |
index 0000000000..a9fcc7d486 100644 |
| 1930 |
--- a/another_file |
| 1931 |
+++ b/another_file |
| 1932 |
@@ -1,8 +1,1 @@ |
| 1933 |
-<<<<<<< conflict 1 of 1 |
| 1934 |
-%%%%%%% diff from: rlvkpnrz fa081b8c "base" |
| 1935 |
-\\\\\\\ to: zsuskuln 2c821f70 "a" |
| 1936 |
--second base |
| 1937 |
-+second a |
| 1938 |
-+++++++ royxmykx 4c2029de "b" |
| 1939 |
-second b |
| 1940 |
->>>>>>> conflict 1 of 1 ends |
| 1941 |
+resolution another_file |
| 1942 |
[EOF] |
| 1943 |
"#); |
| 1944 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 1945 |
this_file_has_a_very_long_name_to_test_padding 2-sided conflict |
| 1946 |
[EOF] |
| 1947 |
"); |
| 1948 |
|
| 1949 |
// Repeat the above with the `--quiet` option. |
| 1950 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1951 |
std::fs::write(&editor_script, "expect\n\0write\nresolution another_file\n")?; |
| 1952 |
let output = work_dir.run_jj(["resolve", "--quiet", "another_file"]); |
| 1953 |
insta::assert_snapshot!(output, @""); |
| 1954 |
|
| 1955 |
// Without a path, `jj resolve` should call the merge tool multiple times |
| 1956 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1957 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 1958 |
std::fs::write( |
| 1959 |
&editor_script, |
| 1960 |
[ |
| 1961 |
"expect\n", |
| 1962 |
"write\nfirst resolution for auto-chosen file\n", |
| 1963 |
"next invocation\n", |
| 1964 |
"expect\n", |
| 1965 |
"write\nsecond resolution for auto-chosen file\n", |
| 1966 |
] |
| 1967 |
.join("\0"), |
| 1968 |
)?; |
| 1969 |
work_dir.run_jj(["resolve"]).success(); |
| 1970 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 1971 |
diff --git a/another_file b/another_file |
| 1972 |
index 0000000000..7903e1c1c7 100644 |
| 1973 |
--- a/another_file |
| 1974 |
+++ b/another_file |
| 1975 |
@@ -1,8 +1,1 @@ |
| 1976 |
-<<<<<<< conflict 1 of 1 |
| 1977 |
-%%%%%%% diff from: rlvkpnrz fa081b8c "base" |
| 1978 |
-\\\\\\\ to: zsuskuln 2c821f70 "a" |
| 1979 |
--second base |
| 1980 |
-+second a |
| 1981 |
-+++++++ royxmykx 4c2029de "b" |
| 1982 |
-second b |
| 1983 |
->>>>>>> conflict 1 of 1 ends |
| 1984 |
+first resolution for auto-chosen file |
| 1985 |
diff --git a/this_file_has_a_very_long_name_to_test_padding b/this_file_has_a_very_long_name_to_test_padding |
| 1986 |
index 0000000000..f8c72adf17 100644 |
| 1987 |
--- a/this_file_has_a_very_long_name_to_test_padding |
| 1988 |
+++ b/this_file_has_a_very_long_name_to_test_padding |
| 1989 |
@@ -1,8 +1,1 @@ |
| 1990 |
-<<<<<<< conflict 1 of 1 |
| 1991 |
-%%%%%%% diff from: rlvkpnrz fa081b8c "base" |
| 1992 |
-\\\\\\\ to: zsuskuln 2c821f70 "a" |
| 1993 |
--first base |
| 1994 |
-+first a |
| 1995 |
-+++++++ royxmykx 4c2029de "b" |
| 1996 |
-first b |
| 1997 |
->>>>>>> conflict 1 of 1 ends |
| 1998 |
+second resolution for auto-chosen file |
| 1999 |
[EOF] |
| 2000 |
"#); |
| 2001 |
|
| 2002 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2003 |
------- stderr ------- |
| 2004 |
Error: No conflicts found at this revision |
| 2005 |
[EOF] |
| 2006 |
[exit status: 2] |
| 2007 |
"); |
| 2008 |
insta::assert_snapshot!(work_dir.run_jj(["resolve"]), @" |
| 2009 |
------- stderr ------- |
| 2010 |
Error: No conflicts found at this revision |
| 2011 |
[EOF] |
| 2012 |
[exit status: 2] |
| 2013 |
"); |
| 2014 |
Ok(()) |
| 2015 |
} |
| 2016 |
|
| 2017 |
#[test] |
| 2018 |
fn test_multiple_conflicts_with_error() -> TestResult { |
| 2019 |
let mut test_env = TestEnvironment::default(); |
| 2020 |
let editor_script = test_env.set_up_fake_editor(); |
| 2021 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2022 |
let work_dir = test_env.work_dir("repo"); |
| 2023 |
|
| 2024 |
// Create two conflicted files, and one non-conflicted file |
| 2025 |
create_commit_with_files( |
| 2026 |
&work_dir, |
| 2027 |
"base", |
| 2028 |
&[], |
| 2029 |
&[ |
| 2030 |
("file1", "base1\n"), |
| 2031 |
("file2", "base2\n"), |
| 2032 |
("file3", "base3\n"), |
| 2033 |
], |
| 2034 |
); |
| 2035 |
create_commit_with_files( |
| 2036 |
&work_dir, |
| 2037 |
"a", |
| 2038 |
&["base"], |
| 2039 |
&[("file1", "a1\n"), ("file2", "a2\n")], |
| 2040 |
); |
| 2041 |
create_commit_with_files( |
| 2042 |
&work_dir, |
| 2043 |
"b", |
| 2044 |
&["base"], |
| 2045 |
&[("file1", "b1\n"), ("file2", "b2\n")], |
| 2046 |
); |
| 2047 |
create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); |
| 2048 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2049 |
file1 2-sided conflict |
| 2050 |
file2 2-sided conflict |
| 2051 |
[EOF] |
| 2052 |
"); |
| 2053 |
insta::assert_snapshot!(work_dir.read_file("file1"), @r#" |
| 2054 |
<<<<<<< conflict 1 of 1 |
| 2055 |
%%%%%%% diff from: rlvkpnrz 6591ac1d "base" |
| 2056 |
\\\\\\\ to: zsuskuln 6c31698c "a" |
| 2057 |
-base1 |
| 2058 |
+a1 |
| 2059 |
+++++++ royxmykx ba0a5538 "b" |
| 2060 |
b1 |
| 2061 |
>>>>>>> conflict 1 of 1 ends |
| 2062 |
"# |
| 2063 |
); |
| 2064 |
insta::assert_snapshot!(work_dir.read_file("file2"), @r#" |
| 2065 |
<<<<<<< conflict 1 of 1 |
| 2066 |
%%%%%%% diff from: rlvkpnrz 6591ac1d "base" |
| 2067 |
\\\\\\\ to: zsuskuln 6c31698c "a" |
| 2068 |
-base2 |
| 2069 |
+a2 |
| 2070 |
+++++++ royxmykx ba0a5538 "b" |
| 2071 |
b2 |
| 2072 |
>>>>>>> conflict 1 of 1 ends |
| 2073 |
"# |
| 2074 |
); |
| 2075 |
let setup_opid = work_dir.current_operation_id(); |
| 2076 |
|
| 2077 |
// Test resolving one conflict, then exiting without resolving the second one |
| 2078 |
std::fs::write( |
| 2079 |
&editor_script, |
| 2080 |
["write\nresolution1\n", "next invocation\n"].join("\0"), |
| 2081 |
)?; |
| 2082 |
let output = work_dir.run_jj(["resolve"]); |
| 2083 |
insta::assert_snapshot!(output.normalize_stderr_exit_status(), @" |
| 2084 |
------- stderr ------- |
| 2085 |
Resolving conflicts in: file1 |
| 2086 |
Resolving conflicts in: file2 |
| 2087 |
Working copy (@) now at: vruxwmqv e2442c8d conflict | (conflict) conflict |
| 2088 |
Parent commit (@-) : zsuskuln 6c31698c a | a |
| 2089 |
Parent commit (@-) : royxmykx ba0a5538 b | b |
| 2090 |
Added 0 files, modified 1 files, removed 0 files |
| 2091 |
Warning: There are unresolved conflicts at these paths: |
| 2092 |
file2 2-sided conflict |
| 2093 |
New conflicts appeared in 1 commits: |
| 2094 |
vruxwmqv e2442c8d conflict | (conflict) conflict |
| 2095 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 2096 |
the conflicted commit: |
| 2097 |
jj new vruxwmqv |
| 2098 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 2099 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 2100 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 2101 |
Error: Stopped due to error after resolving 1 conflicts |
| 2102 |
Caused by: The output file is either unchanged or empty after the editor quit (run with --debug to see the exact invocation). |
| 2103 |
[EOF] |
| 2104 |
[exit status: 1] |
| 2105 |
"); |
| 2106 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 2107 |
diff --git a/file1 b/file1 |
| 2108 |
index 0000000000..95cc18629d 100644 |
| 2109 |
--- a/file1 |
| 2110 |
+++ b/file1 |
| 2111 |
@@ -1,8 +1,1 @@ |
| 2112 |
-<<<<<<< conflict 1 of 1 |
| 2113 |
-%%%%%%% diff from: rlvkpnrz 6591ac1d "base" |
| 2114 |
-\\\\\\\ to: zsuskuln 6c31698c "a" |
| 2115 |
--base1 |
| 2116 |
-+a1 |
| 2117 |
-+++++++ royxmykx ba0a5538 "b" |
| 2118 |
-b1 |
| 2119 |
->>>>>>> conflict 1 of 1 ends |
| 2120 |
+resolution1 |
| 2121 |
[EOF] |
| 2122 |
"#); |
| 2123 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2124 |
file2 2-sided conflict |
| 2125 |
[EOF] |
| 2126 |
"); |
| 2127 |
|
| 2128 |
// Test resolving one conflict, then failing during the second resolution |
| 2129 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2130 |
std::fs::write( |
| 2131 |
&editor_script, |
| 2132 |
["write\nresolution1\n", "next invocation\n", "fail"].join("\0"), |
| 2133 |
)?; |
| 2134 |
let output = work_dir.run_jj(["resolve"]); |
| 2135 |
insta::assert_snapshot!(output.normalize_stderr_exit_status(), @" |
| 2136 |
------- stderr ------- |
| 2137 |
Resolving conflicts in: file1 |
| 2138 |
Resolving conflicts in: file2 |
| 2139 |
Working copy (@) now at: vruxwmqv fa64d807 conflict | (conflict) conflict |
| 2140 |
Parent commit (@-) : zsuskuln 6c31698c a | a |
| 2141 |
Parent commit (@-) : royxmykx ba0a5538 b | b |
| 2142 |
Added 0 files, modified 1 files, removed 0 files |
| 2143 |
Warning: There are unresolved conflicts at these paths: |
| 2144 |
file2 2-sided conflict |
| 2145 |
New conflicts appeared in 1 commits: |
| 2146 |
vruxwmqv fa64d807 conflict | (conflict) conflict |
| 2147 |
Hint: To resolve the conflicts, start by creating a commit on top of |
| 2148 |
the conflicted commit: |
| 2149 |
jj new vruxwmqv |
| 2150 |
Then use `jj resolve`, or edit the conflict markers in the file directly. |
| 2151 |
Once the conflicts are resolved, you can inspect the result with `jj diff`. |
| 2152 |
Then run `jj squash` to move the resolution into the conflicted commit. |
| 2153 |
Error: Stopped due to error after resolving 1 conflicts |
| 2154 |
Caused by: Tool exited with exit status: 1 (run with --debug to see the exact invocation) |
| 2155 |
[EOF] |
| 2156 |
[exit status: 1] |
| 2157 |
"); |
| 2158 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r#" |
| 2159 |
diff --git a/file1 b/file1 |
| 2160 |
index 0000000000..95cc18629d 100644 |
| 2161 |
--- a/file1 |
| 2162 |
+++ b/file1 |
| 2163 |
@@ -1,8 +1,1 @@ |
| 2164 |
-<<<<<<< conflict 1 of 1 |
| 2165 |
-%%%%%%% diff from: rlvkpnrz 6591ac1d "base" |
| 2166 |
-\\\\\\\ to: zsuskuln 6c31698c "a" |
| 2167 |
--base1 |
| 2168 |
-+a1 |
| 2169 |
-+++++++ royxmykx ba0a5538 "b" |
| 2170 |
-b1 |
| 2171 |
->>>>>>> conflict 1 of 1 ends |
| 2172 |
+resolution1 |
| 2173 |
[EOF] |
| 2174 |
"#); |
| 2175 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2176 |
file2 2-sided conflict |
| 2177 |
[EOF] |
| 2178 |
"); |
| 2179 |
|
| 2180 |
// Test immediately failing to resolve any conflict |
| 2181 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2182 |
std::fs::write(&editor_script, "fail")?; |
| 2183 |
let output = work_dir.run_jj(["resolve"]); |
| 2184 |
insta::assert_snapshot!(output.normalize_stderr_exit_status(), @" |
| 2185 |
------- stderr ------- |
| 2186 |
Resolving conflicts in: file1 |
| 2187 |
Error: Failed to resolve conflicts |
| 2188 |
Caused by: Tool exited with exit status: 1 (run with --debug to see the exact invocation) |
| 2189 |
[EOF] |
| 2190 |
[exit status: 1] |
| 2191 |
"); |
| 2192 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 2193 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2194 |
file1 2-sided conflict |
| 2195 |
file2 2-sided conflict |
| 2196 |
[EOF] |
| 2197 |
"); |
| 2198 |
Ok(()) |
| 2199 |
} |
| 2200 |
|
| 2201 |
#[test] |
| 2202 |
fn test_resolve_with_contents_of_side() -> TestResult { |
| 2203 |
let test_env = TestEnvironment::default(); |
| 2204 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2205 |
let work_dir = test_env.work_dir("repo"); |
| 2206 |
|
| 2207 |
create_commit_with_files( |
| 2208 |
&work_dir, |
| 2209 |
"base", |
| 2210 |
&[], |
| 2211 |
&[("file", "base\n"), ("other", "base\n")], |
| 2212 |
); |
| 2213 |
create_commit_with_files( |
| 2214 |
&work_dir, |
| 2215 |
"a", |
| 2216 |
&["base"], |
| 2217 |
&[("file", "a\n"), ("other", "base\n")], |
| 2218 |
); |
| 2219 |
create_commit_with_files( |
| 2220 |
&work_dir, |
| 2221 |
"b", |
| 2222 |
&["base"], |
| 2223 |
&[("file", "base\n"), ("other", "left\n")], |
| 2224 |
); |
| 2225 |
create_commit_with_files( |
| 2226 |
&work_dir, |
| 2227 |
"c", |
| 2228 |
&["base"], |
| 2229 |
&[("file", "b\n"), ("other", "right\n")], |
| 2230 |
); |
| 2231 |
create_commit_with_files(&work_dir, "conflict", &["a", "b", "c"], &[]); |
| 2232 |
create_commit_with_files(&work_dir, "tip", &["conflict"], &[]); |
| 2233 |
|
| 2234 |
// Test the setup |
| 2235 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2236 |
@ tip |
| 2237 |
× conflict |
| 2238 |
├─┬─╮ |
| 2239 |
│ │ ○ c |
| 2240 |
│ ○ │ b |
| 2241 |
│ ├─╯ |
| 2242 |
○ │ a |
| 2243 |
├─╯ |
| 2244 |
○ base |
| 2245 |
◆ |
| 2246 |
[EOF] |
| 2247 |
"); |
| 2248 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2249 |
file 2-sided conflict |
| 2250 |
other 2-sided conflict |
| 2251 |
[EOF] |
| 2252 |
"); |
| 2253 |
insta::assert_snapshot!(work_dir.read_file("file"), @r#" |
| 2254 |
<<<<<<< conflict 1 of 1 |
| 2255 |
%%%%%%% diff from: rlvkpnrz ed3e06b2 "base" |
| 2256 |
\\\\\\\ to: zsuskuln 72dced6e "a" |
| 2257 |
-base |
| 2258 |
+a |
| 2259 |
+++++++ vruxwmqv dd35236a "c" |
| 2260 |
b |
| 2261 |
>>>>>>> conflict 1 of 1 ends |
| 2262 |
"#); |
| 2263 |
insta::assert_snapshot!(work_dir.read_file("other"), @r#" |
| 2264 |
<<<<<<< conflict 1 of 1 |
| 2265 |
%%%%%%% diff from: rlvkpnrz ed3e06b2 "base" |
| 2266 |
\\\\\\\ to: royxmykx e5747f42 "b" |
| 2267 |
-base |
| 2268 |
+left |
| 2269 |
+++++++ vruxwmqv dd35236a "c" |
| 2270 |
right |
| 2271 |
>>>>>>> conflict 1 of 1 ends |
| 2272 |
"#); |
| 2273 |
let setup_opid = work_dir.current_operation_id(); |
| 2274 |
|
| 2275 |
// Check that ":ours" merge tool works correctly |
| 2276 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 2277 |
let output = work_dir.run_jj(["resolve", "-r", "conflict", "--tool", ":ours"]); |
| 2278 |
insta::assert_snapshot!(output, @r" |
| 2279 |
------- stderr ------- |
| 2280 |
Rebased 1 descendant commits. |
| 2281 |
Working copy (@) now at: kmkuslsw 6cca6d79 tip | (empty) tip |
| 2282 |
Parent commit (@-) : znkkpsqq b84d5da4 conflict | conflict |
| 2283 |
Added 0 files, modified 2 files, removed 0 files |
| 2284 |
[EOF] |
| 2285 |
"); |
| 2286 |
insta::assert_snapshot!(work_dir.read_file("file"), @"a"); |
| 2287 |
insta::assert_snapshot!(work_dir.read_file("other"), @"left"); |
| 2288 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2289 |
------- stderr ------- |
| 2290 |
Error: No conflicts found at this revision |
| 2291 |
[EOF] |
| 2292 |
[exit status: 2] |
| 2293 |
"); |
| 2294 |
|
| 2295 |
// Check that ":theirs" merge tool works correctly |
| 2296 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2297 |
insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); |
| 2298 |
let output = work_dir.run_jj(["resolve", "-r", "conflict", "--tool", ":theirs"]); |
| 2299 |
insta::assert_snapshot!(output, @r" |
| 2300 |
------- stderr ------- |
| 2301 |
Rebased 1 descendant commits. |
| 2302 |
Working copy (@) now at: kmkuslsw 4a54e224 tip | (empty) tip |
| 2303 |
Parent commit (@-) : znkkpsqq ffd341c7 conflict | conflict |
| 2304 |
Added 0 files, modified 2 files, removed 0 files |
| 2305 |
[EOF] |
| 2306 |
"); |
| 2307 |
insta::assert_snapshot!(work_dir.read_file("file"), @"b"); |
| 2308 |
insta::assert_snapshot!(work_dir.read_file("other"), @"right"); |
| 2309 |
insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @" |
| 2310 |
------- stderr ------- |
| 2311 |
Error: No conflicts found at this revision |
| 2312 |
[EOF] |
| 2313 |
[exit status: 2] |
| 2314 |
"); |
| 2315 |
Ok(()) |
| 2316 |
} |