OSDN Git Service

Del RefLog work.
authorFrank Li <lznuaa@gmail.com>
Wed, 18 Mar 2009 04:40:14 +0000 (12:40 +0800)
committerFrank Li <lznuaa@gmail.com>
Wed, 18 Mar 2009 04:40:14 +0000 (12:40 +0800)
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/Commands/StashCommand.cpp
src/TortoiseProc/GitLogListAction.cpp
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/RefLogDlg.cpp
src/TortoiseProc/RefLogDlg.h
src/TortoiseShell/resource.h
src/TortoiseShell/resourceshell.rc

index 86f0339..fe90817 100644 (file)
@@ -42,6 +42,7 @@
 #include "GitSwitchDlg.h"\r
 #include "ResetDlg.h"\r
 #include "DeleteConflictDlg.h"\r
+#include "ChangedDlg.h"\r
 \r
 CAppUtils::CAppUtils(void)\r
 {\r
@@ -51,6 +52,29 @@ CAppUtils::~CAppUtils(void)
 {\r
 }\r
 \r
+int     CAppUtils::StashApply(CString ref)\r
+{\r
+       CString cmd,out;\r
+       cmd=_T("git.exe stash apply ");\r
+       cmd+=ref;\r
+       \r
+       if(g_Git.Run(cmd,&out,CP_ACP))\r
+       {\r
+               CMessageBox::Show(NULL,CString(_T("<ct=0x0000FF>Stash Apply Fail!!!</ct>\n"))+out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+\r
+       }else\r
+       {\r
+               if(CMessageBox::Show(NULL,CString(_T("<ct=0xff0000>Stash Apply Success</ct>\nDo you want to show change?"))\r
+                       ,_T("TortoiseGit"),MB_YESNO|MB_ICONINFORMATION) == IDYES)\r
+               {\r
+                       CChangedDlg dlg;\r
+                       dlg.m_pathList.AddPath(CTGitPath());\r
+                       dlg.DoModal();                  \r
+               }\r
+               return 0;\r
+       }\r
+       return -1;\r
+}\r
 bool CAppUtils::GetMimeType(const CTGitPath& file, CString& mimetype)\r
 {\r
 #if 0\r
index 415604d..efde195 100644 (file)
@@ -183,6 +183,7 @@ public:
        static CString ToRelativeTimeString(CTime time);\r
 \r
        static CString GetMergeTempFile(CString str,CTGitPath &merge);\r
+       static int         StashApply(CString ref);\r
 private:\r
        static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);\r
        static bool GetMimeType(const CTGitPath& file, CString& mimetype);\r
index fb97f54..15029bc 100644 (file)
@@ -25,7 +25,8 @@
 #include "Git.h"\r
 #include "DirFileEnum.h"\r
 #include "ShellUpdater.h"\r
-#include "ChangedDlg.h"\r
+\r
+#include "AppUtils.h"\r
 \r
 bool StashSaveCommand::Execute()\r
 {\r
@@ -47,25 +48,8 @@ bool StashSaveCommand::Execute()
 \r
 bool StashApplyCommand::Execute()\r
 {\r
-       bool bRet = false;\r
-\r
-       CString cmd,out;\r
-       cmd=_T("git.exe stash apply");\r
+       if(CAppUtils::StashApply(_T("")))\r
+               return false;\r
+       return true;\r
        \r
-       if(g_Git.Run(cmd,&out,CP_ACP))\r
-       {\r
-               CMessageBox::Show(NULL,CString(_T("<ct=0x0000FF>Stash Apply Fail!!!</ct>\n"))+out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
-\r
-       }else\r
-       {\r
-               if(CMessageBox::Show(NULL,CString(_T("<ct=0xff0000>Stash Apply Success</ct>\nDo you want to show change?"))\r
-                       ,_T("TortoiseGit"),MB_YESNO|MB_ICONINFORMATION) == IDYES)\r
-               {\r
-                       CChangedDlg dlg;\r
-                       dlg.m_pathList = pathList;\r
-                       dlg.DoModal();                  \r
-               }\r
-               bRet = true;\r
-       }\r
-       return bRet;\r
 }\r
index e73a913..63c33cf 100644 (file)
@@ -417,6 +417,26 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
 \r
                        break;\r
 \r
+               case ID_STASH_APPLY:\r
+                       CAppUtils::StashApply(pSelLogEntry->m_Ref);\r
+                       break;\r
+               \r
+               case ID_REFLOG_DEL:\r
+                       {       \r
+                               CString str;\r
+                               str.Format(_T("Warning: %s will be deleted. It can <ct=0x0000FF><b>NOT</b></ct> recovered,\r\n \r\n Are you sure delete these?"),pSelLogEntry->m_Ref);\r
+                               if(CMessageBox::Show(NULL,str,_T("TortoiseGit"),MB_YESNO|MB_ICONWARNING) == IDYES)\r
+                               {\r
+                                       CString cmd,out;\r
+                                       cmd.Format(_T("git.exe reflog delete %s"),pSelLogEntry->m_Ref);\r
+                                       if(g_Git.Run(cmd,&out,CP_ACP))\r
+                                       {\r
+                                               CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);\r
+                                       }                                               \r
+                                       ::PostMessage(this->GetParent()->m_hWnd,MSG_REFLOG_CHANGED,0,0);\r
+                               }\r
+                       }\r
+                       break;\r
                default:\r
                        //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);\r
                        break;\r
index e61f6a2..cde551f 100644 (file)
@@ -1127,6 +1127,13 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
                        popup.AppendMenu(MF_SEPARATOR, NULL);\r
 \r
                }\r
+\r
+               if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1)\r
+               {\r
+                       popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL,     IDI_DELETE);    \r
+                       popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE);  \r
+                       popup.AppendMenu(MF_SEPARATOR, NULL);\r
+               }\r
        \r
                if (GetSelectedCount() >= 2)\r
                {\r
index 949ea2a..4f1b6f7 100644 (file)
@@ -56,6 +56,7 @@ enum LISTITEMSTATES_MINE {
 //typedef void CALLBACK_PROCESS(void * data, int progress);\r
 #define MSG_LOADED                             (WM_USER+110)\r
 #define MSG_LOAD_PERCENTAGE            (WM_USER+111)\r
+#define MSG_REFLOG_CHANGED             (WM_USER+112)\r
 \r
 class CGitLogListBase : public CHintListCtrl\r
 {\r
@@ -139,6 +140,8 @@ public:
        ID_REBASE_SQUASH,\r
        ID_REBASE_SKIP,\r
        ID_COMBINE_COMMIT,\r
+       ID_STASH_APPLY,\r
+       ID_REFLOG_DEL,\r
        ID_REBASE_TO_VERSION,\r
        };\r
        inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<<i ;}\r
index 03ad3d0..d3bb480 100644 (file)
@@ -31,8 +31,16 @@ void CRefLogDlg::DoDataExchange(CDataExchange* pDX)
 BEGIN_MESSAGE_MAP(CRefLogDlg, CResizableStandAloneDialog)\r
        ON_BN_CLICKED(IDOK, &CRefLogDlg::OnBnClickedOk)\r
        ON_CBN_SELCHANGE(IDC_COMBOBOXEX_REF,   &CRefLogDlg::OnCbnSelchangeRef)\r
+       ON_MESSAGE(MSG_REFLOG_CHANGED,OnRefLogChanged)\r
 END_MESSAGE_MAP()\r
 \r
+LRESULT CRefLogDlg::OnRefLogChanged(WPARAM wParam, LPARAM lParam)\r
+{\r
+       m_RefList.m_RefMap.clear();\r
+       OnCbnSelchangeRef();\r
+       return 0;\r
+}\r
+\r
 BOOL CRefLogDlg::OnInitDialog()\r
 {\r
        CResizableStandAloneDialog::OnInitDialog();\r
index 13f7f4e..c8b0517 100644 (file)
@@ -20,6 +20,7 @@ protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        BOOL OnInitDialog();\r
        afx_msg void OnCbnSelchangeRef();       \r
+       afx_msg LRESULT OnRefLogChanged(WPARAM wParam, LPARAM lParam);\r
        DECLARE_MESSAGE_MAP()\r
 public:\r
        CHistoryCombo m_ChooseRef;\r
index 2c2b267..da3d321 100644 (file)
 #define IDS_MENUREFLOG                                 317\r
 #define IDS_MENUDESCREFLOG                             318\r
 #define IDS_MENUSTASHLIST                              319\r
+#define IDS_REFLOG_DEL                                 320\r
 \r
 #define IDC_REVISION                    1001\r
 #define IDC_LOCKED                      1002\r
index 7e35c59..651d527 100644 (file)
@@ -267,6 +267,7 @@ BEGIN
        IDS_MENUSTASHLIST               "Stash List"\r
        IDS_MENUSUBADD                  "Submodule Add"\r
        IDS_MENUSUBSYNC                 "Submodule Sync"\r
+       IDS_REFLOG_DEL                  "Delete Ref..."\r
 END\r
 \r
 STRINGTABLE \r