From: Frank Li Date: Tue, 28 Apr 2009 06:38:08 +0000 (+0800) Subject: Enable formatpatch at log dialog X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=commitdiff_plain;h=b5bdab9f961c2084385980f6533a18096f71a74c Enable formatpatch at log dialog Signed-off-by: Frank Li --- diff --git a/src/Resources/CommonResource.h b/src/Resources/CommonResource.h index bc3583e..e875d91 100644 --- a/src/Resources/CommonResource.h +++ b/src/Resources/CommonResource.h @@ -67,4 +67,5 @@ #define IDS_COMBINE_TO_ONE 20065 #define IDS_CHERRY_PICK_VERSION 20066 #define IDS_COPY_COMMIT_HASH 20067 +#define IDS_CREATE_PATCH 20068 diff --git a/src/Resources/TortoiseCommon.rc2 b/src/Resources/TortoiseCommon.rc2 index e74c38e..e4816f7 100644 --- a/src/Resources/TortoiseCommon.rc2 +++ b/src/Resources/TortoiseCommon.rc2 @@ -76,6 +76,7 @@ BEGIN IDS_COMBINE_TO_ONE "*Combine to one commit" IDS_CHERRY_PICK_VERSION "Cherry Pick this version..." IDS_COPY_COMMIT_HASH "Copy Commit Hash" + IDS_CREATE_PATCH "Format Patch..." END diff --git a/src/TortoiseProc/Commands/FormatPatchCommand.cpp b/src/TortoiseProc/Commands/FormatPatchCommand.cpp index f5e7cb2..b3fa3ea 100644 --- a/src/TortoiseProc/Commands/FormatPatchCommand.cpp +++ b/src/TortoiseProc/Commands/FormatPatchCommand.cpp @@ -33,7 +33,21 @@ bool FormatPatchCommand::Execute() { CFormatPatchDlg dlg; // dlg.m_bIsTag=TRUE; - + CString startval = parser.GetVal(_T("startrev")); + CString endval = parser.GetVal(_T("endrev")); + + if( endval.IsEmpty() && (!startval.IsEmpty())) + { + dlg.m_Since=startval; + dlg.m_Radio = IDC_RADIO_SINCE; + + }else if( (!endval.IsEmpty()) && (!startval.IsEmpty())) + { + dlg.m_From=startval; + dlg.m_To=endval; + dlg.m_Radio = IDC_RADIO_RANGE; + } + if(dlg.DoModal()==IDOK) { CString cmd; diff --git a/src/TortoiseProc/FormatPatchDlg.cpp b/src/TortoiseProc/FormatPatchDlg.cpp index 5b613fd..f644b94 100644 --- a/src/TortoiseProc/FormatPatchDlg.cpp +++ b/src/TortoiseProc/FormatPatchDlg.cpp @@ -16,6 +16,7 @@ CFormatPatchDlg::CFormatPatchDlg(CWnd* pParent /*=NULL*/) { m_Num=1; this->m_bSendMail = m_regSendMail; + this->m_Radio = IDC_RADIO_SINCE; } CFormatPatchDlg::~CFormatPatchDlg() @@ -84,13 +85,22 @@ BOOL CFormatPatchDlg::OnInitDialog() g_Git.GetBranchList(list,NULL,CGit::BRANCH_ALL); m_cSince.AddString(list); + if(!m_Since.IsEmpty()) + m_cSince.SetWindowText(m_Since); + m_cFrom.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchFromURLS"), _T("ver")); m_cFrom.SetCurSel(0); + if(!m_From.IsEmpty()) + m_cFrom.SetWindowText(m_From); + m_cTo.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchToURLS"), _T("ver")); m_cTo.SetCurSel(0); - this->CheckRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE,IDC_RADIO_SINCE); + if(!m_To.IsEmpty()) + m_cTo.SetWindowText(m_To); + + this->CheckRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE,this->m_Radio); OnBnClickedRadio(); diff --git a/src/TortoiseProc/GitLogListAction.cpp b/src/TortoiseProc/GitLogListAction.cpp index 63c33cf..a40b32e 100644 --- a/src/TortoiseProc/GitLogListAction.cpp +++ b/src/TortoiseProc/GitLogListAction.cpp @@ -437,6 +437,38 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) } } break; + case ID_CREATE_PATCH: + { + int select=this->GetSelectedCount(); + CString cmd; + cmd = CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe"); + cmd += _T(" /command:formatpatch"); + + GitRev * r1 = reinterpret_cast(m_arShownList.GetAt(FirstSelect)); + GitRev * r2 = NULL; + if(select == 1) + { + cmd += _T(" /startrev:")+r1->m_CommitHash; + } + else + { + r2 = reinterpret_cast(m_arShownList.GetAt(LastSelect)); + if( this->m_IsOldFirst ) + { + cmd += _T(" /startrev:")+r1->m_CommitHash; + cmd += _T(" /endrev:")+r2->m_CommitHash; + + }else + { + cmd += _T(" /startrev:")+r2->m_CommitHash; + cmd += _T(" /endrev:")+r1->m_CommitHash; + } + + } + + CAppUtils::LaunchApplication(cmd,IDS_ERR_PROC,false); + } + 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 29ba187..6dd415e 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -1191,6 +1191,11 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) } if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK)) popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT); + + if(GetSelectedCount()<=2) + if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH)) + popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH); + popup.AppendMenu(MF_SEPARATOR, NULL); } diff --git a/src/TortoiseProc/GitLogListBase.h b/src/TortoiseProc/GitLogListBase.h index ac6f6ca..b91a7d2 100644 --- a/src/TortoiseProc/GitLogListBase.h +++ b/src/TortoiseProc/GitLogListBase.h @@ -143,6 +143,7 @@ public: ID_STASH_APPLY, ID_REFLOG_DEL, ID_REBASE_TO_VERSION, + ID_CREATE_PATCH, }; inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)< @@ -166,19 +165,14 @@ @@ -259,14 +254,19 @@