OSDN Git Service

TortoiseMerge Support Review patch created by git format patch
authorFrank Li <lznuaa@gmail.com>
Thu, 23 Apr 2009 04:44:09 +0000 (12:44 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 23 Apr 2009 04:44:09 +0000 (12:44 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseMergeENG.rc
src/TortoiseMerge/FilePatchesDlg.cpp
src/TortoiseMerge/FilePatchesDlg.h
src/TortoiseMerge/MainFrm.cpp
src/TortoiseMerge/MainFrm.h
src/TortoiseMerge/Patch.h
src/TortoiseMerge/resource.h

index 1332dd5..d16e20a 100644 (file)
Binary files a/src/Resources/TortoiseMergeENG.rc and b/src/Resources/TortoiseMergeENG.rc differ
index 0c9c245..d2322a8 100644 (file)
@@ -225,7 +225,7 @@ void CFilePatchesDlg::OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult)
        {\r
                if (m_arFileStates.GetAt(pNMLV->iItem)!=FPDLG_FILESTATE_PATCHED)\r
                {\r
-                       m_pCallBack->PatchFile(GetFullPath(pNMLV->iItem), m_pPatch->GetRevision(pNMLV->iItem));\r
+                       m_pCallBack->PatchFile(GetFullPath(pNMLV->iItem), m_pPatch->GetRevision(pNMLV->iItem),false,true);\r
                }\r
        }\r
 }\r
@@ -287,9 +287,13 @@ void CFilePatchesDlg::OnNMRclickFilelist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
                UINT nFlags;\r
                \r
                nFlags = MF_STRING | (m_cFileList.GetSelectedCount()==1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED);\r
+\r
+               temp.LoadString(IDS_PATCH_REVIEW);\r
+               popup.AppendMenu(nFlags, ID_PATCH_REVIEW, temp);\r
+               popup.SetDefaultItem(ID_PATCH_REVIEW, FALSE);\r
+\r
                temp.LoadString(IDS_PATCH_PREVIEW);\r
-               popup.AppendMenu(nFlags, ID_PATCHPREVIEW, temp);\r
-               popup.SetDefaultItem(ID_PATCHPREVIEW, FALSE);\r
+               popup.AppendMenu(nFlags, ID_PATCHPREVIEW, temp);                \r
 \r
                temp.LoadString(IDS_PATCH_ALL);\r
                popup.AppendMenu(MF_STRING | MF_ENABLED, ID_PATCHALL, temp);\r
@@ -307,9 +311,14 @@ void CFilePatchesDlg::OnNMRclickFilelist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
                        point = rect.CenterPoint();\r
                }\r
 \r
+               bool bReview=false;\r
+\r
                int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
                switch (cmd)\r
                {\r
+               case ID_PATCH_REVIEW:\r
+                       bReview = true;\r
+                       //go through case\r
                case ID_PATCHPREVIEW:\r
                        {\r
                                if (m_pCallBack)\r
@@ -317,7 +326,7 @@ void CFilePatchesDlg::OnNMRclickFilelist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
                                        int nIndex = m_cFileList.GetSelectionMark();\r
                                        if ( m_arFileStates.GetAt(nIndex)!=FPDLG_FILESTATE_PATCHED)\r
                                        {\r
-                                               m_pCallBack->PatchFile(GetFullPath(nIndex), m_pPatch->GetRevision(nIndex));\r
+                                               m_pCallBack->PatchFile(GetFullPath(nIndex), m_pPatch->GetRevision(nIndex),false,bReview);\r
                                        }\r
                                }\r
                        }\r
index 6d1ce02..18238cb 100644 (file)
@@ -36,7 +36,7 @@ public:
         * \param sVersion the revision number of the file to patch\r
         * \return TRUE if patching was successful\r
         */\r
-       virtual BOOL PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch = FALSE) = 0;\r
+       virtual BOOL PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch = FALSE,BOOL bIsReview=FALSE) = 0;\r
        \r
        /**\r
         * Callback function. Called when the user double clicks on a\r
@@ -58,6 +58,7 @@ public:
 #define ID_PATCHALL                                    1\r
 #define ID_PATCHSELECTED                       2\r
 #define ID_PATCHPREVIEW                                3\r
+#define ID_PATCH_REVIEW                                4\r
 /**\r
  * \ingroup TortoiseMerge\r
  *\r
index 0f95fb2..a82c300 100644 (file)
@@ -381,7 +381,7 @@ BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContex
 }\r
 \r
 // Callback function\r
-BOOL CMainFrame::PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch)\r
+BOOL CMainFrame::PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch,BOOL bIsReview)\r
 {\r
        //first, do a "dry run" of patching...\r
        if (!m_Patch.PatchFile(sFilePath))\r
@@ -399,7 +399,10 @@ BOOL CMainFrame::PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch)
                progDlg.SetShowProgressBar(false);\r
                progDlg.SetAnimation(IDR_DOWNLOAD);\r
                progDlg.SetTime(FALSE);\r
-               progDlg.ShowModeless(this);\r
+\r
+               if(!m_Patch.m_IsGitPatch)\r
+                       progDlg.ShowModeless(this);\r
+\r
                CString sBaseFile = m_TempFiles.GetTempFilePath();\r
                if (!CAppUtils::GetVersionedFile(sFilePath, sVersion, sBaseFile, &progDlg, m_hWnd))\r
                {\r
@@ -416,18 +419,36 @@ BOOL CMainFrame::PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch)
                        MessageBox(m_Patch.GetErrorMessage(), NULL, MB_ICONERROR);\r
                        return FALSE;\r
                }\r
+               \r
                CString temp;\r
-               temp.Format(_T("%s Revision %s"), (LPCTSTR)CPathUtils::GetFileNameFromPath(sFilePath), (LPCTSTR)sVersion);\r
-               m_Data.m_baseFile.SetFileName(sBaseFile);\r
-               m_Data.m_baseFile.SetDescriptiveName(temp);\r
-               temp.Format(_T("%s %s"), (LPCTSTR)CPathUtils::GetFileNameFromPath(sFilePath), (LPCTSTR)m_Data.m_sPatchPatched);\r
-               m_Data.m_theirFile.SetFileName(sTempFile);\r
-               m_Data.m_theirFile.SetDescriptiveName(temp);\r
-               m_Data.m_yourFile.SetFileName(sFilePath);\r
-               m_Data.m_yourFile.SetDescriptiveName(CPathUtils::GetFileNameFromPath(sFilePath));\r
-               m_Data.m_mergedFile.SetFileName(sFilePath);\r
-               m_Data.m_mergedFile.SetDescriptiveName(CPathUtils::GetFileNameFromPath(sFilePath));\r
+               if(bIsReview)\r
+               {\r
+                       \r
+                       temp.Format(_T("%s Revision %s"), (LPCTSTR)CPathUtils::GetFileNameFromPath(sFilePath), (LPCTSTR)sVersion);\r
+                       m_Data.m_baseFile.SetFileName(sBaseFile);\r
+                       m_Data.m_baseFile.SetDescriptiveName(temp);\r
+                       temp.Format(_T("%s %s"), (LPCTSTR)CPathUtils::GetFileNameFromPath(sFilePath), (LPCTSTR)m_Data.m_sPatchPatched);\r
+                       m_Data.m_yourFile.SetFileName(sTempFile);\r
+                       m_Data.m_yourFile.SetDescriptiveName(temp);\r
+                       m_Data.m_theirFile.SetOutOfUse();\r
+                       m_Data.m_mergedFile.SetOutOfUse();\r
+               \r
+               }else\r
+               {\r
+                       temp.Format(_T("%s Revision %s"), (LPCTSTR)CPathUtils::GetFileNameFromPath(sFilePath), (LPCTSTR)sVersion);\r
+                       m_Data.m_baseFile.SetFileName(sBaseFile);\r
+                       m_Data.m_baseFile.SetDescriptiveName(temp);\r
+                       temp.Format(_T("%s %s"), (LPCTSTR)CPathUtils::GetFileNameFromPath(sFilePath), (LPCTSTR)m_Data.m_sPatchPatched);\r
+                       m_Data.m_theirFile.SetFileName(sTempFile);\r
+                       m_Data.m_theirFile.SetDescriptiveName(temp);\r
+                       m_Data.m_yourFile.SetFileName(sFilePath);\r
+                       m_Data.m_yourFile.SetDescriptiveName(CPathUtils::GetFileNameFromPath(sFilePath));\r
+                       m_Data.m_mergedFile.SetFileName(sFilePath);\r
+                       m_Data.m_mergedFile.SetDescriptiveName(CPathUtils::GetFileNameFromPath(sFilePath));\r
+               }\r
                TRACE(_T("comparing %s and %s\nagainst the base file %s\n"), (LPCTSTR)sTempFile, (LPCTSTR)sFilePath, (LPCTSTR)sBaseFile);\r
+\r
+       \r
        }\r
        else\r
        {\r
index c6ae01e..9e846ea 100644 (file)
@@ -119,7 +119,7 @@ protected:
        DECLARE_MESSAGE_MAP()\r
 protected:\r
        void                    UpdateLayout();\r
-       virtual BOOL    PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch);\r
+       virtual BOOL    PatchFile(CString sFilePath, CString sVersion, BOOL bAutoPatch,BOOL bIsReview);\r
        virtual BOOL    DiffFiles(CString sURL1, CString sRev1, CString sURL2, CString sRev2);\r
        int                             CheckResolved();\r
        BOOL                    MarkAsResolved();\r
index 366b83a..91f4101 100644 (file)
@@ -97,5 +97,6 @@ protected:
         * stripped by 4 prefixes is interpreted as "dir/file.txt"\r
         */\r
        int                                                     m_nStrip;\r
+public:\r
        bool                                            m_IsGitPatch;\r
 };\r
index cf5b6ec..59ecc96 100644 (file)
Binary files a/src/TortoiseMerge/resource.h and b/src/TortoiseMerge/resource.h differ