1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009, 2012-2019 - 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 "GitTagCompareList.h"
30 #include "SyncTabCtrl.h"
31 #include "GestureEnabledControl.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
44 #define IDC_TAGCOMPARELIST 0x9
48 class CSyncDlg
: public CResizableStandAloneDialog
,public CBranchCombox
50 DECLARE_DYNAMIC(CSyncDlg
)
53 CSyncDlg(CWnd
* pParent
= nullptr); // standard constructor
57 enum { IDD
= IDD_SYNC
};
59 enum { GIT_COMMAND_PUSH
,
62 GIT_COMMAND_FETCHANDREBASE
,
63 GIT_COMMAND_SUBMODULE
,
68 virtual void DoDataExchange(CDataExchange
* pDX
) override
; // DDX/DDV support
69 BRANCH_COMBOX_EVENT_HANDLE();
71 virtual BOOL
OnInitDialog() override
;
72 afx_msg
void OnBnClickedButtonManage();
73 virtual BOOL
PreTranslateMessage(MSG
* pMsg
) override
;
74 afx_msg
void OnCbnEditchangeComboboxex();
75 afx_msg
void OnBnClickedButtonPull();
76 afx_msg
void OnBnClickedButtonPush();
77 afx_msg
void OnBnClickedButtonApply();
78 afx_msg
void OnBnClickedButtonEmail();
79 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
80 afx_msg
void OnDestroy();
81 afx_msg LRESULT
OnThemeChanged();
83 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
84 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
88 CRegDWORD m_regPullButton
;
89 CRegDWORD m_regPushButton
;
90 CRegDWORD m_regSubmoduleButton
;
91 CRegDWORD m_regAutoLoadPutty
;
93 CSyncTabCtrl m_ctrlTabCtrl
;
97 CGitLogList m_OutLogList
;
98 CGitLogList m_InLogList
;
99 CGitProgressList m_GitProgressList
;
100 std::unique_ptr
<ProgressCommand
> progressCommand
;
102 CGitStatusListCtrl m_OutChangeFileList
;
103 CGitStatusListCtrl m_InChangeFileList
;
104 CGitStatusListCtrl m_ConflictFileList
;
105 ProjectProperties m_ProjectProperties
;
107 CGestureEnabledControlTmpl
<CRichEditCtrl
> m_ctrlCmdOut
;
108 CGitRefCompareList m_refList
;
109 CGitTagCompareList m_tagCompareList
;
111 CTGitPathList m_arOutChangeList
;
112 CTGitPathList m_arInChangeList
;
114 int m_CmdOutCurrentPos
;
116 CWinThread
* m_pThread
;
118 volatile LONG m_bBlock
;
119 CGitGuardedByteArray m_Databuf
;
122 void ParserCmdOutput(char ch
);
124 virtual void LocalBranchChange() override
{ FetchOutList(); };
125 virtual void RemoteBranchChange() override
{};
127 void ShowTab(int windowid
)
129 this->m_ctrlTabCtrl
.ShowTab(windowid
-1);
130 this->m_ctrlTabCtrl
.SetActiveTab(windowid
-1);
133 void FetchOutList(bool force
=false);
137 virtual void SetRemote(CString remote
) override
139 if(!remote
.IsEmpty())
141 int index
=this->m_ctrlURL
.FindStringExact(0,remote
);
144 m_ctrlURL
.SetCurSel(index
);
147 this->m_ctrlURL
.AddString(remote
);
151 std::vector
<CString
> m_GitCmdList
;
152 STRING_VECTOR m_remotelist
;
154 volatile bool m_bAbort
;
156 ULONGLONG m_startTick
;
162 CString m_OutLocalBranch
;
163 CString m_OutRemoteBranch
;
166 CGitHash m_oldRemoteHash
;
167 MAP_HASH_NAME m_oldHashMap
;
168 MAP_HASH_NAME m_newHashMap
;
170 void ShowProgressCtrl(bool bShow
=true);
171 void ShowInputCtrl(bool bShow
=true);
172 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
173 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
175 LRESULT
OnProgressUpdateUI(WPARAM wParam
,LPARAM lParam
);
176 LRESULT
OnProgCmdFinish(WPARAM wParam
, LPARAM lParam
);
177 void FillNewRefMap();
178 void RunPostAction();
181 this->m_strLocalBranch
= this->m_ctrlLocalBranch
.GetString();
182 this->m_ctrlRemoteBranch
.GetWindowText(this->m_strRemoteBranch
);
183 this->m_ctrlURL
.GetWindowText(this->m_strURL
);
184 m_strRemoteBranch
=m_strRemoteBranch
.Trim();
187 void AddDiffFileList(CGitStatusListCtrl
*pCtrlList
, CTGitPathList
*pGitList
,
188 CString rev1
, CString rev2
)
190 g_Git
.GetCommitDiffList(rev1
,rev2
,*pGitList
);
191 pCtrlList
->m_Rev1
=rev1
;
192 pCtrlList
->m_Rev2
=rev2
;
193 pCtrlList
->SetEmptyString(CString(MAKEINTRESOURCE(IDS_COMPAREREV_NODIFF
)));
194 pCtrlList
->UpdateWithGitPathList(*pGitList
);
195 pCtrlList
->Show(GITSLC_SHOWALL
);
199 void ShowInCommits(const CString
& friendname
);
201 void FetchComplete();
202 void StashComplete();
204 DECLARE_MESSAGE_MAP()
207 BOOL m_bAutoLoadPuttyKey
;
213 static UINT
ProgressThreadEntry(LPVOID pVoid
) { return reinterpret_cast<CSyncDlg
*>(pVoid
)->ProgressThread(); };
214 UINT
ProgressThread();
216 void StartWorkerThread();
218 CHistoryCombo m_ctrlURL
;
219 CButton m_ctrlDumyButton
;
220 CMenuButton m_ctrlPull
;
221 CMenuButton m_ctrlPush
;
222 CStatic m_ctrlStatus
;
223 CMenuButton m_ctrlSubmodule
;
224 CMenuButton m_ctrlStash
;
225 CProgressCtrl m_ctrlProgress
;
226 CAnimateCtrl m_ctrlAnimate
;
227 CStatic m_ctrlProgLabel
;
230 void EnableControlButton(bool bEnabled
=true);
231 afx_msg
void OnBnClickedButtonCommit();
233 virtual void OnOK() override
;
234 virtual void OnCancel() override
;
236 bool AskSetTrackedBranch();
238 afx_msg
void OnBnClickedButtonSubmodule();
239 afx_msg
void OnBnClickedButtonStash();
240 afx_msg
void OnBnClickedCheckForce();
241 afx_msg
void OnBnClickedLog();
242 afx_msg
void OnEnscrollLog();
243 afx_msg
void OnEnLinkLog(NMHDR
* pNMHDR
, LRESULT
* pResult
);
245 friend class CSyncTabCtrl
;