diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b74375d52..568458d42b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * New `ui.conflict-marker-style` config option to change how conflicts are materialized in the working copy. The default option ("diff") renders conflicts as a snapshot with a list of diffs to apply to the snapshot. + The new "snapshot" option just renders conflicts as a series of snapshots, + showing each side of the conflict and the base(s). ### Fixed bugs diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index df2cde1b72..f5f1fb9016 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -140,6 +140,8 @@ pub async fn extract_as_single_hunk( pub enum ConflictMarkerStyle { /// Style which shows a snapshot and a series of diffs to apply Diff, + /// Style which shows a snapshot for each base and side + Snapshot, } /// A type similar to `MergedTreeValue` but with associated data to include in @@ -241,7 +243,7 @@ async fn materialize_tree_value_no_access_denied( pub fn materialize_merge_result( single_hunk: &Merge, - _conflict_marker_style: ConflictMarkerStyle, + conflict_marker_style: ConflictMarkerStyle, output: &mut dyn Write, ) -> std::io::Result<()> { let merge_result = files::merge(single_hunk); @@ -280,6 +282,15 @@ pub fn materialize_merge_result( write_base(&base_str, left, output)?; continue; }; + + // For snapshot style, always emit sides and bases separately + if conflict_marker_style == ConflictMarkerStyle::Snapshot { + write_side(add_index, right1, output)?; + write_base(&base_str, left, output)?; + add_index += 1; + continue; + } + let diff1 = Diff::by_line([&left, &right1]).hunks().collect_vec(); // Check if the diff against the next positive term is better. Since // we want to preserve the order of the terms, we don't match against