Provide (experimental) clang-format file
[TortoiseGit.git] / src / TortoiseProc / RebaseDlg.h
blob8fe5a89b540d0da3c0ac71fd74fa23205919cada
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2018 - 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.
20 #pragma once
21 #include "StandAloneDlg.h"
22 #include "GitStatusListCtrl.h"
23 #include "SciEdit.h"
24 #include "SplitterControl.h"
25 #include "HistoryCombo.h"
26 #include "GitLogList.h"
27 #include "MenuButton.h"
28 #include "ProjectProperties.h"
29 #include "AppUtils.h"
31 // CRebaseDlg dialog
32 #define IDC_REBASE_TAB 0x1000000
34 #define REBASE_TAB_CONFLICT 0
35 #define REBASE_TAB_MESSAGE 1
36 #define REBASE_TAB_LOG 2
38 #define MSG_REBASE_UPDATE_UI (WM_USER+151)
40 class CRebaseDlg : public CResizableStandAloneDialog
42 DECLARE_DYNAMIC(CRebaseDlg)
44 public:
45 CRebaseDlg(CWnd* pParent = nullptr); // standard constructor
46 virtual ~CRebaseDlg();
48 // Dialog Data
49 enum { IDD = IDD_REBASE };
51 enum REBASE_STAGE
53 CHOOSE_BRANCH,
54 CHOOSE_COMMIT_PICK_MODE,
55 REBASE_START,
56 REBASE_CONTINUE,
57 REBASE_ABORT,
58 REBASE_FINISH,
59 REBASE_CONFLICT,
60 REBASE_EDIT,
61 REBASE_SQUASH_EDIT,
62 REBASE_SQUASH_CONFLICT,
63 REBASE_DONE,
64 REBASE_ERROR,
67 protected:
68 virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
69 virtual BOOL OnInitDialog() override;
70 DECLARE_MESSAGE_MAP()
71 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) override;
72 afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
73 afx_msg LRESULT OnRebaseUpdateUI(WPARAM wParam, LPARAM lParam);
74 void DoSize(int delta);
75 void AddRebaseAnchor();
77 void SetSplitterRange();
78 void SaveSplitterPos();
80 void LoadBranchInfo();
81 void FetchLogList();
82 void SetAllRebaseAction(int action);
83 void OnCancel();
85 CRect m_DlgOrigRect;
86 CRect m_CommitListOrigRect;
87 CString m_sStatusText;
88 bool m_bStatusWarning;
89 virtual BOOL PreTranslateMessage(MSG* pMsg) override;
90 bool LogListHasFocus(HWND hwnd);
91 bool LogListHasMenuItem(int i);
93 CSciEdit m_wndOutputRebase;
94 void SetContinueButtonText();
95 void SetControlEnable();
96 void UpdateProgress();
97 void UpdateCurrentStatus();
98 void ListConflictFile(bool noStoreScrollPosition);
99 int RunGitCmdRetryOrAbort(const CString& cmd);
100 int DoRebase();
101 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
102 void Refresh();
103 volatile LONG m_bThreadRunning;
104 volatile LONG m_bAbort;
105 int RebaseThread();
106 static UINT RebaseThreadEntry(LPVOID pVoid) { return reinterpret_cast<CRebaseDlg*>(pVoid)->RebaseThread(); };
107 BOOL IsEnd();
109 int IsCommitEmpty(const CGitHash& hash);
111 BOOL m_IsFastForward;
113 CGitHash m_OrigBranchHash;
114 CGitHash m_OrigUpstreamHash;
115 CString m_OrigHEADBranch;
116 CGitHash m_OrigHEADHash;
118 ProjectProperties m_ProjectProperties;
120 int VerifyNoConflict();
122 CString m_SquashMessage;
123 struct SquashFirstMetaData
125 CString name;
126 CString email;
127 CTime time;
128 bool set = false;
130 SquashFirstMetaData()
131 : set(false)
135 SquashFirstMetaData(GitRev* rev)
136 : set(true)
138 name = rev->GetAuthorName();
139 email = rev->GetAuthorEmail();
140 time = rev->GetAuthorDate();
143 void UpdateDate(GitRev* rev)
145 ATLASSERT(set);
146 time = rev->GetAuthorDate();
149 void Empty()
151 set = false;
152 name.Empty();
153 email.Empty();
154 time = 0;
157 CString GetAuthor() const
159 if (!set)
160 return CString();
161 CString temp;
162 temp.Format(L"%s <%s>", (LPCTSTR)name, (LPCTSTR)email);
163 return temp;
166 CString GetAsParam(bool now) const
168 if (!set)
169 return CString();
171 CString date = time.Format(L"%Y-%m-%dT%H:%M:%S");
172 if (now)
173 date = L"\"now\"";
175 CString temp;
176 temp.Format(L"--date=%s --author=\"%s\" ", (LPCTSTR)date, (LPCTSTR)GetAuthor());
177 return temp;
179 } m_SquashFirstMetaData;
180 int m_iSquashdate;
182 int CheckNextCommitIsSquash();
183 int GetCurrentCommitID();
184 int FinishRebase();
185 void RewriteNotes();
187 CMenuButton m_PostButton;
189 afx_msg void OnBnClickedRebaseSplit();
190 afx_msg void OnSize(UINT nType, int cx, int cy);
191 afx_msg void OnCbnSelchangeBranch();
192 afx_msg void OnCbnSelchangeUpstream();
193 afx_msg void OnBnClickedContinue();
194 afx_msg void OnBnClickedAbort();
195 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
196 afx_msg void OnSysColorChange();
197 afx_msg LRESULT OnThemeChanged();
198 void FillLogMessageCtrl();
200 CProgressCtrl m_ProgressBar;
201 CStatic m_CtrlStatusText;
203 BOOL m_bForce;
204 BOOL m_bAddCherryPickedFrom;
205 BOOL m_bAutoSkipFailedCommit;
206 bool m_bRebaseAutoEnd;
208 public:
209 CStringArray m_PostButtonTexts;
210 CGitLogList m_CommitList;
212 CString m_Upstream;
213 CString m_Branch;
214 CString m_Onto;
216 BOOL m_IsCherryPick;
217 bool m_bRebaseAutoStart;
218 BOOL m_bPreserveMerges;
219 protected:
220 CSplitterControl m_wndSplitter;
221 CMFCTabCtrl m_ctrlTabCtrl;
222 CGitStatusListCtrl m_FileListCtrl;
223 CSciEdit m_LogMessageCtrl;
225 CHistoryCombo m_BranchCtrl;
226 CHistoryCombo m_UpstreamCtrl;
228 CMenuButton m_SplitAllOptions;
230 BOOL m_bSplitCommit;
232 REBASE_STAGE m_RebaseStage;
233 bool m_bFinishedRebase;
234 bool m_bStashed;
236 std::unordered_map<CGitHash, CGitHash> m_rewrittenCommitsMap;
237 std::vector<CGitHash> m_forRewrite;
238 std::unordered_map<CGitHash, GIT_REV_LIST> m_droppedCommitsMap;
239 std::vector<CGitHash> m_currentCommits;
241 void AddBranchToolTips(CHistoryCombo *pBranch);
242 void AddLogString(CString str);
243 int StartRebase();
244 int CheckRebaseCondition();
245 void CheckRestoreStash();
246 int m_CurrentRebaseIndex;
247 int GoNext();
248 void ResetParentForSquash(const CString& commitMessage);
249 void CleanUpRebaseActiveFolder();
250 afx_msg void OnBnClickedButtonReverse();
251 afx_msg void OnBnClickedButtonBrowse();
252 afx_msg void OnBnClickedRebaseCheckForce();
253 afx_msg void OnBnClickedCheckCherryPickedFrom();
254 afx_msg void OnBnClickedRebasePostButton();
255 afx_msg void OnBnClickedSplitAllOptions();
256 afx_msg void OnBnClickedButtonUp();
257 afx_msg void OnBnClickedButtonDown();
258 afx_msg void OnHelp();
260 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
261 CComPtr<ITaskbarList3> m_pTaskbarList;
263 afx_msg LRESULT OnRebaseActionMessage(WPARAM wParam, LPARAM lParam);
264 afx_msg LRESULT OnCommitsReordered(WPARAM wParam, LPARAM lParam);
265 afx_msg void OnBnClickedRebaseSplitCommit();
266 afx_msg void OnBnClickedButtonOnto();
267 afx_msg void OnBnClickedButtonAdd();