OSDN Git Service

Add Reset Command
authorFrank Li <lznuaa@gmail.com>
Thu, 22 Jan 2009 13:56:46 +0000 (21:56 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 22 Jan 2009 13:56:46 +0000 (21:56 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/CommitDlg.h
src/TortoiseProc/GitLogListAction.cpp
src/TortoiseProc/ResetDlg.cpp
src/TortoiseProc/ResetDlg.h
src/TortoiseProc/TortoiseProc.vcproj

index 575fa72..abc81d4 100644 (file)
@@ -40,6 +40,7 @@
 #include "GitStatus.h"\r
 #include "CreateBranchTagDlg.h"\r
 #include "GitSwitchDlg.h"\r
+#include "ResetDlg.h"\r
 \r
 CAppUtils::CAppUtils(void)\r
 {\r
@@ -1215,4 +1216,38 @@ bool CAppUtils::IgnoreFile(CTGitPath &path,bool IsMask)
 \r
        file.Close();\r
        return TRUE;\r
+}\r
+\r
+bool CAppUtils::GitReset(CString *CommitHash,int type)\r
+{\r
+       CResetDlg dlg;\r
+       dlg.m_ResetType=type;\r
+       if (dlg.DoModal() == IDOK)\r
+       {\r
+               CString cmd;\r
+               CString type;\r
+               switch(dlg.m_ResetType)\r
+               {\r
+               case 0:\r
+                       type=_T("--soft");\r
+                       break;\r
+               case 1:\r
+                       type=_T("--mixed");\r
+                       break;\r
+               case 2:\r
+                       type=_T("--hard");\r
+                       break;\r
+               default:\r
+                       type=_T("--mixed");\r
+                       break;\r
+               }\r
+               cmd.Format(_T("git.exe reset %s %s"),type, *CommitHash);\r
+\r
+               CProgressDlg progress;\r
+               progress.m_GitCmd=cmd;\r
+               if(progress.DoModal()==IDOK)\r
+                       return TRUE;\r
+\r
+       }\r
+       return FALSE;\r
 }
\ No newline at end of file
index 0264563..8248bb9 100644 (file)
@@ -165,7 +165,7 @@ public:
        static bool Switch(CString *CommitHash);\r
 \r
        static bool IgnoreFile(CTGitPath &file, bool IsMask);\r
-\r
+       static bool GitReset(CString *CommitHash,int type=1);\r
 private:\r
        static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);\r
        static bool GetMimeType(const CTGitPath& file, CString& mimetype);\r
index e4bb91d..c3c7a8f 100644 (file)
@@ -139,4 +139,5 @@ private:
 public:\r
        afx_msg void OnBnClickedSignOff();\r
        afx_msg void OnStnClickedCommitlabel();\r
+       afx_msg void OnBnClickedCommitAmend();\r
 };\r
index 230ad54..556be8c 100644 (file)
@@ -176,7 +176,10 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
                        Invalidate();\r
                        break;\r
                case ID_RESET:\r
-\r
+                       CAppUtils::GitReset(&pSelLogEntry->m_CommitHash);\r
+                       m_HashMap.clear();\r
+                       g_Git.GetMapHashToFriendName(m_HashMap);\r
+                       Invalidate();\r
                        break;\r
                default:\r
                        //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);\r
index 04d1395..6d563e3 100644 (file)
@@ -8,11 +8,11 @@
 \r
 // CResetDlg dialog\r
 \r
-IMPLEMENT_DYNAMIC(CResetDlg, CDialog)\r
+IMPLEMENT_DYNAMIC(CResetDlg, CResizableStandAloneDialog)\r
 \r
 CResetDlg::CResetDlg(CWnd* pParent /*=NULL*/)\r
-       : CDialog(CResetDlg::IDD, pParent)\r
-    , m_ResetType(0)\r
+       : CResizableStandAloneDialog(CResetDlg::IDD, pParent)\r
+    , m_ResetType(1)\r
 {\r
 \r
 }\r
@@ -27,8 +27,28 @@ void CResetDlg::DoDataExchange(CDataExchange* pDX)
 }\r
 \r
 \r
-BEGIN_MESSAGE_MAP(CResetDlg, CDialog)\r
+BEGIN_MESSAGE_MAP(CResetDlg, CResizableStandAloneDialog)\r
 END_MESSAGE_MAP()\r
 \r
 \r
 // CResetDlg message handlers\r
+BOOL CResetDlg::OnInitDialog()\r
+{\r
+       CResizableStandAloneDialog::OnInitDialog();\r
+\r
+       AddAnchor(IDC_RESET_BRANCH_NAME, TOP_LEFT, TOP_RIGHT);\r
+       AddAnchor(IDC_GROUP_RESET_TYPE, TOP_LEFT,TOP_RIGHT);\r
+\r
+       AddAnchor(IDOK,BOTTOM_RIGHT);\r
+       AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
+       \r
+       this->CheckRadioButton(IDC_RADIO_RESET_SOFT,IDC_RADIO_RESET_HARD,IDC_RADIO_RESET_SOFT+m_ResetType);\r
+\r
+       return TRUE;\r
+}\r
+\r
+void CResetDlg::OnOK()\r
+{\r
+       m_ResetType=this->GetCheckedRadioButton(IDC_RADIO_RESET_SOFT,IDC_RADIO_RESET_HARD)-IDC_RADIO_RESET_SOFT;\r
+       return CResizableStandAloneDialog::OnOK();\r
+}
\ No newline at end of file
index 3174b29..8c81ae7 100644 (file)
@@ -1,9 +1,9 @@
 #pragma once\r
 \r
-\r
+#include "StandAloneDlg.h"\r
 // CResetDlg dialog\r
 \r
-class CResetDlg : public CDialog\r
+class CResetDlg : public CResizableStandAloneDialog\r
 {\r
        DECLARE_DYNAMIC(CResetDlg)\r
 \r
@@ -16,6 +16,8 @@ public:
 \r
 protected:\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
+       virtual BOOL OnInitDialog();\r
+       virtual void OnOK();\r
 \r
        DECLARE_MESSAGE_MAP()\r
 public:\r
index a438452..bb50e5e 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\open.ico"\r
+                               RelativePath=".\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\open.ico"\r
+                               RelativePath="..\Resources\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\saveas.ico"\r
+                               RelativePath=".\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\saveas.ico"\r
+                               RelativePath="..\Resources\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\ResetDlg.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\ResetDlg.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\StatGraphDlg.cpp"\r
                                >\r
                        </File>\r