1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2012-2016 - 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.
21 #include "StandAloneDlg.h"
22 #include "HistoryCombo.h"
23 #include "MenuButton.h"
25 #include "BranchCombox.h"
26 #include "GitLoglist.h"
27 #include "GitProgressList.h"
28 #include "GitRefCompareList.h"
29 #include "SyncTabCtrl.h"
32 #define IDC_SYNC_TAB 0x1000000
34 #define IDC_CMD_LOG 0x1
35 #define IDC_IN_LOGLIST 0x2
36 #define IDC_IN_CHANGELIST 0x3
37 #define IDC_IN_CONFLICT 0x4
38 #define IDC_OUT_LOGLIST 0x5
39 #define IDC_OUT_CHANGELIST 0x6
40 #define IDC_CMD_GIT_PROG 0x7
41 #define IDC_REFLIST 0x8
45 class CSyncDlg
: public CResizableStandAloneDialog
,public CBranchCombox
47 DECLARE_DYNAMIC(CSyncDlg
)
50 CSyncDlg(CWnd
* pParent
= nullptr); // standard constructor
54 enum { IDD
= IDD_SYNC
};
56 enum { GIT_COMMAND_PUSH
,
59 GIT_COMMAND_FETCHANDREBASE
,
60 GIT_COMMAND_SUBMODULE
,
65 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
66 BRANCH_COMBOX_EVENT_HANDLE();
68 virtual BOOL
OnInitDialog();
69 afx_msg
void OnBnClickedButtonManage();
70 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
71 afx_msg
void OnCbnEditchangeComboboxex();
72 afx_msg
void OnBnClickedButtonPull();
73 afx_msg
void OnBnClickedButtonPush();
74 afx_msg
void OnBnClickedButtonApply();
75 afx_msg
void OnBnClickedButtonEmail();
76 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
77 afx_msg
void OnDestroy();
78 afx_msg LRESULT
OnThemeChanged();
80 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
81 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
85 CRegDWORD m_regPullButton
;
86 CRegDWORD m_regPushButton
;
87 CRegDWORD m_regSubmoduleButton
;
88 CRegDWORD m_regAutoLoadPutty
;
90 CSyncTabCtrl m_ctrlTabCtrl
;
94 CGitLogList m_OutLogList
;
95 CGitLogList m_InLogList
;
96 CGitProgressList m_GitProgressList
;
97 std::unique_ptr
<ProgressCommand
> progressCommand
;
99 CGitStatusListCtrl m_OutChangeFileList
;
100 CGitStatusListCtrl m_InChangeFileList
;
101 CGitStatusListCtrl m_ConflictFileList
;
103 CRichEditCtrl m_ctrlCmdOut
;
104 CGitRefCompareList m_refList
;
106 CTGitPathList m_arOutChangeList
;
107 CTGitPathList m_arInChangeList
;
109 int m_CmdOutCurrentPos
;
111 CWinThread
* m_pThread
;
113 volatile LONG m_bBlock
;
114 CGitGuardedByteArray m_Databuf
;
117 void ParserCmdOutput(char ch
);
119 virtual void LocalBranchChange(){FetchOutList();};
120 virtual void RemoteBranchChange(){};
122 void ShowTab(int windowid
)
124 this->m_ctrlTabCtrl
.ShowTab(windowid
-1);
125 this->m_ctrlTabCtrl
.SetActiveTab(windowid
-1);
128 void FetchOutList(bool force
=false);
132 void SetRemote(CString remote
)
134 if(!remote
.IsEmpty())
136 int index
=this->m_ctrlURL
.FindStringExact(0,remote
);
139 m_ctrlURL
.SetCurSel(index
);
142 this->m_ctrlURL
.AddString(remote
);
146 std::vector
<CString
> m_GitCmdList
;
148 volatile bool m_bAbort
;
150 ULONGLONG m_startTick
;
156 CString m_OutLocalBranch
;
157 CString m_OutRemoteBranch
;
160 CGitHash m_oldRemoteHash
;
161 MAP_HASH_NAME m_oldHashMap
;
162 MAP_HASH_NAME m_newHashMap
;
164 void ShowProgressCtrl(bool bShow
=true);
165 void ShowInputCtrl(bool bShow
=true);
166 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
167 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
169 LRESULT
OnProgressUpdateUI(WPARAM wParam
,LPARAM lParam
);
170 LRESULT
OnProgCmdFinish(WPARAM wParam
, LPARAM lParam
);
171 void FillNewRefMap();
172 void RunPostAction();
175 this->m_strLocalBranch
= this->m_ctrlLocalBranch
.GetString();
176 this->m_ctrlRemoteBranch
.GetWindowText(this->m_strRemoteBranch
);
177 this->m_ctrlURL
.GetWindowText(this->m_strURL
);
178 m_strRemoteBranch
=m_strRemoteBranch
.Trim();
181 void AddDiffFileList(CGitStatusListCtrl
*pCtrlList
, CTGitPathList
*pGitList
,
182 CString rev1
, CString rev2
)
184 g_Git
.GetCommitDiffList(rev1
,rev2
,*pGitList
);
185 pCtrlList
->m_Rev1
=rev1
;
186 pCtrlList
->m_Rev2
=rev2
;
187 pCtrlList
->Show(0,*pGitList
);
188 pCtrlList
->SetEmptyString(CString(MAKEINTRESOURCE(IDS_COMPAREREV_NODIFF
)));
192 void ShowInCommits(const CString
& friendname
);
194 void FetchComplete();
195 void StashComplete();
197 DECLARE_MESSAGE_MAP()
200 BOOL m_bAutoLoadPuttyKey
;
206 static UINT
ProgressThreadEntry(LPVOID pVoid
) { return reinterpret_cast<CSyncDlg
*>(pVoid
)->ProgressThread(); };
207 UINT
ProgressThread();
209 CHistoryCombo m_ctrlURL
;
210 CButton m_ctrlDumyButton
;
211 CMenuButton m_ctrlPull
;
212 CMenuButton m_ctrlPush
;
213 CStatic m_ctrlStatus
;
214 CMenuButton m_ctrlSubmodule
;
215 CMenuButton m_ctrlStash
;
216 CProgressCtrl m_ctrlProgress
;
217 CAnimateCtrl m_ctrlAnimate
;
218 CStatic m_ctrlProgLabel
;
221 void EnableControlButton(bool bEnabled
=true);
222 afx_msg
void OnBnClickedButtonCommit();
227 bool AskSetTrackedBranch();
229 afx_msg
void OnBnClickedButtonSubmodule();
230 afx_msg
void OnBnClickedButtonStash();
231 afx_msg
void OnBnClickedCheckForce();
232 afx_msg
void OnBnClickedLog();
233 afx_msg
void OnEnscrollLog();
234 afx_msg
void OnEnLinkLog(NMHDR
* pNMHDR
, LRESULT
* pResult
);
236 friend class CSyncTabCtrl
;