1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2012 - 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 SetFilter(const CString
& findstr
, LONG findtype
, bool findregex
);
91 void SetIncludeMerge(bool bInclude
= true) {m_bIncludeMerges
= bInclude
;}
92 bool IsThreadRunning() {return !!m_LogList
.m_bThreadRunning
;}
93 void SetDialogTitle(const CString
& sTitle
) {m_sTitle
= sTitle
;}
94 void SetSelect(bool bSelect
) {m_bSelect
= bSelect
;}
95 void ContinuousSelection(bool bCont
= true) {m_bSelectionMustBeContinuous
= bCont
;}
96 void SingleSelection(bool bSingle
= true) {m_bSelectionMustBeSingle
= bSingle
;}
97 void SetMergePath(const CTGitPath
& mergepath
) {m_mergePath
= mergepath
;}
98 void SetStartRef(const CString
& StartRef
);
100 afx_msg LRESULT
OnRefLogChanged(WPARAM wParam
, LPARAM lParam
);
102 * Provides selected commit hash if available, call after OK return from here
105 CString
GetSelectedHash(){ return m_sSelectedHash
; }
107 // const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}
110 enum { IDD
= IDD_LOGMESSAGE
};
112 void FillLogMessageCtrl(bool bShow
= true);
113 CString
GetTagInfo(GitRev
* pLogEntry
);
115 void UpdateLogInfoLabel();
117 afx_msg
void OnFind()
122 //implement the virtual methods from Git base class
123 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
);
124 virtual BOOL
Cancel();
125 virtual bool Validate(LPCTSTR string
);
127 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
129 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
130 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
132 afx_msg LRESULT
OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
);
133 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
134 afx_msg LRESULT
OnLogListLoading(WPARAM wParam
, LPARAM lParam
);
136 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
137 afx_msg
void OnContextMenu(CWnd
* pWnd
, CPoint point
);
138 afx_msg
void OnBnClickedGetall();
139 afx_msg
void OnNMDblclkChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
140 afx_msg
void OnNMDblclkLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
141 afx_msg
void OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
142 afx_msg
void OnBnClickedHelp();
143 afx_msg
void OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
);
144 afx_msg
void OnBnClickedStatbutton();
146 afx_msg
void OnNMCustomdrawChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
147 afx_msg
void OnLvnGetdispinfoChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
148 afx_msg
void OnEnChangeSearchedit();
149 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
150 afx_msg
void OnDtnDatetimechangeDateto(NMHDR
*pNMHDR
, LRESULT
*pResult
);
151 afx_msg
void OnDtnDatetimechangeDatefrom(NMHDR
*pNMHDR
, LRESULT
*pResult
);
152 afx_msg
void OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
);
153 afx_msg
void OnLvnColumnclickChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
154 afx_msg
void OnBnClickShowWholeProject();
155 afx_msg
void OnBnClickedHidepaths();
156 afx_msg
void OnBnClickedAllBranch();
157 afx_msg
void OnBnClickedFollowRenames();
158 afx_msg
void OnBnClickedBrowseRef();
159 afx_msg
void OnBnClickedCheckStoponcopy();
161 afx_msg
void OnDtnDropdownDatefrom(NMHDR
*pNMHDR
, LRESULT
*pResult
);
162 afx_msg
void OnDtnDropdownDateto(NMHDR
*pNMHDR
, LRESULT
*pResult
);
163 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
164 afx_msg
void OnBnClickedFirstParent();
165 afx_msg
void OnBnClickedRefresh();
166 afx_msg
void OnRefresh();
167 afx_msg
void OnFocusFilter();
168 afx_msg
void OnEditCopy();
170 virtual void OnCancel();
172 virtual BOOL
OnInitDialog();
173 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
175 void DoDiffFromLog(INT_PTR selIndex
, GitRev
*rev1
, GitRev
*rev2
, bool blame
, bool unified
);
177 static void LogCallBack(void *data
, int cur
){((CLogDlg
*)data
)->LogRunStatus(cur
);}
178 void LogRunStatus(int cur
);
180 DECLARE_MESSAGE_MAP()
183 CRegDWORD m_regbAllBranch
;
185 void Refresh (bool clearfilter
= false);
186 BOOL
IsDiffPossible(LogChangedPath
* changedpath
, git_revnum_t rev
);
187 BOOL
Open(bool bOpenWith
, CString changedpath
, git_revnum_t rev
);
188 void EditAuthor(const CLogDataVector
& logs
);
189 void EditLogMessage(int index
);
190 void DoSizeV1(int delta
);
191 void DoSizeV2(int delta
);
192 void AdjustMinSize();
193 void SetSplitterRange();
194 void SetFilterCueText();
196 void CopySelectionToClipBoard();
197 void CopyChangedSelectionToClipBoard();
198 CTGitPathList
GetChangedPathsFromSelectedRevisions(bool bRelativePaths
= false, bool bUseFilter
= true);
199 void SortShownListArray();
201 void SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
);
202 void SortByColumn(int nSortColumn
, bool bAscending
);
204 void EnableOKButton();
205 void GetAll(bool bIsShowProjectOrBranch
= false);
207 void SaveSplitterPos();
208 bool ValidateRegexp(LPCTSTR regexp_str
, tr1::wregex
& pat
, bool bMatchCase
);
209 void CheckRegexpTooltip();
210 void GetChangedPaths(std::vector
<CString
>& changedpaths
, std::vector
<LogChangedPath
*>& changedlogpaths
);
211 void DiffSelectedFile();
212 void DiffSelectedRevWithPrevious();
214 CString
GetAbsoluteUrlFromRelativeUrl(const CString
& url
);
217 * Extracts part of commit message suitable for displaying in revision list.
219 CString
MakeShortMessage(const CString
& message
);
220 // inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }
223 virtual LRESULT
DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
);
224 static int __cdecl
SortCompare(const void * pElem1
, const void * pElem2
); ///< sort callback function
226 void ShowContextMenuForRevisions(CWnd
* pWnd
, CPoint point
);
227 void ShowContextMenuForChangedpaths(CWnd
* pWnd
, CPoint point
);
229 CWnd
* m_pNotifyWindow
;
233 CString m_sRelativeRoot
;
234 CString m_sRepositoryRoot
;
235 CString m_sSelfRelativeURL
;
237 CString m_sUUID
; ///< empty if the log cache is not used
238 CGitLogList m_LogList
;
239 CGitStatusListCtrl m_ChangedFileListCtrl
;
240 CFilterEdit m_cFilter
;
241 CHyperLink m_staticRef
;
242 CProgressCtrl m_LogProgress
;
243 CMenuButton m_btnShow
;
244 CMenuButton m_btnShowWholeProject
;
247 CTGitPath m_mergePath
;
248 CString m_hightlightRevision
;
250 CString m_LogRevision
;
253 // GitRevRangeArray m_selectedRevs;
254 // GitRevRangeArray m_selectedRevsOneRange;
255 CString m_sSelectedHash
; // set to selected commit hash on OK if appropriate
256 bool m_bSelectionMustBeContinuous
;
257 bool m_bSelectionMustBeSingle
;
261 BOOL m_bIncludeMerges
;
264 BOOL m_bWholeProject
;
265 BOOL m_bFollowRenames
;
267 git_revnum_t m_lowestRev
;
268 CTGitPathList
* m_currentChangedArray
;
269 LogChangedPathArray m_CurrentFilteredChangedArray
;
270 CTGitPathList m_currentChangedPathList
;
271 //CPtrArray m_arShownList;
274 bool m_bFilterWithRegex
;
278 CString m_sMessageBuf
;
279 CSplitterControl m_wndSplitter1
;
280 CSplitterControl m_wndSplitter2
;
282 CRect m_MsgViewOrigRect
;
283 CRect m_LogListOrigRect
;
285 // CString m_sFilterText;
287 //volatile LONG m_bNoDispUpdates;
288 CDateTimeCtrl m_DateFrom
;
289 CDateTimeCtrl m_DateTo
;
294 static int m_nSortColumnPathList
;
295 static bool m_bAscendingPathList
;
296 CButton m_cHidePaths
;
300 //bool m_bShowBugtraqColumn;
302 std::set
<git_revnum_t
> m_mergedRevs
;
304 CToolTips m_tooltips
;
307 CImageList m_imgList
;
309 HICON m_hModifiedIcon
;
310 HICON m_hReplacedIcon
;
312 HICON m_hDeletedIcon
;
315 DWORD m_childCounter
;
321 static UINT WM_REVSELECTED
= RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
322 static UINT WM_REVLIST
= RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
323 static UINT WM_REVLISTONERANGE
= RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));