1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2012-2013 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "StandAloneDlg.h"
25 #include "HistoryCombo.h"
26 #include "MenuButton.h"
28 #include "BranchCombox.h"
29 #include "GitLoglist.h"
30 #include "GitProgressList.h"
31 #include "GitRefCompareList.h"
34 #define IDC_SYNC_TAB 0x1000000
36 #define IDC_CMD_LOG 0x1
37 #define IDC_IN_LOGLIST 0x2
38 #define IDC_IN_CHANGELIST 0x3
39 #define IDC_IN_CONFLICT 0x4
40 #define IDC_OUT_LOGLIST 0x5
41 #define IDC_OUT_CHANGELIST 0x6
42 #define IDC_CMD_GIT_PROG 0x7
43 #define IDC_REFLIST 0x8
47 class CSyncDlg
: public CResizableStandAloneDialog
,public CBranchCombox
49 DECLARE_DYNAMIC(CSyncDlg
)
52 CSyncDlg(CWnd
* pParent
= NULL
); // standard constructor
56 enum { IDD
= IDD_SYNC
};
58 enum { GIT_COMMAND_PUSH
,
61 GIT_COMMAND_FETCHANDREBASE
,
62 GIT_COMMAND_SUBMODULE
,
67 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
68 BRANCH_COMBOX_EVENT_HANDLE();
70 virtual BOOL
OnInitDialog();
71 afx_msg
void OnBnClickedButtonManage();
72 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
73 afx_msg
void OnCbnEditchangeComboboxex();
74 afx_msg
void OnBnClickedButtonPull();
75 afx_msg
void OnBnClickedButtonPush();
76 afx_msg
void OnBnClickedButtonApply();
77 afx_msg
void OnBnClickedButtonEmail();
78 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
79 afx_msg
void OnDestroy();
81 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
82 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
86 CRegDWORD m_regPullButton
;
87 CRegDWORD m_regPushButton
;
88 CRegDWORD m_regSubmoduleButton
;
89 CRegDWORD m_regAutoLoadPutty
;
91 CMFCTabCtrl m_ctrlTabCtrl
;
97 CGitLogList m_OutLogList
;
98 CGitLogList m_InLogList
;
99 CGitProgressList m_GitProgressList
;
101 CGitStatusListCtrl m_OutChangeFileList
;
102 CGitStatusListCtrl m_InChangeFileList
;
103 CGitStatusListCtrl m_ConflictFileList
;
105 CRichEditCtrl m_ctrlCmdOut
;
106 CGitRefCompareList m_refList
;
108 CTGitPathList m_arOutChangeList
;
109 CTGitPathList m_arInChangeList
;
111 int m_CmdOutCurrentPos
;
113 CWinThread
* m_pThread
;
115 volatile LONG m_bBlock
;
116 CGitByteArray m_Databuf
;
119 void ParserCmdOutput(char ch
);
121 virtual void LocalBranchChange(){FetchOutList();};
122 virtual void RemoteBranchChange(){};
124 void ShowTab(int windowid
)
126 this->m_ctrlTabCtrl
.ShowTab(windowid
-1);
127 this->m_ctrlTabCtrl
.SetActiveTab(windowid
-1);
130 void FetchOutList(bool force
=false);
134 void SetRemote(CString remote
)
136 if(!remote
.IsEmpty())
138 int index
=this->m_ctrlURL
.FindStringExact(0,remote
);
141 m_ctrlURL
.SetCurSel(index
);
144 this->m_ctrlURL
.AddString(remote
);
148 std::vector
<CString
> m_GitCmdList
;
158 CString m_OutLocalBranch
;
159 CString m_OutRemoteBranch
;
162 MAP_HASH_NAME m_oldHashMap
;
163 MAP_HASH_NAME m_newHashMap
;
165 void ShowProgressCtrl(bool bShow
=true);
166 void ShowInputCtrl(bool bShow
=true);
167 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
168 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
170 LRESULT
OnProgressUpdateUI(WPARAM wParam
,LPARAM lParam
);
171 LRESULT
OnProgCmdFinish(WPARAM wParam
, LPARAM lParam
);
172 void FillNewRefMap();
173 void RunPostAction();
176 this->m_strLocalBranch
= this->m_ctrlLocalBranch
.GetString();
177 this->m_ctrlRemoteBranch
.GetWindowText(this->m_strRemoteBranch
);
178 this->m_ctrlURL
.GetWindowText(this->m_strURL
);
179 m_strRemoteBranch
=m_strRemoteBranch
.Trim();
182 void AddDiffFileList(CGitStatusListCtrl
*pCtrlList
, CTGitPathList
*pGitList
,
183 CString rev1
, CString rev2
)
185 g_Git
.GetCommitDiffList(rev1
,rev2
,*pGitList
);
186 pCtrlList
->m_Rev1
=rev1
;
187 pCtrlList
->m_Rev2
=rev2
;
188 pCtrlList
->Show(0,*pGitList
);
189 pCtrlList
->SetEmptyString(CString(_T("No changed file")));
194 void FetchComplete();
195 void StashComplete();
197 DECLARE_MESSAGE_MAP()
200 BOOL m_bAutoLoadPuttyKey
;
208 static UINT
ProgressThreadEntry(LPVOID pVoid
){ return ((CSyncDlg
*)pVoid
) ->ProgressThread(); };
209 UINT
ProgressThread();
211 CHistoryCombo m_ctrlURL
;
212 CButton m_ctrlDumyButton
;
213 CMenuButton m_ctrlPull
;
214 CMenuButton m_ctrlPush
;
215 CStatic m_ctrlStatus
;
216 CMenuButton m_ctrlSubmodule
;
217 CMenuButton m_ctrlStash
;
218 CProgressCtrl m_ctrlProgress
;
219 CAnimateCtrl m_ctrlAnimate
;
220 CStatic m_ctrlProgLabel
;
222 void EnableControlButton(bool bEnabled
=true);
223 afx_msg
void OnBnClickedButtonCommit();
229 afx_msg
void OnBnClickedButtonSubmodule();
230 afx_msg
void OnBnClickedButtonStash();
231 afx_msg
void OnLvnInLogListColumnClick(NMHDR
*pNMHDR
, LRESULT
*pResult
);
232 afx_msg
void OnBnClickedCheckForce();
233 afx_msg
void OnBnClickedLog();