From 9834531ebabd41f77e7faad2fd48f398c0cb7634 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 18 Mar 2009 12:40:14 +0800 Subject: [PATCH] Del RefLog work. --- src/TortoiseProc/AppUtils.cpp | 24 ++++++++++++++++++++++++ src/TortoiseProc/AppUtils.h | 1 + src/TortoiseProc/Commands/StashCommand.cpp | 26 +++++--------------------- src/TortoiseProc/GitLogListAction.cpp | 20 ++++++++++++++++++++ src/TortoiseProc/GitLogListBase.cpp | 7 +++++++ src/TortoiseProc/GitLogListBase.h | 3 +++ src/TortoiseProc/RefLogDlg.cpp | 8 ++++++++ src/TortoiseProc/RefLogDlg.h | 1 + src/TortoiseShell/resource.h | 1 + src/TortoiseShell/resourceshell.rc | 1 + 10 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 86f0339..fe90817 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -42,6 +42,7 @@ #include "GitSwitchDlg.h" #include "ResetDlg.h" #include "DeleteConflictDlg.h" +#include "ChangedDlg.h" CAppUtils::CAppUtils(void) { @@ -51,6 +52,29 @@ CAppUtils::~CAppUtils(void) { } +int CAppUtils::StashApply(CString ref) +{ + CString cmd,out; + cmd=_T("git.exe stash apply "); + cmd+=ref; + + if(g_Git.Run(cmd,&out,CP_ACP)) + { + CMessageBox::Show(NULL,CString(_T("Stash Apply Fail!!!\n"))+out,_T("TortoiseGit"),MB_OK|MB_ICONERROR); + + }else + { + if(CMessageBox::Show(NULL,CString(_T("Stash Apply Success\nDo you want to show change?")) + ,_T("TortoiseGit"),MB_YESNO|MB_ICONINFORMATION) == IDYES) + { + CChangedDlg dlg; + dlg.m_pathList.AddPath(CTGitPath()); + dlg.DoModal(); + } + return 0; + } + return -1; +} bool CAppUtils::GetMimeType(const CTGitPath& file, CString& mimetype) { #if 0 diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index 415604d..efde195 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -183,6 +183,7 @@ public: static CString ToRelativeTimeString(CTime time); static CString GetMergeTempFile(CString str,CTGitPath &merge); + static int StashApply(CString ref); private: static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2); static bool GetMimeType(const CTGitPath& file, CString& mimetype); diff --git a/src/TortoiseProc/Commands/StashCommand.cpp b/src/TortoiseProc/Commands/StashCommand.cpp index fb97f54..15029bc 100644 --- a/src/TortoiseProc/Commands/StashCommand.cpp +++ b/src/TortoiseProc/Commands/StashCommand.cpp @@ -25,7 +25,8 @@ #include "Git.h" #include "DirFileEnum.h" #include "ShellUpdater.h" -#include "ChangedDlg.h" + +#include "AppUtils.h" bool StashSaveCommand::Execute() { @@ -47,25 +48,8 @@ bool StashSaveCommand::Execute() bool StashApplyCommand::Execute() { - bool bRet = false; - - CString cmd,out; - cmd=_T("git.exe stash apply"); + if(CAppUtils::StashApply(_T(""))) + return false; + return true; - if(g_Git.Run(cmd,&out,CP_ACP)) - { - CMessageBox::Show(NULL,CString(_T("Stash Apply Fail!!!\n"))+out,_T("TortoiseGit"),MB_OK|MB_ICONERROR); - - }else - { - if(CMessageBox::Show(NULL,CString(_T("Stash Apply Success\nDo you want to show change?")) - ,_T("TortoiseGit"),MB_YESNO|MB_ICONINFORMATION) == IDYES) - { - CChangedDlg dlg; - dlg.m_pathList = pathList; - dlg.DoModal(); - } - bRet = true; - } - return bRet; } diff --git a/src/TortoiseProc/GitLogListAction.cpp b/src/TortoiseProc/GitLogListAction.cpp index e73a913..63c33cf 100644 --- a/src/TortoiseProc/GitLogListAction.cpp +++ b/src/TortoiseProc/GitLogListAction.cpp @@ -417,6 +417,26 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) break; + case ID_STASH_APPLY: + CAppUtils::StashApply(pSelLogEntry->m_Ref); + break; + + case ID_REFLOG_DEL: + { + CString str; + str.Format(_T("Warning: %s will be deleted. It can NOT recovered,\r\n \r\n Are you sure delete these?"),pSelLogEntry->m_Ref); + if(CMessageBox::Show(NULL,str,_T("TortoiseGit"),MB_YESNO|MB_ICONWARNING) == IDYES) + { + CString cmd,out; + cmd.Format(_T("git.exe reflog delete %s"),pSelLogEntry->m_Ref); + if(g_Git.Run(cmd,&out,CP_ACP)) + { + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + } + ::PostMessage(this->GetParent()->m_hWnd,MSG_REFLOG_CHANGED,0,0); + } + } + break; default: //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK); break; diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index e61f6a2..cde551f 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -1127,6 +1127,13 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) popup.AppendMenu(MF_SEPARATOR, NULL); } + + if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1) + { + popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE); + popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE); + popup.AppendMenu(MF_SEPARATOR, NULL); + } if (GetSelectedCount() >= 2) { diff --git a/src/TortoiseProc/GitLogListBase.h b/src/TortoiseProc/GitLogListBase.h index 949ea2a..4f1b6f7 100644 --- a/src/TortoiseProc/GitLogListBase.h +++ b/src/TortoiseProc/GitLogListBase.h @@ -56,6 +56,7 @@ enum LISTITEMSTATES_MINE { //typedef void CALLBACK_PROCESS(void * data, int progress); #define MSG_LOADED (WM_USER+110) #define MSG_LOAD_PERCENTAGE (WM_USER+111) +#define MSG_REFLOG_CHANGED (WM_USER+112) class CGitLogListBase : public CHintListCtrl { @@ -139,6 +140,8 @@ public: ID_REBASE_SQUASH, ID_REBASE_SKIP, ID_COMBINE_COMMIT, + ID_STASH_APPLY, + ID_REFLOG_DEL, ID_REBASE_TO_VERSION, }; inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<