From 5cf8f29f51d4264094261f7b141794da34159ba2 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Fri, 24 Jul 2009 23:53:17 +0800 Subject: [PATCH] SyncDlg implement "apply patch" command. Signed-off-by: Frank Li --- src/TortoiseProc/SyncDlg.cpp | 95 ++++++++++++++++++++++++++++++++++++++++---- src/TortoiseProc/SyncDlg.h | 23 +++++++++-- 2 files changed, 108 insertions(+), 10 deletions(-) diff --git a/src/TortoiseProc/SyncDlg.cpp b/src/TortoiseProc/SyncDlg.cpp index 636eb18..5b1159a 100644 --- a/src/TortoiseProc/SyncDlg.cpp +++ b/src/TortoiseProc/SyncDlg.cpp @@ -25,7 +25,7 @@ #include "SyncDlg.h" #include "progressdlg.h" #include "MessageBox.h" - +#include "ImportPatchDlg.h" // CSyncDlg dialog IMPLEMENT_DYNAMIC(CSyncDlg, CResizableStandAloneDialog) @@ -160,6 +160,58 @@ void CSyncDlg::OnBnClickedButtonPush() void CSyncDlg::OnBnClickedButtonApply() { // TODO: Add your control notification handler code here + CString oldhash; + oldhash=g_Git.GetHash(CString(_T("HEAD"))); + + CImportPatchDlg dlg; + CString cmd,output; + + if(dlg.DoModal() == IDOK) + { + int err=0; + for(int i=0;im_ctrlCmdOut.SetSel(-1,-1); + this->m_ctrlCmdOut.ReplaceSel(output); + + CString newhash=g_Git.GetHash(CString(_T("HEAD"))); + + this->m_InLogList.Clear(); + this->m_InChangeFileList.Clear(); + + if(newhash == oldhash) + { + this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false); + this->m_InLogList.ShowText(_T("No commits get from patch")); + this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true); + + }else + { + this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,true); + this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true); + + this->AddDiffFileList(&m_InChangeFileList,&m_arInChangeList,newhash,oldhash); + } + + if(err) + { + this->ShowTab(IDC_CMD_LOG); + + }else + { + this->ShowTab(IDC_IN_LOGLIST); + } + } } void CSyncDlg::OnBnClickedButtonEmail() @@ -250,6 +302,35 @@ BOOL CSyncDlg::OnInitDialog() //m_ctrlCmdOut.ReplaceSel(_T("Hello")); + //---------- Create in coming list ctrl ----------- + dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;; + + if( !m_InLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_LOGLIST)) + { + TRACE0("Failed to create output commits window\n"); + return FALSE; // fail to create + + } + + m_ctrlTabCtrl.InsertTab(&m_InLogList,_T("In Commits"),-1); + + m_InLogList.InsertGitColumn(); + + //----------- Create In Change file list ----------- + dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE; + + if( !m_InChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_CHANGELIST)) + { + TRACE0("Failed to create output change files window\n"); + return FALSE; // fail to create + } + m_ctrlTabCtrl.InsertTab(&m_InChangeFileList,_T("Out ChangeList"),-1); + + m_InChangeFileList.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("OutSyncDlg"), + (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMPARETWO)| + CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_GNUDIFF2)),false); + + //---------- Create Commit List Ctrl--------------- dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;; @@ -341,7 +422,9 @@ BOOL CSyncDlg::OnInitDialog() FetchOutList(); m_ctrlTabCtrl.ShowTab(IDC_CMD_LOG-1,false); - + m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false); + m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false); + return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } @@ -419,11 +502,9 @@ void CSyncDlg::FetchOutList(bool force) { str.Format(_T("%d commits ahead \"%s\""),m_OutLogList.GetItemCount(),remotebranch); this->m_ctrlStatus.SetWindowText(str); - g_Git.GetCommitDiffList(localbranch,remotebranch,m_arOutChangeList); - m_OutChangeFileList.m_Rev1=localbranch; - m_OutChangeFileList.m_Rev2=remotebranch; - m_OutChangeFileList.Show(0,this->m_arOutChangeList); - m_OutChangeFileList.SetEmptyString(CString(_T("No changed file"))); + + AddDiffFileList(&m_OutChangeFileList,&m_arOutChangeList,localbranch,remotebranch); + this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(TRUE); } diff --git a/src/TortoiseProc/SyncDlg.h b/src/TortoiseProc/SyncDlg.h index 31b4180..7f54c3b 100644 --- a/src/TortoiseProc/SyncDlg.h +++ b/src/TortoiseProc/SyncDlg.h @@ -30,9 +30,13 @@ #include "GitLoglist.h" // CSyncDlg dialog #define IDC_SYNC_TAB 0x1000000 -#define IDC_CMD_LOG 0x1 -#define IDC_OUT_LOGLIST 0x2 -#define IDC_OUT_CHANGELIST 0x3 + +#define IDC_CMD_LOG 0x1 +#define IDC_IN_LOGLIST 0x2 +#define IDC_IN_CHANGELIST 0x3 +#define IDC_OUT_LOGLIST 0x4 +#define IDC_OUT_CHANGELIST 0x5 + class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox { DECLARE_DYNAMIC(CSyncDlg) @@ -70,6 +74,8 @@ protected: CRichEditCtrl m_ctrlCmdOut; CTGitPathList m_arOutChangeList; + CTGitPathList m_arInChangeList; + int m_CmdOutCurrentPos; CWinThread* m_pThread; @@ -110,8 +116,19 @@ protected: void ShowInputCtrl(bool bShow=true); void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);} void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);} + LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam); + void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList, + CString &rev1,CString &rev2) + { + g_Git.GetCommitDiffList(rev1,rev2,*pGitList); + pCtrlList->m_Rev1=rev1; + pCtrlList->m_Rev2=rev2; + pCtrlList->Show(0,*pGitList); + pCtrlList->SetEmptyString(CString(_T("No changed file"))); + return; + } DECLARE_MESSAGE_MAP() public: -- 2.11.0