OSDN Git Service

Add Compare and GNU diff at Change File list at sync dialog. Double click also support.
authorFrank Li <lznuaa@gmail.com>
Mon, 20 Jul 2009 16:21:47 +0000 (00:21 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 20 Jul 2009 16:22:25 +0000 (00:22 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/GitStatusListCtrl.cpp
src/Git/GitStatusListCtrl.h
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/SyncDlg.cpp

index bdd1131..7861509 100644 (file)
@@ -2321,10 +2321,12 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                        //      {\r
                                        //              if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing))\r
                                        //              {\r
-                                       if(!g_Git.IsInitRepos())\r
+                                       if(!g_Git.IsInitRepos() && (m_dwContextMenus&SVNSLC_POPGNUDIFF))\r
+                                       {\r
                                                popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
 \r
-                                       bEntryAdded = true;\r
+                                               bEntryAdded = true;\r
+                                       }\r
                                        //              }\r
                                        //      }\r
                                        //\r
@@ -2356,6 +2358,21 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                //}\r
                        }\r
                        \r
+                       if( (!this->m_Rev1.IsEmpty()) || (!this->m_Rev1.IsEmpty()) )\r
+                       {\r
+                               if(GetSelectedCount() == 1)\r
+                               {\r
+                                       if (m_dwContextMenus & this->GetContextMenuBit(IDSVNLC_COMPARETWO))\r
+                                       {       \r
+                                               popup.AppendMenuIcon(IDSVNLC_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);\r
+                                               popup.SetDefaultItem(IDSVNLC_COMPARETWO, FALSE);\r
+                                       }\r
+                                       if (m_dwContextMenus & this->GetContextMenuBit(IDSVNLC_GNUDIFF2))\r
+                                       {       \r
+                                               popup.AppendMenuIcon(IDSVNLC_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
+                                       }\r
+                               }\r
+                       }\r
        \r
                        ///Select Multi item\r
                        //if (GetSelectedCount() > 0)\r
@@ -2672,6 +2689,16 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                        }\r
                                }\r
                                break;\r
+                       case IDSVNLC_COMPARETWO:\r
+                               {\r
+                                       POSITION pos = GetFirstSelectedItemPosition();\r
+                                       while ( pos )\r
+                                       {\r
+                                               int index = GetNextSelectedItem(pos);\r
+                                               StartDiffTwo(index);\r
+                                       }\r
+                               }\r
+                               break;\r
                        case IDSVNLC_GNUDIFF1:\r
                                {\r
                                //      SVNDiff diff(NULL, this->m_hWnd, true);\r
@@ -2688,6 +2715,20 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                                                                                                        *filepath,m_CurrentVersion+_T("~1"));\r
                                }\r
                                break;\r
+                       case IDSVNLC_GNUDIFF2:\r
+                               {\r
+                               //      SVNDiff diff(NULL, this->m_hWnd, true);\r
+                               //\r
+                               //      if (entry->remotestatus <= git_wc_status_normal)\r
+                               //              CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_BASE, entry->path, SVNRev::REV_WC);\r
+                               //      else\r
+                               //              CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_WC, entry->path, SVNRev::REV_HEAD);\r
+                                       \r
+                                       CAppUtils::StartShowUnifiedDiff(m_hWnd,*filepath,m_Rev1,\r
+                                                                                                                       *filepath,m_Rev2);\r
+                               }\r
+                               break;\r
+                       \r
                        case IDSVNLC_ADD:\r
                                {       // The add went ok, but we now need to run through the selected items again\r
                                        // and update their status\r
@@ -4031,10 +4072,25 @@ void CGitStatusListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
 \r
        }else\r
        {\r
-               StartDiff(pNMLV->iItem);\r
+               if( (!m_Rev1.IsEmpty()) || (!m_Rev1.IsEmpty()))\r
+                       StartDiffTwo(pNMLV->iItem);\r
+               else\r
+                       StartDiff(pNMLV->iItem);\r
        }\r
 \r
 }\r
+void CGitStatusListCtrl::StartDiffTwo(int fileindex)\r
+{\r
+       if(fileindex<0)\r
+               return;\r
+\r
+       CTGitPath file1=*(CTGitPath*)GetItemData(fileindex);\r
+\r
+       CGitDiff::Diff(&file1,&file1,\r
+                               m_Rev1,\r
+                                       m_Rev2);\r
+\r
+}\r
 void CGitStatusListCtrl::StartDiffWC(int fileindex)\r
 {\r
        if(fileindex<0)\r
index e119499..130d7bf 100644 (file)
@@ -23,6 +23,7 @@
 #include "GitConfig.h"\r
 #include "Colors.h"\r
 #include "XPTheme.h"\r
+#include "CommonResource.h"\r
 \r
 #define SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN (-1)\r
 \r
@@ -199,6 +200,8 @@ public:
                IDSVNLC_REVERTTOREV             ,\r
                IDSVNLC_VIEWREV                 ,\r
                IDSVNLC_FINDENTRY       ,\r
+               IDSVNLC_COMPARETWO              ,\r
+               IDSVNLC_GNUDIFF2                ,\r
 // the IDSVNLC_MOVETOCS *must* be the last index, because it contains a dynamic submenu where \r
 // the submenu items get command ID's sequent to this number\r
                IDSVNLC_MOVETOCS                ,\r
@@ -234,6 +237,9 @@ public:
        CGitStatusListCtrl(void);\r
        ~CGitStatusListCtrl(void);\r
 \r
+       CString m_Rev1;\r
+       CString m_Rev2;\r
+\r
        /**\r
         * \ingroup TortoiseProc\r
         * Helper class for CGitStatusListCtrl which represents\r
@@ -781,6 +787,7 @@ private:
        bool BuildStatistics(); ///< build the statistics and correct the case of files/folders\r
        void StartDiff(int fileindex);  ///< start the external diff program\r
        void StartDiffWC(int fileindex);        ///< start the external diff program\r
+       void StartDiffTwo(int fileindex);\r
        \r
        enum\r
        {\r
index c95d38e..c0a76cd 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 63a4d60..7a04f71 100644 (file)
@@ -132,7 +132,9 @@ BOOL CSyncDlg::OnInitDialog()
        }\r
        m_ctrlTabCtrl.InsertTab(&m_OutChangeFileList,_T("Out ChangeList"),1);\r
 \r
-       m_OutChangeFileList.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("RebaseDlg"),(SVNSLC_POPALL ^ SVNSLC_POPCOMMIT),false);\r
+       m_OutChangeFileList.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("OutSyncDlg"),\r
+                                   (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMPARETWO)|\r
+                                                       CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_GNUDIFF2)),false);\r
 \r
        this->m_tooltips.Create(this);\r
 \r
@@ -266,6 +268,8 @@ void CSyncDlg::FetchOutList()
                                str.Format(_T("%d commits ahead \"%s\""),m_OutLogList.GetItemCount(),remotebranch);\r
                                this->m_ctrlStatus.SetWindowText(str);\r
                                g_Git.GetCommitDiffList(localbranch,remotebranch,m_arOutChangeList);\r
+                               m_OutChangeFileList.m_Rev1=localbranch;\r
+                               m_OutChangeFileList.m_Rev2=remotebranch;\r
                                m_OutChangeFileList.Show(0,this->m_arOutChangeList);\r
                                m_OutChangeFileList.SetEmptyString(CString(_T("No changed file")));\r
                                this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE);\r