OSDN Git Service

Add Revert to Version feature.
authorFrank Li <lznuaa@gmail.com>
Sun, 8 Mar 2009 04:17:50 +0000 (12:17 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 9 Mar 2009 13:23:41 +0000 (21:23 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/GitStatusListCtrl.cpp
src/Git/GitStatusListCtrl.h

index 8b7b30c..fa4302a 100644 (file)
@@ -3214,6 +3214,10 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                        case IDSVNLC_SAVEAS:\r
                                FileSaveAs(filepath);\r
                                break;\r
+\r
+                       case IDSVNLC_REVERTTOREV:\r
+                               RevertSelectedItemToVersion();\r
+                               break;\r
 #if 0\r
                        case IDSVNLC_PROPERTIES:\r
                                {\r
@@ -5536,4 +5540,26 @@ void CGitStatusListCtrl::FileSaveAs(CTGitPath *path)
                }\r
        }\r
 \r
+}\r
+\r
+int CGitStatusListCtrl::RevertSelectedItemToVersion()\r
+{\r
+       if(this->m_CurrentVersion.IsEmpty())\r
+               return 0;\r
+       if(this->m_CurrentVersion == GIT_REV_ZERO)\r
+               return 0;\r
+\r
+       POSITION pos = GetFirstSelectedItemPosition();\r
+       int index;\r
+       CString cmd,out;\r
+       while ((index = GetNextSelectedItem(pos)) >= 0)\r
+       {\r
+               CTGitPath *fentry=(CTGitPath*)GetItemData(index);\r
+               cmd.Format(_T("git.exe checkout %s -- \"%s\""),m_CurrentVersion,fentry->GetGitPathString());\r
+               out.Empty();\r
+               if(g_Git.Run(cmd,&out,CP_ACP))\r
+               {\r
+                       CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);\r
+               }\r
+       }       \r
 }
\ No newline at end of file
index dff4d6c..8a2bdd8 100644 (file)
@@ -875,6 +875,7 @@ private:
 \r
 \r
        void FileSaveAs(CTGitPath *path);\r
+       int RevertSelectedItemToVersion();\r
 \r
 private:\r
        bool *                                          m_pbCanceled;\r