OSDN Git Service

Fix Issue #111: Undo Add does not work
authorFrank Li <lznuaa@gmail.com>
Fri, 10 Jul 2009 05:38:17 +0000 (13:38 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 10 Jul 2009 05:38:17 +0000 (13:38 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/Commands/RevertCommand.cpp
src/TortoiseProc/SVNProgressDlg.cpp
src/TortoiseProc/SVNProgressDlg.h

index 32827c7..53dabdc 100644 (file)
@@ -20,7 +20,7 @@
 #include "RevertCommand.h"\r
 \r
 #include "RevertDlg.h"\r
-//#include "SVNProgressDlg.h"\r
+#include "SVNProgressDlg.h"\r
 #include "MessageBox.h"\r
 \r
 bool RevertCommand::Execute()\r
@@ -30,22 +30,9 @@ bool RevertCommand::Execute()
        if (dlg.DoModal() == IDOK)\r
        {\r
 \r
-               if (dlg.m_selectedPathList.GetCount() == 0)\r
-                       return FALSE;\r
-               CString cmd;\r
-               CString out;\r
-               for(int i=0;i< dlg.m_selectedPathList.GetCount() ;i++)\r
-               {\r
-                       cmd.Format(_T("git.exe checkout -f -- \"%s\""),dlg.m_selectedPathList[i].GetGitPathString());\r
-                       if(g_Git.Run(cmd,&out,CP_ACP))\r
-                       {\r
-                               CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);\r
-                       }\r
-               }\r
-#if 0\r
-               CSVNProgressDlg progDlg;\r
+               CGitProgressDlg progDlg;\r
                theApp.m_pMainWnd = &progDlg;\r
-               progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Revert);\r
+               progDlg.SetCommand(CGitProgressDlg::GitProgress_Revert);\r
                if (parser.HasVal(_T("closeonend")))\r
                        progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
                progDlg.SetOptions(dlg.m_bRecursive ? ProgOptRecursive : ProgOptNonRecursive);\r
@@ -53,7 +40,7 @@ bool RevertCommand::Execute()
                progDlg.SetItemCount(dlg.m_selectedPathList.GetCount());\r
                progDlg.SetSelectedList(dlg.m_selectedPathList);\r
                progDlg.DoModal();\r
-#endif\r
+\r
                return true;\r
        }\r
        return false;\r
index 08b16bc..88b6542 100644 (file)
@@ -306,6 +306,10 @@ BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t actio
                data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);\r
                break;\r
 \r
+       case git_wc_notify_revert:\r
+               data->sActionColumnText.LoadString(IDS_SVNACTION_REVERT);\r
+               break;\r
+\r
 #if 0\r
        case svn_wc_notify_commit_added:\r
                data->sActionColumnText.LoadString(IDS_SVNACTION_ADDING);\r
@@ -331,9 +335,7 @@ BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t actio
        case svn_wc_notify_restore:\r
                data->sActionColumnText.LoadString(IDS_SVNACTION_RESTORE);\r
                break;\r
-       case svn_wc_notify_revert:\r
-               data->sActionColumnText.LoadString(IDS_SVNACTION_REVERT);\r
-               break;\r
+\r
        case svn_wc_notify_update_replace:\r
        case svn_wc_notify_commit_replaced:\r
                data->sActionColumnText.LoadString(IDS_SVNACTION_REPLACED);\r
@@ -2457,7 +2459,7 @@ bool CGitProgressDlg::CmdResolve(CString& sWindowTitle, bool& localoperation)
 \r
 bool CGitProgressDlg::CmdRevert(CString& sWindowTitle, bool& localoperation)\r
 {\r
-#if 0\r
+\r
        localoperation = true;\r
        sWindowTitle.LoadString(IDS_PROGRS_TITLE_REVERT);\r
        SetWindowText(sWindowTitle);\r
@@ -2468,13 +2470,19 @@ bool CGitProgressDlg::CmdRevert(CString& sWindowTitle, bool& localoperation)
                delList.DeleteAllFiles(true);\r
 \r
        ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT)));\r
-       if (!Revert(m_targetPathList, CStringArray(), !!(m_options & ProgOptRecursive)))\r
+       for(int i=0;i<m_selectedPaths.GetCount();i++)\r
        {\r
-               ReportSVNError();\r
-               return false;\r
+               if(g_Git.Revert((CTGitPath&)m_selectedPaths[i],true))\r
+               {\r
+                       CMessageBox::Show(NULL,_T("Revert Fail"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       m_bErrorsOccurred=true;\r
+                       return false;\r
+               }\r
+               Notify(m_selectedPaths[i],git_wc_notify_revert);\r
        }\r
+\r
        CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);\r
-#endif\r
+\r
        return true;\r
 }\r
 \r
index a99784f..97ba6c8 100644 (file)
@@ -74,6 +74,7 @@ typedef enum
        git_wc_notify_sendmail_retry,\r
        git_wc_notify_sendmail_done,\r
        git_wc_notify_resolved,\r
+       git_wc_notify_revert,\r
 \r
 }git_wc_notify_action_t;\r
 typedef enum\r