OSDN Git Service

RebaseDlg: Add New is top option. Disable Edit control after start rebase
authorFrank Li <lznuaa@gmail.com>
Sun, 15 Feb 2009 03:27:38 +0000 (11:27 +0800)
committerFrank Li <lznuaa@gmail.com>
Sun, 15 Feb 2009 03:27:38 +0000 (11:27 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/TGitPath.cpp
src/Git/TGitPath.h
src/TortoiseProc/GitLogListAction.cpp
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/RebaseDlg.cpp
src/TortoiseProc/RebaseDlg.h

index c3a5444..f8b5435 100644 (file)
@@ -1886,6 +1886,8 @@ CString CTGitPath::GetActionName()
                return _T("Squash");\r
        if(m_Action & CTGitPath::LOGACTIONS_REBASE_PICK)\r
                return _T("Pick");\r
+       if(m_Action & CTGitPath::LOGACTIONS_REBASE_SKIP)\r
+               return _T("Skip");\r
 \r
        return _T("Unknown");\r
 }\r
index aa10018..632d8a1 100644 (file)
@@ -32,8 +32,9 @@ public:
                LOGACTIONS_REBASE_SQUASH  = 0x02000000,\r
                LOGACTIONS_REBASE_EDIT    = 0x01000000,\r
                LOGACTIONS_REBASE_DONE    = 0x00800000,\r
-               LOGACTIONS_REBASE_MASK    = 0x0F100000,\r
-               LOGACTIONS_REBASE_MODE_MASK=0x07100000,\r
+               LOGACTIONS_REBASE_SKIP    = 0x00400000,\r
+               LOGACTIONS_REBASE_MASK    = 0x0FC00000,\r
+               LOGACTIONS_REBASE_MODE_MASK=0x07C00000,\r
 \r
        };\r
 \r
index fea068f..0b3d003 100644 (file)
@@ -185,6 +185,9 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
                case ID_REBASE_SQUASH:\r
                        SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SQUASH);\r
                        break;\r
+               case ID_REBASE_SKIP:\r
+                       SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SKIP);\r
+                       break;\r
                default:\r
                        //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);\r
                        break;\r
index 59041ee..0b5e3d4 100644 (file)
@@ -92,6 +92,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
        m_bExitThread=FALSE;\r
        m_IsOldFirst = FALSE;\r
        m_IsRebaseReplaceGraph = FALSE;\r
+       m_IsEnableRebaseMenu = FALSE;\r
 \r
        for(int i=0;i<Lanes::COLORS_NUM;i++)\r
        {\r
@@ -705,7 +706,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                        if (data->bCopies)\r
                                                crText = m_Colors.GetColor(CColors::Modified);\r
 #endif\r
-                                       if (data->m_Action&CTGitPath::LOGACTIONS_REBASE_DONE )\r
+                                       if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) ) \r
                                                crText = RGB(128,128,128);\r
 \r
                                        if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)\r
@@ -1014,11 +1015,12 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
        if (popup.CreatePopupMenu())\r
        {\r
 \r
-               if(this->m_IsRebaseReplaceGraph)\r
+               if(this->m_IsEnableRebaseMenu)\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
+                       popup.AppendMenuIcon(ID_REBASE_SKIP,   _T("SKIP"),   IDI_OPEN);\r
                }\r
 \r
                if (GetSelectedCount() == 1)\r
index a7af487..9204307 100644 (file)
@@ -68,6 +68,7 @@ public:
        BOOL m_IsIDReplaceAction;\r
        BOOL m_IsOldFirst;\r
        BOOL m_IsRebaseReplaceGraph;\r
+       BOOL m_IsEnableRebaseMenu;\r
 \r
        BOOL m_bStrictStopped;\r
        BOOL m_bShowBugtraqColumn;\r
@@ -133,7 +134,8 @@ public:
        ID_RESET,\r
        ID_REBASE_PICK,\r
        ID_REBASE_EDIT,\r
-       ID_REBASE_SQUASH\r
+       ID_REBASE_SQUASH,\r
+       ID_REBASE_SKIP,\r
        };\r
        void InsertGitColumn();\r
        void ResizeAllListCtrlCols();\r
index d8944d9..bb9bef6 100644 (file)
@@ -97,7 +97,7 @@ BOOL CRebaseDlg::OnInitDialog()
        m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);\r
        // Create output panes:\r
        //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;\r
-       const DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;\r
+       DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;\r
 \r
        if (! this->m_FileListCtrl.Create(dwStyle,rectDummy,&this->m_ctrlTabCtrl,0) )\r
        {\r
@@ -110,13 +110,25 @@ BOOL CRebaseDlg::OnInitDialog()
                TRACE0("Failed to create log message control");\r
                return FALSE;\r
        }\r
+       m_LogMessageCtrl.Init(0);\r
 \r
+       dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;\r
+\r
+       if (!m_wndOutputRebase.Create(_T("Scintilla"),_T("source"),0,rectDummy, &m_ctrlTabCtrl, 0,0) )\r
+       {\r
+               TRACE0("Failed to create output windows\n");\r
+               return -1;      // fail to create\r
+       }\r
+       m_wndOutputRebase.Init(0);\r
+       m_wndOutputRebase.Call(SCI_SETREADONLY, TRUE);\r
+       \r
        m_tooltips.Create(this);\r
 \r
        m_FileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS , _T("RebaseDlg"));\r
 \r
        m_ctrlTabCtrl.AddTab(&m_FileListCtrl,_T("Conflict File"));\r
        m_ctrlTabCtrl.AddTab(&m_LogMessageCtrl,_T("Commit Message"),1);\r
+       m_ctrlTabCtrl.AddTab(&m_wndOutputRebase,_T("Log"),2);\r
        AddRebaseAnchor();\r
 \r
 \r
@@ -153,13 +165,14 @@ BOOL CRebaseDlg::OnInitDialog()
        }\r
 \r
        m_CommitList.m_IsIDReplaceAction = TRUE;\r
-       m_CommitList.m_IsOldFirst = TRUE;\r
+//     m_CommitList.m_IsOldFirst = TRUE;\r
        m_CommitList.m_IsRebaseReplaceGraph = TRUE;\r
 \r
        m_CommitList.DeleteAllItems();\r
        m_CommitList.InsertGitColumn();\r
 \r
        FetchLogList();\r
+       SetContinueButtonText();\r
        return TRUE;\r
 }\r
 // CRebaseDlg message handlers\r
@@ -358,6 +371,12 @@ void CRebaseDlg::FetchLogList()
        }\r
        \r
        m_CommitList.Invalidate();\r
+\r
+       if(m_CommitList.m_IsOldFirst)\r
+               this->m_CurrentRebaseIndex = -1;\r
+       else\r
+               this->m_CurrentRebaseIndex = m_CommitList.m_logEntries.size();\r
+       \r
 }\r
 \r
 void CRebaseDlg::AddBranchToolTips(CHistoryCombo *pBranch)\r
@@ -393,24 +412,31 @@ void CRebaseDlg::OnBnClickedContinue()
        GitRev *prevRev,*curRev;\r
        prevRev=curRev=NULL;\r
        CRect rect;\r
-       if( m_CurrentRebaseIndex >= m_CommitList.m_arShownList.GetSize())\r
-               return;\r
+       int prevIndex=m_CurrentRebaseIndex;\r
+       \r
+       UpdateCurrentStatus();\r
 \r
-       if( m_CurrentRebaseIndex >= 0)\r
+       if( m_CurrentRebaseIndex >= 0 && m_CurrentRebaseIndex< m_CommitList.m_arShownList.GetSize())\r
        {\r
                prevRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];\r
        }\r
-       m_CurrentRebaseIndex++;\r
-       if(m_CurrentRebaseIndex<m_CommitList.m_arShownList.GetSize())\r
+       \r
+       if(m_CommitList.m_IsOldFirst)\r
+               m_CurrentRebaseIndex++;\r
+       else\r
+               m_CurrentRebaseIndex--;\r
+\r
+       if(m_CurrentRebaseIndex >= 0 && m_CurrentRebaseIndex<m_CommitList.m_arShownList.GetSize())\r
        {\r
                curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];\r
 \r
        }\r
+\r
        if(prevRev)\r
        {\r
                prevRev->m_Action &= ~ CTGitPath::LOGACTIONS_REBASE_CURRENT;\r
                prevRev->m_Action |= CTGitPath::LOGACTIONS_REBASE_DONE;\r
-               m_CommitList.GetItemRect(m_CurrentRebaseIndex-1,&rect,LVIR_BOUNDS);\r
+               m_CommitList.GetItemRect(prevIndex,&rect,LVIR_BOUNDS);\r
                m_CommitList.InvalidateRect(rect);\r
 \r
        }\r
@@ -422,5 +448,107 @@ void CRebaseDlg::OnBnClickedContinue()
                m_CommitList.InvalidateRect(rect);\r
        }\r
 \r
+\r
+       UpdateCurrentStatus();\r
+\r
+       m_CommitList.EnsureVisible(m_CurrentRebaseIndex,FALSE);\r
        \r
+       this->SetContinueButtonText();\r
+       this->SetControlEnable();\r
+       UpdateProgress();\r
+}\r
+\r
+void CRebaseDlg::SetContinueButtonText()\r
+{\r
+       CString Text;\r
+       switch(this->m_RebaseStage)\r
+       {\r
+       case CHOOSE_BRANCH:\r
+       case CHOOSE_COMMIT_PICK_MODE:\r
+               Text = _T("Start");\r
+               break;\r
+\r
+       case REBASE_START:\r
+       case REBASE_CONTINUE:\r
+               Text = _T("Continue");\r
+               break;\r
+       case REBASE_ABORT:\r
+       case REBASE_FINISH:\r
+               Text = _T("Finish");\r
+               break;\r
+       }\r
+       this->GetDlgItem(IDC_REBASE_CONTINUE)->SetWindowText(Text);\r
+}\r
+\r
+void CRebaseDlg::SetControlEnable()\r
+{\r
+       switch(this->m_RebaseStage)\r
+       {\r
+       case CHOOSE_BRANCH:\r
+       case CHOOSE_COMMIT_PICK_MODE:\r
+               \r
+               this->GetDlgItem(IDC_PICK_ALL)->EnableWindow(TRUE);\r
+               this->GetDlgItem(IDC_EDIT_ALL)->EnableWindow(TRUE);\r
+               this->GetDlgItem(IDC_SQUASH_ALL)->EnableWindow(TRUE);\r
+               this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH)->EnableWindow(TRUE);\r
+               this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM)->EnableWindow(TRUE);\r
+               this->m_CommitList.m_IsEnableRebaseMenu=TRUE;\r
+               break;\r
+\r
+       case REBASE_START:\r
+       case REBASE_CONTINUE:\r
+       case REBASE_ABORT:\r
+       case REBASE_FINISH:\r
+               this->GetDlgItem(IDC_PICK_ALL)->EnableWindow(FALSE);\r
+               this->GetDlgItem(IDC_EDIT_ALL)->EnableWindow(FALSE);\r
+               this->GetDlgItem(IDC_SQUASH_ALL)->EnableWindow(FALSE);\r
+               this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH)->EnableWindow(FALSE);\r
+               this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM)->EnableWindow(FALSE);\r
+               this->m_CommitList.m_IsEnableRebaseMenu=FALSE;\r
+               break;\r
+       }\r
+}\r
+\r
+void CRebaseDlg::UpdateProgress()\r
+{\r
+       int index;\r
+\r
+       if(m_CommitList.m_IsOldFirst)\r
+               index = m_CurrentRebaseIndex+1;\r
+       else\r
+               index = m_CommitList.GetItemCount()-m_CurrentRebaseIndex;\r
+\r
+       m_ProgressBar.SetRange(1,m_CommitList.GetItemCount());\r
+       m_ProgressBar.SetPos(index);\r
+\r
+       if(m_CurrentRebaseIndex>0 && m_CurrentRebaseIndex< m_CommitList.GetItemCount())\r
+       {\r
+               CString text;\r
+               text.Format(_T("Rebasing...(%d/%d)"),index,m_CommitList.GetItemCount());\r
+               m_CtrlStatusText.SetWindowText(text);\r
+\r
+       }\r
+}\r
+\r
+void CRebaseDlg::UpdateCurrentStatus()\r
+{\r
+       if( m_CurrentRebaseIndex < 0)\r
+       {\r
+               if(m_CommitList.m_IsOldFirst)\r
+                       m_RebaseStage = CRebaseDlg::REBASE_START;\r
+               else\r
+                       m_RebaseStage = CRebaseDlg::REBASE_FINISH;\r
+       }\r
+\r
+       if( m_CurrentRebaseIndex == m_CommitList.m_arShownList.GetSize())\r
+       {\r
+               if(m_CommitList.m_IsOldFirst)\r
+                       m_RebaseStage = CRebaseDlg::REBASE_FINISH;\r
+               else\r
+                       m_RebaseStage = CRebaseDlg::REBASE_START;\r
+       }\r
+\r
+       SetContinueButtonText();\r
+       SetControlEnable();\r
+       UpdateProgress();\r
 }
\ No newline at end of file
index 357a053..9cfb567 100644 (file)
 // CRebaseDlg dialog\r
 #define IDC_REBASE_TAB 0x1000000\r
 \r
+#define REBASE_TAB_CONFLICT  0\r
+#define REBASE_TAB_MESSAGE   1\r
+#define REBASE_TAB_LOG          2\r
+\r
 class CRebaseDlg : public CResizableStandAloneDialog\r
 {\r
        DECLARE_DYNAMIC(CRebaseDlg)\r
@@ -29,6 +33,7 @@ public:
                REBASE_START,\r
                REBASE_CONTINUE,\r
                REBASE_ABORT,\r
+               REBASE_FINISH,\r
        };\r
 \r
 protected:\r
@@ -51,6 +56,12 @@ protected:
        CRect                           m_CommitListOrigRect;\r
        BOOL PreTranslateMessage(MSG* pMsg);\r
 \r
+       CSciEdit m_wndOutputRebase;\r
+       void SetContinueButtonText();\r
+       void SetControlEnable();\r
+       void UpdateProgress();\r
+       void UpdateCurrentStatus();\r
+\r
 public:\r
    \r
     afx_msg void OnBnClickedPickAll();\r