OSDN Git Service

Fixed issue #157: Move progress dlg before rebase dialog SVN Rebase doesn't fast...
authorFrank Li <lznuaa@gmail.com>
Fri, 4 Sep 2009 15:24:00 +0000 (23:24 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 4 Sep 2009 15:24:00 +0000 (23:24 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/Commands/SVNRebaseCommand.cpp

index 7a08704..19cd322 100644 (file)
@@ -51,7 +51,7 @@ bool SVNRebaseCommand::Execute()
 \r
        CRebaseDlg dlg;\r
        \r
-       dlg.m_PreCmd=_T("git.exe svn fetch");\r
+//     dlg.m_PreCmd=_T("git.exe svn fetch");\r
 \r
        CString cmd,out;\r
        cmd = _T("git.exe config svn-remote.svn.fetch");\r
@@ -62,10 +62,53 @@ bool SVNRebaseCommand::Execute()
                        out=out.Mid(6);\r
                int start = 0;\r
                out=out.Tokenize(_T("\n"),start);\r
+       }else\r
+       {\r
+               CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               return false;\r
        }\r
 \r
        dlg.m_Upstream=out;\r
 \r
+       CString UpStreamOldHash,HeadHash,UpStreamNewHash;\r
+       UpStreamOldHash=g_Git.GetHash(out);\r
+       HeadHash = g_Git.GetHash(_T("HEAD"));\r
+       CProgressDlg progress; \r
+       progress.m_GitCmd=_T("git.exe svn fetch");\r
+       progress.m_bAutoCloseOnSuccess = true;\r
+\r
+       if(progress.DoModal()!=IDOK)\r
+               return false;\r
+\r
+       if(progress.m_GitStatus)\r
+               return false;\r
+       \r
+       UpStreamNewHash=g_Git.GetHash(out);\r
+\r
+       //everything updated\r
+       if(UpStreamNewHash==HeadHash)\r
+       {\r
+               CMessageBox::Show(NULL,_T("Everything Updated"),_T("TortoiseGit"),MB_OK);\r
+               return true;\r
+       }\r
+       \r
+       //fast forward;\r
+       CString ff;\r
+       if(g_Git.IsFastForward(CString(_T("HEAD")),out))\r
+       {\r
+               cmd.Format(_T("git.exe reset --hard %s"),out);\r
+               if(g_Git.Run(cmd,&ff,CP_ACP))\r
+               {\r
+                       CMessageBox::Show(NULL,ff,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return false;\r
+               }else\r
+               {\r
+                       CMessageBox::Show(NULL,CString(_T("Fast Forward:"))+ff,_T("TortoiseGit"),MB_OK);\r
+                       return true;\r
+               }\r
+       }\r
+\r
+       //need rebase\r
        if(dlg.DoModal() == IDOK)\r
        {\r
                bRet=true;\r