OSDN Git Service

Enhance Rebase dialog. Add force rebase checkbox.
authorFrank Li <lznuaa@gmail.com>
Wed, 15 Jul 2009 05:45:29 +0000 (13:45 +0800)
committerFrank Li <lznuaa@gmail.com>
Wed, 15 Jul 2009 05:45:29 +0000 (13:45 +0800)
Disable start button when no item rebase.
Don't show merge commit

Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/Commands/FetchCommand.cpp
src/TortoiseProc/RebaseDlg.cpp
src/TortoiseProc/RebaseDlg.h
src/TortoiseProc/resource.h

index cefbb60..e192c14 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 86f168c..e11ce89 100644 (file)
@@ -45,17 +45,24 @@ bool FetchCommand::Execute()
                CString cmd;\r
                cmd.Format(_T("git.exe fetch \"%s\" %s"),url, dlg.m_RemoteBranchName);\r
                CProgressDlg progress;\r
+\r
+               if(!dlg.m_bRebase)\r
+               {\r
+                       progress.m_changeAbortButtonOnSuccessTo=_T("&Rebase");\r
+               }else\r
+               {\r
+                       progress.m_bAutoCloseOnSuccess = true;\r
+               }\r
+\r
                progress.m_GitCmd=cmd;\r
-               if(progress.DoModal()==IDOK)\r
+               int userResponse=progress.DoModal();\r
+\r
+               if( (userResponse==IDC_PROGRESS_BUTTON1) || ( progress.m_GitStatus ==0 && dlg.m_bRebase) )\r
                {\r
-                       if( progress.m_GitStatus ==0 && dlg.m_bRebase)\r
+                       CRebaseDlg dlg;\r
+                       if(dlg.DoModal() == IDOK)\r
                        {\r
-                                       CRebaseDlg dlg;\r
-                                       if(dlg.DoModal() == IDOK)\r
-                                       {\r
-                                               return TRUE;\r
-                                       }\r
-\r
+                               return TRUE;\r
                        }\r
                        return TRUE;\r
                }\r
index 7772a95..c39c386 100644 (file)
@@ -23,6 +23,7 @@ CRebaseDlg::CRebaseDlg(CWnd* pParent /*=NULL*/)
        m_CurrentRebaseIndex=-1;\r
        m_bThreadRunning =FALSE;\r
        this->m_IsCherryPick = FALSE;\r
+       m_bForce=FALSE;\r
 }\r
 \r
 CRebaseDlg::~CRebaseDlg()\r
@@ -41,6 +42,7 @@ void CRebaseDlg::DoDataExchange(CDataExchange* pDX)
        DDX_Control(pDX,IDC_COMMIT_LIST,m_CommitList);\r
        DDX_Control(pDX,IDC_REBASE_COMBOXEX_BRANCH, this->m_BranchCtrl);\r
        DDX_Control(pDX,IDC_REBASE_COMBOXEX_UPSTREAM,   this->m_UpstreamCtrl);\r
+       DDX_Check(pDX, IDC_REBASE_CHECK_FORCE,m_bForce);\r
 \r
 }\r
 \r
@@ -57,6 +59,7 @@ BEGIN_MESSAGE_MAP(CRebaseDlg, CResizableStandAloneDialog)
        ON_CBN_SELCHANGE(IDC_REBASE_COMBOXEX_UPSTREAM, &CRebaseDlg::OnCbnSelchangeUpstream)\r
        ON_MESSAGE(MSG_REBASE_UPDATE_UI, OnRebaseUpdateUI)\r
        ON_BN_CLICKED(IDC_BUTTON_BROWSE, &CRebaseDlg::OnBnClickedButtonBrowse)\r
+       ON_BN_CLICKED(IDC_REBASE_CHECK_FORCE, &CRebaseDlg::OnBnClickedRebaseCheckForce)\r
 END_MESSAGE_MAP()\r
 \r
 void CRebaseDlg::AddRebaseAnchor()\r
@@ -76,6 +79,7 @@ void CRebaseDlg::AddRebaseAnchor()
        AddAnchor(IDC_REBASE_STATIC_UPSTREAM,TOP_LEFT);\r
        AddAnchor(IDC_REBASE_STATIC_BRANCH,TOP_LEFT);\r
        AddAnchor(IDHELP, BOTTOM_RIGHT);\r
+       AddAnchor(IDC_REBASE_CHECK_FORCE,TOP_RIGHT);\r
        this->AddOthersToAnchor();\r
 }\r
 \r
@@ -127,6 +131,8 @@ BOOL CRebaseDlg::OnInitDialog()
        m_wndOutputRebase.Call(SCI_SETREADONLY, TRUE);\r
        \r
        m_tooltips.Create(this);\r
+       \r
+       m_tooltips.AddTool(IDC_REBASE_CHECK_FORCE,IDS_REBASE_FORCE_TT);\r
 \r
        m_FileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("RebaseDlg"),(SVNSLC_POPALL ^ SVNSLC_POPCOMMIT),false);\r
 \r
@@ -408,40 +414,74 @@ void CRebaseDlg::OnCbnSelchangeUpstream()
 \r
 void CRebaseDlg::FetchLogList()\r
 {\r
-       m_CommitList.Clear();\r
-       this->m_CommitList.FillGitLog(NULL,0,&m_UpstreamCtrl.GetString(),&m_BranchCtrl.GetString());\r
-       if( m_CommitList.GetItemCount() == 0 )\r
-               m_CommitList.ShowText(_T("Nothing to Rebase"));\r
+       if(!this->m_bForce)\r
+       {\r
+               CString base,hash;\r
+               CString cmd;\r
+               cmd.Format(_T("git.exe merge-base %s %s"), m_UpstreamCtrl.GetString(),m_BranchCtrl.GetString());\r
+               if(g_Git.Run(cmd,&base,CP_ACP))\r
+               {\r
+                       CMessageBox::Show(NULL,base,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return;\r
+               }\r
+               base=base.Left(40);\r
+\r
+               cmd.Format(_T("git.exe rev-parse %s"), m_UpstreamCtrl.GetString());\r
+               if( g_Git.Run(cmd,&hash,CP_ACP))\r
+               {\r
+                       CMessageBox::Show(NULL,base,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return;\r
+               }\r
+               hash=hash.Left(40);\r
+               \r
+               if( base == hash )\r
+               {\r
+                       m_CommitList.Clear();\r
+                       CString text,fmt;\r
+                       fmt.LoadString(IDS_REBASE_UPTODATE_FMT);\r
+                       text.Format(fmt,m_BranchCtrl.GetString());\r
+                       m_CommitList.ShowText(text);\r
+               }\r
+               \r
+       }else\r
+       {\r
+               m_CommitList.Clear();\r
+               this->m_CommitList.FillGitLog(NULL,0,&m_UpstreamCtrl.GetString(),&m_BranchCtrl.GetString());\r
+               if( m_CommitList.GetItemCount() == 0 )\r
+                       m_CommitList.ShowText(_T("Nothing to Rebase"));\r
 \r
-       CString hash=g_Git.GetHash(m_UpstreamCtrl.GetString());\r
+               CString hash=g_Git.GetHash(m_UpstreamCtrl.GetString());\r
        \r
 #if 0\r
-       if(m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash.size() >=0 )\r
-       {\r
-               if(hash ==  m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash[0])\r
+               if(m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash.size() >=0 )\r
                {\r
-                       m_CommitList.Clear();\r
-                       m_CommitList.ShowText(_T("Nothing Rebase"));\r
+                       if(hash ==  m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash[0])\r
+                       {\r
+                               m_CommitList.Clear();\r
+                               m_CommitList.ShowText(_T("Nothing Rebase"));\r
+                       }\r
                }\r
-       }\r
 #endif\r
 \r
-       m_tooltips.Pop();\r
-       AddBranchToolTips(&this->m_BranchCtrl);\r
-       AddBranchToolTips(&this->m_UpstreamCtrl);\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
+               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
+               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
+               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
+       this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(m_CommitList.GetItemCount());\r
 }\r
 \r
 void CRebaseDlg::AddBranchToolTips(CHistoryCombo *pBranch)\r
@@ -1242,3 +1282,10 @@ void CRebaseDlg::OnBnClickedButtonBrowse()
        if(CBrowseRefsDlg::PickRefForCombo(&m_UpstreamCtrl, gPickRef_NoTag))\r
                OnCbnSelchangeUpstream();\r
 }\r
+\r
+void CRebaseDlg::OnBnClickedRebaseCheckForce()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       this->UpdateData();\r
+       this->FetchLogList();\r
+}\r
index 1f2dfe9..6b981e8 100644 (file)
@@ -110,6 +110,8 @@ public:
     BOOL m_bPickAll;\r
     BOOL m_bSquashAll;\r
     BOOL m_bEditAll;\r
+       \r
+       BOOL m_bForce;\r
 \r
        CSplitterControl        m_wndSplitter;\r
        CMFCTabCtrl m_ctrlTabCtrl;\r
@@ -134,4 +136,5 @@ public:
        int  StateAction();\r
        int  GoNext();\r
        afx_msg void OnBnClickedButtonBrowse();\r
+       afx_msg void OnBnClickedRebaseCheckForce();\r
 };\r
index 7542b8d..6ba4b02 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ