diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index bd55bb3d2..5f2708da7 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -2787,7 +2787,7 @@ 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 sides = conflict.adds().len(); + let sides = conflict.num_sides(); let n_adds = conflict.adds().iter().flatten().count(); let deletions = sides - n_adds; diff --git a/cli/src/merge_tools/mod.rs b/cli/src/merge_tools/mod.rs index 2e49fef76..05ba78a84 100644 --- a/cli/src/merge_tools/mod.rs +++ b/cli/src/merge_tools/mod.rs @@ -98,10 +98,10 @@ pub fn run_mergetool( ) })?; // We only support conflicts with 2 sides (3-way conflicts) - if file_merge.adds().len() > 2 { + if file_merge.num_sides() > 2 { return Err(ConflictResolveError::ConflictTooComplicated { path: repo_path.clone(), - sides: file_merge.adds().len(), + sides: file_merge.num_sides(), }); }; let content = extract_as_single_hunk(&file_merge, tree.store(), repo_path); diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index ba8c5649b..46ad68b54 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -206,7 +206,7 @@ pub fn parse_conflict(input: &[u8], num_sides: usize) -> Option Merge { &self.adds } + /// The number of positive terms in the conflict. + pub fn num_sides(&self) -> usize { + self.adds.len() + } + /// Whether this merge is resolved. Does not resolve trivial merges. pub fn is_resolved(&self) -> bool { self.removes.is_empty() diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index d6f6f0d5b..522212845 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -299,7 +299,7 @@ line 5 right // The first add should always be from the left side insta::assert_debug_snapshot!( - parse_conflict(materialized.as_bytes(), conflict.adds().len()), + parse_conflict(materialized.as_bytes(), conflict.num_sides()), @r###" Some( [