| 360 | } |
| 361 | |
| 362 | bool CDiffData::DoTwoWayDiff(const CString& sBaseFilename, const CString& sYourFilename, IgnoreWS ignoreWs, bool bIgnoreEOL, bool bIgnoreCase, bool bIgnoreComments, apr_pool_t* pool) |
| 363 | { |
| 364 | svn_diff_file_options_t* options = CreateDiffFileOptions(ignoreWs, bIgnoreEOL, pool); |
| 365 | // convert CString filenames (UTF-16 or ANSI) to UTF-8 |
| 366 | CStringA sBaseFilenameUtf8 = CUnicodeUtils::GetUTF8(sBaseFilename); |
| 367 | CStringA sYourFilenameUtf8 = CUnicodeUtils::GetUTF8(sYourFilename); |
| 368 | |
| 369 | svn_diff_t* diffYourBase = nullptr; |
| 370 | svn_error_t * svnerr = svn_diff_file_diff_2(&diffYourBase, sBaseFilenameUtf8, sYourFilenameUtf8, options, pool); |
| 371 | |
| 372 | if (svnerr) |
| 373 | return HandleSvnError(svnerr); |
| 374 | |
| 375 | tsvn_svn_diff_t_extension* movedBlocks = nullptr; |
| 376 | if(m_bViewMovedBlocks) |
| 377 | movedBlocks = MovedBlocksDetect(diffYourBase, ignoreWs, pool); // Side effect is that diffs are now splitted |
| 378 | |
| 379 | svn_diff_t * tempdiff = diffYourBase; |
| 380 | LONG baseline = 0; |
| 381 | LONG yourline = 0; |
| 382 | while (tempdiff) |
| 383 | { |
| 384 | svn_diff__type_e diffType = tempdiff->type; |
| 385 | // Side effect described above overcoming - sticking together |
| 386 | apr_off_t original_length_sticked = tempdiff->original_length; |
| 387 | apr_off_t modified_length_sticked = tempdiff->modified_length; |
| 388 | StickAndSkip(tempdiff, original_length_sticked, modified_length_sticked); |
| 389 | |
| 390 | for (int i=0; i<original_length_sticked; i++) |
| 391 | { |
| 392 | if (baseline >= m_arBaseFile.GetCount()) |
| 393 | { |
| 394 | m_sError.LoadString(IDS_ERR_DIFF_NEWLINES); |
| 395 | return false; |
| 396 | } |
| 397 | const CString& sCurrentBaseLine = m_arBaseFile.GetAt(baseline); |
| 398 | EOL endingBase = m_arBaseFile.GetLineEnding(baseline); |
| 399 | if (diffType == svn_diff__type_common) |
| 400 | { |
| 401 | if (yourline >= m_arYourFile.GetCount()) |
| 402 | { |
| 403 | m_sError.LoadString(IDS_ERR_DIFF_NEWLINES); |
| 404 | return false; |
| 405 | } |
| 406 | const CString& sCurrentYourLine = m_arYourFile.GetAt(yourline); |
| 407 | EOL endingYours = m_arYourFile.GetLineEnding(yourline); |
| 408 | if (sCurrentBaseLine != sCurrentYourLine) |
| 409 | { |
| 410 | bool changedWS = false; |
| 411 | if (ignoreWs == IgnoreWS::WhiteSpaces) |
| 412 | changedWS = CompareWithIgnoreWS(sCurrentBaseLine, sCurrentYourLine, ignoreWs); |
| 413 | if (changedWS || ignoreWs == IgnoreWS::None) |
| 414 | { |
| 415 | // one-pane view: two lines, one 'removed' and one 'added' |
| 416 | m_YourBaseBoth.AddData(sCurrentBaseLine, DiffState::RemovedWhitespace, yourline, endingBase, changedWS && ignoreWs != IgnoreWS::None ? HideState::Hidden : HideState::Shown, -1); |
| 417 | m_YourBaseBoth.AddData(sCurrentYourLine, DiffState::AddedWhitespace, yourline, endingYours, changedWS && ignoreWs != IgnoreWS::None ? HideState::Hidden : HideState::Shown, -1); |
| 418 | } |
| 419 | else |
nothing calls this directly
no test coverage detected