1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2011 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "ProjectProperties.h"
25 #include "StandAloneDlg.h"
28 #include "SplitterControl.h"
30 #include "MenuButton.h"
31 #include "LogDlgHelper.h"
32 #include "FilterEdit.h"
35 #include "HintListCtrl.h"
37 #include "GitLogList.h"
38 #include "GitStatusListCtrl.h"
39 #include "HyperLink.h"
45 #define MERGE_REVSELECTSTART 1
46 #define MERGE_REVSELECTEND 2
47 #define MERGE_REVSELECTSTARTEND 3 ///< both
48 #define MERGE_REVSELECTMINUSONE 4 ///< first with N-1
51 #define LOGFILTER_TIMER 101
52 #define LOGFTIME_TIMER 102
54 typedef int (__cdecl
*GENERICCOMPAREFN
)(const void * elem1
, const void * elem2
);
57 * \ingroup TortoiseProc
58 * Shows log messages of a single file or folder in a listbox.
60 class CLogDlg
: public CResizableStandAloneDialog
, IFilterEditValidator
62 DECLARE_DYNAMIC(CLogDlg
)
64 friend class CStoreSelection
;
67 CLogDlg(CWnd
* pParent
= NULL
); // standard constructor
78 LOGLIST_MESSAGE_MAX
=250
89 void SetParams(const CTGitPath
& orgPath
, const CTGitPath
& path
, CString hightlightRevision
, CString startrev
, CString endrev
, int limit
);
90 void SetIncludeMerge(bool bInclude
= true) {m_bIncludeMerges
= bInclude
;}
91 bool IsThreadRunning() {return !!m_LogList
.m_bThreadRunning
;}
92 void SetDialogTitle(const CString
& sTitle
) {m_sTitle
= sTitle
;}
93 void SetSelect(bool bSelect
) {m_bSelect
= bSelect
;}
94 void ContinuousSelection(bool bCont
= true) {m_bSelectionMustBeContinuous
= bCont
;}
95 void SingleSelection(bool bSingle
= true) {m_bSelectionMustBeSingle
= bSingle
;}
96 void SetMergePath(const CTGitPath
& mergepath
) {m_mergePath
= mergepath
;}
97 void SetStartRef(const CString
& StartRef
);
99 afx_msg LRESULT
OnRefLogChanged(WPARAM wParam
, LPARAM lParam
);
101 * Provides selected commit hash if available, call after OK return from here
104 CString
GetSelectedHash(){ return m_sSelectedHash
; }
106 // const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}
109 enum { IDD
= IDD_LOGMESSAGE
};
111 void FillLogMessageCtrl(bool bShow
= true);
112 CString
GetTagInfo(GitRev
* pLogEntry
);
114 void UpdateLogInfoLabel();
116 afx_msg
void OnFind()
121 //implement the virtual methods from Git base class
122 virtual BOOL
Log(git_revnum_t rev
, const CString
& author
, const CString
& date
, const CString
& message
, LogChangedPathArray
* cpaths
, int filechanges
, BOOL copies
, DWORD actions
, BOOL haschildren
);
123 virtual BOOL
Cancel();
124 virtual bool Validate(LPCTSTR string
);
126 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
128 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
129 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
131 afx_msg LRESULT
OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
);
132 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
133 afx_msg LRESULT
OnLogListLoading(WPARAM wParam
, LPARAM lParam
);
135 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
136 afx_msg
void OnContextMenu(CWnd
* pWnd
, CPoint point
);
137 afx_msg
void OnBnClickedGetall();
138 afx_msg
void OnNMDblclkChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
139 afx_msg
void OnNMDblclkLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
140 afx_msg
void OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
141 afx_msg
void OnBnClickedHelp();
142 afx_msg
void OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
);
143 afx_msg
void OnBnClickedStatbutton();
145 afx_msg
void OnNMCustomdrawChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
146 afx_msg
void OnLvnGetdispinfoChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
147 afx_msg
void OnEnChangeSearchedit();
148 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
149 afx_msg
void OnDtnDatetimechangeDateto(NMHDR
*pNMHDR
, LRESULT
*pResult
);
150 afx_msg
void OnDtnDatetimechangeDatefrom(NMHDR
*pNMHDR
, LRESULT
*pResult
);
151 afx_msg
void OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
);
152 afx_msg
void OnLvnColumnclickChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
153 afx_msg
void OnBnClickShowWholeProject();
154 afx_msg
void OnBnClickedHidepaths();
155 afx_msg
void OnBnClickedAllBranch();
156 afx_msg
void OnBnClickedBrowseRef();
157 afx_msg
void OnBnClickedCheckStoponcopy();
159 afx_msg
void OnDtnDropdownDatefrom(NMHDR
*pNMHDR
, LRESULT
*pResult
);
160 afx_msg
void OnDtnDropdownDateto(NMHDR
*pNMHDR
, LRESULT
*pResult
);
161 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
162 afx_msg
void OnBnClickedFirstParent();
163 afx_msg
void OnBnClickedRefresh();
164 afx_msg
void OnRefresh();
165 afx_msg
void OnFocusFilter();
166 afx_msg
void OnEditCopy();
168 virtual void OnCancel();
170 virtual BOOL
OnInitDialog();
171 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
173 void DoDiffFromLog(INT_PTR selIndex
, GitRev
*rev1
, GitRev
*rev2
, bool blame
, bool unified
);
175 static void LogCallBack(void *data
, int cur
){((CLogDlg
*)data
)->LogRunStatus(cur
);}
176 void LogRunStatus(int cur
);
178 DECLARE_MESSAGE_MAP()
181 CRegDWORD m_regbAllBranch
;
183 void Refresh (bool clearfilter
= false);
184 BOOL
IsDiffPossible(LogChangedPath
* changedpath
, git_revnum_t rev
);
185 BOOL
Open(bool bOpenWith
, CString changedpath
, git_revnum_t rev
);
186 void EditAuthor(const CLogDataVector
& logs
);
187 void EditLogMessage(int index
);
188 void DoSizeV1(int delta
);
189 void DoSizeV2(int delta
);
190 void AdjustMinSize();
191 void SetSplitterRange();
192 void SetFilterCueText();
194 void CopySelectionToClipBoard();
195 void CopyChangedSelectionToClipBoard();
196 CTGitPathList
GetChangedPathsFromSelectedRevisions(bool bRelativePaths
= false, bool bUseFilter
= true);
197 void SortShownListArray();
199 void SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
);
200 void SortByColumn(int nSortColumn
, bool bAscending
);
202 void EnableOKButton();
203 void GetAll(bool bIsShowProjectOrBranch
= false);
205 void SaveSplitterPos();
206 bool ValidateRegexp(LPCTSTR regexp_str
, tr1::wregex
& pat
, bool bMatchCase
);
207 void CheckRegexpTooltip();
208 void GetChangedPaths(std::vector
<CString
>& changedpaths
, std::vector
<LogChangedPath
*>& changedlogpaths
);
209 void DiffSelectedFile();
210 void DiffSelectedRevWithPrevious();
212 CString
GetAbsoluteUrlFromRelativeUrl(const CString
& url
);
215 * Extracts part of commit message suitable for displaying in revision list.
217 CString
MakeShortMessage(const CString
& message
);
218 // inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }
221 virtual LRESULT
DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
);
222 static int __cdecl
SortCompare(const void * pElem1
, const void * pElem2
); ///< sort callback function
224 void ShowContextMenuForRevisions(CWnd
* pWnd
, CPoint point
);
225 void ShowContextMenuForChangedpaths(CWnd
* pWnd
, CPoint point
);
227 CWnd
* m_pNotifyWindow
;
231 CString m_sRelativeRoot
;
232 CString m_sRepositoryRoot
;
233 CString m_sSelfRelativeURL
;
235 CString m_sUUID
; ///< empty if the log cache is not used
236 CGitLogList m_LogList
;
237 CGitStatusListCtrl m_ChangedFileListCtrl
;
238 CFilterEdit m_cFilter
;
239 CHyperLink m_staticRef
;
240 CProgressCtrl m_LogProgress
;
241 CMenuButton m_btnShow
;
242 CMenuButton m_btnShowWholeProject
;
245 CTGitPath m_mergePath
;
246 CString m_hightlightRevision
;
248 CString m_LogRevision
;
251 // GitRevRangeArray m_selectedRevs;
252 // GitRevRangeArray m_selectedRevsOneRange;
253 CString m_sSelectedHash
; // set to selected commit hash on OK if appropriate
254 bool m_bSelectionMustBeContinuous
;
255 bool m_bSelectionMustBeSingle
;
259 BOOL m_bIncludeMerges
;
262 BOOL m_bWholeProject
;
264 git_revnum_t m_lowestRev
;
265 CTGitPathList
* m_currentChangedArray
;
266 LogChangedPathArray m_CurrentFilteredChangedArray
;
267 CTGitPathList m_currentChangedPathList
;
268 //CPtrArray m_arShownList;
271 bool m_bFilterWithRegex
;
275 CString m_sMessageBuf
;
276 CSplitterControl m_wndSplitter1
;
277 CSplitterControl m_wndSplitter2
;
279 CRect m_MsgViewOrigRect
;
280 CRect m_LogListOrigRect
;
282 // CString m_sFilterText;
284 //volatile LONG m_bNoDispUpdates;
285 CDateTimeCtrl m_DateFrom
;
286 CDateTimeCtrl m_DateTo
;
291 static int m_nSortColumnPathList
;
292 static bool m_bAscendingPathList
;
293 CButton m_cHidePaths
;
297 //bool m_bShowBugtraqColumn;
299 std::set
<git_revnum_t
> m_mergedRevs
;
301 CToolTips m_tooltips
;
304 CImageList m_imgList
;
306 HICON m_hModifiedIcon
;
307 HICON m_hReplacedIcon
;
309 HICON m_hDeletedIcon
;
312 DWORD m_childCounter
;
318 static UINT WM_REVSELECTED
= RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
319 static UINT WM_REVLIST
= RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
320 static UINT WM_REVLISTONERANGE
= RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));