From d8a795e8b2b77cb27046a5f7dc575508da65f0ba Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 19 Apr 2010 20:45:19 +0800 Subject: [PATCH] Fix issue review patch fail when there are new FilePatchesDlg.cpp /dev/null can't open Signed-off-by: Frank Li --- src/TortoiseMerge/FilePatchesDlg.cpp | 39 ++++++++++++++++++++++++++++++- src/TortoiseMerge/FilePatchesDlg.h | 3 +++ src/TortoiseMerge/FileTextLines.h | 4 +++- src/TortoiseMerge/Patch.cpp | 6 +++++ src/TortoiseMerge/libsvn_diff/diff_file.c | 9 ++++++- src/TortoiseMerge/libsvn_diff/io.c | 6 ++++- 6 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/TortoiseMerge/FilePatchesDlg.cpp b/src/TortoiseMerge/FilePatchesDlg.cpp index d2322a8eb..129257abc 100644 --- a/src/TortoiseMerge/FilePatchesDlg.cpp +++ b/src/TortoiseMerge/FilePatchesDlg.cpp @@ -62,6 +62,9 @@ CString CFilePatchesDlg::GetFullPath(int nIndex) CString temp = m_pPatch->GetFilename(nIndex); temp.Replace('/', '\\'); //temp = temp.Mid(temp.Find('\\')+1); + if(temp == _T("NUL")) + return temp; + if (PathIsRelative(temp)) temp = m_sPath + temp; return temp; @@ -114,14 +117,32 @@ BOOL CFilePatchesDlg::Init(CPatch * pPatch, CPatchFilesDlgCallBack * pCallBack, for(int i=0; iGetNumberOfFiles(); i++) { - CString sFile = CPathUtils::GetFileNameFromPath(m_pPatch->GetFilename(i)); + CString sFile = CPathUtils::GetFileNameFromPath(m_pPatch->GetFilename2(i)); + if(sFile == _T("NUL")) + sFile = CPathUtils::GetFileNameFromPath(m_pPatch->GetFilename(i)); + DWORD state; if (m_sPath.IsEmpty()) state = FPDLG_FILESTATE_GOOD; else { + if(m_pPatch->GetFilename(i) != m_pPatch->GetFilename2(i)) + { + if( m_pPatch->GetFilename(i) == _T("NUL")) + state = FPDLG_FILESTATE_NEW; + else if (m_pPatch->GetFilename2(i) == _T("NUL")) + state = FPDLG_FILESTATE_DELETE; + else + state = FPDLG_FILESTATE_RENAME; + } + if (m_pPatch->PatchFile(GetFullPath(i))) + { + if(state != FPDLG_FILESTATE_NEW && + state != FPDLG_FILESTATE_RENAME && + state != FPDLG_FILESTATE_DELETE) state = FPDLG_FILESTATE_GOOD; + } else state = FPDLG_FILESTATE_CONFLICTED; } @@ -258,6 +279,22 @@ void CFilePatchesDlg::OnNMCustomdrawFilelist(NMHDR *pNMHDR, LRESULT *pResult) { crText = RGB(200, 0, 0); } + + if (m_arFileStates.GetAt(pLVCD->nmcd.dwItemSpec)==FPDLG_FILESTATE_DELETE) + { + crText = RGB(200, 0, 0); + } + + if (m_arFileStates.GetAt(pLVCD->nmcd.dwItemSpec)==FPDLG_FILESTATE_RENAME) + { + crText = RGB(0, 200, 200); + } + + if (m_arFileStates.GetAt(pLVCD->nmcd.dwItemSpec)==FPDLG_FILESTATE_NEW) + { + crText = RGB(0, 0, 200); + } + if (m_arFileStates.GetAt(pLVCD->nmcd.dwItemSpec)==FPDLG_FILESTATE_PATCHED) { crText = ::GetSysColor(COLOR_GRAYTEXT); diff --git a/src/TortoiseMerge/FilePatchesDlg.h b/src/TortoiseMerge/FilePatchesDlg.h index 18238cbc9..3746caccb 100644 --- a/src/TortoiseMerge/FilePatchesDlg.h +++ b/src/TortoiseMerge/FilePatchesDlg.h @@ -54,6 +54,9 @@ public: #define FPDLG_FILESTATE_GOOD 0x0000 #define FPDLG_FILESTATE_CONFLICTED 0x0001 #define FPDLG_FILESTATE_PATCHED 0x0002 +#define FPDLG_FILESTATE_NEW 0x0003 +#define FPDLG_FILESTATE_DELETE 0x0004 +#define FPDLG_FILESTATE_RENAME 0x0005 #define ID_PATCHALL 1 #define ID_PATCHSELECTED 2 diff --git a/src/TortoiseMerge/FileTextLines.h b/src/TortoiseMerge/FileTextLines.h index 06cf279bb..a64a1cc60 100644 --- a/src/TortoiseMerge/FileTextLines.h +++ b/src/TortoiseMerge/FileTextLines.h @@ -96,6 +96,8 @@ public: void SetLineEnding(int index, EOL ending) {m_endings[index] = ending;} void RemoveAll() {CStdCStringArray::RemoveAll(); m_endings.clear();} + + CFileTextLines::UnicodeType CheckUnicodeType(LPVOID pBuffer, int cb); private: /** * Checks the line endings in a text buffer @@ -108,7 +110,7 @@ private: * \param pBuffer pointer to the buffer containing text * \param cd size of the text buffer in bytes */ - CFileTextLines::UnicodeType CheckUnicodeType(LPVOID pBuffer, int cb); + void SetErrorString(); diff --git a/src/TortoiseMerge/Patch.cpp b/src/TortoiseMerge/Patch.cpp index 0f696e5c3..ca564162b 100644 --- a/src/TortoiseMerge/Patch.cpp +++ b/src/TortoiseMerge/Patch.cpp @@ -145,6 +145,9 @@ BOOL CPatch::ParserGitPatch(CFileTextLines &PatchLines,int nIndex) chunks->sFilePath=chunks->sFilePath.Mid(2); chunks->sFilePath.Replace(_T('/'),_T('\\')); + + if(chunks->sFilePath == _T("\\dev\\null")) + chunks->sFilePath = _T("NUL"); } // +++ @@ -171,6 +174,9 @@ BOOL CPatch::ParserGitPatch(CFileTextLines &PatchLines,int nIndex) chunks->sFilePath2=chunks->sFilePath2.Mid(2); chunks->sFilePath2.Replace(_T('/'),_T('\\')); + + if(chunks->sFilePath2 == _T("\\dev\\null")) + chunks->sFilePath2 = _T("NUL"); } //@@ -xxx,xxx +xxx,xxx @@ diff --git a/src/TortoiseMerge/libsvn_diff/diff_file.c b/src/TortoiseMerge/libsvn_diff/diff_file.c index 8d0970376..0b7106d4c 100644 --- a/src/TortoiseMerge/libsvn_diff/diff_file.c +++ b/src/TortoiseMerge/libsvn_diff/diff_file.c @@ -228,8 +228,15 @@ datasource_open(void *baton, svn_diff_datasource_e datasource) SVN_ERR(svn_io_file_open(&file_baton->file[idx], file_baton->path[idx], APR_READ, APR_OS_DEFAULT, file_baton->pool)); - SVN_ERR(svn_io_file_info_get(&finfo, APR_FINFO_SIZE, + if( strcmp(file_baton->path[idx], "NUL") == 0) + { + memset(&finfo, 0, sizeof(apr_finfo_t)); + + }else + { + SVN_ERR(svn_io_file_info_get(&finfo, APR_FINFO_SIZE, file_baton->file[idx], file_baton->pool)); + } file_baton->size[idx] = finfo.size; length = finfo.size > CHUNK_SIZE ? CHUNK_SIZE : finfo.size; diff --git a/src/TortoiseMerge/libsvn_diff/io.c b/src/TortoiseMerge/libsvn_diff/io.c index 2fb3936fc..c98632f15 100644 --- a/src/TortoiseMerge/libsvn_diff/io.c +++ b/src/TortoiseMerge/libsvn_diff/io.c @@ -2663,7 +2663,11 @@ svn_io_file_open(apr_file_t **new_file, const char *fname, apr_status_t status; SVN_ERR(cstring_from_utf8(&fname_apr, fname, pool)); - status = file_open(new_file, fname_apr, flag | APR_BINARY, perm, TRUE, + if( strcmp(fname, "NUL") == 0) + status = file_open(new_file, fname_apr, flag | APR_BINARY |APR_FILE_NOCLEANUP, perm, TRUE, + pool); + else + status = file_open(new_file, fname_apr, flag | APR_BINARY, perm, TRUE, pool); if (status) -- 2.11.4.GIT