1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2015 - 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 "GitStatusListCtrl.h"
24 #include "SplitterControl.h"
25 #include "HistoryCombo.h"
26 #include "GitLogList.h"
27 #include "MenuButton.h"
29 #include "ProjectProperties.h"
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
)
45 CRebaseDlg(CWnd
* pParent
= NULL
); // standard constructor
46 virtual ~CRebaseDlg();
49 enum { IDD
= IDD_REBASE
};
54 CHOOSE_COMMIT_PICK_MODE
,
62 REBASE_SQUASH_CONFLICT
,
68 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
69 virtual BOOL
OnInitDialog();
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();
78 void SetSplitterRange();
79 void SaveSplitterPos();
81 void LoadBranchInfo();
83 void SetAllRebaseAction(int action
);
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();
101 afx_msg LRESULT
OnGitStatusListCtrlNeedsRefresh(WPARAM
, LPARAM
);
103 volatile LONG m_bThreadRunning
;
105 static UINT
RebaseThreadEntry(LPVOID pVoid
){return ((CRebaseDlg
*)pVoid
)->RebaseThread();};
108 int IsCommitEmpty(const CGitHash
& hash
);
110 BOOL m_IsFastForward
;
112 CGitHash m_OrigBranchHash
;
113 CGitHash m_OrigUpstreamHash
;
114 CString m_OrigHEADBranch
;
115 CGitHash m_OrigHEADHash
;
117 ProjectProperties m_ProjectProperties
;
119 int VerifyNoConflict();
120 CString
GetRebaseModeName(int rebasemode
);
122 CString m_SquashMessage
;
123 CString m_SquashFirstMetaData
;
125 int CheckNextCommitIsSquash();
126 int GetCurrentCommitID();
129 CMenuButton m_PostButton
;
131 afx_msg
void OnBnClickedPickAll();
132 afx_msg
void OnBnClickedSquashAll();
133 afx_msg
void OnBnClickedEditAll();
134 afx_msg
void OnBnClickedRebaseSplit();
135 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
136 afx_msg
void OnCbnSelchangeBranch();
137 afx_msg
void OnCbnSelchangeUpstream();
138 afx_msg
void OnBnClickedContinue();
139 afx_msg
void OnBnClickedAbort();
140 afx_msg
void OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
141 void FillLogMessageCtrl();
143 CProgressCtrl m_ProgressBar
;
144 CStatic m_CtrlStatusText
;
147 BOOL m_bPreserveMerges
;
148 BOOL m_bAddCherryPickedFrom
;
149 BOOL m_bAutoSkipFailedCommit
;
152 CStringArray m_PostButtonTexts
;
153 CGitLogList m_CommitList
;
162 CSplitterControl m_wndSplitter
;
163 CMFCTabCtrl m_ctrlTabCtrl
;
164 CGitStatusListCtrl m_FileListCtrl
;
165 CSciEdit m_LogMessageCtrl
;
167 CHistoryCombo m_BranchCtrl
;
168 CHistoryCombo m_UpstreamCtrl
;
170 CMenuButton m_SplitAllOptions
;
174 REBASE_STAGE m_RebaseStage
;
175 bool m_bFinishedRebase
;
178 std::map
<CGitHash
, CGitHash
> rewrittenCommitsMap
;
179 std::vector
<CGitHash
> forRewrite
;
180 std::map
<CGitHash
, GIT_REV_LIST
> droppedCommitsMap
;
182 void AddBranchToolTips(CHistoryCombo
*pBranch
);
183 void AddLogString(CString str
);
185 int CheckRebaseCondition();
186 void CheckRestoreStash();
187 int m_CurrentRebaseIndex
;
190 void ResetParentForSquash(const CString
& commitMessage
);
191 afx_msg
void OnBnClickedButtonReverse();
192 afx_msg
void OnBnClickedButtonBrowse();
193 afx_msg
void OnBnClickedRebaseCheckForce();
194 afx_msg
void OnBnClickedCheckCherryPickedFrom();
195 afx_msg
void OnBnClickedRebasePostButton();
196 afx_msg
void OnBnClickedSplitAllOptions();
197 afx_msg
void OnBnClickedButtonUp2();
198 afx_msg
void OnBnClickedButtonDown2();
199 afx_msg
void OnHelp();
201 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
202 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
204 afx_msg LRESULT
OnRebaseActionMessage(WPARAM wParam
, LPARAM lParam
);
205 afx_msg
void OnBnClickedRebaseSplitCommit();
206 afx_msg
void OnBnClickedButtonOnto();