1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009, 2012-2020, 2023 - 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 void DoDataExchange(CDataExchange
* pDX
) override
; // DDX/DDV support
69 BRANCH_COMBOX_EVENT_HANDLE();
71 BOOL
OnInitDialog() override
;
72 afx_msg
void OnBnClickedButtonManage();
73 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 void SetTheme(bool bDark
) override
;
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
;
95 bool m_bInited
= false;
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
= 0;
116 CWinThread
* m_pThread
= nullptr;
118 volatile LONG m_bBlock
= 0;
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
= false;
155 bool m_bDone
= false;
156 ULONGLONG m_startTick
;
157 bool m_bWantToExit
= false;
159 int m_GitCmdStatus
= -1;
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 const CGitHash
& rev1
, const CGitHash
& rev2
)
190 g_Git
.GetCommitDiffList(rev1
.ToString(), rev2
.ToString(), *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
);
198 void ShowInCommits(const CString
& friendname
);
200 void FetchComplete();
201 void StashComplete();
203 DECLARE_MESSAGE_MAP()
206 BOOL m_bAutoLoadPuttyKey
;
212 static UINT
ProgressThreadEntry(LPVOID pVoid
) { return static_cast<CSyncDlg
*>(pVoid
)->ProgressThread(); };
213 UINT
ProgressThread();
215 void StartWorkerThread();
217 CHistoryCombo m_ctrlURL
;
218 CButton m_ctrlDumyButton
;
219 CMenuButton m_ctrlPull
;
220 CMenuButton m_ctrlPush
;
221 CStatic m_ctrlStatus
;
222 CMenuButton m_ctrlSubmodule
;
223 CMenuButton m_ctrlStash
;
224 CProgressCtrl m_ctrlProgress
;
225 CAnimateCtrl m_ctrlAnimate
;
226 CStatic m_ctrlProgLabel
;
227 int m_iPullRebase
= 0;
229 void EnableControlButton(bool bEnabled
=true);
230 afx_msg
void OnBnClickedButtonCommit();
232 void OnOK() override
;
233 void OnCancel() override
;
235 bool AskSetTrackedBranch();
237 afx_msg
void OnBnClickedButtonSubmodule();
238 afx_msg
void OnBnClickedButtonStash();
239 afx_msg
void OnBnClickedCheckForce();
240 afx_msg
void OnBnClickedLog();
241 afx_msg
void OnEnscrollLog();
242 afx_msg
void OnEnLinkLog(NMHDR
* pNMHDR
, LRESULT
* pResult
);
244 friend class CSyncTabCtrl
;