MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / PatchFile

Method PatchFile

src/TortoiseMerge/MainFrm.cpp:552–640  ·  view source on GitHub ↗

Callback function

Source from the content-addressed store, hash-verified

550
551// Callback function
552BOOL CMainFrame::PatchFile(CString sFilePath, bool /*bContentMods*/, bool bPropMods, const CString& /* sVersion */, BOOL bAutoPatch)
553{
554 //"dry run" was successful, so save the patched file somewhere...
555 CString sTempFile = CTempFiles::Instance().GetTempFilePathString();
556 CString sRejectedFile, sBasePath;
557 if (m_Patch.GetPatchResult(sFilePath, sTempFile, sRejectedFile, sBasePath) < 0)
558 {
559 MessageBox(m_Patch.GetErrorMessage(), nullptr, MB_ICONERROR);
560 return FALSE;
561 }
562 sFilePath = m_Patch.GetTargetPath() + L'\\' + sFilePath;
563 sFilePath.Replace('/', '\\');
564 if (sBasePath.IsEmpty())
565 sBasePath = sFilePath;
566 if (m_bReversedPatch)
567 {
568 m_Data.m_baseFile.SetFileName(sTempFile);
569 CString temp;
570 temp.Format(L"%s %s", static_cast<LPCWSTR>(CPathUtils::GetFileNameFromPath(sFilePath)), static_cast<LPCWSTR>(m_Data.m_sPatchPatched));
571 m_Data.m_baseFile.SetDescriptiveName(temp);
572 m_Data.m_yourFile.SetFileName(sFilePath);
573 temp.Format(L"%s %s", static_cast<LPCWSTR>(CPathUtils::GetFileNameFromPath(sFilePath)), static_cast<LPCWSTR>(m_Data.m_sPatchOriginal));
574 m_Data.m_yourFile.SetDescriptiveName(temp);
575 m_Data.m_theirFile.SetOutOfUse();
576 m_Data.m_mergedFile.SetOutOfUse();
577 }
578 else
579 {
580 if ((!PathFileExists(sBasePath))||(PathIsDirectory(sBasePath)))
581 {
582 m_Data.m_baseFile.SetFileName(CTempFiles::Instance().GetTempFilePathString());
583 m_Data.m_baseFile.CreateEmptyFile();
584 }
585 else
586 {
587 m_Data.m_baseFile.SetFileName(sBasePath);
588 }
589 CString sDescription;
590 sDescription.Format(L"%s %s", static_cast<LPCWSTR>(CPathUtils::GetFileNameFromPath(sBasePath)), static_cast<LPCWSTR>(m_Data.m_sPatchOriginal));
591 m_Data.m_baseFile.SetDescriptiveName(sDescription);
592 if (sBasePath == sFilePath)
593 {
594 m_Data.m_yourFile.SetFileName(sTempFile);
595 CString temp;
596 temp.Format(L"%s %s", static_cast<LPCWSTR>(CPathUtils::GetFileNameFromPath(sBasePath)), static_cast<LPCWSTR>(m_Data.m_sPatchPatched));
597 m_Data.m_yourFile.SetDescriptiveName(temp);
598 m_Data.m_theirFile.SetOutOfUse();
599 }
600 else
601 {
602 if (!PathFileExists(sFilePath) || PathIsDirectory(sFilePath))
603 {
604 m_Data.m_yourFile.SetFileName(CTempFiles::Instance().GetTempFilePathString());
605 m_Data.m_yourFile.CreateEmptyFile();
606 CString temp;
607 temp.Format(L"%s %s", static_cast<LPCWSTR>(CPathUtils::GetFileNameFromPath(sFilePath)), static_cast<LPCWSTR>(CString(MAKEINTRESOURCE(IDS_NOTFOUNDVIEWTITLEINDICATOR))));
608 m_Data.m_yourFile.SetDescriptiveName(temp);
609 }

Callers

nothing calls this directly

Calls 12

CStringClass · 0.85
TRACEFunction · 0.85
GetTempFilePathStringMethod · 0.80
GetPatchResultMethod · 0.80
GetTargetPathMethod · 0.80
ReplaceMethod · 0.80
SetFileNameMethod · 0.80
SetDescriptiveNameMethod · 0.80
SetOutOfUseMethod · 0.80
CreateEmptyFileMethod · 0.80
GetErrorMessageMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected