Prepare release and bump version numbers to 2.2.0.0
[TortoiseGit.git] / src / TortoiseProc / RebaseDlg.h
blob8cb0ca5a3687f23d3f75fda3e9bb21e92acb3f00
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-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.
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 "Win7.h"
29 #include "ProjectProperties.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); // DDX/DDV support
69 virtual BOOL OnInitDialog();
70 DECLARE_MESSAGE_MAP()
71 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
72 virtual HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
73 LRESULT OnRebaseUpdateUI(WPARAM wParam, LPARAM lParam);
74 void DoSize(int delta);
75 void AddRebaseAnchor();
76 void RemoveAnchor();
78 void SetSplitterRange();
79 void SaveSplitterPos();
81 void LoadBranchInfo();
82 void FetchLogList();
83 void SetAllRebaseAction(int action);
84 void OnCancel();
86 CRect m_DlgOrigRect;
87 CRect m_CommitListOrigRect;
88 CString m_sStatusText;
89 bool m_bStatusWarning;
90 BOOL PreTranslateMessage(MSG* pMsg);
91 bool LogListHasFocus(HWND hwnd);
92 bool LogListHasMenuItem(int i);
94 CSciEdit m_wndOutputRebase;
95 void SetContinueButtonText();
96 void SetControlEnable();
97 void UpdateProgress();
98 void UpdateCurrentStatus();
99 void ListConflictFile();
100 int RunGitCmdRetryOrAbort(const CString& cmd);
101 int DoRebase();
102 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
103 void Refresh();
104 volatile LONG m_bThreadRunning;
105 int RebaseThread();
106 static UINT RebaseThreadEntry(LPVOID pVoid){return ((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();
121 CString GetRebaseModeName(int rebasemode);
123 CString m_SquashMessage;
124 struct SquashFirstMetaData
126 CString name;
127 CString email;
128 CTime time;
129 bool set = false;
131 SquashFirstMetaData()
132 : set(false)
136 SquashFirstMetaData(GitRev* rev)
137 : set(true)
139 name = rev->GetAuthorName();
140 email = rev->GetAuthorEmail();
141 time = rev->GetAuthorDate();
144 void Empty()
146 set = false;
147 name.Empty();
148 email.Empty();
149 time = 0;
152 CString GetAuthor() const
154 if (!set)
155 return CString();
156 CString temp;
157 temp.Format(L"%s <%s>", (LPCTSTR)name, (LPCTSTR)email);
158 return temp;
161 CString GetAsParam() const
163 if (!set)
164 return CString();
165 CString temp;
166 temp.Format(_T("--date=%s --author=\"%s\" "), (LPCTSTR)time.Format(_T("%Y-%m-%dT%H:%M:%S")), (LPCTSTR)GetAuthor());
167 return temp;
169 } m_SquashFirstMetaData;
171 int CheckNextCommitIsSquash();
172 int GetCurrentCommitID();
173 int FinishRebase();
174 void RewriteNotes();
176 CMenuButton m_PostButton;
178 afx_msg void OnBnClickedPickAll();
179 afx_msg void OnBnClickedSquashAll();
180 afx_msg void OnBnClickedEditAll();
181 afx_msg void OnBnClickedRebaseSplit();
182 afx_msg void OnSize(UINT nType, int cx, int cy);
183 afx_msg void OnCbnSelchangeBranch();
184 afx_msg void OnCbnSelchangeUpstream();
185 afx_msg void OnBnClickedContinue();
186 afx_msg void OnBnClickedAbort();
187 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
188 void FillLogMessageCtrl();
190 CProgressCtrl m_ProgressBar;
191 CStatic m_CtrlStatusText;
193 BOOL m_bForce;
194 BOOL m_bAddCherryPickedFrom;
195 BOOL m_bAutoSkipFailedCommit;
196 bool m_bRebaseAutoEnd;
198 public:
199 CStringArray m_PostButtonTexts;
200 CGitLogList m_CommitList;
202 CString m_Upstream;
203 CString m_Branch;
204 CString m_Onto;
206 BOOL m_IsCherryPick;
207 bool m_bRebaseAutoStart;
208 BOOL m_bPreserveMerges;
209 protected:
210 CSplitterControl m_wndSplitter;
211 CMFCTabCtrl m_ctrlTabCtrl;
212 CGitStatusListCtrl m_FileListCtrl;
213 CSciEdit m_LogMessageCtrl;
215 CHistoryCombo m_BranchCtrl;
216 CHistoryCombo m_UpstreamCtrl;
218 CMenuButton m_SplitAllOptions;
220 BOOL m_bSplitCommit;
222 REBASE_STAGE m_RebaseStage;
223 bool m_bFinishedRebase;
224 bool m_bStashed;
226 std::map<CGitHash, CGitHash> m_rewrittenCommitsMap;
227 std::vector<CGitHash> m_forRewrite;
228 std::map<CGitHash, GIT_REV_LIST> m_droppedCommitsMap;
229 std::vector<CGitHash> m_currentCommits;
231 void AddBranchToolTips(CHistoryCombo *pBranch);
232 void AddLogString(CString str);
233 int StartRebase();
234 int CheckRebaseCondition();
235 void CheckRestoreStash();
236 int m_CurrentRebaseIndex;
237 int StateAction();
238 int GoNext();
239 void ResetParentForSquash(const CString& commitMessage);
240 void CleanUpRebaseActiveFolder();
241 afx_msg void OnBnClickedButtonReverse();
242 afx_msg void OnBnClickedButtonBrowse();
243 afx_msg void OnBnClickedRebaseCheckForce();
244 afx_msg void OnBnClickedCheckCherryPickedFrom();
245 afx_msg void OnBnClickedRebasePostButton();
246 afx_msg void OnBnClickedSplitAllOptions();
247 afx_msg void OnBnClickedButtonUp2();
248 afx_msg void OnBnClickedButtonDown2();
249 afx_msg void OnHelp();
251 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
252 CComPtr<ITaskbarList3> m_pTaskbarList;
254 afx_msg LRESULT OnRebaseActionMessage(WPARAM wParam, LPARAM lParam);
255 afx_msg void OnBnClickedRebaseSplitCommit();
256 afx_msg void OnBnClickedButtonOnto();