OSDN Git Service

Add Diff with work copy and file list
authorFrank Li <lznuaa@gmail.com>
Sun, 8 Mar 2009 13:29:32 +0000 (21:29 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 9 Mar 2009 13:23:48 +0000 (21:23 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/GitStatusListCtrl.cpp
src/Git/GitStatusListCtrl.h

index 50dc24f..ce9ee8d 100644 (file)
@@ -2305,7 +2305,8 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
 \r
                                if (m_dwContextMenus & this->GetContextMenuBit(IDSVNLC_COMPAREWC))\r
                                {\r
-                                       popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF);\r
+                                       if( (!m_CurrentVersion.IsEmpty()) && m_CurrentVersion != GIT_REV_ZERO)\r
+                                               popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF);\r
                                }\r
                                //Select one items\r
                                if (GetSelectedCount() == 1)\r
@@ -2677,6 +2678,19 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                        ShellExecute(this->m_hWnd, _T("explore"), filepath->GetDirectory().GetWinPath(), NULL, NULL, SW_SHOW);\r
                                }\r
                                break;\r
+\r
+                       // Compare current version and work copy. \r
+                       case IDSVNLC_COMPAREWC:\r
+                               {\r
+                                       POSITION pos = GetFirstSelectedItemPosition();\r
+                                       while ( pos )\r
+                                       {\r
+                                               int index = GetNextSelectedItem(pos);\r
+                                               StartDiffWC(index);\r
+                                       }\r
+                               }\r
+                               break;\r
+                       // Compare with base version. when current version is zero, compare workcopy and HEAD. \r
                        case IDSVNLC_COMPARE:\r
                                {\r
                                        POSITION pos = GetFirstSelectedItemPosition();\r
@@ -3970,6 +3984,22 @@ void CGitStatusListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
        }\r
 \r
 }\r
+void CGitStatusListCtrl::StartDiffWC(int fileindex)\r
+{\r
+       if(fileindex<0)\r
+               return;\r
+\r
+       CString Ver;\r
+       if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion== GIT_REV_ZERO)\r
+               return;\r
+\r
+       CTGitPath file1=*(CTGitPath*)GetItemData(fileindex);\r
+\r
+       CGitDiff::Diff(&file1,&file1,\r
+                               CString(GIT_REV_ZERO),\r
+                                       m_CurrentVersion);\r
+\r
+}\r
 \r
 void CGitStatusListCtrl::StartDiff(int fileindex)\r
 {\r
index 8a2bdd8..04856f3 100644 (file)
@@ -780,6 +780,7 @@ private:
        void RemoveListEntry(int index);        ///< removes an entry from the listcontrol and both arrays\r
        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
 \r
     /// fetch all user properties for all items\r
     void FetchUserProperties();\r