MCPcopy Create free account
hub / github.com/KDE/kdiff3 / buildFromDiff3

Method buildFromDiff3

src/MergeEditLine.cpp:197–245  ·  view source on GitHub ↗

Build a new MergeBlockList from scratch using a Diff3LineList. */

Source from the content-addressed store, hash-verified

195 Build a new MergeBlockList from scratch using a Diff3LineList.
196*/
197void MergeBlockList::buildFromDiff3(const Diff3LineList &diff3List, bool isThreeway)
198{
199 LineType lineIdx = 0;
200 for(auto it = diff3List.cbegin(); it != diff3List.cend(); ++it)
201 {
202 const Diff3Line &d = *it;
203 MergeBlock mb;
204 bool bLineRemoved;
205
206 mb.mergeOneLine(d, bLineRemoved, !isThreeway);
207 mb.dectectWhiteSpaceConflict(d, isThreeway);
208
209 mb.d3lLineIdx = lineIdx;
210 mb.bDelta = mb.srcSelect != e_SrcSelector::A;
211 mb.mId3l = it;
212 mb.srcRangeLength = 1;
213
214 MergeBlock *lBack = empty() ? nullptr : &back();
215
216 bool bSame = lBack != nullptr && mb.isSameKind(*lBack);
217 if(bSame)
218 {
219 ++lBack->srcRangeLength;
220 if(lBack->isWhiteSpaceConflict() && !mb.isWhiteSpaceConflict())
221 lBack->bWhiteSpaceConflict = false;
222 }
223 else
224 {
225 push_back(mb);
226 }
227
228 if(!mb.isConflict())
229 {
230 MergeBlock &tmpBack = back();
231 MergeEditLine mel(mb.id3l());
232 mel.setSource(mb.srcSelect, bLineRemoved);
233 tmpBack.list().push_back(mel);
234 }
235 else if(lBack == nullptr || !lBack->isConflict() || !bSame)
236 {
237 MergeBlock &tmpBack = back();
238 MergeEditLine mel(mb.id3l());
239 mel.setConflict();
240 tmpBack.list().push_back(mel);
241 }
242
243 ++lineIdx;
244 }
245}
246/*
247 Changes default merge settings currently used when not in auto mode or if white space is being auto solved.
248*/

Callers 1

mergeMethod · 0.80

Calls 9

mergeOneLineMethod · 0.80
isSameKindMethod · 0.80
isWhiteSpaceConflictMethod · 0.80
setSourceMethod · 0.80
push_backMethod · 0.80
setConflictMethod · 0.80
isConflictMethod · 0.45
id3lMethod · 0.45

Tested by

no test coverage detected