From 9d4ac81c277fb0f8ef619557b9d3b58b796afe31 Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Fri, 31 May 2024 06:58:41 +0800 Subject: [PATCH] print_conflicted_paths: simplify file conflicts before printing --- cli/src/cli_util.rs | 1 + cli/tests/test_resolve_command.rs | 5 ++--- cli/tests/test_status_command.rs | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index bc46d7e08..d8b83e0b0 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -1840,6 +1840,7 @@ pub fn print_conflicted_paths( .map(|p| format!("{:width$}", p, width = max_path_len.min(32) + 3)); for ((_, conflict), formatted_path) in std::iter::zip(conflicts.iter(), formatted_paths) { + let conflict = conflict.clone().simplify(); let sides = conflict.num_sides(); let n_adds = conflict.adds().flatten().count(); let deletions = sides - n_adds; diff --git a/cli/tests/test_resolve_command.rs b/cli/tests/test_resolve_command.rs index 086bc92cd..882a68023 100644 --- a/cli/tests/test_resolve_command.rs +++ b/cli/tests/test_resolve_command.rs @@ -523,11 +523,10 @@ fn test_simplify_conflict_sides() { fileA: Ok(Conflicted([Some(File { id: FileId("d00491fd7e5bb6fa28c517a0bb32b8b506539d4d"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("0cfbf08886fca9a91cb753ec8734c84fcbe52c9f"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false })])) fileB: Ok(Conflicted([Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("d00491fd7e5bb6fa28c517a0bb32b8b506539d4d"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("0cfbf08886fca9a91cb753ec8734c84fcbe52c9f"), executable: false })])) "###); - // TODO: The conflict should be simplified before being displayed. insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]), @r###" - fileA 4-sided conflict - fileB 4-sided conflict + fileA 2-sided conflict + fileB 2-sided conflict "###); insta::assert_snapshot!( std::fs::read_to_string(repo_path.join("fileA")).unwrap(), @r###" diff --git a/cli/tests/test_status_command.rs b/cli/tests/test_status_command.rs index 57aabd82c..b8925e242 100644 --- a/cli/tests/test_status_command.rs +++ b/cli/tests/test_status_command.rs @@ -207,13 +207,12 @@ fn test_status_simplify_conflict_sides() { &[], ); - // TODO: The conflict should be simplified before being displayed. insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["status"]), @r###" The working copy is clean There are unresolved conflicts at these paths: - fileA 4-sided conflict - fileB 4-sided conflict + fileA 2-sided conflict + fileB 2-sided conflict Working copy : nkmrtpmo 7b1cdcaa conflict | (conflict) (empty) conflict Parent commit: kmkuslsw 18c1fb00 conflictA | (conflict) (empty) conflictA Parent commit: lylxulpl d11c92eb conflictB | (conflict) (empty) conflictB