OSDN Git Service

RebaseDlg Fix don't start rebase problem
authorFrank Li <lznuaa@gmail.com>
Fri, 27 Feb 2009 05:49:32 +0000 (13:49 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 27 Feb 2009 05:49:32 +0000 (13:49 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/RebaseDlg.cpp
src/TortoiseProc/RebaseDlg.h
src/TortoiseShell/ContextMenu.cpp

index 2839f2e..6c17618 100644 (file)
@@ -453,6 +453,7 @@ int CRebaseDlg::CheckRebaseCondition()
                return -1;\r
 \r
        //Todo call pre_rebase_hook\r
+       return 0;\r
 }\r
 int CRebaseDlg::StartRebase()\r
 {\r
@@ -493,9 +494,10 @@ int CRebaseDlg::StartRebase()
        {\r
                return -1;\r
        }\r
-       \r
-       cmd.Format(_T("git.exe rev-parse %s"),this->m_UpstreamCtrl.GetString());\r
-       if(g_Git.Run(cmd,&this->m_OrigUpstreamHash,CP_UTF8))\r
+\r
+       m_OrigUpstreamHash.Empty();\r
+       m_OrigUpstreamHash= g_Git.GetHash(this->m_UpstreamCtrl.GetString());\r
+       if(m_OrigUpstreamHash.IsEmpty())\r
        {\r
                this->AddLogString(m_OrigUpstreamHash);\r
                return -1;\r
@@ -527,6 +529,31 @@ int  CRebaseDlg::VerifyNoConflict()
        return 0;\r
 \r
 }\r
+int CRebaseDlg::FinishRebase()\r
+{\r
+       CString cmd,out;\r
+       cmd.Format(_T("git.exe branch -f %s"),this->m_BranchCtrl.GetString());\r
+       if(g_Git.Run(cmd,&out,CP_UTF8))\r
+       {\r
+               AddLogString(out);\r
+               return -1;\r
+       }\r
+       out.Empty();\r
+       cmd.Format(_T("git.exe reset --hard %s"),this->m_OrigUpstreamHash);\r
+       if(g_Git.Run(cmd,&out,CP_UTF8))\r
+       {\r
+               AddLogString(out);\r
+               return -1;\r
+       }\r
+       out.Empty();\r
+       cmd.Format(_T("git.exe checkout -f %s"),this->m_BranchCtrl.GetString());\r
+       if(g_Git.Run(cmd,&out,CP_UTF8))\r
+       {\r
+               AddLogString(out);\r
+               return -1;\r
+       }\r
+       return 0;\r
+}\r
 void CRebaseDlg::OnBnClickedContinue()\r
 {\r
        if( m_RebaseStage == CHOOSE_BRANCH|| m_RebaseStage == CHOOSE_COMMIT_PICK_MODE )\r
@@ -536,21 +563,16 @@ void CRebaseDlg::OnBnClickedContinue()
                m_RebaseStage = REBASE_START;\r
        }\r
 \r
+       if( m_RebaseStage == REBASE_DONE)\r
+       {\r
+               OnOK();\r
+       }\r
+\r
        if( m_RebaseStage == REBASE_FINISH )\r
        {\r
-               CString cmd,out;\r
-               cmd.Format(_T("git branch -f %s"),this->m_BranchCtrl.GetString());\r
-               if(g_Git.Run(cmd,&out,CP_UTF8))\r
-               {\r
-                       AddLogString(out);\r
+               if(FinishRebase())\r
                        return ;\r
-               }\r
-               cmd.Format(_T("git reset --hard %s"),this->m_OrigUpstreamHash);\r
-               if(g_Git.Run(cmd,&out,CP_UTF8))\r
-               {\r
-                       AddLogString(out);\r
-                       return ;\r
-               }\r
+\r
                OnOK();\r
        }\r
 \r
@@ -754,6 +776,10 @@ void CRebaseDlg::SetContinueButtonText()
        case REBASE_FINISH:\r
                Text = _T("Finish");\r
                break;\r
+\r
+       case REBASE_DONE:\r
+               Text = _T("Done");\r
+               break;\r
        }\r
        this->GetDlgItem(IDC_REBASE_CONTINUE)->SetWindowText(Text);\r
 }\r
@@ -787,6 +813,7 @@ void CRebaseDlg::SetControlEnable()
        case REBASE_CONFLICT:\r
        case REBASE_EDIT:\r
        case REBASE_SQUASH_CONFLICT:\r
+       case REBASE_DONE:\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
@@ -825,7 +852,7 @@ void CRebaseDlg::UpdateProgress()
        m_ProgressBar.SetRange(1,m_CommitList.GetItemCount());\r
        m_ProgressBar.SetPos(index);\r
 \r
-       if(m_CurrentRebaseIndex>0 && m_CurrentRebaseIndex< m_CommitList.GetItemCount())\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
@@ -863,7 +890,7 @@ void CRebaseDlg::UpdateProgress()
 \r
 void CRebaseDlg::UpdateCurrentStatus()\r
 {\r
-       if( m_CurrentRebaseIndex < 0)\r
+       if( m_CurrentRebaseIndex < 0 && m_RebaseStage!= REBASE_DONE)\r
        {\r
                if(m_CommitList.m_IsOldFirst)\r
                        m_RebaseStage = CRebaseDlg::REBASE_START;\r
@@ -871,12 +898,12 @@ void CRebaseDlg::UpdateCurrentStatus()
                        m_RebaseStage = CRebaseDlg::REBASE_FINISH;\r
        }\r
 \r
-       if( m_CurrentRebaseIndex == m_CommitList.m_arShownList.GetSize())\r
+       if( m_CurrentRebaseIndex == m_CommitList.m_arShownList.GetSize() && m_RebaseStage!= REBASE_DONE)\r
        {\r
                if(m_CommitList.m_IsOldFirst)\r
-                       m_RebaseStage = CRebaseDlg::REBASE_FINISH;\r
+                       m_RebaseStage = CRebaseDlg::REBASE_DONE;\r
                else\r
-                       m_RebaseStage = CRebaseDlg::REBASE_START;\r
+                       m_RebaseStage = CRebaseDlg::REBASE_FINISH;\r
        }\r
 \r
        SetContinueButtonText();\r
@@ -1019,7 +1046,6 @@ int CRebaseDlg::RebaseThread()
                                break;\r
                        }\r
                        m_RebaseStage = REBASE_CONTINUE;\r
-                       continue;\r
 \r
                }else if( m_RebaseStage == REBASE_CONTINUE )\r
                {\r
@@ -1028,18 +1054,27 @@ int CRebaseDlg::RebaseThread()
                        {\r
                                ret = 0;\r
                                m_RebaseStage = REBASE_FINISH;\r
-                               break;\r
-                       }\r
-\r
-                       ret = DoRebase();\r
+                               \r
+                       }else\r
+                       {\r
+                               ret = DoRebase();\r
 \r
-                       if( ret )\r
-                       {       \r
-                               break;\r
+                               if( ret )\r
+                               {       \r
+                                       break;\r
+                               }\r
                        }\r
 \r
+               }else if( m_RebaseStage == REBASE_FINISH )\r
+               {                       \r
+                       FinishRebase();\r
+                       m_RebaseStage = REBASE_DONE;\r
+                       break;\r
+                       \r
                }else\r
+               {\r
                        break;\r
+               }\r
                this->PostMessage(MSG_REBASE_UPDATE_UI);\r
                //this->UpdateCurrentStatus();\r
        }\r
index 05523c8..581d3ef 100644 (file)
@@ -40,6 +40,7 @@ public:
                REBASE_EDIT,\r
                REBASE_SQUASH_EDIT,\r
                REBASE_SQUASH_CONFLICT,\r
+               REBASE_DONE,\r
        };\r
 \r
 protected:\r
@@ -86,6 +87,7 @@ protected:
 \r
        int CheckNextCommitIsSquash();\r
        int GetCurrentCommitID();\r
+       int FinishRebase();\r
 \r
 public:\r
    \r
index 7f99798..8f34bc4 100644 (file)
@@ -164,7 +164,7 @@ CShellExt::MenuInfo CShellExt::menuInfo[] =
        //       why was this changed, is this related to GitStatus?\r
 \r
        { ShellMenuIgnoreSub,                                   MENUIGNORE,                     IDI_IGNORE,                             IDS_MENUIGNORE,                         IDS_MENUDESCIGNORE,\r
-       ITEMIS_INVERSIONEDFOLDER, ITEMIS_IGNORED|ITEMIS_INSVN, 0, 0, 0, 0, 0, 0 },\r
+       ITEMIS_INVERSIONEDFOLDER,C, 0, 0, 0, 0, 0, 0 },\r
 \r
        { ShellMenuUnIgnoreSub,                                 MENUIGNORE,                     IDI_IGNORE,                             IDS_MENUUNIGNORE,                       IDS_MENUDESCUNIGNORE,\r
        ITEMIS_IGNORED, 0, 0, 0, 0, 0, 0, 0 },\r