Add support for "project" config level
[TortoiseGit.git] / src / TortoiseProc / LogDlg.cpp
blob46bb55d6d86efe3f47c560ed9d7bdf635bf06bd8
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2013 - 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.
20 #include "stdafx.h"
21 #include "TortoiseProc.h"
22 #include "cursor.h"
23 #include "StatGraphDlg.h"
24 #include "LogDlg.h"
25 #include "MessageBox.h"
26 #include "registry.h"
27 #include "AppUtils.h"
28 #include "PathUtils.h"
29 #include "StringUtils.h"
30 #include "UnicodeUtils.h"
31 #include "TempFile.h"
32 #include "IconMenu.h"
33 #include "BrowseRefsDlg.h"
34 #include "SmartHandle.h"
35 #include "LogOrdering.h"
37 IMPLEMENT_DYNAMIC(CLogDlg, CResizableStandAloneDialog)
38 CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)
39 : CResizableStandAloneDialog(CLogDlg::IDD, pParent)
40 , m_wParam(0)
41 , m_currentChangedArray(NULL)
42 , m_nSortColumn(0)
43 , m_bFollowRenames(FALSE)
44 , m_bSelect(false)
45 , m_bSelectionMustBeSingle(true)
46 , m_bShowTags(TRUE)
48 , m_bSelectionMustBeContinuous(false)
50 , m_sLogInfo(_T(""))
52 , m_bCancelled(FALSE)
53 , m_pNotifyWindow(NULL)
55 , m_bAscending(FALSE)
57 , m_limit(0)
58 , m_hAccel(NULL)
60 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
62 CString str;
63 str=g_Git.m_CurrentDir;
64 str.Replace(_T(":"),_T("_"));
65 str=CString(_T("Software\\TortoiseGit\\LogDialog\\AllBranch\\"))+str;
67 m_regbAllBranch=CRegDWORD(str,FALSE);
69 m_bAllBranch=m_regbAllBranch;
71 str = g_Git.m_CurrentDir;
72 str.Replace(_T(":"),_T("_"));
73 str = CString(_T("Software\\TortoiseGit\\LogDialog\\ShowTags\\")) + str;
74 m_regbShowTags = CRegDWORD(str, TRUE);
75 m_bShowTags = m_regbShowTags;
77 m_bFirstParent=FALSE;
78 m_bWholeProject=FALSE;
80 m_bShowUnversioned = CRegDWORD(_T("Software\\TortoiseGit\\AddBeforeCommit"), TRUE);
83 CLogDlg::~CLogDlg()
86 m_regbAllBranch=m_bAllBranch;
87 m_regbShowTags = m_bShowTags;
89 m_CurrentFilteredChangedArray.RemoveAll();
93 void CLogDlg::DoDataExchange(CDataExchange* pDX)
95 CResizableStandAloneDialog::DoDataExchange(pDX);
96 DDX_Control(pDX, IDC_LOGLIST, m_LogList);
97 DDX_Control(pDX, IDC_LOGMSG, m_ChangedFileListCtrl);
98 DDX_Control(pDX, IDC_PROGRESS, m_LogProgress);
99 DDX_Control(pDX, IDC_SPLITTERTOP, m_wndSplitter1);
100 DDX_Control(pDX, IDC_SPLITTERBOTTOM, m_wndSplitter2);
101 DDX_Text(pDX, IDC_SEARCHEDIT, m_LogList.m_sFilterText);
102 DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);
103 DDX_Control(pDX, IDC_DATETO, m_DateTo);
104 DDX_Control(pDX, IDC_LOG_JUMPTYPE, m_JumpType);
105 DDX_Control(pDX, IDC_LOG_JUMPUP, m_JumpUp);
106 DDX_Control(pDX, IDC_LOG_JUMPDOWN, m_JumpDown);
107 DDX_Control(pDX, IDC_HIDEPATHS, m_cHidePaths);
108 DDX_Text(pDX, IDC_LOGINFO, m_sLogInfo);
109 DDX_Check(pDX, IDC_LOG_FIRSTPARENT, m_bFirstParent);
110 DDX_Check(pDX, IDC_LOG_ALLBRANCH,m_bAllBranch);
111 DDX_Check(pDX, IDC_LOG_FOLLOWRENAMES, m_bFollowRenames);
112 DDX_Check(pDX, IDC_SHOWWHOLEPROJECT,m_bWholeProject);
113 DDX_Check(pDX, IDC_LOG_SHOWTAGS, m_bShowTags);
114 DDX_Control(pDX, IDC_SEARCHEDIT, m_cFilter);
115 DDX_Control(pDX, IDC_STATIC_REF, m_staticRef);
116 DDX_Control(pDX, IDC_PIC_AUTHOR, m_gravatar);
119 BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)
120 ON_WM_CONTEXTMENU()
121 ON_WM_SETCURSOR()
122 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGLIST, OnLvnItemchangedLoglist)
123 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGMSG, OnLvnItemchangedLogmsg)
124 ON_NOTIFY(EN_LINK, IDC_MSGVIEW, OnEnLinkMsgview)
125 ON_BN_CLICKED(IDC_STATBUTTON, OnBnClickedStatbutton)
127 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)
128 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)
130 ON_MESSAGE(MSG_LOAD_PERCENTAGE,OnLogListLoading)
132 ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)
133 ON_WM_TIMER()
134 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)
135 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)
136 ON_CBN_SELCHANGE(IDC_LOG_JUMPTYPE, &CLogDlg::OnCbnSelchangeJumpType)
137 ON_COMMAND(IDC_LOG_JUMPUP, &CLogDlg::OnBnClickedJumpUp)
138 ON_COMMAND(IDC_LOG_JUMPDOWN, &CLogDlg::OnBnClickedJumpDown)
139 ON_BN_CLICKED(IDC_SHOWWHOLEPROJECT, OnBnClickShowWholeProject)
140 ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST, OnLvnColumnclick)
141 ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)
142 ON_COMMAND(MSG_FETCHED_DIFF, OnBnClickedHidepaths)
143 ON_BN_CLICKED(IDC_LOG_ALLBRANCH, OnBnClickedAllBranch)
144 ON_BN_CLICKED(IDC_LOG_FOLLOWRENAMES, OnBnClickedFollowRenames)
145 ON_BN_CLICKED(IDC_LOG_SHOWTAGS, OnBnClickedShowTags)
147 ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)
148 ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)
149 ON_WM_SIZE()
150 ON_BN_CLICKED(IDC_LOG_FIRSTPARENT, &CLogDlg::OnBnClickedFirstParent)
151 ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)
152 ON_STN_CLICKED(IDC_STATIC_REF, &CLogDlg::OnBnClickedBrowseRef)
153 ON_COMMAND(ID_LOGDLG_REFRESH, &CLogDlg::OnBnClickedRefresh)
154 ON_COMMAND(ID_LOGDLG_FIND, &CLogDlg::OnFind)
155 ON_COMMAND(ID_LOGDLG_FOCUSFILTER, &CLogDlg::OnFocusFilter)
156 ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)
157 ON_MESSAGE(MSG_REFLOG_CHANGED, OnRefLogChanged)
158 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED, OnTaskbarBtnCreated)
159 END_MESSAGE_MAP()
161 enum JumpType
163 JumpType_AuthorEmail,
164 JumpType_CommitterEmail,
165 JumpType_MergePoint,
166 JumpType_Parent1,
167 JumpType_Parent2,
168 JumpType_Tag,
169 JumpType_TagFF
172 void CLogDlg::SetParams(const CTGitPath& orgPath, const CTGitPath& path, CString hightlightRevision, CString range, int limit)
174 m_orgPath = orgPath;
175 m_path = path;
176 m_hightlightRevision = hightlightRevision;
178 if (!(range.IsEmpty() || range == _T("HEAD")))
179 m_bAllBranch = false;
181 SetRange(range);
183 m_limit = limit;
184 if (::IsWindow(m_hWnd))
185 UpdateData(FALSE);
188 void CLogDlg::SetFilter(const CString& findstr, LONG findtype, bool findregex)
190 m_LogList.m_sFilterText = findstr;
191 if (findtype)
192 m_LogList.m_SelectedFilters = findtype;
193 m_LogList.m_bFilterWithRegex = m_bFilterWithRegex = findregex;
196 BOOL CLogDlg::OnInitDialog()
198 CString temp;
199 CResizableStandAloneDialog::OnInitDialog();
200 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
202 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
203 // do this, Explorer would be unable to send that message to our window if we
204 // were running elevated. It's OK to make the call all the time, since if we're
205 // not elevated, this is a no-op.
206 CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
207 typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
208 CAutoLibrary hUser = AtlLoadSystemLibraryUsingFullPath(_T("user32.dll"));
209 if (hUser)
211 ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
212 if (pfnChangeWindowMessageFilterEx)
214 pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
217 m_pTaskbarList.Release();
218 if (FAILED(m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList)))
219 m_pTaskbarList = nullptr;
221 m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));
223 // use the state of the "stop on copy/rename" option from the last time
224 UpdateData(FALSE);
226 // set the font to use in the log message view, configured in the settings dialog
227 CAppUtils::CreateFontForLogs(m_logFont);
228 GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);
229 // automatically detect URLs in the log message and turn them into links
230 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);
231 // make the log message rich edit control send a message when the mouse pointer is over a link
232 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);
233 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
235 // the "hide unrelated paths" checkbox should be indeterminate
236 m_cHidePaths.SetCheck(BST_INDETERMINATE);
239 //SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
240 //SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
242 // set up the columns
243 m_LogList.DeleteAllItems();
245 m_LogList.m_Path=m_path;
246 m_LogList.m_hasWC = m_LogList.m_bShowWC = !g_GitAdminDir.IsBareRepo(g_Git.m_CurrentDir);
247 m_LogList.InsertGitColumn();
249 m_ChangedFileListCtrl.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL, _T("LogDlg"), (GITSLC_POPALL ^ (GITSLC_POPCOMMIT|GITSLC_POPIGNORE|GITSLC_POPRESTORE)), false, m_LogList.m_hasWC, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL);
251 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
253 SetDlgTitle();
255 m_tooltips.Create(this);
256 CheckRegexpTooltip();
258 SetSplitterRange();
260 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
261 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
262 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
263 m_cFilter.SetValidator(this);
265 AdjustControlSize(IDC_HIDEPATHS);
266 AdjustControlSize(IDC_LOG_FIRSTPARENT);
267 AdjustControlSize(IDC_LOG_ALLBRANCH);
268 AdjustControlSize(IDC_SHOWWHOLEPROJECT);
269 AdjustControlSize(IDC_LOG_FOLLOWRENAMES);
270 AdjustControlSize(IDC_LOG_SHOWTAGS);
272 if (m_gravatar.IsGravatarEnabled())
274 RECT rect, rect2;
275 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(&rect);
276 ScreenToClient(&rect);
277 m_gravatar.GetWindowRect(&rect2);
278 ScreenToClient(&rect2);
279 rect.right = rect2.left;
280 GetDlgItem(IDC_MSGVIEW)->MoveWindow(&rect);
282 else
283 m_gravatar.ShowWindow(SW_HIDE);
285 GetClientRect(m_DlgOrigRect);
286 m_LogList.GetClientRect(m_LogListOrigRect);
287 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
288 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
290 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
291 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
293 m_staticRef.SetURL(CString());
295 // resizable stuff
296 AddAnchor(IDC_STATIC_REF, TOP_LEFT);
297 //AddAnchor(IDC_BUTTON_BROWSE_REF, TOP_LEFT);
298 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
299 AddAnchor(IDC_DATEFROM, TOP_LEFT);
300 AddAnchor(IDC_TOLABEL, TOP_LEFT);
301 AddAnchor(IDC_DATETO, TOP_LEFT);
303 SetFilterCueText();
304 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
305 AddAnchor(IDC_LOG_JUMPTYPE, TOP_RIGHT);
306 AddAnchor(IDC_LOG_JUMPUP, TOP_RIGHT);
307 AddAnchor(IDC_LOG_JUMPDOWN, TOP_RIGHT);
309 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
310 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
311 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
312 AddAnchor(IDC_PIC_AUTHOR, TOP_RIGHT);
313 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
314 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
316 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
317 AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);
318 AddAnchor(IDC_LOG_ALLBRANCH,BOTTOM_LEFT);
319 AddAnchor(IDC_LOG_FOLLOWRENAMES, BOTTOM_LEFT);
320 AddAnchor(IDC_LOG_FIRSTPARENT, BOTTOM_LEFT);
321 AddAnchor(IDC_SHOWWHOLEPROJECT, BOTTOM_LEFT);
322 AddAnchor(IDC_LOG_SHOWTAGS, BOTTOM_LEFT);
323 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
324 AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);
325 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
326 AddAnchor(IDOK, BOTTOM_RIGHT);
327 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
328 AddAnchor(IDHELP, BOTTOM_RIGHT);
330 if(this->m_bAllBranch)
331 m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH;
332 else
333 m_LogList.m_ShowMask&=~CGit::LOG_INFO_ALL_BRANCH;
335 if (m_bShowTags)
336 m_LogList.m_ShowRefMask |= LOGLIST_SHOWTAGS;
337 else
338 m_LogList.m_ShowRefMask &= ~LOGLIST_SHOWTAGS;
340 // SetPromptParentWindow(m_hWnd);
341 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_AUTHOREMAIL)));
342 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_COMMITTEREMAIL)));
343 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_MERGEPOINT)));
344 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_PARENT1)));
345 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_PARENT2)));
346 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_TAG)));
347 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_TAG_FF)));
348 m_JumpType.SetCurSel(0);
349 m_JumpUp.SetIcon((HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_JUMPUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
350 m_JumpDown.SetIcon((HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_JUMPDOWN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
352 if (hWndExplorer)
353 CenterWindow(CWnd::FromHandle(hWndExplorer));
354 EnableSaveRestore(_T("LogDlg"));
356 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
357 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
358 RECT rcDlg, rcLogList, rcChgMsg;
359 GetClientRect(&rcDlg);
360 m_LogList.GetWindowRect(&rcLogList);
361 ScreenToClient(&rcLogList);
362 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
363 ScreenToClient(&rcChgMsg);
364 if (yPos1)
366 RECT rectSplitter;
367 m_wndSplitter1.GetWindowRect(&rectSplitter);
368 ScreenToClient(&rectSplitter);
369 int delta = yPos1 - rectSplitter.top;
371 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
373 m_wndSplitter1.SetWindowPos(NULL, rectSplitter.left, yPos1, 0, 0, SWP_NOSIZE);
374 DoSizeV1(delta);
377 if (yPos2)
379 RECT rectSplitter;
380 m_wndSplitter2.GetWindowRect(&rectSplitter);
381 ScreenToClient(&rectSplitter);
382 int delta = yPos2 - rectSplitter.top;
384 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
386 m_wndSplitter2.SetWindowPos(NULL, rectSplitter.left, yPos2, 0, 0, SWP_NOSIZE);
387 DoSizeV2(delta);
391 SetSplitterRange();
393 if (m_bSelect)
395 // the dialog is used to select revisions
396 // enable the OK button if appropriate
397 EnableOKButton();
399 else
401 // the dialog is used to just view log messages
402 // hide the OK button and set text on Cancel button to OK
403 GetDlgItemText(IDOK, temp);
404 SetDlgItemText(IDCANCEL, temp);
405 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
408 // first start a thread to obtain the log messages without
409 // blocking the dialog
410 //m_tTo = 0;
411 //m_tFrom = (DWORD)-1;
413 // scroll to user selected or current revision
414 if (!m_hightlightRevision.IsEmpty() && m_hightlightRevision.GetLength() >= GIT_HASH_SIZE)
415 m_LogList.m_lastSelectedHash = m_hightlightRevision;
416 else
418 if (g_Git.GetHash(m_LogList.m_lastSelectedHash, _T("HEAD")))
419 MessageBox(g_Git.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR);
422 if (m_path.IsEmpty() || m_path.IsDirectory())
423 DialogEnableWindow(IDC_LOG_FOLLOWRENAMES, FALSE);
425 m_LogList.FetchLogAsync(this);
426 m_gravatar.Init();
428 GetDlgItem(IDC_LOGLIST)->SetFocus();
430 ShowStartRef();
431 return FALSE;
434 LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM /*lParam*/)
436 int cur=(int)wParam;
438 if( cur == GITLOG_START )
440 CString temp;
441 temp.LoadString(IDS_PROGRESSWAIT);
443 this->m_LogList.ShowText(temp, true);
445 // We use a progress bar while getting the logs
446 m_LogProgress.SetRange32(0, 100);
447 m_LogProgress.SetPos(0);
448 if (m_pTaskbarList)
450 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
451 m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
454 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
456 //DialogEnableWindow(IDC_SHOWWHOLEPROJECT, FALSE);
457 //DialogEnableWindow(IDC_LOG_FIRSTPARENT, FALSE);
458 DialogEnableWindow(IDC_STATBUTTON, FALSE);
459 //DialogEnableWindow(IDC_REFRESH, FALSE);
460 DialogEnableWindow(IDC_HIDEPATHS,FALSE);
463 else if( cur == GITLOG_END)
465 if(this->m_LogList.HasText())
467 this->m_LogList.ClearText();
469 UpdateLogInfoLabel();
471 if (m_pTaskbarList)
472 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
474 DialogEnableWindow(IDC_SHOWWHOLEPROJECT, !m_bFollowRenames);
476 DialogEnableWindow(IDC_STATBUTTON, !(m_LogList.m_arShownList.IsEmpty() || m_LogList.m_arShownList.GetCount() == 1 && m_LogList.m_bShowWC));
477 DialogEnableWindow(IDC_REFRESH, TRUE);
478 DialogEnableWindow(IDC_HIDEPATHS,TRUE);
480 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
481 GetDlgItem(IDC_PROGRESS)->ShowWindow(FALSE);
482 //CTime time=m_LogList.GetOldestTime();
483 CTime begin,end;
484 m_LogList.GetTimeRange(begin,end);
486 if(m_LogList.m_From == -1)
487 m_DateFrom.SetTime(&begin);
489 if(m_LogList.m_To == -1)
490 m_DateTo.SetTime(&end);
494 else
496 if(this->m_LogList.HasText())
498 this->m_LogList.ClearText();
499 this->m_LogList.Invalidate();
501 UpdateLogInfoLabel();
502 m_LogProgress.SetPos(cur);
503 if (m_pTaskbarList)
505 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
506 m_pTaskbarList->SetProgressValue(m_hWnd, cur, 100);
509 return 0;
511 void CLogDlg::SetDlgTitle()
513 if (m_sTitle.IsEmpty())
514 GetWindowText(m_sTitle);
516 if (m_LogList.m_Path.IsEmpty() || m_orgPath.GetWinPathString().IsEmpty())
518 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, m_sTitle);
520 else
521 CAppUtils::SetWindowTitle(m_hWnd, m_orgPath.GetWinPathString(), m_sTitle);
524 void CLogDlg::CheckRegexpTooltip()
526 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
527 // Since tooltip describes regexp features, show it only if regexps are enabled.
528 if (m_bFilterWithRegex)
530 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
532 else
533 m_tooltips.DelTool(pWnd);
536 void CLogDlg::EnableOKButton()
538 if (m_bSelect)
540 // the dialog is used to select revisions
541 if (m_bSelectionMustBeSingle)
543 // enable OK button if only a single revision is selected
544 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()==1));
546 else if (m_bSelectionMustBeContinuous)
547 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
548 else
549 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
551 else
552 DialogEnableWindow(IDOK, TRUE);
555 CString CLogDlg::GetTagInfo(GitRev* pLogEntry)
557 CString cmd;
558 CString output;
560 if(m_LogList.m_HashMap.find(pLogEntry->m_CommitHash) != m_LogList.m_HashMap.end())
562 STRING_VECTOR &vector = m_LogList.m_HashMap[pLogEntry->m_CommitHash];
563 for (int i = 0; i < vector.size(); ++i)
565 if(vector[i].Find(_T("refs/tags/")) == 0 )
567 CString tag= vector[i];
568 int start = vector[i].Find(_T("^{}"));
569 if(start>0)
570 tag=tag.Left(start);
571 else
572 continue;
574 cmd.Format(_T("git.exe cat-file tag %s"), tag);
576 if(g_Git.Run(cmd, &output, NULL, CP_UTF8) == 0 )
577 output+=_T("\n");
582 if(!output.IsEmpty())
584 output = _T("\n*") + CString(MAKEINTRESOURCE(IDS_PROC_LOG_TAGINFO)) + _T("*\n\n") + output;
587 return output;
590 bool LookLikeGitHash(const CString& msg, int &pos)
592 int c = 0;
593 for (; pos < msg.GetLength(); ++pos)
595 if (msg[pos] >= '0' && msg[pos] <= '9' || msg[pos] >= 'a' && msg[pos] <= 'f')
597 c++;
599 else
601 return c >= g_Git.GetShortHASHLength() && c <= GIT_HASH_SIZE * 2;
604 return c >= g_Git.GetShortHASHLength() && c <= GIT_HASH_SIZE * 2;
607 std::vector<CHARRANGE> FindGitHashPositions(const CString& msg, int offset)
609 std::vector<CHARRANGE> result;
610 offset = offset < 0 ? 0 : offset;
611 int old = offset;
612 while (offset < msg.GetLength())
614 old = offset;
615 TCHAR b = offset > 1 ? msg[offset - 2] : '\0';
616 TCHAR c = offset > 0 ? msg[offset - 1] : '\0';
617 // git hash can optionally starts with 'g'
618 if ((c == 'g' && (offset == 0 || !((b >= 'A' && b <= 'Z') || (b >= 'h' && b <= 'z'))))
619 || (!((c >= 'A' && c <= 'Z') || (c >= 'h' && c <= 'z'))))
621 if (b == '\n')
623 if (msg.Mid(offset, 11) == _T("git-svn-id:") || msg.Mid(offset, 14) == _T("Signed-off-by:"))
625 offset += 11;
626 while (offset < msg.GetLength())
628 if (msg[offset++] == '\n')
629 break;
631 continue;
635 if (LookLikeGitHash(msg, offset))
637 TCHAR d = offset < msg.GetLength() ? msg[offset] : '\0';
638 if (!((d >= 'A' && d <= 'Z') || (d >= 'g' && d <= 'z')))
640 CHARRANGE range = { old, offset };
641 result.push_back(range);
645 ++offset;
648 return result;
651 BOOL FindGitHash(const CString& msg, int offset, CWnd *pWnd)
653 std::vector<CHARRANGE> positions = FindGitHashPositions(msg, offset);
654 CAppUtils::SetCharFormat(pWnd, CFM_LINK, CFE_LINK, positions);
656 return positions.empty() ? FALSE : TRUE;
659 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
661 // we fill here the log message rich edit control,
662 // and also populate the changed files list control
663 // according to the selected revision(s).
665 CRichEditCtrl * pMsgView = (CRichEditCtrl*)GetDlgItem(IDC_MSGVIEW);
666 // empty the log message view
667 pMsgView->SetWindowText(_T(" "));
668 // empty the changed files list
669 m_ChangedFileListCtrl.SetRedraw(FALSE);
670 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
671 m_currentChangedArray = NULL;
672 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
673 m_ChangedFileListCtrl.DeleteAllItems();
675 // if we're not here to really show a selected revision, just
676 // get out of here after clearing the views, which is what is intended
677 // if that flag is not set.
678 if (!bShow)
680 // force a redraw
681 m_ChangedFileListCtrl.Invalidate();
682 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
683 m_ChangedFileListCtrl.SetRedraw(TRUE);
684 m_gravatar.LoadGravatar();
685 return;
688 // depending on how many revisions are selected, we have to do different
689 // tasks.
690 int selCount = m_LogList.GetSelectedCount();
691 if (selCount == 0)
693 // if nothing is selected, we have nothing more to do
694 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
695 m_ChangedFileListCtrl.SetRedraw(TRUE);
696 m_gravatar.LoadGravatar();
697 return;
699 else if (selCount == 1)
701 // if one revision is selected, we have to fill the log message view
702 // with the corresponding log message, and also fill the changed files
703 // list fully.
704 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
705 int selIndex = m_LogList.GetNextSelectedItem(pos);
706 if (selIndex >= m_LogList.m_arShownList.GetCount())
708 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
709 m_ChangedFileListCtrl.SetRedraw(TRUE);
710 return;
712 Locker lock(m_LogList.m_critSec_AsyncDiff);
713 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.SafeGetAt(selIndex));
716 // set the log message text
717 pMsgView->SetWindowText(CString(MAKEINTRESOURCE(IDS_HASH)) + _T(": ") + pLogEntry->m_CommitHash.ToString() + _T("\r\n\r\n"));
718 // turn bug ID's into links if the bugtraq: properties have been set
719 // and we can find a match of those in the log message
721 pMsgView->SetSel(-1,-1);
722 CHARFORMAT2 format;
723 SecureZeroMemory(&format, sizeof(CHARFORMAT2));
724 format.cbSize = sizeof(CHARFORMAT2);
725 format.dwMask = CFM_BOLD;
726 format.dwEffects = CFE_BOLD;
727 pMsgView->SendMessage(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format);
729 CString msg=_T("* ");
730 msg+=pLogEntry->GetSubject();
731 pMsgView->ReplaceSel(msg);
733 pMsgView->SetSel(-1,-1);
734 format.dwEffects = 0;
735 pMsgView->SendMessage(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format);
737 msg=_T("\n");
738 msg+=pLogEntry->GetBody();
740 if(!pLogEntry->m_Notes.IsEmpty())
742 msg+= _T("\n*") + CString(MAKEINTRESOURCE(IDS_NOTES)) + _T("* ");
743 msg+= pLogEntry->m_Notes;
744 msg+= _T("\n\n");
747 msg+=GetTagInfo(pLogEntry);
749 pMsgView->ReplaceSel(msg);
751 CString text;
752 pMsgView->GetWindowText(text);
753 // the rich edit control doesn't count the CR char!
754 // to be exact: CRLF is treated as one char.
755 text.Remove('\r');
757 FindGitHash(text, text.Find('\n'), pMsgView);
758 m_LogList.m_ProjectProperties.FindBugID(text, pMsgView);
759 if (((DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\StyleCommitMessages"), TRUE)) == TRUE)
760 CAppUtils::FormatTextInRichEditControl(pMsgView);
762 int HidePaths=m_cHidePaths.GetState() & 0x0003;
763 CString matchpath=this->m_path.GetGitPathString();
765 int count = pLogEntry->GetFiles(&m_LogList).GetCount();
766 for (int i = 0 ; i < count && (!matchpath.IsEmpty()); ++i)
768 if( m_bWholeProject )
769 break;
771 ((CTGitPath&)pLogEntry->GetFiles(&m_LogList)[i]).m_Action &= ~(CTGitPath::LOGACTIONS_HIDE|CTGitPath::LOGACTIONS_GRAY);
773 if(pLogEntry->GetFiles(&m_LogList)[i].GetGitPathString().Left(matchpath.GetLength()) != matchpath && pLogEntry->GetFiles(&m_LogList)[i].GetGitOldPathString().Left(matchpath.GetLength()) != matchpath)
775 if(HidePaths==BST_CHECKED)
776 ((CTGitPath&)pLogEntry->GetFiles(&m_LogList)[i]).m_Action |= CTGitPath::LOGACTIONS_HIDE;
777 if(HidePaths==BST_INDETERMINATE)
778 ((CTGitPath&)pLogEntry->GetFiles(&m_LogList)[i]).m_Action |= CTGitPath::LOGACTIONS_GRAY;
782 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->GetFiles(&m_LogList));
783 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;
784 if (pLogEntry->m_CommitHash.IsEmpty() && m_bShowUnversioned)
786 m_ChangedFileListCtrl.UpdateUnRevFileList(pLogEntry->GetUnRevFiles());
787 m_ChangedFileListCtrl.Show(GITSLC_SHOWVERSIONED | GITSLC_SHOWUNVERSIONED);
789 else
790 m_ChangedFileListCtrl.Show(GITSLC_SHOWVERSIONED);
792 m_ChangedFileListCtrl.SetBusyString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_FETCHINGFILES)));
794 if(!pLogEntry->m_IsDiffFiles)
795 m_ChangedFileListCtrl.SetBusy(TRUE);
796 else
797 m_ChangedFileListCtrl.SetBusy(FALSE);
799 m_ChangedFileListCtrl.SetRedraw(TRUE);
800 m_gravatar.LoadGravatar(pLogEntry->GetAuthorEmail());
801 return;
805 else
807 // more than one revision is selected:
808 // the log message view must be emptied
809 // the changed files list contains all the changed paths from all
810 // selected revisions, with 'doubles' removed
811 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
814 // redraw the views
815 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
816 #if 0
817 if (m_currentChangedArray)
819 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
820 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
822 else if (m_currentChangedPathList.GetCount())
824 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
825 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
827 else
829 m_ChangedFileListCtrl.SetItemCountEx(0);
830 m_ChangedFileListCtrl.Invalidate();
832 #endif
833 // sort according to the settings
834 if (m_nSortColumnPathList > 0)
835 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
836 else
837 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
838 m_ChangedFileListCtrl.SetRedraw(TRUE);
839 m_gravatar.LoadGravatar();
843 void CLogDlg::OnBnClickedRefresh()
845 Refresh (true);
848 void CLogDlg::Refresh (bool clearfilter /*autoGoOnline*/)
850 m_limit = 0;
851 m_LogList.Refresh(clearfilter);
852 EnableOKButton();
853 ShowStartRef();
854 FillLogMessageCtrl(false);
859 BOOL CLogDlg::Cancel()
861 return m_bCancelled;
864 void CLogDlg::SaveSplitterPos()
866 if (!IsIconic())
868 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
869 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
870 RECT rectSplitter;
871 m_wndSplitter1.GetWindowRect(&rectSplitter);
872 ScreenToClient(&rectSplitter);
873 regPos1 = rectSplitter.top;
874 m_wndSplitter2.GetWindowRect(&rectSplitter);
875 ScreenToClient(&rectSplitter);
876 regPos2 = rectSplitter.top;
880 void CLogDlg::OnCancel()
882 this->ShowWindow(SW_HIDE);
884 // canceling means stopping the working thread if it's still running.
885 m_LogList.SafeTerminateAsyncDiffThread();
886 if (this->IsThreadRunning())
888 m_LogList.SafeTerminateThread();
890 m_gravatar.SafeTerminateGravatarThread();
891 UpdateData();
893 SaveSplitterPos();
894 __super::OnCancel();
897 void CLogDlg::CopyChangedSelectionToClipBoard()
900 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
901 if (pos == NULL)
902 return; // nothing is selected, get out of here
904 CString sPaths;
906 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
907 // if (pos)
909 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
910 while (pos)
912 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
913 CTGitPath *path = (CTGitPath*)m_ChangedFileListCtrl.GetItemData(nItem);
914 if(path)
915 sPaths += path->GetGitPathString();
916 sPaths += _T("\r\n");
919 #if 0
920 else
922 // only one revision is selected in the log dialog top pane
923 // but multiple items could be selected in the changed items list
924 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
925 while (pos)
927 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
928 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->SafeGetAt(nItem);
930 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
932 // some items are hidden! So find out which item the user really selected
933 INT_PTR selRealIndex = -1;
934 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
936 if (pLogEntry->pArChangedPaths->SafeGetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
937 ++selRealIndex;
938 if (selRealIndex == nItem)
940 changedlogpath = pLogEntry->pArChangedPaths->SafeGetAt(hiddenindex);
941 break;
945 if (changedlogpath)
947 sPaths += changedlogpath->sPath;
948 sPaths += _T("\r\n");
952 #endif
953 sPaths.Trim();
954 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
958 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
960 // we have two separate context menus:
961 // one shown on the log message list control,
962 // the other shown in the changed-files list control
963 int selCount = m_LogList.GetSelectedCount();
964 if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
966 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
967 int selIndex = -1;
968 if (pos)
969 selIndex = m_LogList.GetNextSelectedItem(pos);
971 GitRev *pRev = ((GitRev*)m_LogList.m_arShownList[selIndex]);
973 if ((point.x == -1) && (point.y == -1))
975 CRect rect;
976 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
977 ClientToScreen(&rect);
978 point = rect.CenterPoint();
980 CString sMenuItemText;
981 CIconMenu popup;
982 if (popup.CreatePopupMenu())
984 // add the 'default' entries
985 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
986 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
987 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
988 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
989 sMenuItemText.LoadString(IDS_EDIT_NOTES);
990 popup.AppendMenuIcon( CGitLogList::ID_EDITNOTE, sMenuItemText, IDI_EDIT);
992 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
993 switch (cmd)
995 case 0:
996 break; // no command selected
997 case EM_SETSEL:
998 case WM_COPY:
999 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
1000 break;
1001 case CGitLogList::ID_EDITNOTE:
1002 CAppUtils::EditNote(pRev);
1003 this->FillLogMessageCtrl(true);
1004 break;
1010 void CLogDlg::OnOK()
1012 // since the log dialog is also used to select revisions for other
1013 // dialogs, we have to do some work before closing this dialog
1014 if (GetFocus() != GetDlgItem(IDOK))
1015 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
1017 m_LogList.SafeTerminateAsyncDiffThread();
1018 if (this->IsThreadRunning())
1020 m_LogList.SafeTerminateThread();
1022 m_gravatar.SafeTerminateGravatarThread();
1023 UpdateData();
1024 // check that one and only one row is selected
1025 if (m_LogList.GetSelectedCount() == 1)
1027 // get the selected row
1028 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1029 int selIndex = m_LogList.GetNextSelectedItem(pos);
1030 if (selIndex < m_LogList.m_arShownList.GetCount())
1032 // all ok, pick up the revision
1033 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.SafeGetAt(selIndex));
1034 // extract the hash
1035 m_sSelectedHash = pLogEntry->m_CommitHash;
1038 UpdateData(FALSE);
1039 SaveSplitterPos();
1040 __super::OnOK();
1042 #if 0
1043 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
1044 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
1046 CString temp;
1047 CString buttontext;
1048 GetDlgItemText(IDOK, buttontext);
1049 temp.LoadString(IDS_MSGBOX_CANCEL);
1050 if (temp.Compare(buttontext) != 0)
1051 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
1052 m_bCancelled = TRUE;
1053 m_selectedRevs.Clear();
1054 m_selectedRevsOneRange.Clear();
1055 if (m_pNotifyWindow)
1057 int selIndex = m_LogList.GetSelectionMark();
1058 if (selIndex >= 0)
1060 PLOGENTRYDATA pLogEntry = NULL;
1061 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1062 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1063 m_selectedRevs.AddRevision(pLogEntry->Rev);
1064 git_revnum_t lowerRev = pLogEntry->Rev;
1065 git_revnum_t higherRev = lowerRev;
1066 while (pos)
1068 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1069 git_revnum_t rev = pLogEntry->Rev;
1070 m_selectedRevs.AddRevision(pLogEntry->Rev);
1071 if (lowerRev > rev)
1072 lowerRev = rev;
1073 if (higherRev < rev)
1074 higherRev = rev;
1076 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
1078 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
1080 BOOL bSentMessage = FALSE;
1081 if (m_LogList.GetSelectedCount() == 1)
1083 // if only one revision is selected, check if the path/url with which the dialog was started
1084 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
1085 // if it was copied, use the copy from revision as lowerRev
1086 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
1088 CString sUrl = m_path.GetGitPathString();
1089 if (!m_path.IsUrl())
1091 sUrl = GetURLFromPath(m_path);
1093 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
1094 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
1096 LogChangedPath * pData = pLogEntry->pArChangedPaths->SafeGetAt(cp);
1097 if (pData)
1099 if (sUrl.Compare(pData->sPath) == 0)
1101 if (!pData->sCopyFromPath.IsEmpty())
1103 lowerRev = pData->lCopyFromRev;
1104 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
1105 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
1106 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
1107 bSentMessage = TRUE;
1114 if ( !bSentMessage )
1116 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
1117 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
1118 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
1119 if (m_selectedRevsOneRange.GetCount())
1120 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
1124 UpdateData();
1125 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
1126 SaveSplitterPos();
1127 #endif
1130 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool /*blame*/, bool /*unified*/)
1132 DialogEnableWindow(IDOK, FALSE);
1133 // SetPromptApp(&theApp);
1134 theApp.DoWaitCursor(1);
1136 CString temppath;
1137 GetTempPath(temppath);
1139 CString file1;
1140 file1.Format(_T("%s%s_%s%s"),
1141 temppath,
1142 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
1143 rev1->m_CommitHash.ToString().Left(g_Git.GetShortHASHLength()),
1144 (*m_currentChangedArray)[selIndex].GetFileExtension());
1146 CString file2;
1147 file2.Format(_T("%s\\%s_%s%s"),
1148 temppath,
1149 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
1150 rev2->m_CommitHash.ToString().Left(g_Git.GetShortHASHLength()),
1151 (*m_currentChangedArray)[selIndex].GetFileExtension());
1153 CString cmd;
1154 CTGitPath &path = (CTGitPath &)(*m_currentChangedArray)[selIndex];
1156 g_Git.GetOneFile(rev1->m_CommitHash.ToString(), path, file1);
1157 g_Git.GetOneFile(rev2->m_CommitHash.ToString(), path, file2);
1159 CAppUtils::DiffFlags flags;
1160 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),
1161 g_Git.m_CurrentDir + _T("\\") + path.GetWinPathString(), g_Git.m_CurrentDir + _T("\\") + path.GetWinPathString(),
1162 rev1->m_CommitHash.ToString(), rev2->m_CommitHash.ToString(),
1163 flags);
1165 theApp.DoWaitCursor(-1);
1166 EnableOKButton();
1169 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
1171 // Skip Ctrl-C when copying text out of the log message or search filter
1172 bool bSkipAccelerator = (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 'C' || pMsg->wParam == VK_INSERT) && (GetFocus() == GetDlgItem(IDC_MSGVIEW) || GetFocus() == GetDlgItem(IDC_SEARCHEDIT)) && GetKeyState(VK_CONTROL) & 0x8000);
1173 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
1175 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
1177 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
1179 m_LogList.DiffSelectedRevWithPrevious();
1180 return TRUE;
1183 if (GetFocus() == GetDlgItem(IDC_SEARCHEDIT))
1185 KillTimer(LOGFILTER_TIMER);
1186 m_limit = 0;
1187 m_LogList.Refresh(FALSE);
1188 FillLogMessageCtrl(false);
1191 if (m_hAccel && !bSkipAccelerator)
1193 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
1194 if (ret)
1195 return TRUE;
1198 if(::IsWindow(m_tooltips.m_hWnd))
1199 m_tooltips.RelayEvent(pMsg);
1200 return __super::PreTranslateMessage(pMsg);
1204 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
1206 //if (this->IsThreadRunning())
1207 if(m_LogList.m_bNoDispUpdates)
1209 // only show the wait cursor over the list control
1210 if ((pWnd)&&
1211 ((pWnd == GetDlgItem(IDC_LOGLIST))||
1212 (pWnd == GetDlgItem(IDC_MSGVIEW))||
1213 (pWnd == GetDlgItem(IDC_LOGMSG))))
1215 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
1216 SetCursor(hCur);
1217 return TRUE;
1220 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
1221 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
1223 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
1224 SetCursor(hCur);
1225 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
1228 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1230 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1231 *pResult = 0;
1232 //if (this->IsThreadRunning())
1233 if(m_LogList.m_bNoDispUpdates)
1234 return;
1235 if (pNMLV->iItem >= 0)
1237 this->m_LogList.m_nSearchIndex = pNMLV->iItem;
1238 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.SafeGetAt(pNMLV->iItem));
1239 m_LogList.m_lastSelectedHash = pLogEntry->m_CommitHash;
1240 if (pNMLV->iSubItem != 0)
1241 return;
1242 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount()))
1244 // remove the selected state
1245 if (pNMLV->uChanged & LVIF_STATE)
1247 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
1248 FillLogMessageCtrl();
1249 UpdateData(FALSE);
1250 UpdateLogInfoLabel();
1252 return;
1254 if (pNMLV->uChanged & LVIF_STATE)
1256 FillLogMessageCtrl();
1257 UpdateData(FALSE);
1260 else
1262 m_LogList.m_lastSelectedHash.Empty();
1263 FillLogMessageCtrl();
1264 UpdateData(FALSE);
1266 EnableOKButton();
1267 UpdateLogInfoLabel();
1270 void CLogDlg::OnLvnItemchangedLogmsg(NMHDR * /*pNMHDR*/, LRESULT * /*pResult*/)
1272 UpdateLogInfoLabel();
1275 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
1277 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
1278 if (pEnLink->msg == WM_LBUTTONUP)
1280 CString url, msg;
1281 GetDlgItemText(IDC_MSGVIEW, msg);
1282 msg.Replace(_T("\r\n"), _T("\n"));
1283 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
1284 int pos = 0;
1285 if (LookLikeGitHash(url, pos))
1287 bool found = false;
1288 for (int i = 0; i < m_LogList.m_arShownList.GetCount(); ++i)
1290 GitRev *rev = (GitRev *)m_LogList.m_arShownList.SafeGetAt(i);
1291 if (!rev) continue;
1292 if (rev->m_CommitHash.ToString().Left(url.GetLength()) == url)
1294 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1295 if (pos)
1297 int index = m_LogList.GetNextSelectedItem(pos);
1298 if (index > 0)
1299 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
1301 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
1302 m_LogList.EnsureVisible(i, FALSE);
1303 m_LogList.SetSelectionMark(i);
1304 found = true;
1305 break;
1309 if (!found)
1310 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND, IDS_APPNAME, 1, IDI_INFORMATION, IDS_OKBUTTON, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN);
1312 else
1314 if (!::PathIsURL(url))
1316 url = m_LogList.m_ProjectProperties.GetBugIDUrl(url);
1317 url = GetAbsoluteUrlFromRelativeUrl(url);
1319 if (!url.IsEmpty())
1320 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
1323 *pResult = 0;
1326 void CLogDlg::OnBnClickedStatbutton()
1328 if (this->IsThreadRunning())
1329 return;
1330 if (m_LogList.m_arShownList.IsEmpty() || m_LogList.m_arShownList.GetCount() == 1 && m_LogList.m_bShowWC)
1331 return; // nothing or just the working copy changes are shown, so no statistics.
1332 // the statistics dialog expects the log entries to be sorted by date
1333 SortByColumn(3, false);
1335 CStatGraphDlg dlg;
1336 m_LogList.RecalculateShownList(&dlg.m_ShowList);
1338 dlg.m_path = m_orgPath;
1339 dlg.DoModal();
1340 // restore the previous sorting
1341 SortByColumn(m_nSortColumn, m_bAscending);
1342 OnTimer(LOGFILTER_TIMER);
1345 void CLogDlg::MoveToSameTop(CWnd *pWndRef, CWnd *pWndTarget)
1347 CRect rcWndPicAuthor, rcWndMsgView;
1348 pWndRef->GetWindowRect(rcWndMsgView);
1349 ScreenToClient(rcWndMsgView);
1350 pWndTarget->GetWindowRect(rcWndPicAuthor);
1351 ScreenToClient(rcWndPicAuthor);
1352 int diff = rcWndMsgView.top - rcWndPicAuthor.top;
1353 rcWndPicAuthor.top += diff;
1354 rcWndPicAuthor.bottom += diff;
1355 pWndTarget->MoveWindow(rcWndPicAuthor);
1358 void CLogDlg::DoSizeV1(int delta)
1361 RemoveAnchor(IDC_LOGLIST);
1362 RemoveAnchor(IDC_SPLITTERTOP);
1363 RemoveAnchor(IDC_MSGVIEW);
1364 RemoveAnchor(IDC_PIC_AUTHOR);
1365 RemoveAnchor(IDC_SPLITTERBOTTOM);
1366 RemoveAnchor(IDC_LOGMSG);
1367 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
1368 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
1369 MoveToSameTop(GetDlgItem(IDC_MSGVIEW), GetDlgItem(IDC_PIC_AUTHOR));
1370 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
1371 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
1372 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
1373 AddAnchor(IDC_PIC_AUTHOR, TOP_RIGHT);
1374 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
1375 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
1376 ArrangeLayout();
1377 AdjustMinSize();
1378 SetSplitterRange();
1379 m_LogList.Invalidate();
1380 GetDlgItem(IDC_MSGVIEW)->Invalidate();
1381 m_gravatar.Invalidate();
1385 void CLogDlg::DoSizeV2(int delta)
1388 RemoveAnchor(IDC_LOGLIST);
1389 RemoveAnchor(IDC_SPLITTERTOP);
1390 RemoveAnchor(IDC_MSGVIEW);
1391 RemoveAnchor(IDC_PIC_AUTHOR);
1392 RemoveAnchor(IDC_SPLITTERBOTTOM);
1393 RemoveAnchor(IDC_LOGMSG);
1394 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
1395 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
1396 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
1397 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
1398 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
1399 AddAnchor(IDC_PIC_AUTHOR, TOP_RIGHT);
1400 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
1401 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
1402 ArrangeLayout();
1403 AdjustMinSize();
1404 SetSplitterRange();
1405 GetDlgItem(IDC_MSGVIEW)->Invalidate();
1406 m_ChangedFileListCtrl.Invalidate();
1407 m_gravatar.Invalidate();
1411 void CLogDlg::AdjustMinSize()
1413 // adjust the minimum size of the dialog to prevent the resizing from
1414 // moving the list control too far down.
1415 CRect rcChgListView;
1416 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
1417 CRect rcLogList;
1418 m_LogList.GetClientRect(rcLogList);
1420 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
1421 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
1422 +rcChgListView.Height()+rcLogList.Height()+60));
1425 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
1427 switch (message) {
1428 case WM_NOTIFY:
1429 if (wParam == IDC_SPLITTERTOP)
1431 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
1432 DoSizeV1(pHdr->delta);
1434 else if (wParam == IDC_SPLITTERBOTTOM)
1436 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
1437 DoSizeV2(pHdr->delta);
1439 break;
1442 return CResizableDialog::DefWindowProc(message, wParam, lParam);
1445 void CLogDlg::SetSplitterRange()
1447 if ((m_LogList)&&(m_ChangedFileListCtrl))
1449 CRect rcTop;
1450 m_LogList.GetWindowRect(rcTop);
1451 ScreenToClient(rcTop);
1452 CRect rcMiddle;
1453 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
1454 ScreenToClient(rcMiddle);
1455 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
1456 CRect rcBottom;
1457 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
1458 ScreenToClient(rcBottom);
1459 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
1463 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
1465 // FIXME: x64 version would get this function called with unexpected parameters.
1466 if (!lParam)
1467 return 0;
1469 RECT * rect = (LPRECT)lParam;
1470 CPoint point;
1471 CString temp;
1472 point = CPoint(rect->left, rect->bottom);
1473 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_SelectedFilters & x ? MF_CHECKED : MF_UNCHECKED))
1474 CMenu popup;
1475 if (popup.CreatePopupMenu())
1477 temp.LoadString(IDS_LOG_FILTER_SUBJECT);
1478 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_SUBJECT), LOGFILTER_SUBJECT, temp);
1480 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
1481 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
1483 temp.LoadString(IDS_LOG_FILTER_PATHS);
1484 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
1486 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
1487 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
1489 temp.LoadString(IDS_LOG_FILTER_EMAILS);
1490 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_EMAILS), LOGFILTER_EMAILS, temp);
1492 temp.LoadString(IDS_LOG_FILTER_REVS);
1493 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
1495 temp.LoadString(IDS_LOG_FILTER_REFNAME);
1496 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REFNAME), LOGFILTER_REFNAME, temp);
1498 if (m_LogList.m_bShowBugtraqColumn == TRUE) {
1499 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
1500 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
1503 popup.AppendMenu(MF_SEPARATOR, NULL);
1505 temp.LoadString(IDS_LOG_FILTER_REGEX);
1506 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
1508 m_tooltips.Pop();
1509 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
1510 if (selection != 0)
1513 if (selection == LOGFILTER_REGEX)
1515 m_bFilterWithRegex = !m_bFilterWithRegex;
1516 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
1517 b = m_bFilterWithRegex;
1518 m_LogList.m_bFilterWithRegex = m_bFilterWithRegex;
1519 SetFilterCueText();
1520 CheckRegexpTooltip();
1522 else
1524 m_LogList.m_SelectedFilters ^= selection;
1525 SetFilterCueText();
1527 // Reload only if a search text is entered
1528 if (!m_LogList.m_sFilterText.IsEmpty())
1529 SetTimer(LOGFILTER_TIMER, 1000, NULL);
1532 return 0L;
1535 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
1538 KillTimer(LOGFILTER_TIMER);
1540 m_LogList.m_sFilterText.Empty();
1541 UpdateData(FALSE);
1542 theApp.DoWaitCursor(1);
1543 CStoreSelection storeselection(this);
1544 FillLogMessageCtrl(false);
1546 m_LogList.RemoveFilter();
1548 Refresh();
1550 CTime begin,end;
1551 m_LogList.GetTimeRange(begin,end);
1552 m_DateFrom.SetTime(&begin);
1553 m_DateTo.SetTime(&end);
1555 theApp.DoWaitCursor(-1);
1556 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
1557 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
1558 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
1559 UpdateLogInfoLabel();
1561 return 0L;
1565 void CLogDlg::SetFilterCueText()
1567 CString temp(MAKEINTRESOURCE(IDS_LOG_FILTER_BY));
1568 temp += _T(" ");
1570 if (m_LogList.m_SelectedFilters & LOGFILTER_SUBJECT)
1572 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_SUBJECT));
1575 if (m_LogList.m_SelectedFilters & LOGFILTER_MESSAGES)
1577 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
1578 temp += _T(", ");
1579 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_MESSAGES));
1582 if (m_LogList.m_SelectedFilters & LOGFILTER_PATHS)
1584 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
1585 temp += _T(", ");
1586 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_PATHS));
1589 if (m_LogList.m_SelectedFilters & LOGFILTER_AUTHORS)
1591 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
1592 temp += _T(", ");
1593 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_AUTHORS));
1596 if (m_LogList.m_SelectedFilters & LOGFILTER_EMAILS)
1598 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
1599 temp += _T(", ");
1600 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_EMAILS));
1603 if (m_LogList.m_SelectedFilters & LOGFILTER_REVS)
1605 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
1606 temp += _T(", ");
1607 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_REVS));
1610 if (m_LogList.m_SelectedFilters & LOGFILTER_REFNAME)
1612 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
1613 temp += _T(", ");
1614 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_REFNAME));
1617 if (m_LogList.m_SelectedFilters & LOGFILTER_BUGID)
1619 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
1620 temp += _T(", ");
1621 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_BUGIDS));
1624 // to make the cue banner text appear more to the right of the edit control
1625 temp = _T(" ")+temp;
1626 m_cFilter.SetCueBanner(temp.TrimRight());
1629 bool CLogDlg::Validate(LPCTSTR string)
1631 if (!m_bFilterWithRegex)
1632 return true;
1633 std::tr1::wregex pat;
1634 return m_LogList.ValidateRegexp(string, pat, false);
1638 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
1640 if (nIDEvent == LOGFTIME_TIMER)
1642 KillTimer(LOGFTIME_TIMER);
1643 m_limit = 0;
1644 m_LogList.Refresh(FALSE);
1645 FillLogMessageCtrl(false);
1648 if (nIDEvent == LOGFILTER_TIMER)
1650 KillTimer(LOGFILTER_TIMER);
1651 m_limit = 0;
1652 m_LogList.Refresh(FALSE);
1653 FillLogMessageCtrl(false);
1655 #if 0
1656 /* we will use git built-in grep to filter log */
1657 if (this->IsThreadRunning())
1659 // thread still running! So just restart the timer.
1660 SetTimer(LOGFILTER_TIMER, 1000, NULL);
1661 return;
1663 CWnd * focusWnd = GetFocus();
1664 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
1665 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
1666 if (m_LogList.m_sFilterText.IsEmpty())
1668 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
1669 // do not return here!
1670 // we also need to run the filter if the filter text is empty:
1671 // 1. to clear an existing filter
1672 // 2. to rebuild the m_arShownList after sorting
1674 theApp.DoWaitCursor(1);
1675 CStoreSelection storeselection(this);
1676 KillTimer(LOGFILTER_TIMER);
1677 FillLogMessageCtrl(false);
1679 // now start filter the log list
1680 m_LogList.StartFilter();
1682 if ( m_LogList.GetItemCount()==1 )
1684 m_LogList.SetSelectionMark(0);
1685 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
1687 theApp.DoWaitCursor(-1);
1688 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
1689 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
1690 if (bSetFocusToFilterControl)
1691 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
1692 UpdateLogInfoLabel();
1693 #endif
1694 } // if (nIDEvent == LOGFILTER_TIMER)
1695 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty() || m_LogList.m_arShownList.GetCount() == 1 && m_LogList.m_bShowWC))));
1696 __super::OnTimer(nIDEvent);
1699 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
1703 CTime _time;
1704 m_DateTo.GetTime(_time);
1706 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
1707 if (time.GetTime() != m_LogList.m_To)
1709 m_LogList.m_To = (DWORD)time.GetTime();
1710 SetTimer(LOGFTIME_TIMER, 10, NULL);
1713 catch (...)
1715 CMessageBox::Show(NULL,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1718 *pResult = 0;
1721 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
1726 CTime _time;
1727 m_DateFrom.GetTime(_time);
1729 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
1730 if (time.GetTime() != m_LogList.m_From)
1732 m_LogList.m_From = (DWORD)time.GetTime();
1733 SetTimer(LOGFTIME_TIMER, 10, NULL);
1736 catch (...)
1738 CMessageBox::Show(NULL,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1741 *pResult = 0;
1744 void CLogDlg::OnCbnSelchangeJumpType()
1746 // reserved for future use
1749 void CLogDlg::OnBnClickedJumpUp()
1751 int sel = m_JumpType.GetCurSel();
1752 if (sel < 0) return;
1753 JumpType jumpType = (JumpType)sel;
1755 CString strValue;
1756 CGitHash hashValue;
1757 int index = -1;
1758 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1759 if (pos)
1761 index = m_LogList.GetNextSelectedItem(pos);
1762 if (index == 0) return;
1764 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(index);
1765 if (jumpType == JumpType_AuthorEmail)
1766 strValue = data->GetAuthorEmail();
1767 else if (jumpType == JumpType_CommitterEmail)
1768 strValue = data->GetCommitterEmail();
1769 else if (jumpType == JumpType_Parent1)
1770 hashValue = data->m_CommitHash;
1771 else if (jumpType == JumpType_Parent2)
1772 hashValue = data->m_CommitHash;
1773 else if (jumpType == JumpType_TagFF)
1774 hashValue = data->m_CommitHash;
1776 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
1778 else
1779 return;
1781 while (pos)
1783 index = m_LogList.GetNextSelectedItem(pos);
1784 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
1786 m_LogList.SetSelectionMark(-1);
1788 for (int i = index - 1; i >= 0; i--)
1790 bool found = false;
1791 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(i);
1792 if (jumpType == JumpType_AuthorEmail)
1793 found = strValue == data->GetAuthorEmail();
1794 else if (jumpType == JumpType_CommitterEmail)
1795 found = strValue == data->GetCommitterEmail();
1796 else if (jumpType == JumpType_MergePoint)
1797 found = data->ParentsCount() > 1;
1798 else if (jumpType == JumpType_Parent1)
1800 if (data->m_ParentHash.size() > 0)
1801 found = data->m_ParentHash[0] == hashValue;
1803 else if (jumpType == JumpType_Parent2)
1805 if (data->m_ParentHash.size() > 1)
1806 found = data->m_ParentHash[1] == hashValue;
1808 else if (jumpType == JumpType_Tag || jumpType == JumpType_TagFF)
1810 STRING_VECTOR refList = m_LogList.m_HashMap[data->m_CommitHash];
1811 for (int j = 0; j < refList.size(); ++j)
1813 if (refList[j].Left(10) == _T("refs/tags/"))
1815 found = true;
1816 break;
1820 if (found && jumpType == JumpType_TagFF)
1821 found = g_Git.IsFastForward(hashValue, data->m_CommitHash);
1824 if (found)
1826 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
1827 m_LogList.EnsureVisible(i, FALSE);
1828 m_LogList.SetSelectionMark(i);
1829 return;
1833 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND, IDS_APPNAME, 1, IDI_INFORMATION, IDS_OKBUTTON, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN);
1836 void CLogDlg::OnBnClickedJumpDown()
1838 int jumpType = m_JumpType.GetCurSel();
1839 if (jumpType < 0) return;
1841 CString strValue;
1842 CGitHash hashValue;
1843 int index = -1;
1844 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1845 if (pos)
1847 index = m_LogList.GetNextSelectedItem(pos);
1848 if (index == 0) return;
1850 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(index);
1851 if (jumpType == JumpType_AuthorEmail)
1852 strValue = data->GetAuthorEmail();
1853 else if (jumpType == JumpType_CommitterEmail)
1854 strValue = data->GetCommitterEmail();
1855 else if (jumpType == JumpType_Parent1)
1857 if (data->m_ParentHash.size() > 0)
1858 hashValue = data->m_ParentHash.at(0);
1859 else
1860 return;
1862 else if (jumpType == JumpType_Parent2)
1864 if (data->m_ParentHash.size() > 1)
1865 hashValue = data->m_ParentHash.at(1);
1866 else
1867 return;
1869 else if (jumpType == JumpType_TagFF)
1870 hashValue = data->m_CommitHash;
1872 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
1874 else
1875 return;
1877 while (pos)
1879 index = m_LogList.GetNextSelectedItem(pos);
1880 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
1882 m_LogList.SetSelectionMark(-1);
1884 for (int i = index + 1; i < m_LogList.GetItemCount(); ++i)
1886 bool found = false;
1887 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(i);
1888 if (jumpType == JumpType_AuthorEmail)
1889 found = strValue == data->GetAuthorEmail();
1890 else if (jumpType == JumpType_CommitterEmail)
1891 found = strValue == data->GetCommitterEmail();
1892 else if (jumpType == JumpType_MergePoint)
1893 found = data->ParentsCount() > 1;
1894 else if (jumpType == JumpType_Parent1)
1895 found = data->m_CommitHash == hashValue;
1896 else if (jumpType == JumpType_Parent2)
1897 found = data->m_CommitHash == hashValue;
1898 else if (jumpType == JumpType_Tag || jumpType == JumpType_TagFF)
1900 STRING_VECTOR refList = m_LogList.m_HashMap[data->m_CommitHash];
1901 for (int j = 0; j < refList.size(); ++j)
1903 if (refList[j].Left(10) == _T("refs/tags/"))
1905 found = true;
1906 break;
1910 if (found && jumpType == JumpType_TagFF)
1911 found = g_Git.IsFastForward(data->m_CommitHash, hashValue);
1914 if (found)
1916 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
1917 m_LogList.EnsureVisible(i, FALSE);
1918 m_LogList.SetSelectionMark(i);
1919 return;
1923 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND, IDS_APPNAME, 1, IDI_INFORMATION, IDS_OKBUTTON, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN);
1926 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
1928 CTGitPathList pathList;
1929 #if 0
1931 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
1933 m_sRepositoryRoot = GetRepositoryRoot(m_path);
1935 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
1936 return pathList;
1938 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1939 if (pos != NULL)
1941 while (pos)
1943 int nextpos = m_LogList.GetNextSelectedItem(pos);
1944 if (nextpos >= m_arShownList.GetCount())
1945 continue;
1946 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(nextpos));
1947 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
1948 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
1950 LogChangedPath * cpath = cpatharray->SafeGetAt(cpPathIndex);
1951 if (cpath == NULL)
1952 continue;
1953 CTGitPath path;
1954 if (!bRelativePaths)
1955 path.SetFromGit(m_sRepositoryRoot);
1956 path.AppendPathString(cpath->sPath);
1957 if ((!bUseFilter)||
1958 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
1959 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
1960 pathList.AddPath(path);
1965 pathList.RemoveDuplicates();
1966 #endif
1967 return pathList;
1970 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
1972 #if 0
1973 switch(nSortColumn)
1975 case 0: // Revision
1977 if(bAscending)
1978 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
1979 else
1980 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
1982 break;
1983 case 1: // action
1985 if(bAscending)
1986 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
1987 else
1988 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
1990 break;
1991 case 2: // Author
1993 if(bAscending)
1994 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
1995 else
1996 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
1998 break;
1999 case 3: // Date
2001 if(bAscending)
2002 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
2003 else
2004 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
2006 break;
2007 case 4: // Message or bug id
2008 if (m_bShowBugtraqColumn)
2010 if(bAscending)
2011 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
2012 else
2013 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
2014 break;
2016 // fall through here
2017 case 5: // Message
2019 if(bAscending)
2020 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
2021 else
2022 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
2024 break;
2025 default:
2026 ATLASSERT(0);
2027 break;
2029 #endif
2032 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
2034 if (this->IsThreadRunning())
2035 return; //no sorting while the arrays are filled
2036 #if 0
2037 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
2038 const int nColumn = pNMLV->iSubItem;
2039 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
2040 m_nSortColumn = nColumn;
2041 SortByColumn(m_nSortColumn, m_bAscending);
2042 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
2043 SortShownListArray();
2044 m_LogList.Invalidate();
2045 UpdateLogInfoLabel();
2046 #else
2047 UNREFERENCED_PARAMETER(pNMHDR);
2048 #endif
2049 *pResult = 0;
2051 CLogOrdering orderDlg;
2052 if (orderDlg.DoModal() == IDOK)
2053 Refresh();
2056 void CLogDlg::SortShownListArray()
2058 // make sure the shown list still matches the filter after sorting.
2059 OnTimer(LOGFILTER_TIMER);
2060 // clear the selection states
2061 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
2062 while (pos)
2064 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
2066 m_LogList.SetSelectionMark(-1);
2069 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
2071 if (control == NULL)
2072 return;
2073 // set the sort arrow
2074 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
2075 HDITEM HeaderItem = {0};
2076 HeaderItem.mask = HDI_FORMAT;
2077 for (int i=0; i<pHeader->GetItemCount(); ++i)
2079 pHeader->GetItem(i, &HeaderItem);
2080 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
2081 pHeader->SetItem(i, &HeaderItem);
2083 if (nColumn >= 0)
2085 pHeader->GetItem(nColumn, &HeaderItem);
2086 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
2087 pHeader->SetItem(nColumn, &HeaderItem);
2091 int CLogDlg::m_nSortColumnPathList = 0;
2092 bool CLogDlg::m_bAscendingPathList = false;
2094 void CLogDlg::OnBnClickedHidepaths()
2096 FillLogMessageCtrl();
2097 m_ChangedFileListCtrl.Invalidate();
2100 void CLogDlg::UpdateLogInfoLabel()
2103 CGitHash rev1 ;
2104 CGitHash rev2 ;
2105 long selectedrevs = 0;
2106 long selectedfiles = 0;
2107 int count = (int)m_LogList.m_arShownList.GetCount();
2108 int start = 0;
2109 if (count)
2111 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.SafeGetAt(0)))->m_CommitHash;
2112 if(this->m_LogList.m_bShowWC && rev1.IsEmpty()&&(count>1))
2113 start = 1;
2114 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.SafeGetAt(start)))->m_CommitHash;
2115 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_arShownList.GetCount()-1));
2116 rev2 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.SafeGetAt(count-1)))->m_CommitHash;
2117 selectedrevs = m_LogList.GetSelectedCount();
2118 if (selectedrevs)
2119 selectedfiles = m_ChangedFileListCtrl.GetSelectedCount();
2121 CString sTemp;
2122 sTemp.Format(IDS_PROC_LOG_STATS,
2123 count - start,
2124 rev2.ToString().Left(g_Git.GetShortHASHLength()), rev1.ToString().Left(g_Git.GetShortHASHLength()), selectedrevs, selectedfiles);
2126 if(selectedrevs == 1)
2128 CString str=m_ChangedFileListCtrl.GetStatisticsString(true);
2129 str.Replace(_T('\n'), _T(' '));
2130 sTemp += _T("\r\n") + str;
2132 m_sLogInfo = sTemp;
2134 UpdateData(FALSE);
2137 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
2139 // the date control should not show the "today" button
2140 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
2141 if (pCtrl)
2142 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
2143 *pResult = 0;
2146 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
2148 // the date control should not show the "today" button
2149 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
2150 if (pCtrl)
2151 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
2152 *pResult = 0;
2155 void CLogDlg::OnSize(UINT nType, int cx, int cy)
2157 __super::OnSize(nType, cx, cy);
2158 //set range
2159 SetSplitterRange();
2162 void CLogDlg::OnRefresh()
2165 m_limit = 0;
2166 this->m_LogProgress.SetPos(0);
2168 Refresh (false);
2172 void CLogDlg::OnFocusFilter()
2174 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
2177 void CLogDlg::OnEditCopy()
2179 if (GetFocus() == &m_ChangedFileListCtrl)
2180 CopyChangedSelectionToClipBoard();
2181 else
2182 m_LogList.CopySelectionToClipBoard();
2185 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
2187 // is the URL a relative one?
2188 if (url.Left(2).Compare(_T("^/")) == 0)
2190 // URL is relative to the repository root
2191 CString url1 = m_sRepositoryRoot + url.Mid(1);
2192 TCHAR buf[INTERNET_MAX_URL_LENGTH];
2193 DWORD len = url.GetLength();
2194 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
2195 return CString(buf, len);
2196 return url1;
2198 else if (url[0] == '/')
2200 // URL is relative to the server's hostname
2201 CString sHost;
2202 // find the server's hostname
2203 int schemepos = m_sRepositoryRoot.Find(_T("//"));
2204 if (schemepos >= 0)
2206 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
2207 CString url1 = sHost + url;
2208 TCHAR buf[INTERNET_MAX_URL_LENGTH];
2209 DWORD len = url.GetLength();
2210 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
2211 return CString(buf, len);
2212 return url1;
2215 return url;
2219 void CLogDlg::OnEnChangeSearchedit()
2221 UpdateData();
2222 if (m_LogList.m_sFilterText.IsEmpty())
2224 CStoreSelection storeselection(this);
2225 // clear the filter, i.e. make all entries appear
2226 theApp.DoWaitCursor(1);
2227 KillTimer(LOGFILTER_TIMER);
2228 FillLogMessageCtrl(false);
2230 Refresh();
2231 //m_LogList.StartFilter();
2232 #if 0
2233 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2234 m_arShownList.RemoveAll();
2235 for (DWORD i=0; i<m_logEntries.size(); ++i)
2237 if (IsEntryInDateRange(i))
2238 m_arShownList.Add(m_logEntries[i]);
2240 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2241 m_LogList.DeleteAllItems();
2242 m_LogList.SetItemCountEx(ShownCountWithStopped());
2243 m_LogList.RedrawItems(0, ShownCountWithStopped());
2244 m_LogList.SetRedraw(false);
2245 ResizeAllListCtrlCols();
2246 m_LogList.SetRedraw(true);
2247 #endif
2248 theApp.DoWaitCursor(-1);
2249 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
2250 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
2251 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
2252 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
2253 return;
2255 if (Validate(m_LogList.m_sFilterText))
2256 SetTimer(LOGFILTER_TIMER, 1000, NULL);
2257 else
2258 KillTimer(LOGFILTER_TIMER);
2262 void CLogDlg::OnBnClickedAllBranch()
2264 this->UpdateData();
2266 if(this->m_bAllBranch)
2267 m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH;
2268 else
2269 m_LogList.m_ShowMask&=~CGit::LOG_INFO_ALL_BRANCH;
2271 OnRefresh();
2273 FillLogMessageCtrl(false);
2276 void CLogDlg::OnBnClickedFollowRenames()
2278 this->UpdateData();
2280 if(m_bFollowRenames)
2282 m_LogList.m_ShowMask |= CGit::LOG_INFO_FOLLOW;
2283 if (m_bAllBranch)
2286 m_bAllBranch = FALSE;
2287 m_LogList.m_ShowMask &=~ CGit::LOG_INFO_ALL_BRANCH;
2291 else
2292 m_LogList.m_ShowMask &= ~CGit::LOG_INFO_FOLLOW;
2294 DialogEnableWindow(IDC_LOG_ALLBRANCH, !m_bFollowRenames);
2295 DialogEnableWindow(IDC_SHOWWHOLEPROJECT, !m_bFollowRenames);
2297 OnRefresh();
2299 FillLogMessageCtrl(false);
2302 void CLogDlg::OnBnClickedShowTags()
2304 this->UpdateData();
2306 if (m_bShowTags)
2307 m_LogList.m_ShowRefMask |= LOGLIST_SHOWTAGS;
2308 else
2309 m_LogList.m_ShowRefMask &= ~LOGLIST_SHOWTAGS;
2311 m_LogList.Invalidate();
2314 void CLogDlg::OnBnClickedBrowseRef()
2316 CString newRef = CBrowseRefsDlg::PickRef(false, m_LogList.GetRange(), gPickRef_All, true);
2317 if(newRef.IsEmpty())
2318 return;
2320 SetRange(newRef);
2321 ((CButton*)GetDlgItem(IDC_LOG_ALLBRANCH))->SetCheck(0);
2323 OnBnClickedAllBranch();
2326 void CLogDlg::ShowStartRef()
2328 //Show ref name on top
2329 if(!::IsWindow(m_hWnd))
2330 return;
2331 if(m_bAllBranch)
2333 m_staticRef.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_ALLBRANCHES)));
2334 m_staticRef.Invalidate(TRUE);
2335 m_tooltips.DelTool(GetDlgItem(IDC_STATIC_REF));
2336 return;
2339 CString showStartRef = m_LogList.GetRange();
2340 if (showStartRef.IsEmpty() || showStartRef == _T("HEAD"))
2342 showStartRef.Empty();
2343 //Ref name is HEAD
2344 if (g_Git.Run(L"git symbolic-ref HEAD", &showStartRef, NULL, CP_UTF8))
2345 showStartRef = CString(MAKEINTRESOURCE(IDS_PROC_LOG_NOBRANCH));
2346 showStartRef.Trim(L"\r\n\t ");
2350 showStartRef = g_Git.StripRefName(showStartRef);
2352 m_staticRef.SetWindowText(showStartRef);
2353 CWnd *pWnd = GetDlgItem(IDC_STATIC_REF);
2354 m_tooltips.AddTool(pWnd, showStartRef);
2355 m_staticRef.Invalidate(TRUE);
2358 void CLogDlg::SetRange(const CString& range)
2360 m_LogList.SetRange(range);
2362 ShowStartRef();
2366 void CLogDlg::OnBnClickedFirstParent()
2368 this->UpdateData();
2370 if(this->m_bFirstParent)
2371 m_LogList.m_ShowMask|=CGit::LOG_INFO_FIRST_PARENT;
2372 else
2373 m_LogList.m_ShowMask&=~CGit::LOG_INFO_FIRST_PARENT;
2375 OnRefresh();
2377 FillLogMessageCtrl(false);
2381 void CLogDlg::OnBnClickShowWholeProject()
2383 this->UpdateData();
2385 if(this->m_bWholeProject)
2387 m_LogList.m_Path.Reset();
2388 SetDlgTitle();
2389 DialogEnableWindow(IDC_LOG_FOLLOWRENAMES, FALSE);
2391 else
2393 m_LogList.m_Path=m_path;
2394 DialogEnableWindow(IDC_LOG_FOLLOWRENAMES, !(m_path.IsEmpty() || m_path.IsDirectory()));
2397 SetDlgTitle();
2399 OnRefresh();
2401 FillLogMessageCtrl(false);
2405 LRESULT CLogDlg::OnRefLogChanged(WPARAM /*wParam*/, LPARAM /*lParam*/)
2407 ShowStartRef();
2408 return 0;
2411 LRESULT CLogDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
2413 m_pTaskbarList.Release();
2414 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
2415 SetUUIDOverlayIcon(m_hWnd);
2416 return 0;