OSDN Git Service

RebaseDlg: Implement Pick squash and edit by context menu
authorFrank Li <lznuaa@gmail.com>
Sat, 14 Feb 2009 15:03:31 +0000 (23:03 +0800)
committerFrank Li <lznuaa@gmail.com>
Sat, 14 Feb 2009 15:03:31 +0000 (23:03 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/TGitPath.cpp
src/Git/TGitPath.h
src/TortoiseProc/GitLogList.h
src/TortoiseProc/GitLogListAction.cpp
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/RebaseDlg.cpp
src/TortoiseProc/RebaseDlg.h

index b86b56b..c3a5444 100644 (file)
@@ -1880,6 +1880,12 @@ CString CTGitPath::GetActionName()
                return _T("Rename");\r
        if(m_Action  & CTGitPath::LOGACTIONS_COPY)\r
                return _T("Copy");\r
+       if(m_Action & CTGitPath::LOGACTIONS_REBASE_EDIT)\r
+               return _T("Edit");\r
+       if(m_Action & CTGitPath::LOGACTIONS_REBASE_SQUASH)\r
+               return _T("Squash");\r
+       if(m_Action & CTGitPath::LOGACTIONS_REBASE_PICK)\r
+               return _T("Pick");\r
 \r
        return _T("Unknown");\r
 }\r
index 0e16fe2..32fe7dd 100644 (file)
@@ -25,6 +25,15 @@ public:
                // For log filter only\r
                LOGACTIONS_HIDE         = 0x20000000,\r
                LOGACTIONS_GRAY         = 0x10000000,\r
+\r
+               // For Rebase only\r
+               LOGACTIONS_REBASE_CURRENT = 0x08000000,\r
+               LOGACTIONS_REBASE_PICK    = 0x04000000,\r
+               LOGACTIONS_REBASE_SQUASH  = 0x02000000,\r
+               LOGACTIONS_REBASE_EDIT    = 0x01000000,\r
+               LOGACTIONS_REBASE_MASK    = 0x0F000000,\r
+               LOGACTIONS_REBASE_MODE_MASK=0x07000000,\r
+\r
        };\r
 \r
        CString m_StatAdd;\r
index cf35607..213363f 100644 (file)
@@ -6,6 +6,10 @@ class CGitLogListBase;
 class CGitLogList : public CGitLogListBase\r
 {\r
        DECLARE_DYNAMIC(CGitLogList)\r
+protected:\r
+       \r
+       void SetSelectedAction(int action);\r
+\r
 public:\r
        void ContextMenuAction(int cmd,int FirstSelect, int LastSelect);\r
 };
\ No newline at end of file
index 34833c5..fea068f 100644 (file)
@@ -59,7 +59,6 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
 \r
        theApp.DoWaitCursor(1);\r
        bool bOpenWith = false;\r
-\r
        switch (cmd)\r
                {\r
                        case ID_GNUDIFF1:\r
@@ -177,6 +176,15 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
                        ReloadHashMap();\r
                        Invalidate();\r
                        break;\r
+               case ID_REBASE_PICK:\r
+                       SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_PICK);\r
+                       break;\r
+               case ID_REBASE_EDIT:\r
+                       SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_EDIT);\r
+                       break;\r
+               case ID_REBASE_SQUASH:\r
+                       SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SQUASH);\r
+                       break;\r
                default:\r
                        //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);\r
                        break;\r
@@ -502,4 +510,20 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
                } // switch (cmd)\r
 \r
                theApp.DoWaitCursor(-1);\r
+}\r
+\r
+void CGitLogList::SetSelectedAction(int action)\r
+{\r
+       POSITION pos = GetFirstSelectedItemPosition();\r
+       int index;\r
+       while(pos)\r
+       {\r
+               index = GetNextSelectedItem(pos);\r
+               ((GitRev*)m_arShownList[index])->m_Action = action;\r
+               CRect rect;\r
+               this->GetItemRect(index,&rect,LVIR_BOUNDS);\r
+               this->InvalidateRect(rect);\r
+\r
+       }\r
+\r
 }
\ No newline at end of file
index e37ce97..4fac62d 100644 (file)
@@ -91,6 +91,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
 \r
        m_bExitThread=FALSE;\r
        m_IsOldFirst = FALSE;\r
+       m_IsRebaseReplaceGraph = FALSE;\r
 \r
        for(int i=0;i<Lanes::COLORS_NUM;i++)\r
        {\r
@@ -174,6 +175,14 @@ void CGitLogListBase::InsertGitColumn()
                DeleteColumn(c--);\r
        temp.LoadString(IDS_LOG_GRAPH);\r
 \r
+       if(m_IsRebaseReplaceGraph)\r
+       {\r
+               temp=_T("Rebase");\r
+       }\r
+       else\r
+       {\r
+               temp.LoadString(IDS_LOG_GRAPH);\r
+       }\r
        InsertColumn(this->LOGLIST_GRAPH, temp);\r
        \r
 #if 0  \r
@@ -719,7 +728,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
 \r
                        if (pLVCD->iSubItem == LOGLIST_GRAPH)\r
                        {\r
-                               if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
+                               if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )\r
                                {\r
                                        CRect rect;\r
                                        GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
@@ -856,6 +865,13 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
        case this->LOGLIST_GRAPH:       //Graphic\r
                if (pLogEntry)\r
                {\r
+                       if(this->m_IsRebaseReplaceGraph)\r
+                       {\r
+                               CTGitPath path;\r
+                               path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;\r
+\r
+                               lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);\r
+                       }\r
                }\r
                break;\r
        case this->LOGLIST_ACTION: //action -- no text in the column\r
@@ -974,6 +990,14 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
        CIconMenu popup;\r
        if (popup.CreatePopupMenu())\r
        {\r
+\r
+               if(this->m_IsRebaseReplaceGraph)\r
+               {\r
+                       popup.AppendMenuIcon(ID_REBASE_PICK,   _T("Pick"),   IDI_OPEN);\r
+                       popup.AppendMenuIcon(ID_REBASE_SQUASH, _T("Squash"), IDI_OPEN);\r
+                       popup.AppendMenuIcon(ID_REBASE_EDIT,   _T("Edit"),   IDI_OPEN);\r
+               }\r
+\r
                if (GetSelectedCount() == 1)\r
                {\r
 #if 0\r
index c3d3e22..a7af487 100644 (file)
@@ -130,7 +130,10 @@ public:
        ID_CREATE_BRANCH,\r
        ID_CREATE_TAG,\r
        ID_SWITCHTOREV,\r
-       ID_RESET\r
+       ID_RESET,\r
+       ID_REBASE_PICK,\r
+       ID_REBASE_EDIT,\r
+       ID_REBASE_SQUASH\r
        };\r
        void InsertGitColumn();\r
        void ResizeAllListCtrlCols();\r
index 636c30f..8159247 100644 (file)
@@ -152,6 +152,7 @@ BOOL CRebaseDlg::OnInitDialog()
 \r
        m_CommitList.m_IsIDReplaceAction = TRUE;\r
        m_CommitList.m_IsOldFirst = TRUE;\r
+       m_CommitList.m_IsRebaseReplaceGraph = TRUE;\r
 \r
        m_CommitList.DeleteAllItems();\r
        m_CommitList.InsertGitColumn();\r
@@ -164,20 +165,54 @@ BOOL CRebaseDlg::OnInitDialog()
 void CRebaseDlg::OnBnClickedPickAll()\r
 {\r
     // TODO: Add your control notification handler code here\r
+       this->UpdateData();\r
+       if(this->m_bPickAll)\r
+               this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_PICK);\r
+\r
+       this->m_bEditAll=FALSE;\r
+       this->m_bSquashAll=FALSE;\r
+       this->UpdateData(FALSE);\r
+       \r
 }\r
 \r
 void CRebaseDlg::OnBnClickedSquashAll()\r
 {\r
     // TODO: Add your control notification handler code here\r
+       this->UpdateData();\r
+       if(this->m_bSquashAll)\r
+               this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_SQUASH);\r
+\r
+       this->m_bEditAll=FALSE;\r
+       this->m_bPickAll=FALSE;\r
+       this->UpdateData(FALSE);\r
+\r
 }\r
 \r
 void CRebaseDlg::OnBnClickedEditAll()\r
 {\r
     // TODO: Add your control notification handler code here\r
+       this->UpdateData();\r
+       if( this->m_bEditAll )\r
+               this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_EDIT);\r
+\r
+       this->m_bPickAll=FALSE;\r
+       this->m_bSquashAll=FALSE;\r
+       this->UpdateData(FALSE);\r
+\r
+}\r
+\r
+void CRebaseDlg::SetAllRebaseAction(int action)\r
+{\r
+       for(int i=0;i<this->m_CommitList.m_logEntries.size();i++)\r
+       {\r
+               m_CommitList.m_logEntries[i].m_Action=action;\r
+       }\r
+       m_CommitList.Invalidate();\r
 }\r
 \r
 void CRebaseDlg::OnBnClickedRebaseSplit()\r
 {\r
+       this->UpdateData();\r
     // TODO: Add your control notification handler code here\r
 }\r
 \r
@@ -311,12 +346,16 @@ void CRebaseDlg::FetchLogList()
                }\r
        }\r
        \r
-       m_CommitList.Invalidate();\r
-\r
        m_tooltips.Pop();\r
        AddBranchToolTips(&this->m_BranchCtrl);\r
        AddBranchToolTips(&this->m_UpstreamCtrl);\r
        \r
+       for(int i=0;i<m_CommitList.m_logEntries.size();i++)\r
+       {\r
+               m_CommitList.m_logEntries[i].m_Action = CTGitPath::LOGACTIONS_REBASE_PICK;\r
+       }\r
+       \r
+       m_CommitList.Invalidate();\r
 }\r
 \r
 void CRebaseDlg::AddBranchToolTips(CHistoryCombo *pBranch)\r
index 5673bb5..af7a0f7 100644 (file)
@@ -45,6 +45,7 @@ protected:
        \r
        void LoadBranchInfo();\r
        void FetchLogList();\r
+       void SetAllRebaseAction(int action);\r
 \r
        CRect                           m_DlgOrigRect;\r
        CRect                           m_CommitListOrigRect;\r