Debian Codegraph @

src/handlers/merge_conflict.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#, IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#};
2
3 use itertoolsrust-analyzer cargo itertools 0.14.0 crate/::Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#;
4 use unicode_segmentationrust-analyzer cargo unicode-segmentation 1.12.0 crate/::UnicodeSegmentationrust-analyzer cargo unicode-segmentation 1.12.0 UnicodeSegmentation#;
5
6 use superrust-analyzer cargo git-delta 0.19.2 handlers/::drawrust-analyzer cargo git-delta 0.19.2 handlers/draw/;
7 use craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/;
8 use craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/::{selfrust-analyzer cargo git-delta 0.19.2 config/, delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable().};
9 use craterust-analyzer cargo git-delta 0.19.2 crate/::deltarust-analyzer cargo git-delta 0.19.2 delta/::{DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#, MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#, StateMachinerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#};
10 use craterust-analyzer cargo git-delta 0.19.2 crate/::minusplusrust-analyzer cargo git-delta 0.19.2 minusplus/::MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#;
11 use craterust-analyzer cargo git-delta 0.19.2 crate/::paintrust-analyzer cargo git-delta 0.19.2 paint/::{selfrust-analyzer cargo git-delta 0.19.2 paint/, preparerust-analyzer cargo git-delta 0.19.2 paint/prepare().};
12 use craterust-analyzer cargo git-delta 0.19.2 crate/::stylerust-analyzer cargo git-delta 0.19.2 style/::Stylerust-analyzer cargo git-delta 0.19.2 style/Style#;
13
14 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
15 pub enum MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit# {
16 Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours#,
17 Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#,
18 Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs#,
19 }
20
21 pub struct MergeConflictCommitsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#<T> {
22 oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ours.: T,
23 ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ancestral.: T,
24 theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#theirs.: T,
25 }
26
27 pub type MergeConflictLinesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictLines# = MergeConflictCommitsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#)>>;
28
29 pub type MergeConflictCommitNamesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommitNames# = MergeConflictCommitsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>;
30
31 impl StateMachinerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#<'_> {
32 pub fn handle_merge_conflict_linerust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]handle_merge_conflict_line().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> {
33 use DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#::*;
34 use MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#::*;
35 use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*;
36
37 let mut handled_line = false;
38 if self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..color_onlyrust-analyzer cargo git-delta 0.19.2 config/Config#color_only. || !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..handle_merge_conflictsrust-analyzer cargo git-delta 0.19.2 config/Config#handle_merge_conflicts. {
39 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(handled_line);
40 }
41
42 match self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state..clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().() {
43 HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _, _, _)
44 | HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _)
45 | HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _)
46 | HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _) => {
47 handled_line = self.enter_merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]enter_merge_conflict().(&merge_parents)
48 }
49 MergeConflictrust-analyzer cargo git-delta 0.19.2 delta/State#MergeConflict#(merge_parents, Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours#) => {
50 handled_line = self.enter_ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]enter_ancestral().(&merge_parents)
51 || self.enter_theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]enter_theirs().(&merge_parents)
52 || self.exit_merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]exit_merge_conflict().(&merge_parents)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
53 || self.store_linerust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]store_line().(
54 Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours#,
55 HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Yesrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#Yes#), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
56 );
57 }
58 MergeConflictrust-analyzer cargo git-delta 0.19.2 delta/State#MergeConflict#(merge_parents, Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#) => {
59 handled_line = self.enter_theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]enter_theirs().(&merge_parents)
60 || self.exit_merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]exit_merge_conflict().(&merge_parents)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
61 || self.store_linerust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]store_line().(
62 Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#,
63 HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Yesrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#Yes#), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
64 );
65 }
66 MergeConflictrust-analyzer cargo git-delta 0.19.2 delta/State#MergeConflict#(merge_parents, Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs#) => {
67 handled_line = self.exit_merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]exit_merge_conflict().(&merge_parents)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
68 || self.store_linerust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]store_line().(
69 Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs#,
70 HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Yesrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#Yes#), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
71 );
72 }
73 _ => {}
74 }
75
76 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(handled_line)
77 }
78
79 fn enter_merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]enter_merge_conflict().(&mut self, merge_parents: &MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#) -> bool {
80 use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*;
81 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit) = parse_merge_markerrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/parse_merge_marker().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., "++<<<<<<<") {
82 self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. = MergeConflictrust-analyzer cargo git-delta 0.19.2 delta/State#MergeConflict#(merge_parents.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[MergeParents][Clone]clone().(), Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours#);
83 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..merge_conflict_commit_namesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_commit_names.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut().Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours#]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut(). = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
84 true
85 } else {
86 false
87 }
88 }
89
90 fn enter_ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]enter_ancestral().(&mut self, merge_parents: &MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#) -> bool {
91 use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*;
92 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit) = parse_merge_markerrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/parse_merge_marker().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., "++|||||||") {
93 self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. = MergeConflictrust-analyzer cargo git-delta 0.19.2 delta/State#MergeConflict#(merge_parents.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[MergeParents][Clone]clone().(), Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#);
94 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..merge_conflict_commit_namesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_commit_names.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut().Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut(). = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
95 true
96 } else {
97 false
98 }
99 }
100
101 fn enter_theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]enter_theirs().(&mut self, merge_parents: &MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#) -> bool {
102 use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*;
103 if self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("++=======") {
104 self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. = MergeConflictrust-analyzer cargo git-delta 0.19.2 delta/State#MergeConflict#(merge_parents.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[MergeParents][Clone]clone().(), Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs#);
105 true
106 } else {
107 false
108 }
109 }
110
111 fn exit_merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]exit_merge_conflict().(&mut self, merge_parents: &MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> {
112 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit) = parse_merge_markerrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/parse_merge_marker().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., "++>>>>>>>") {
113 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..merge_conflict_commit_namesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_commit_names.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut().Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs#]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut(). = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
114 self.paint_buffered_merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]paint_buffered_merge_conflict_lines().(merge_parents)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
115 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true)
116 } else {
117 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false)
118 }
119 }
120
121 fn store_linerust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]store_line().(&mut self, commit: MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#, state: Staterust-analyzer cargo git-delta 0.19.2 delta/State#) -> bool {
122 use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*;
123 if let HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(diff_type, _) | HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(diff_type, _) | HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(diff_type, _) = &state {
124 let line = preparerust-analyzer cargo git-delta 0.19.2 paint/prepare().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., diff_type.n_parentsrust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType]n_parents().(), self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.);
125 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_lines.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut().commit]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut()..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((line, state));
126 true
127 } else {
128 delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid state: {state:?}"))
129 }
130 }
131
132 fn paint_buffered_merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`StateMachine<'_>`]paint_buffered_merge_conflict_lines().(
133 &mut self,
134 merge_parents: &MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#,
135 ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
136 use DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#::*;
137 use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*;
138 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..emitrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]emit().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
139
140 write_merge_conflict_barrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/write_merge_conflict_bar().(
141 &self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..merge_conflict_begin_symbolrust-analyzer cargo git-delta 0.19.2 config/Config#merge_conflict_begin_symbol.,
142 &mut self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter.,
143 self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.,
144 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
145 for (derived_commit_type, header_style) in &[
146 (Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours#, self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..merge_conflict_ours_diff_header_stylerust-analyzer cargo git-delta 0.19.2 config/Config#merge_conflict_ours_diff_header_style.),
147 (Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs#, self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..merge_conflict_theirs_diff_header_stylerust-analyzer cargo git-delta 0.19.2 config/Config#merge_conflict_theirs_diff_header_style.),
148 ] {
149 write_diff_headerrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/write_diff_header().(
150 derived_commit_type,
151 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().header_style,
152 &mut self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter.,
153 self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.,
154 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
155 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..emitrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]emit().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
156 paintrust-analyzer cargo git-delta 0.19.2 paint/::paint_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/paint_minus_and_plus_lines().(
157 MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(
158 &self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_lines.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<MergeConflictCommit>`]index().Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<MergeConflictCommit>`]index().,
159 &self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_lines.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<&MergeConflictCommit>`]index().derived_commit_type]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<&MergeConflictCommit>`]index().,
160 ),
161 &mut self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..line_numbers_datarust-analyzer cargo git-delta 0.19.2 paint/Painter#line_numbers_data.,
162 &mut self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..highlighterrust-analyzer cargo git-delta 0.19.2 paint/Painter#highlighter.,
163 &mut self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer.,
164 self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.,
165 );
166 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..emitrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]emit().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
167 }
168 // write_merge_conflict_decoration("bold ol", &mut self.painter, self.config)?;
169 write_merge_conflict_barrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/write_merge_conflict_bar().(
170 &self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..merge_conflict_end_symbolrust-analyzer cargo git-delta 0.19.2 config/Config#merge_conflict_end_symbol.,
171 &mut self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter.,
172 self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.,
173 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
174 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_lines..clearrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Vec<(String, State)>>`]clear().();
175 self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. = HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(merge_parents.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[MergeParents][Clone]clone().(), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
176 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
177 }
178 }
179
180 fn write_diff_headerrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/write_diff_header().(
181 derived_commit_type: &MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#,
182 style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#,
183 painter: &mut paintrust-analyzer cargo git-delta 0.19.2 paint/::Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#,
184 config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
185 ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
186 let (mut draw_fn, pad, decoration_ansi_term_style) =
187 drawrust-analyzer cargo git-delta 0.19.2 handlers/draw/::get_draw_functionrust-analyzer cargo git-delta 0.19.2 handlers/draw/get_draw_function().(style.decoration_stylerust-analyzer cargo git-delta 0.19.2 style/Style#decoration_style.);
188 let derived_commit_name = &painter.merge_conflict_commit_namesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_commit_names.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<&MergeConflictCommit>`]index().derived_commit_type]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<&MergeConflictCommit>`]index().;
189 let text = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_ancestral_commit) = &painter.merge_conflict_commit_namesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_commit_names.[rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<MergeConflictCommit>`]index().Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#]rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<MergeConflictCommit>`]index(). {
190 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
191 "ancestor {} {}{}",
192 config.right_arrowrust-analyzer cargo git-delta 0.19.2 config/Config#right_arrow.,
193 derived_commit_name.as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("?"),
194 if pad { " " } else { "" }
195 )
196 } else {
197 derived_commit_name.as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("?").to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
198 };
199 draw_fn(
200 painter.writerrust-analyzer cargo git-delta 0.19.2 paint/Painter#writer.,
201 &text,
202 &text,
203 "",
204 &config.decorations_widthrust-analyzer cargo git-delta 0.19.2 config/Config#decorations_width.,
205 style,
206 decoration_ansi_term_style,
207 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
208 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
209 }
210
211 fn write_merge_conflict_barrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/write_merge_conflict_bar().(
212 s: &str,
213 painter: &mut paintrust-analyzer cargo git-delta 0.19.2 paint/::Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#,
214 config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
215 ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
216 let width = match config.decorations_widthrust-analyzer cargo git-delta 0.19.2 config/Config#decorations_width. {
217 clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(width) => width,
218 clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Variablerust-analyzer cargo git-delta 0.19.2 cli/Width#Variable# => config.available_terminal_widthrust-analyzer cargo git-delta 0.19.2 config/Config#available_terminal_width.,
219 };
220 writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(
221 painter.writerrust-analyzer cargo git-delta 0.19.2 paint/Painter#writer.,
222 "{}",
223 &s.graphemesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]graphemes().(true).cyclerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cycle().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(width).joinrust-analyzer cargo itertools 0.14.0 Itertools#join().("")
224 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
225 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
226 }
227
228 fn parse_merge_markerrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/parse_merge_marker().<'a>(line: &'a str, marker: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str> {
229 match line.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().(marker) {
230 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix) => {
231 let suffix = suffix.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().();
232 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().suffix.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
233 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix)
234 } else {
235 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
236 }
237 }
238 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
239 }
240 }
241
242 pub use MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#::*;
243
244 impl<T> Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#> for MergeConflictCommitsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#<T> {
245 type Outputrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<MergeConflictCommit>`]Output# = T;
246 fn indexrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<MergeConflictCommit>`]index().(&self, commit: MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#) -> &Selfrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<MergeConflictCommit>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# {
247 match commit {
248 Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours# => &self.oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ours.,
249 Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral# => &self.ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ancestral.,
250 Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs# => &self.theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#theirs.,
251 }
252 }
253 }
254
255 impl<T> Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<&MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#> for MergeConflictCommitsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#<T> {
256 type Outputrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<&MergeConflictCommit>`]Output# = T;
257 fn indexrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<&MergeConflictCommit>`]index().(&self, commit: &MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#) -> &Selfrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`Index<&MergeConflictCommit>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# {
258 match commit {
259 Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours# => &self.oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ours.,
260 Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral# => &self.ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ancestral.,
261 Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs# => &self.theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#theirs.,
262 }
263 }
264 }
265
266 impl<T> IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#> for MergeConflictCommitsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#<T> {
267 fn index_mutrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]index_mut().(&mut self, commit: MergeConflictCommitrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#) -> &mut Selfrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<T>`][`IndexMut<MergeConflictCommit>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# {
268 match commit {
269 Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours# => &mut self.oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ours.,
270 Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral# => &mut self.ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ancestral.,
271 Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs# => &mut self.theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#theirs.,
272 }
273 }
274 }
275
276 impl MergeConflictLinesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictLines# {
277 pub fn newrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Vec<(String, State)>>`]new().() -> Selfrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Vec<(String, State)>>`] {
278 Selfrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Vec<(String, State)>>`] {
279 oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ours.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
280 ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ancestral.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
281 theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#theirs.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
282 }
283 }
284
285 fn clearrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Vec<(String, State)>>`]clear().(&mut self) {
286 self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().Oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ours#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().();
287 self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().Ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Ancestral#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().();
288 self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().Theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommit#Theirs#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().();
289 }
290 }
291
292 impl MergeConflictCommitNamesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommitNames# {
293 pub fn newrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Option<String>>`]new().() -> Selfrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Option<String>>`] {
294 Selfrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Option<String>>`] {
295 oursrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ours.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
296 ancestralrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#ancestral.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
297 theirsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommits#theirs.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
298 }
299 }
300 }
301
302 #[cfg(test)]
303 mod testsrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/ {
304 use craterust-analyzer cargo git-delta 0.19.2 crate/::ansirust-analyzer cargo git-delta 0.19.2 ansi/::strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().;
305 use craterust-analyzer cargo git-delta 0.19.2 crate/::testsrust-analyzer cargo git-delta 0.19.2 tests/::integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/;
306
307 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
308 fn test_toy_merge_conflict_no_contextrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/test_toy_merge_conflict_no_context().() {
309 let config = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&[]);
310 let output = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::run_deltarust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/run_delta().(GIT_TOY_MERGE_CONFLICT_NO_CONTEXTrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/GIT_TOY_MERGE_CONFLICT_NO_CONTEXT., &config);
311 let output = strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().(&output);
312 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("\n▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼"));
313 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(
314 "\
315 ──────────────────┐
316 ancestor ⟶ HEAD │
317 ──────────────────┘
318 "
319 ));
320 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("\n▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲"));
321 }
322
323 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
324 fn test_real_merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/test_real_merge_conflict().() {
325 let config = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&[]);
326 let output = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::run_deltarust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/run_delta().(GIT_MERGE_CONFLICTrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/GIT_MERGE_CONFLICT., &config);
327 let output = strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().(&output);
328 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("\n▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼"));
329 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(
330 "\
331 ──────────────────┐
332 ancestor ⟶ HEAD │
333 ──────────────────┘
334 "
335 ));
336 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("\n▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲"));
337 }
338
339 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
340 #[allow(non_snake_case)]
341 fn test_real_merge_conflict_U0rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/test_real_merge_conflict_U0().() {
342 let config = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&[]);
343 let output = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::run_deltarust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/run_delta().(GIT_MERGE_CONFLICT_U0rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/GIT_MERGE_CONFLICT_U0., &config);
344 let output = strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().(&output);
345 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("\n▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼"));
346 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(
347 "\
348 ──────────────────┐
349 ancestor ⟶ HEAD │
350 ──────────────────┘
351 "
352 ));
353 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("\n▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲"));
354 }
355
356 const GIT_TOY_MERGE_CONFLICT_NO_CONTEXTrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/GIT_TOY_MERGE_CONFLICT_NO_CONTEXT.: &str = "\
357 diff --cc file
358 index 6178079,7898192..0000000
359 --- a/file
360 +++ b/file
361 @@@ -1,1 -1,1 +1,6 @@@
362 ++<<<<<<< HEAD
363 +a
364 ++||||||| parent of 0c20c9d... wip
365 ++=======
366 + b
367 ++>>>>>>> 0c20c9d... wip
368 ";
369
370 const GIT_MERGE_CONFLICTrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/GIT_MERGE_CONFLICT.: &str = r#"\
371 diff --cc src/handlers/merge_conflict.rs
372 index 27d47c0,3a7e7b9..0000000
373 --- a/src/handlers/merge_conflict.rs
374 +++ b/src/handlers/merge_conflict.rs
375 @@@ -1,14 -1,13 +1,24 @@@
376 -use std::cmp::min;
377 use std::ops::{Index, IndexMut};
378
379 ++<<<<<<< HEAD
380 +use itertools::Itertools;
381 +use unicode_segmentation::UnicodeSegmentation;
382 +
383 +use super::draw;
384 +use crate::cli;
385 +use crate::config::{self, delta_unreachable};
386 +use crate::delta::{DiffType, InMergeConflict, MergeParents, State, StateMachine};
387 ++||||||| parent of b2b28c8... Display merge conflict branches
388 ++use crate::delta::{DiffType, MergeParents, State, StateMachine};
389 ++=======
390 + use super::draw;
391 + use crate::cli;
392 + use crate::config::{self, delta_unreachable};
393 + use crate::delta::{DiffType, MergeParents, State, StateMachine};
394 ++>>>>>>> b2b28c8... Display merge conflict branches
395 use crate::minusplus::MinusPlus;
396 use crate::paint;
397 + use crate::style::DecorationStyle;
398
399 #[derive(Clone, Debug, PartialEq)]
400 pub enum MergeConflictCommit {
401 @@@ -30,7 -29,8 +40,15 @@@ pub type MergeConflictCommitNames = Mer
402 impl<'a> StateMachine<'a> {
403 pub fn handle_merge_conflict_line(&mut self) -> std::io::Result<bool> {
404 use DiffType::*;
405 ++<<<<<<< HEAD
406 use MergeConflictCommit::*;
407 ++||||||| parent of b2b28c8... Display merge conflict branches
408 + use MergeParents::*;
409 ++ use Source::*;
410 ++=======
411 ++ use MergeConflictCommit::*;
412 ++ use MergeParents::*;
413 ++>>>>>>> b2b28c8... Display merge conflict branches
414 use State::*;
415
416 let mut handled_line = false;
417 @@@ -38,36 -38,28 +56,113 @@@
418 return Ok(handled_line);
419 }
420
421 ++<<<<<<< HEAD
422 + match self.state.clone() {
423 + HunkHeader(Combined(merge_parents, InMergeConflict::No), _, _)
424 + | HunkMinus(Combined(merge_parents, InMergeConflict::No), _)
425 + | HunkZero(Combined(merge_parents, InMergeConflict::No))
426 + | HunkPlus(Combined(merge_parents, InMergeConflict::No), _) => {
427 + handled_line = self.enter_merge_conflict(&merge_parents)
428 + }
429 + MergeConflict(merge_parents, Ours) => {
430 + handled_line = self.enter_ancestral(&merge_parents)
431 + || self.enter_theirs(&merge_parents)
432 + || self.exit_merge_conflict(&merge_parents)?
433 + || self.store_line(
434 + Ours,
435 + HunkPlus(Combined(merge_parents, InMergeConflict::Yes), None),
436 + );
437 ++||||||| parent of b2b28c8... Display merge conflict branches
438 ++ // TODO: don't allocate on heap at this point
439 ++ let prefix = self.line[..min(self.line.len(), 2)].to_string();
440 ++ let diff_type = Combined(Prefix(prefix));
441 ++
442 ++ match self.state {
443 ++ // The only transition into a merge conflict is HunkZero => MergeConflict(Ours)
444 ++ // TODO: shouldn't this be HunkZero(Some(_))?
445 ++ HunkZero(_) => {
446 ++ if self.line.starts_with("++<<<<<<<") {
447 ++ self.state = MergeConflict(Ours);
448 ++ handled_line = true
449 ++ }
450 + }
451 ++ MergeConflict(Ours) => {
452 ++ if self.line.starts_with("++|||||||") {
453 ++ self.state = MergeConflict(Ancestral);
454 ++ } else if self.line.starts_with("++=======") {
455 ++ self.state = MergeConflict(Theirs);
456 ++ } else if self.line.starts_with("++>>>>>>>") {
457 ++ self.paint_buffered_merge_conflict_lines(diff_type)?;
458 ++ } else {
459 ++ let line = self.painter.prepare(&self.line, diff_type.n_parents());
460 ++ self.painter.merge_conflict_lines[Ours].push((line, HunkPlus(diff_type, None)));
461 ++ }
462 ++ handled_line = true
463 ++=======
464 + // TODO: don't allocate on heap at this point
465 + let prefix = self.line[..min(self.line.len(), 2)].to_string();
466 + let diff_type = Combined(Prefix(prefix));
467 +
468 + match self.state {
469 + // The only transition into a merge conflict is HunkZero => MergeConflict(Ours)
470 + // TODO: shouldn't this be HunkZero(Some(_))?
471 + HunkZero(_) => handled_line = self.enter_merge_conflict(),
472 + MergeConflict(Ours) => {
473 + handled_line = self.enter_ancestral()
474 + || self.enter_theirs()
475 + || self.exit_merge_conflict(diff_type.clone())?
476 + || self.store_line(Ours, HunkPlus(diff_type, None));
477 ++>>>>>>> b2b28c8... Display merge conflict branches
478 + }
479 ++<<<<<<< HEAD
480 + MergeConflict(merge_parents, Ancestral) => {
481 + handled_line = self.enter_theirs(&merge_parents)
482 + || self.exit_merge_conflict(&merge_parents)?
483 + || self.store_line(
484 + Ancestral,
485 + HunkMinus(Combined(merge_parents, InMergeConflict::Yes), None),
486 + );
487 ++||||||| parent of b2b28c8... Display merge conflict branches
488 ++ MergeConflict(Ancestral) => {
489 ++ if self.line.starts_with("++=======") {
490 ++ self.state = MergeConflict(Theirs);
491 ++ } else if self.line.starts_with("++>>>>>>>") {
492 ++ self.paint_buffered_merge_conflict_lines(diff_type)?;
493 ++ } else {
494 ++ let line = self.painter.prepare(&self.line, diff_type.n_parents());
495 ++ self.painter.merge_conflict_lines[Ancestral]
496 ++ .push((line, HunkMinus(diff_type, None)));
497 ++ }
498 ++ handled_line = true
499 ++=======
500 + MergeConflict(Ancestral) => {
501 + handled_line = self.enter_theirs()
502 + || self.exit_merge_conflict(diff_type.clone())?
503 + || self.store_line(Ancestral, HunkMinus(diff_type, None));
504 ++>>>>>>> b2b28c8... Display merge conflict branches
505 }
506 ++<<<<<<< HEAD
507 + MergeConflict(merge_parents, Theirs) => {
508 + handled_line = self.exit_merge_conflict(&merge_parents)?
509 + || self.store_line(
510 + Theirs,
511 + HunkPlus(Combined(merge_parents, InMergeConflict::Yes), None),
512 + );
513 ++||||||| parent of b2b28c8... Display merge conflict branches
514 ++ MergeConflict(Theirs) => {
515 ++ if self.line.starts_with("++>>>>>>>") {
516 ++ self.paint_buffered_merge_conflict_lines(diff_type)?;
517 ++ } else {
518 ++ let line = self.painter.prepare(&self.line, diff_type.n_parents());
519 ++ self.painter.merge_conflict_lines[Theirs]
520 ++ .push((line, HunkPlus(diff_type, None)));
521 ++ }
522 ++ handled_line = true
523 ++=======
524 + MergeConflict(Theirs) => {
525 + handled_line = self.exit_merge_conflict(diff_type.clone())?
526 + || self.store_line(Theirs, HunkPlus(diff_type, None));
527 ++>>>>>>> b2b28c8... Display merge conflict branches
528 }
529 _ => {}
530 }
531 @@@ -75,75 -67,71 +170,150 @@@
532 Ok(handled_line)
533 }
534
535 ++<<<<<<< HEAD
536 + fn enter_merge_conflict(&mut self, merge_parents: &MergeParents) -> bool {
537 + use State::*;
538 + if let Some(commit) = parse_merge_marker(&self.line, "++<<<<<<<") {
539 + self.state = MergeConflict(merge_parents.clone(), Ours);
540 + self.painter.merge_conflict_commit_names[Ours] = Some(commit.to_string());
541 + true
542 + } else {
543 + false
544 + }
545 + }
546 +
547 + fn enter_ancestral(&mut self, merge_parents: &MergeParents) -> bool {
548 + use State::*;
549 + if let Some(commit) = parse_merge_marker(&self.line, "++|||||||") {
550 + self.state = MergeConflict(merge_parents.clone(), Ancestral);
551 + self.painter.merge_conflict_commit_names[Ancestral] = Some(commit.to_string());
552 + true
553 + } else {
554 + false
555 + }
556 + }
557 +
558 + fn enter_theirs(&mut self, merge_parents: &MergeParents) -> bool {
559 + use State::*;
560 + if self.line.starts_with("++=======") {
561 + self.state = MergeConflict(merge_parents.clone(), Theirs);
562 + true
563 + } else {
564 + false
565 + }
566 + }
567 +
568 + fn exit_merge_conflict(&mut self, merge_parents: &MergeParents) -> std::io::Result<bool> {
569 + if let Some(commit) = parse_merge_marker(&self.line, "++>>>>>>>") {
570 + self.painter.merge_conflict_commit_names[Theirs] = Some(commit.to_string());
571 + self.paint_buffered_merge_conflict_lines(merge_parents)?;
572 + Ok(true)
573 + } else {
574 + Ok(false)
575 + }
576 + }
577 +
578 + fn store_line(&mut self, commit: MergeConflictCommit, state: State) -> bool {
579 + use State::*;
580 + if let HunkMinus(diff_type, _) | HunkZero(diff_type) | HunkPlus(diff_type, _) = &state {
581 + let line = self.painter.prepare(&self.line, diff_type.n_parents());
582 + self.painter.merge_conflict_lines[commit].push((line, state));
583 + true
584 + } else {
585 + delta_unreachable(&format!("Invalid state: {:?}", state))
586 + }
587 + }
588 +
589 + fn paint_buffered_merge_conflict_lines(
590 + &mut self,
591 + merge_parents: &MergeParents,
592 + ) -> std::io::Result<()> {
593 + use DiffType::*;
594 + use State::*;
595 ++||||||| parent of b2b28c8... Display merge conflict branches
596 ++ fn paint_buffered_merge_conflict_lines(&mut self, diff_type: DiffType) -> std::io::Result<()> {
597 ++=======
598 + fn enter_merge_conflict(&mut self) -> bool {
599 + use State::*;
600 + if let Some(commit) = parse_merge_marker(&self.line, "++<<<<<<<") {
601 + self.state = MergeConflict(Ours);
602 + self.painter.merge_conflict_commit_names[Ours] = Some(commit.to_string());
603 + true
604 + } else {
605 + false
606 + }
607 + }
608 +
609 + fn enter_ancestral(&mut self) -> bool {
610 + use State::*;
611 + if let Some(commit) = parse_merge_marker(&self.line, "++|||||||") {
612 + self.state = MergeConflict(Ancestral);
613 + self.painter.merge_conflict_commit_names[Ancestral] = Some(commit.to_string());
614 + true
615 + } else {
616 + false
617 + }
618 + }
619 +
620 + fn enter_theirs(&mut self) -> bool {
621 + use State::*;
622 + if self.line.starts_with("++=======") {
623 + self.state = MergeConflict(Theirs);
624 + true
625 + } else {
626 + false
627 + }
628 + }
629 +
630 + fn exit_merge_conflict(&mut self, diff_type: DiffType) -> std::io::Result<bool> {
631 + if let Some(commit) = parse_merge_marker(&self.line, "++>>>>>>>") {
632 + self.painter.merge_conflict_commit_names[Theirs] = Some(commit.to_string());
633 + self.paint_buffered_merge_conflict_lines(diff_type)?;
634 + Ok(true)
635 + } else {
636 + Ok(false)
637 + }
638 + }
639 +
640 + fn store_line(&mut self, commit: MergeConflictCommit, state: State) -> bool {
641 + use State::*;
642 + if let HunkMinus(diff_type, _) | HunkZero(diff_type) | HunkPlus(diff_type, _) = &state {
643 + let line = self.painter.prepare(&self.line, diff_type.n_parents());
644 + self.painter.merge_conflict_lines[commit].push((line, state));
645 + true
646 + } else {
647 + delta_unreachable(&format!("Invalid state: {:?}", state))
648 + }
649 + }
650 +
651 + fn paint_buffered_merge_conflict_lines(&mut self, diff_type: DiffType) -> std::io::Result<()> {
652 ++>>>>>>> b2b28c8... Display merge conflict branches
653 self.painter.emit()?;
654 ++<<<<<<< HEAD
655 +
656 + write_merge_conflict_bar(
657 + &self.config.merge_conflict_begin_symbol,
658 + &mut self.painter,
659 + self.config,
660 + )?;
661 + for derived_commit_type in &[Ours, Theirs] {
662 + write_diff_header(derived_commit_type, &mut self.painter, self.config)?;
663 + self.painter.emit()?;
664 ++||||||| parent of b2b28c8... Display merge conflict branches
665 ++ let lines = &self.painter.merge_conflict_lines;
666 ++ for derived_lines in &[&lines[Ours], &lines[Theirs]] {
667 ++=======
668 +
669 + write_merge_conflict_bar("▼", &mut self.painter, self.config)?;
670 + for (derived_commit_type, decoration_style) in &[(Ours, "box"), (Theirs, "box")] {
671 + write_subhunk_header(
672 + derived_commit_type,
673 + decoration_style,
674 + &mut self.painter,
675 + self.config,
676 + )?;
677 + self.painter.emit()?;
678 ++>>>>>>> b2b28c8... Display merge conflict branches
679 paint::paint_minus_and_plus_lines(
680 MinusPlus::new(
681 &self.painter.merge_conflict_lines[Ancestral],
682 @@@ -156,78 -144,94 +326,190 @@@
683 );
684 self.painter.emit()?;
685 }
686 ++<<<<<<< HEAD
687 + // write_merge_conflict_decoration("bold ol", &mut self.painter, self.config)?;
688 + write_merge_conflict_bar(
689 + &self.config.merge_conflict_end_symbol,
690 + &mut self.painter,
691 + self.config,
692 + )?;
693 ++||||||| parent of b2b28c8... Display merge conflict branches
694 ++=======
695 + // write_merge_conflict_decoration("bold ol", &mut self.painter, self.config)?;
696 + write_merge_conflict_bar("▲", &mut self.painter, self.config)?;
697 ++>>>>>>> b2b28c8... Display merge conflict branches
698 self.painter.merge_conflict_lines.clear();
699 - self.state = State::HunkZero(diff_type);
700 + self.state = HunkZero(Combined(merge_parents.clone(), InMergeConflict::No));
701 Ok(())
702 }
703 }
704
705 ++<<<<<<< HEAD
706 +fn write_diff_header(
707 + derived_commit_type: &MergeConflictCommit,
708 + painter: &mut paint::Painter,
709 + config: &config::Config,
710 +) -> std::io::Result<()> {
711 + let (mut draw_fn, pad, decoration_ansi_term_style) =
712 + draw::get_draw_function(config.merge_conflict_diff_header_style.decoration_style);
713 + let derived_commit_name = &painter.merge_conflict_commit_names[derived_commit_type];
714 + let text = if let Some(_ancestral_commit) = &painter.merge_conflict_commit_names[Ancestral] {
715 + format!(
716 + "ancestor {} {}{}",
717 + config.right_arrow,
718 + derived_commit_name.as_deref().unwrap_or("?"),
719 + if pad { " " } else { "" }
720 + )
721 + } else {
722 + derived_commit_name.as_deref().unwrap_or("?").to_string()
723 + };
724 + draw_fn(
725 + painter.writer,
726 + &text,
727 + &text,
728 + &config.decorations_width,
729 + config.merge_conflict_diff_header_style,
730 + decoration_ansi_term_style,
731 + )?;
732 + Ok(())
733 +}
734 +
735 +fn write_merge_conflict_bar(
736 + s: &str,
737 + painter: &mut paint::Painter,
738 + config: &config::Config,
739 +) -> std::io::Result<()> {
740 + if let cli::Width::Fixed(width) = config.decorations_width {
741 + writeln!(
742 + painter.writer,
743 + "{}",
744 + &s.graphemes(true).cycle().take(width).join("")
745 + )?;
746 + }
747 + Ok(())
748 +}
749 +
750 +fn parse_merge_marker<'a>(line: &'a str, marker: &str) -> Option<&'a str> {
751 + match line.strip_prefix(marker) {
752 + Some(suffix) => {
753 + let suffix = suffix.trim();
754 + if !suffix.is_empty() {
755 + Some(suffix)
756 + } else {
757 + None
758 + }
759 + }
760 + None => None,
761 + }
762 +}
763 +
764 +pub use MergeConflictCommit::*;
765 +
766 ++impl<T> Index<MergeConflictCommit> for MergeConflictCommits<T> {
767 ++ type Output = T;
768 ++ fn index(&self, commit: MergeConflictCommit) -> &Self::Output {
769 ++ match commit {
770 ++ Ours => &self.ours,
771 ++ Ancestral => &self.ancestral,
772 ++ Theirs => &self.theirs,
773 ++ }
774 ++ }
775 ++}
776 ++||||||| parent of b2b28c8... Display merge conflict branches
777 ++pub use Source::*;
778 ++=======
779 + fn write_subhunk_header(
780 + derived_commit_type: &MergeConflictCommit,
781 + decoration_style: &str,
782 + painter: &mut paint::Painter,
783 + config: &config::Config,
784 + ) -> std::io::Result<()> {
785 + let (mut draw_fn, pad, decoration_ansi_term_style) =
786 + draw::get_draw_function(DecorationStyle::from_str(
787 + decoration_style,
788 + config.true_color,
789 + config.git_config.as_ref(),
790 + ));
791 + let derived_commit_name = &painter.merge_conflict_commit_names[derived_commit_type];
792 + let text = if let Some(_ancestral_commit) = &painter.merge_conflict_commit_names[Ancestral] {
793 + format!(
794 + "ancestor {} {}{}",
795 + config.right_arrow,
796 + derived_commit_name.as_deref().unwrap_or("?"),
797 + if pad { " " } else { "" }
798 + )
799 + } else {
800 + derived_commit_name.as_deref().unwrap_or("?").to_string()
801 + };
802 + draw_fn(
803 + painter.writer,
804 + &text,
805 + &text,
806 + &config.decorations_width,
807 + config.hunk_header_style,
808 + decoration_ansi_term_style,
809 + )?;
810 + Ok(())
811 + }
812 ++>>>>>>> b2b28c8... Display merge conflict branches
813 +
814 ++<<<<<<< HEAD
815 ++impl<T> Index<&MergeConflictCommit> for MergeConflictCommits<T> {
816 ++ type Output = T;
817 ++ fn index(&self, commit: &MergeConflictCommit) -> &Self::Output {
818 ++ match commit {
819 ++||||||| parent of b2b28c8... Display merge conflict branches
820 ++impl Index<Source> for MergeConflictLines {
821 ++ type Output = Vec<(String, State)>;
822 ++ fn index(&self, source: Source) -> &Self::Output {
823 ++ match source {
824 ++=======
825 + #[allow(unused)]
826 + fn write_merge_conflict_line(
827 + painter: &mut paint::Painter,
828 + config: &config::Config,
829 + ) -> std::io::Result<()> {
830 + let (mut draw_fn, _pad, decoration_ansi_term_style) = draw::get_draw_function(
831 + DecorationStyle::from_str("bold ol", config.true_color, config.git_config.as_ref()),
832 + );
833 + draw_fn(
834 + painter.writer,
835 + "",
836 + "",
837 + &config.decorations_width,
838 + config.hunk_header_style,
839 + decoration_ansi_term_style,
840 + )?;
841 + Ok(())
842 + }
843 +
844 + fn write_merge_conflict_bar(
845 + s: &str,
846 + painter: &mut paint::Painter,
847 + config: &config::Config,
848 + ) -> std::io::Result<()> {
849 + if let cli::Width::Fixed(width) = config.decorations_width {
850 + writeln!(painter.writer, "{}", s.repeat(width))?;
851 + }
852 + Ok(())
853 + }
854 +
855 + fn parse_merge_marker<'a>(line: &'a str, marker: &str) -> Option<&'a str> {
856 + match line.strip_prefix(marker) {
857 + Some(suffix) => {
858 + let suffix = suffix.trim();
859 + if !suffix.is_empty() {
860 + Some(suffix)
861 + } else {
862 + None
863 + }
864 + }
865 + None => None,
866 + }
867 + }
868 +
869 + pub use MergeConflictCommit::*;
870 +
871 impl<T> Index<MergeConflictCommit> for MergeConflictCommits<T> {
872 type Output = T;
873 fn index(&self, commit: MergeConflictCommit) -> &Self::Output {
874 @@@ -243,6 -247,6 +525,7 @@@ impl<T> Index<&MergeConflictCommit> fo
875 type Output = T;
876 fn index(&self, commit: &MergeConflictCommit) -> &Self::Output {
877 match commit {
878 ++>>>>>>> b2b28c8... Display merge conflict branches
879 Ours => &self.ours,
880 Ancestral => &self.ancestral,
881 Theirs => &self.theirs,
882 "#;
883
884 const GIT_MERGE_CONFLICT_U0rust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/tests/GIT_MERGE_CONFLICT_U0.: &str = r#"\
885 diff --cc src/handlers/merge_conflict.rs
886 index 27d47c0,3a7e7b9..0000000
887 --- a/src/handlers/merge_conflict.rs
888 +++ b/src/handlers/merge_conflict.rs
889 @@@ -3,7 -4,4 +3,16 @@@ use std::ops::{Index, IndexMut}
890 ++<<<<<<< HEAD
891 +use itertools::Itertools;
892 +use unicode_segmentation::UnicodeSegmentation;
893 +
894 +use super::draw;
895 +use crate::cli;
896 +use crate::config::{self, delta_unreachable};
897 +use crate::delta::{DiffType, InMergeConflict, MergeParents, State, StateMachine};
898 ++||||||| parent of b2b28c8... Display merge conflict branches
899 ++use crate::delta::{DiffType, MergeParents, State, StateMachine};
900 ++=======
901 + use super::draw;
902 + use crate::cli;
903 + use crate::config::{self, delta_unreachable};
904 + use crate::delta::{DiffType, MergeParents, State, StateMachine};
905 ++>>>>>>> b2b28c8... Display merge conflict branches
906 @@@ -33,0 -32,0 +43,1 @@@ impl<'a> StateMachine<'a>
907 ++<<<<<<< HEAD
908 @@@ -34,0 -33,1 +45,7 @@@
909 ++||||||| parent of b2b28c8... Display merge conflict branches
910 + use MergeParents::*;
911 ++ use Source::*;
912 ++=======
913 ++ use MergeConflictCommit::*;
914 ++ use MergeParents::*;
915 ++>>>>>>> b2b28c8... Display merge conflict branches
916 @@@ -41,23 -41,18 +59,84 @@@
917 ++<<<<<<< HEAD
918 + match self.state.clone() {
919 + HunkHeader(Combined(merge_parents, InMergeConflict::No), _, _)
920 + | HunkMinus(Combined(merge_parents, InMergeConflict::No), _)
921 + | HunkZero(Combined(merge_parents, InMergeConflict::No))
922 + | HunkPlus(Combined(merge_parents, InMergeConflict::No), _) => {
923 + handled_line = self.enter_merge_conflict(&merge_parents)
924 + }
925 + MergeConflict(merge_parents, Ours) => {
926 + handled_line = self.enter_ancestral(&merge_parents)
927 + || self.enter_theirs(&merge_parents)
928 + || self.exit_merge_conflict(&merge_parents)?
929 + || self.store_line(
930 + Ours,
931 + HunkPlus(Combined(merge_parents, InMergeConflict::Yes), None),
932 + );
933 ++||||||| parent of b2b28c8... Display merge conflict branches
934 ++ // TODO: don't allocate on heap at this point
935 ++ let prefix = self.line[..min(self.line.len(), 2)].to_string();
936 ++ let diff_type = Combined(Prefix(prefix));
937 ++
938 ++ match self.state {
939 ++ // The only transition into a merge conflict is HunkZero => MergeConflict(Ours)
940 ++ // TODO: shouldn't this be HunkZero(Some(_))?
941 ++ HunkZero(_) => {
942 ++ if self.line.starts_with("++<<<<<<<") {
943 ++ self.state = MergeConflict(Ours);
944 ++ handled_line = true
945 ++ }
946 + }
947 ++ MergeConflict(Ours) => {
948 ++ if self.line.starts_with("++|||||||") {
949 ++ self.state = MergeConflict(Ancestral);
950 ++ } else if self.line.starts_with("++=======") {
951 ++ self.state = MergeConflict(Theirs);
952 ++ } else if self.line.starts_with("++>>>>>>>") {
953 ++ self.paint_buffered_merge_conflict_lines(diff_type)?;
954 ++ } else {
955 ++ let line = self.painter.prepare(&self.line, diff_type.n_parents());
956 ++ self.painter.merge_conflict_lines[Ours].push((line, HunkPlus(diff_type, None)));
957 ++ }
958 ++ handled_line = true
959 ++=======
960 + // TODO: don't allocate on heap at this point
961 + let prefix = self.line[..min(self.line.len(), 2)].to_string();
962 + let diff_type = Combined(Prefix(prefix));
963 +
964 + match self.state {
965 + // The only transition into a merge conflict is HunkZero => MergeConflict(Ours)
966 + // TODO: shouldn't this be HunkZero(Some(_))?
967 + HunkZero(_) => handled_line = self.enter_merge_conflict(),
968 + MergeConflict(Ours) => {
969 + handled_line = self.enter_ancestral()
970 + || self.enter_theirs()
971 + || self.exit_merge_conflict(diff_type.clone())?
972 + || self.store_line(Ours, HunkPlus(diff_type, None));
973 ++>>>>>>> b2b28c8... Display merge conflict branches
974 + }
975 ++<<<<<<< HEAD
976 + MergeConflict(merge_parents, Ancestral) => {
977 + handled_line = self.enter_theirs(&merge_parents)
978 + || self.exit_merge_conflict(&merge_parents)?
979 + || self.store_line(
980 + Ancestral,
981 + HunkMinus(Combined(merge_parents, InMergeConflict::Yes), None),
982 + );
983 ++||||||| parent of b2b28c8... Display merge conflict branches
984 ++ MergeConflict(Ancestral) => {
985 ++ if self.line.starts_with("++=======") {
986 ++ self.state = MergeConflict(Theirs);
987 ++ } else if self.line.starts_with("++>>>>>>>") {
988 ++ self.paint_buffered_merge_conflict_lines(diff_type)?;
989 ++ } else {
990 ++ let line = self.painter.prepare(&self.line, diff_type.n_parents());
991 ++ self.painter.merge_conflict_lines[Ancestral]
992 ++ .push((line, HunkMinus(diff_type, None)));
993 ++ }
994 ++ handled_line = true
995 ++=======
996 + MergeConflict(Ancestral) => {
997 + handled_line = self.enter_theirs()
998 + || self.exit_merge_conflict(diff_type.clone())?
999 + || self.store_line(Ancestral, HunkMinus(diff_type, None));
1000 ++>>>>>>> b2b28c8... Display merge conflict branches
1001 @@@ -65,6 -60,3 +144,22 @@@
1002 ++<<<<<<< HEAD
1003 + MergeConflict(merge_parents, Theirs) => {
1004 + handled_line = self.exit_merge_conflict(&merge_parents)?
1005 + || self.store_line(
1006 + Theirs,
1007 + HunkPlus(Combined(merge_parents, InMergeConflict::Yes), None),
1008 + );
1009 ++||||||| parent of b2b28c8... Display merge conflict branches
1010 ++ MergeConflict(Theirs) => {
1011 ++ if self.line.starts_with("++>>>>>>>") {
1012 ++ self.paint_buffered_merge_conflict_lines(diff_type)?;
1013 ++ } else {
1014 ++ let line = self.painter.prepare(&self.line, diff_type.n_parents());
1015 ++ self.painter.merge_conflict_lines[Theirs]
1016 ++ .push((line, HunkPlus(diff_type, None)));
1017 ++ }
1018 ++ handled_line = true
1019 ++=======
1020 + MergeConflict(Theirs) => {
1021 + handled_line = self.exit_merge_conflict(diff_type.clone())?
1022 + || self.store_line(Theirs, HunkPlus(diff_type, None));
1023 ++>>>>>>> b2b28c8... Display merge conflict branches
1024 @@@ -78,59 -70,54 +173,118 @@@
1025 ++<<<<<<< HEAD
1026 + fn enter_merge_conflict(&mut self, merge_parents: &MergeParents) -> bool {
1027 + use State::*;
1028 + if let Some(commit) = parse_merge_marker(&self.line, "++<<<<<<<") {
1029 + self.state = MergeConflict(merge_parents.clone(), Ours);
1030 + self.painter.merge_conflict_commit_names[Ours] = Some(commit.to_string());
1031 + true
1032 + } else {
1033 + false
1034 + }
1035 + }
1036 +
1037 + fn enter_ancestral(&mut self, merge_parents: &MergeParents) -> bool {
1038 + use State::*;
1039 + if let Some(commit) = parse_merge_marker(&self.line, "++|||||||") {
1040 + self.state = MergeConflict(merge_parents.clone(), Ancestral);
1041 + self.painter.merge_conflict_commit_names[Ancestral] = Some(commit.to_string());
1042 + true
1043 + } else {
1044 + false
1045 + }
1046 + }
1047 +
1048 + fn enter_theirs(&mut self, merge_parents: &MergeParents) -> bool {
1049 + use State::*;
1050 + if self.line.starts_with("++=======") {
1051 + self.state = MergeConflict(merge_parents.clone(), Theirs);
1052 + true
1053 + } else {
1054 + false
1055 + }
1056 + }
1057 +
1058 + fn exit_merge_conflict(&mut self, merge_parents: &MergeParents) -> std::io::Result<bool> {
1059 + if let Some(commit) = parse_merge_marker(&self.line, "++>>>>>>>") {
1060 + self.painter.merge_conflict_commit_names[Theirs] = Some(commit.to_string());
1061 + self.paint_buffered_merge_conflict_lines(merge_parents)?;
1062 + Ok(true)
1063 + } else {
1064 + Ok(false)
1065 + }
1066 + }
1067 +
1068 + fn store_line(&mut self, commit: MergeConflictCommit, state: State) -> bool {
1069 + use State::*;
1070 + if let HunkMinus(diff_type, _) | HunkZero(diff_type) | HunkPlus(diff_type, _) = &state {
1071 + let line = self.painter.prepare(&self.line, diff_type.n_parents());
1072 + self.painter.merge_conflict_lines[commit].push((line, state));
1073 + true
1074 + } else {
1075 + delta_unreachable(&format!("Invalid state: {:?}", state))
1076 + }
1077 + }
1078 +
1079 + fn paint_buffered_merge_conflict_lines(
1080 + &mut self,
1081 + merge_parents: &MergeParents,
1082 + ) -> std::io::Result<()> {
1083 + use DiffType::*;
1084 + use State::*;
1085 ++||||||| parent of b2b28c8... Display merge conflict branches
1086 ++ fn paint_buffered_merge_conflict_lines(&mut self, diff_type: DiffType) -> std::io::Result<()> {
1087 ++=======
1088 + fn enter_merge_conflict(&mut self) -> bool {
1089 + use State::*;
1090 + if let Some(commit) = parse_merge_marker(&self.line, "++<<<<<<<") {
1091 + self.state = MergeConflict(Ours);
1092 + self.painter.merge_conflict_commit_names[Ours] = Some(commit.to_string());
1093 + true
1094 + } else {
1095 + false
1096 + }
1097 + }
1098 +
1099 + fn enter_ancestral(&mut self) -> bool {
1100 + use State::*;
1101 + if let Some(commit) = parse_merge_marker(&self.line, "++|||||||") {
1102 + self.state = MergeConflict(Ancestral);
1103 + self.painter.merge_conflict_commit_names[Ancestral] = Some(commit.to_string());
1104 + true
1105 + } else {
1106 + false
1107 + }
1108 + }
1109 +
1110 + fn enter_theirs(&mut self) -> bool {
1111 + use State::*;
1112 + if self.line.starts_with("++=======") {
1113 + self.state = MergeConflict(Theirs);
1114 + true
1115 + } else {
1116 + false
1117 + }
1118 + }
1119 +
1120 + fn exit_merge_conflict(&mut self, diff_type: DiffType) -> std::io::Result<bool> {
1121 + if let Some(commit) = parse_merge_marker(&self.line, "++>>>>>>>") {
1122 + self.painter.merge_conflict_commit_names[Theirs] = Some(commit.to_string());
1123 + self.paint_buffered_merge_conflict_lines(diff_type)?;
1124 + Ok(true)
1125 + } else {
1126 + Ok(false)
1127 + }
1128 + }
1129 +
1130 + fn store_line(&mut self, commit: MergeConflictCommit, state: State) -> bool {
1131 + use State::*;
1132 + if let HunkMinus(diff_type, _) | HunkZero(diff_type) | HunkPlus(diff_type, _) = &state {
1133 + let line = self.painter.prepare(&self.line, diff_type.n_parents());
1134 + self.painter.merge_conflict_lines[commit].push((line, state));
1135 + true
1136 + } else {
1137 + delta_unreachable(&format!("Invalid state: {:?}", state))
1138 + }
1139 + }
1140 +
1141 + fn paint_buffered_merge_conflict_lines(&mut self, diff_type: DiffType) -> std::io::Result<()> {
1142 ++>>>>>>> b2b28c8... Display merge conflict branches
1143 @@@ -138,9 -125,10 +292,25 @@@
1144 ++<<<<<<< HEAD
1145 +
1146 + write_merge_conflict_bar(
1147 + &self.config.merge_conflict_begin_symbol,
1148 + &mut self.painter,
1149 + self.config,
1150 + )?;
1151 + for derived_commit_type in &[Ours, Theirs] {
1152 + write_diff_header(derived_commit_type, &mut self.painter, self.config)?;
1153 + self.painter.emit()?;
1154 ++||||||| parent of b2b28c8... Display merge conflict branches
1155 ++ let lines = &self.painter.merge_conflict_lines;
1156 ++ for derived_lines in &[&lines[Ours], &lines[Theirs]] {
1157 ++=======
1158 +
1159 + write_merge_conflict_bar("▼", &mut self.painter, self.config)?;
1160 + for (derived_commit_type, decoration_style) in &[(Ours, "box"), (Theirs, "box")] {
1161 + write_subhunk_header(
1162 + derived_commit_type,
1163 + decoration_style,
1164 + &mut self.painter,
1165 + self.config,
1166 + )?;
1167 + self.painter.emit()?;
1168 ++>>>>>>> b2b28c8... Display merge conflict branches
1169 @@@ -159,6 -147,2 +329,12 @@@
1170 ++<<<<<<< HEAD
1171 + // write_merge_conflict_decoration("bold ol", &mut self.painter, self.config)?;
1172 + write_merge_conflict_bar(
1173 + &self.config.merge_conflict_end_symbol,
1174 + &mut self.painter,
1175 + self.config,
1176 + )?;
1177 ++||||||| parent of b2b28c8... Display merge conflict branches
1178 ++=======
1179 + // write_merge_conflict_decoration("bold ol", &mut self.painter, self.config)?;
1180 + write_merge_conflict_bar("▲", &mut self.painter, self.config)?;
1181 ++>>>>>>> b2b28c8... Display merge conflict branches
1182 @@@ -171,60 -155,80 +347,166 @@@
1183 ++<<<<<<< HEAD
1184 +fn write_diff_header(
1185 + derived_commit_type: &MergeConflictCommit,
1186 + painter: &mut paint::Painter,
1187 + config: &config::Config,
1188 +) -> std::io::Result<()> {
1189 + let (mut draw_fn, pad, decoration_ansi_term_style) =
1190 + draw::get_draw_function(config.merge_conflict_diff_header_style.decoration_style);
1191 + let derived_commit_name = &painter.merge_conflict_commit_names[derived_commit_type];
1192 + let text = if let Some(_ancestral_commit) = &painter.merge_conflict_commit_names[Ancestral] {
1193 + format!(
1194 + "ancestor {} {}{}",
1195 + config.right_arrow,
1196 + derived_commit_name.as_deref().unwrap_or("?"),
1197 + if pad { " " } else { "" }
1198 + )
1199 + } else {
1200 + derived_commit_name.as_deref().unwrap_or("?").to_string()
1201 + };
1202 + draw_fn(
1203 + painter.writer,
1204 + &text,
1205 + &text,
1206 + &config.decorations_width,
1207 + config.merge_conflict_diff_header_style,
1208 + decoration_ansi_term_style,
1209 + )?;
1210 + Ok(())
1211 +}
1212 +
1213 +fn write_merge_conflict_bar(
1214 + s: &str,
1215 + painter: &mut paint::Painter,
1216 + config: &config::Config,
1217 +) -> std::io::Result<()> {
1218 + if let cli::Width::Fixed(width) = config.decorations_width {
1219 + writeln!(
1220 + painter.writer,
1221 + "{}",
1222 + &s.graphemes(true).cycle().take(width).join("")
1223 + )?;
1224 + }
1225 + Ok(())
1226 +}
1227 +
1228 +fn parse_merge_marker<'a>(line: &'a str, marker: &str) -> Option<&'a str> {
1229 + match line.strip_prefix(marker) {
1230 + Some(suffix) => {
1231 + let suffix = suffix.trim();
1232 + if !suffix.is_empty() {
1233 + Some(suffix)
1234 + } else {
1235 + None
1236 + }
1237 + }
1238 + None => None,
1239 + }
1240 +}
1241 +
1242 +pub use MergeConflictCommit::*;
1243 +
1244 ++impl<T> Index<MergeConflictCommit> for MergeConflictCommits<T> {
1245 ++ type Output = T;
1246 ++ fn index(&self, commit: MergeConflictCommit) -> &Self::Output {
1247 ++ match commit {
1248 ++ Ours => &self.ours,
1249 ++ Ancestral => &self.ancestral,
1250 ++ Theirs => &self.theirs,
1251 ++ }
1252 ++ }
1253 ++}
1254 ++||||||| parent of b2b28c8... Display merge conflict branches
1255 ++pub use Source::*;
1256 ++=======
1257 + fn write_subhunk_header(
1258 + derived_commit_type: &MergeConflictCommit,
1259 + decoration_style: &str,
1260 + painter: &mut paint::Painter,
1261 + config: &config::Config,
1262 + ) -> std::io::Result<()> {
1263 + let (mut draw_fn, pad, decoration_ansi_term_style) =
1264 + draw::get_draw_function(DecorationStyle::from_str(
1265 + decoration_style,
1266 + config.true_color,
1267 + config.git_config.as_ref(),
1268 + ));
1269 + let derived_commit_name = &painter.merge_conflict_commit_names[derived_commit_type];
1270 + let text = if let Some(_ancestral_commit) = &painter.merge_conflict_commit_names[Ancestral] {
1271 + format!(
1272 + "ancestor {} {}{}",
1273 + config.right_arrow,
1274 + derived_commit_name.as_deref().unwrap_or("?"),
1275 + if pad { " " } else { "" }
1276 + )
1277 + } else {
1278 + derived_commit_name.as_deref().unwrap_or("?").to_string()
1279 + };
1280 + draw_fn(
1281 + painter.writer,
1282 + &text,
1283 + &text,
1284 + &config.decorations_width,
1285 + config.hunk_header_style,
1286 + decoration_ansi_term_style,
1287 + )?;
1288 + Ok(())
1289 + }
1290 ++>>>>>>> b2b28c8... Display merge conflict branches
1291 +
1292 ++<<<<<<< HEAD
1293 ++impl<T> Index<&MergeConflictCommit> for MergeConflictCommits<T> {
1294 ++ type Output = T;
1295 ++ fn index(&self, commit: &MergeConflictCommit) -> &Self::Output {
1296 ++ match commit {
1297 ++||||||| parent of b2b28c8... Display merge conflict branches
1298 ++impl Index<Source> for MergeConflictLines {
1299 ++ type Output = Vec<(String, State)>;
1300 ++ fn index(&self, source: Source) -> &Self::Output {
1301 ++ match source {
1302 ++=======
1303 + #[allow(unused)]
1304 + fn write_merge_conflict_line(
1305 + painter: &mut paint::Painter,
1306 + config: &config::Config,
1307 + ) -> std::io::Result<()> {
1308 + let (mut draw_fn, _pad, decoration_ansi_term_style) = draw::get_draw_function(
1309 + DecorationStyle::from_str("bold ol", config.true_color, config.git_config.as_ref()),
1310 + );
1311 + draw_fn(
1312 + painter.writer,
1313 + "",
1314 + "",
1315 + &config.decorations_width,
1316 + config.hunk_header_style,
1317 + decoration_ansi_term_style,
1318 + )?;
1319 + Ok(())
1320 + }
1321 +
1322 + fn write_merge_conflict_bar(
1323 + s: &str,
1324 + painter: &mut paint::Painter,
1325 + config: &config::Config,
1326 + ) -> std::io::Result<()> {
1327 + if let cli::Width::Fixed(width) = config.decorations_width {
1328 + writeln!(painter.writer, "{}", s.repeat(width))?;
1329 + }
1330 + Ok(())
1331 + }
1332 +
1333 + fn parse_merge_marker<'a>(line: &'a str, marker: &str) -> Option<&'a str> {
1334 + match line.strip_prefix(marker) {
1335 + Some(suffix) => {
1336 + let suffix = suffix.trim();
1337 + if !suffix.is_empty() {
1338 + Some(suffix)
1339 + } else {
1340 + None
1341 + }
1342 + }
1343 + None => None,
1344 + }
1345 + }
1346 +
1347 + pub use MergeConflictCommit::*;
1348 +
1349 @@@ -246,0 -250,0 +528,1 @@@ impl<T> Index<&MergeConflictCommit> fo
1350 ++>>>>>>> b2b28c8... Display merge conflict branches
1351 "#;
1352 }