1 // TortoiseGit - a Windows shell extension for easy version control
2 // Copyright (C) 2003-2008 - TortoiseGit
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License for more details.
12 // You should have received a copy of the GNU General Public License
13 // along with this program; if not, write to the Free Software Foundation,
14 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #include "TortoiseProc.h"
21 #include "SVNProgressDlg.h"
22 #include "ProgressDlg.h"
23 //#include "RepositoryBrowser.h"
24 //#include "CopyDlg.h"
25 #include "StatGraphDlg.h"
27 #include "MessageBox.h"
30 #include "PathUtils.h"
31 #include "StringUtils.h"
32 #include "UnicodeUtils.h"
34 //#include "GitInfo.h"
35 //#include "GitDiff.h"
37 //#include "RevisionRangeDlg.h"
38 //#include "BrowseFolder.h"
39 //#include "BlameDlg.h"
41 //#include "GitHelpers.h"
42 #include "GitStatus.h"
43 //#include "LogDlgHelper.h"
44 //#include "CachedLogInfo.h"
45 //#include "RepositoryInfo.h"
46 //#include "EditPropertiesDlg.h"
47 #include "FileDiffDlg.h"
50 const UINT
CLogDlg::m_FindDialogMessage
= RegisterWindowMessage(FINDMSGSTRING
);
53 IMPLEMENT_DYNAMIC(CLogDlg
, CResizableStandAloneDialog
)
54 CLogDlg::CLogDlg(CWnd
* pParent
/*=NULL*/)
55 : CResizableStandAloneDialog(CLogDlg::IDD
, pParent
)
59 , m_currentChangedArray(NULL
)
63 , m_regLastStrict(_T("Software\\TortoiseGit\\LastLogStrict"), FALSE
)
65 , m_bSelectionMustBeContinuous(false)
66 , m_bShowBugtraqColumn(false)
72 , m_pNotifyWindow(NULL
)
79 , m_bIncludeMerges(FALSE
)
83 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
90 m_CurrentFilteredChangedArray
.RemoveAll();
94 void CLogDlg::DoDataExchange(CDataExchange
* pDX
)
96 CResizableStandAloneDialog::DoDataExchange(pDX
);
97 DDX_Control(pDX
, IDC_LOGLIST
, m_LogList
);
98 DDX_Control(pDX
, IDC_LOGMSG
, m_ChangedFileListCtrl
);
99 DDX_Control(pDX
, IDC_PROGRESS
, m_LogProgress
);
100 DDX_Control(pDX
, IDC_SPLITTERTOP
, m_wndSplitter1
);
101 DDX_Control(pDX
, IDC_SPLITTERBOTTOM
, m_wndSplitter2
);
102 DDX_Check(pDX
, IDC_CHECK_STOPONCOPY
, m_bStrict
);
103 DDX_Text(pDX
, IDC_SEARCHEDIT
, m_LogList
.m_sFilterText
);
104 DDX_Control(pDX
, IDC_DATEFROM
, m_DateFrom
);
105 DDX_Control(pDX
, IDC_DATETO
, m_DateTo
);
106 DDX_Control(pDX
, IDC_HIDEPATHS
, m_cHidePaths
);
107 DDX_Control(pDX
, IDC_GETALL
, m_btnShow
);
108 DDX_Text(pDX
, IDC_LOGINFO
, m_sLogInfo
);
109 DDX_Check(pDX
, IDC_INCLUDEMERGE
, m_bIncludeMerges
);
110 DDX_Control(pDX
, IDC_SEARCHEDIT
, m_cFilter
);
113 BEGIN_MESSAGE_MAP(CLogDlg
, CResizableStandAloneDialog
)
114 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
115 ON_BN_CLICKED(IDC_GETALL
, OnBnClickedGetall
)
116 //ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)
119 ON_BN_CLICKED(IDHELP
, OnBnClickedHelp
)
120 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_LOGLIST
, OnLvnItemchangedLoglist
)
121 ON_NOTIFY(EN_LINK
, IDC_MSGVIEW
, OnEnLinkMsgview
)
122 ON_BN_CLICKED(IDC_STATBUTTON
, OnBnClickedStatbutton
)
124 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED
, OnClickedInfoIcon
)
125 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED
, OnClickedCancelFilter
)
127 ON_EN_CHANGE(IDC_SEARCHEDIT
, OnEnChangeSearchedit
)
129 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATETO
, OnDtnDatetimechangeDateto
)
130 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATEFROM
, OnDtnDatetimechangeDatefrom
)
131 ON_BN_CLICKED(IDC_NEXTHUNDRED
, OnBnClickedNexthundred
)
132 //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
133 //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
134 ON_NOTIFY(LVN_COLUMNCLICK
,IDC_LOGLIST
, OnLvnColumnclick
)
135 //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
136 ON_BN_CLICKED(IDC_HIDEPATHS
, OnBnClickedHidepaths
)
138 ON_BN_CLICKED(IDC_CHECK_STOPONCOPY
, &CLogDlg::OnBnClickedCheckStoponcopy
)
139 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATEFROM
, &CLogDlg::OnDtnDropdownDatefrom
)
140 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATETO
, &CLogDlg::OnDtnDropdownDateto
)
142 ON_BN_CLICKED(IDC_INCLUDEMERGE
, &CLogDlg::OnBnClickedIncludemerge
)
143 ON_BN_CLICKED(IDC_REFRESH
, &CLogDlg::OnBnClickedRefresh
)
144 ON_COMMAND(ID_LOGDLG_REFRESH
,&CLogDlg::OnRefresh
)
145 ON_COMMAND(ID_LOGDLG_FIND
,&CLogDlg::OnFind
)
146 ON_COMMAND(ID_LOGDLG_FOCUSFILTER
,&CLogDlg::OnFocusFilter
)
147 ON_COMMAND(ID_EDIT_COPY
, &CLogDlg::OnEditCopy
)
150 void CLogDlg::SetParams(const CTGitPath
& path
, GitRev pegrev
, GitRev startrev
, GitRev endrev
, int limit
, BOOL bStrict
/* = FALSE */, BOOL bSaveStrict
/* = TRUE */)
154 m_startrev
= startrev
;
155 m_LogRevision
= startrev
;
157 m_hasWC
= !path
.IsUrl();
159 m_bSaveStrict
= bSaveStrict
;
161 if (::IsWindow(m_hWnd
))
165 BOOL
CLogDlg::OnInitDialog()
167 CResizableStandAloneDialog::OnInitDialog();
169 m_hAccel
= LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG
));
172 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
173 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
174 GetVersionEx((OSVERSIONINFO
*)&inf
);
175 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
176 m_bVista
= (fullver
>= 0x0600);
178 // use the state of the "stop on copy/rename" option from the last time
180 m_bStrict
= m_regLastStrict
;
184 temp
.Format(IDS_LOG_SHOWNEXT
, m_limit
);
186 temp
.Format(IDS_LOG_SHOWNEXT
, (int)(DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100));
188 SetDlgItemText(IDC_NEXTHUNDRED
, temp
);
190 // set the font to use in the log message view, configured in the settings dialog
191 CAppUtils::CreateFontForLogs(m_logFont
);
192 GetDlgItem(IDC_MSGVIEW
)->SetFont(&m_logFont
);
193 // automatically detect URLs in the log message and turn them into links
194 GetDlgItem(IDC_MSGVIEW
)->SendMessage(EM_AUTOURLDETECT
, TRUE
, NULL
);
195 // make the log message rich edit control send a message when the mouse pointer is over a link
196 GetDlgItem(IDC_MSGVIEW
)->SendMessage(EM_SETEVENTMASK
, NULL
, ENM_LINK
);
197 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
199 // the "hide unrelated paths" checkbox should be indeterminate
200 m_cHidePaths
.SetCheck(BST_INDETERMINATE
);
203 // if there is a working copy, load the project properties
204 // to get information about the bugtraq: integration
206 m_ProjectProperties
.ReadProps(m_path
);
208 // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set
209 if ((!m_ProjectProperties
.sUrl
.IsEmpty())||(!m_ProjectProperties
.sCheckRe
.IsEmpty()))
210 m_bShowBugtraqColumn
= true;
212 //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
213 //theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
215 // set up the columns
216 m_LogList
.DeleteAllItems();
217 m_LogList
.InsertGitColumn();
219 m_ChangedFileListCtrl
.Init(SVNSLC_COLEXT
| SVNSLC_COLSTATUS
|IDS_STATUSLIST_COLADD
|IDS_STATUSLIST_COLDEL
, _T("LogDlg"));
221 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
224 m_sMessageBuf
.Preallocate(100000);
226 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
229 m_tooltips
.Create(this);
230 CheckRegexpTooltip();
234 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
235 m_cFilter
.SetCancelBitmaps(IDI_CANCELNORMAL
, IDI_CANCELPRESSED
);
236 m_cFilter
.SetInfoIcon(IDI_LOGFILTER
);
237 m_cFilter
.SetValidator(this);
239 AdjustControlSize(IDC_HIDEPATHS
);
240 AdjustControlSize(IDC_CHECK_STOPONCOPY
);
241 AdjustControlSize(IDC_INCLUDEMERGE
);
243 GetClientRect(m_DlgOrigRect
);
244 m_LogList
.GetClientRect(m_LogListOrigRect
);
245 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(m_MsgViewOrigRect
);
246 m_ChangedFileListCtrl
.GetClientRect(m_ChgOrigRect
);
248 m_DateFrom
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
249 m_DateTo
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
252 AddAnchor(IDC_FROMLABEL
, TOP_LEFT
);
253 AddAnchor(IDC_DATEFROM
, TOP_LEFT
);
254 AddAnchor(IDC_TOLABEL
, TOP_LEFT
);
255 AddAnchor(IDC_DATETO
, TOP_LEFT
);
258 AddAnchor(IDC_SEARCHEDIT
, TOP_LEFT
, TOP_RIGHT
);
260 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
261 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
262 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
263 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
264 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
266 AddAnchor(IDC_LOGINFO
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
267 AddAnchor(IDC_HIDEPATHS
, BOTTOM_LEFT
);
268 AddAnchor(IDC_CHECK_STOPONCOPY
, BOTTOM_LEFT
);
269 AddAnchor(IDC_INCLUDEMERGE
, BOTTOM_LEFT
);
270 AddAnchor(IDC_GETALL
, BOTTOM_LEFT
);
271 AddAnchor(IDC_NEXTHUNDRED
, BOTTOM_LEFT
);
272 AddAnchor(IDC_REFRESH
, BOTTOM_LEFT
);
273 AddAnchor(IDC_STATBUTTON
, BOTTOM_RIGHT
);
274 AddAnchor(IDC_PROGRESS
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
275 AddAnchor(IDOK
, BOTTOM_RIGHT
);
276 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
277 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
279 // SetPromptParentWindow(m_hWnd);
282 CenterWindow(CWnd::FromHandle(hWndExplorer
));
283 EnableSaveRestore(_T("LogDlg"));
285 DWORD yPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
286 DWORD yPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
287 RECT rcDlg
, rcLogList
, rcChgMsg
;
288 GetClientRect(&rcDlg
);
289 m_LogList
.GetWindowRect(&rcLogList
);
290 ScreenToClient(&rcLogList
);
291 m_ChangedFileListCtrl
.GetWindowRect(&rcChgMsg
);
292 ScreenToClient(&rcChgMsg
);
296 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
297 ScreenToClient(&rectSplitter
);
298 int delta
= yPos1
- rectSplitter
.top
;
300 if ((rcLogList
.bottom
+ delta
> rcLogList
.top
)&&(rcLogList
.bottom
+ delta
< rcChgMsg
.bottom
- 30))
302 m_wndSplitter1
.SetWindowPos(NULL
, 0, yPos1
, 0, 0, SWP_NOSIZE
);
309 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
310 ScreenToClient(&rectSplitter
);
311 int delta
= yPos2
- rectSplitter
.top
;
313 if ((rcChgMsg
.top
+ delta
< rcChgMsg
.bottom
)&&(rcChgMsg
.top
+ delta
> rcLogList
.top
+ 30))
315 m_wndSplitter2
.SetWindowPos(NULL
, 0, yPos2
, 0, 0, SWP_NOSIZE
);
323 // the dialog is used to select revisions
324 if (m_bSelectionMustBeContinuous
)
325 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()!=0)&&(m_LogList
.IsSelectionContinuous()));
327 DialogEnableWindow(IDOK
, m_LogList
.GetSelectedCount()!=0);
331 // the dialog is used to just view log messages
332 GetDlgItemText(IDOK
, temp
);
333 SetDlgItemText(IDCANCEL
, temp
);
334 GetDlgItem(IDOK
)->ShowWindow(SW_HIDE
);
337 // set the choices for the "Show All" button
338 temp
.LoadString(IDS_LOG_SHOWALL
);
339 m_btnShow
.AddEntry(temp
);
340 temp
.LoadString(IDS_LOG_SHOW_WHOLE
);
341 m_btnShow
.AddEntry(temp
);
342 m_btnShow
.SetCurrentEntry((LONG
)CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry")));
344 m_mergedRevs
.clear();
346 // first start a thread to obtain the log messages without
347 // blocking the dialog
349 //m_tFrom = (DWORD)-1;
351 m_LogList
.m_Path
=m_path
;
352 m_LogList
.FetchLogAsync(LogCallBack
,this);
354 GetDlgItem(IDC_LOGLIST
)->SetFocus();
358 void CLogDlg::LogRunStatus(int cur
)
360 if( cur
== GITLOG_START
)
363 temp
.LoadString(IDS_PROGRESSWAIT
);
365 // change the text of the close button to "Cancel" since now the thread
366 // is running, and simply closing the dialog doesn't work.
367 if (!GetDlgItem(IDOK
)->IsWindowVisible())
369 temp
.LoadString(IDS_MSGBOX_CANCEL
);
370 SetDlgItemText(IDCANCEL
, temp
);
373 // We use a progress bar while getting the logs
374 m_LogProgress
.SetRange32(0, 100);
375 m_LogProgress
.SetPos(0);
377 GetDlgItem(IDC_PROGRESS
)->ShowWindow(TRUE
);
379 //DialogEnableWindow(IDC_GETALL, FALSE);
380 DialogEnableWindow(IDC_NEXTHUNDRED
, FALSE
);
381 DialogEnableWindow(IDC_CHECK_STOPONCOPY
, FALSE
);
382 DialogEnableWindow(IDC_INCLUDEMERGE
, FALSE
);
383 DialogEnableWindow(IDC_STATBUTTON
, FALSE
);
384 DialogEnableWindow(IDC_REFRESH
, FALSE
);
385 DialogEnableWindow(IDC_HIDEPATHS
,FALSE
);
388 if( cur
== GITLOG_END
)
392 DialogEnableWindow(IDC_NEXTHUNDRED
, TRUE
);
394 DialogEnableWindow(IDC_GETALL
, TRUE
);
395 //DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);
396 DialogEnableWindow(IDC_STATBUTTON
, TRUE
);
397 DialogEnableWindow(IDC_REFRESH
, TRUE
);
399 PostMessage(WM_TIMER
, LOGFILTER_TIMER
);
401 //CTime time=m_LogList.GetOldestTime();
403 m_LogList
.GetTimeRange(begin
,end
);
404 m_DateFrom
.SetTime(&begin
);
405 m_DateTo
.SetTime(&end
);
408 m_LogProgress
.SetPos(cur
);
410 void CLogDlg::SetDlgTitle(bool bOffline
)
412 if (m_sTitle
.IsEmpty())
413 GetWindowText(m_sTitle
);
419 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetUIPathString());
420 else if (m_path
.IsDirectory())
421 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetWinPathString());
423 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetFilename());
424 SetWindowText(sTemp
);
429 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetUIPathString());
430 else if (m_path
.IsEmpty())
431 SetWindowText(m_sTitle
+ _T(" - ") + CString(_T("Whole Project")));
432 else if (m_path
.IsDirectory())
433 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetWinPathString());
435 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetFilename());
439 void CLogDlg::CheckRegexpTooltip()
441 CWnd
*pWnd
= GetDlgItem(IDC_SEARCHEDIT
);
442 // Since tooltip describes regexp features, show it only if regexps are enabled.
443 if (m_bFilterWithRegex
)
445 m_tooltips
.AddTool(pWnd
, IDS_LOG_FILTER_REGEX_TT
);
448 m_tooltips
.DelTool(pWnd
);
451 void CLogDlg::EnableOKButton()
455 // the dialog is used to select revisions
456 if (m_bSelectionMustBeContinuous
)
457 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()!=0)&&(m_LogList
.IsSelectionContinuous()));
459 DialogEnableWindow(IDOK
, m_LogList
.GetSelectedCount()!=0);
462 DialogEnableWindow(IDOK
, TRUE
);
465 void CLogDlg::FillLogMessageCtrl(bool bShow
/* = true*/)
467 // we fill here the log message rich edit control,
468 // and also populate the changed files list control
469 // according to the selected revision(s).
471 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
472 // empty the log message view
473 pMsgView
->SetWindowText(_T(" "));
474 // empty the changed files list
475 m_ChangedFileListCtrl
.SetRedraw(FALSE
);
476 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
477 m_currentChangedArray
= NULL
;
478 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
479 m_ChangedFileListCtrl
.DeleteAllItems();
481 // if we're not here to really show a selected revision, just
482 // get out of here after clearing the views, which is what is intended
483 // if that flag is not set.
487 m_ChangedFileListCtrl
.Invalidate();
488 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
489 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
493 // depending on how many revisions are selected, we have to do different
495 int selCount
= m_LogList
.GetSelectedCount();
498 // if nothing is selected, we have nothing more to do
499 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
500 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
503 else if (selCount
== 1)
505 // if one revision is selected, we have to fill the log message view
506 // with the corresponding log message, and also fill the changed files
508 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
509 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
510 if (selIndex
>= m_LogList
.m_arShownList
.GetCount())
512 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
513 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
516 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(selIndex
));
518 if(!pLogEntry
->m_IsFull
)
520 pMsgView
->SetWindowText(_T("load ..."));
523 // set the log message text
524 pMsgView
->SetWindowText(_T("Commit:")+pLogEntry
->m_CommitHash
+_T("\r\n\r\n*")+pLogEntry
->m_Subject
+_T("\n\n")+pLogEntry
->m_Body
);
525 // turn bug ID's into links if the bugtraq: properties have been set
526 // and we can find a match of those in the log message
527 m_ProjectProperties
.FindBugID(pLogEntry
->m_Body
, pMsgView
);
528 CAppUtils::FormatTextInRichEditControl(pMsgView
);
530 m_ChangedFileListCtrl
.UpdateWithGitPathList(pLogEntry
->m_Files
);
531 m_ChangedFileListCtrl
.m_CurrentVersion
=pLogEntry
->m_CommitHash
;
532 m_ChangedFileListCtrl
.Show(SVNSLC_SHOWVERSIONED
);
534 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
538 // fill in the changed files list control
539 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
541 m_CurrentFilteredChangedArray
.RemoveAll();
542 for (INT_PTR c
= 0; c
< m_currentChangedArray
->GetCount(); ++c
)
544 LogChangedPath
* cpath
= m_currentChangedArray
->GetAt(c
);
547 if (m_currentChangedArray
->GetAt(c
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
549 m_CurrentFilteredChangedArray
.Add(cpath
);
552 m_currentChangedArray
= &m_CurrentFilteredChangedArray
;
558 // more than one revision is selected:
559 // the log message view must be emptied
560 // the changed files list contains all the changed paths from all
561 // selected revisions, with 'doubles' removed
562 m_currentChangedPathList
= GetChangedPathsFromSelectedRevisions(true);
566 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
568 if (m_currentChangedArray
)
570 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedArray
->GetCount());
571 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedArray
->GetCount());
573 else if (m_currentChangedPathList
.GetCount())
575 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedPathList
.GetCount());
576 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedPathList
.GetCount());
580 m_ChangedFileListCtrl
.SetItemCountEx(0);
581 m_ChangedFileListCtrl
.Invalidate();
584 CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl
);
585 // sort according to the settings
586 if (m_nSortColumnPathList
> 0)
587 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
589 SetSortArrow(&m_ChangedFileListCtrl
, -1, false);
590 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
594 void CLogDlg::OnBnClickedGetall()
599 void CLogDlg::GetAll(bool bForceAll
/* = false */)
602 // fetch all requested log messages, either the specified range or
603 // really *all* available log messages.
605 INT_PTR entry
= m_btnShow
.GetCurrentEntry();
611 case 0: // show all branch;
612 m_LogList
.m_bAllBranch
=true;
614 case 1: // show whole project
615 m_LogList
.m_Path
.Reset();
616 SetWindowText(m_sTitle
+ _T(" - "));
619 m_LogList
.m_bExitThread
=TRUE
;
620 ::WaitForSingleObject(m_LogList
.m_LoadingThread
->m_hThread
,INFINITE
);
623 m_LogList
.FetchLogAsync(LogCallBack
,this);
625 m_ChangedFileListCtrl
.SetItemCountEx(0);
626 m_ChangedFileListCtrl
.Invalidate();
627 // We need to create CStoreSelection on the heap or else
628 // the variable will run out of the scope before the
629 // thread ends. Therefore we let the thread delete
631 m_pStoreSelection
= new CStoreSelection(this);
632 m_LogList
.SetItemCountEx(0);
633 m_LogList
.Invalidate();
634 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
635 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
636 pMsgView
->SetWindowText(_T(""));
638 SetSortArrow(&m_LogList
, -1, true);
640 m_LogList
.DeleteAllItems();
641 m_arShownList
.RemoveAll();
642 m_logEntries
.ClearAll();
645 m_bCancelled
= FALSE
;
650 InterlockedExchange(&m_bThreadRunning
, TRUE
);
651 if (AfxBeginThread(LogThreadEntry
, this)==NULL
)
653 InterlockedExchange(&m_bThreadRunning
, FALSE
);
654 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
656 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
657 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
661 void CLogDlg::OnBnClickedRefresh()
667 void CLogDlg::Refresh (bool autoGoOnline
)
672 void CLogDlg::OnBnClickedNexthundred()
676 // we have to fetch the next X log messages.
677 if (m_logEntries
.size() < 1)
679 // since there weren't any log messages fetched before, just
680 // fetch all since we don't have an 'anchor' to fetch the 'next'
684 git_revnum_t rev
= m_logEntries
[m_logEntries
.size()-1]->Rev
;
687 return; // do nothing! No more revisions to get
691 m_bCancelled
= FALSE
;
693 // rev is is revision we already have and we will receive it again
694 // -> fetch one extra revision to get NumberOfLogs *new* revisions
696 m_limit
= (int)(DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;
697 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
698 SetSortArrow(&m_LogList
, -1, true);
699 InterlockedExchange(&m_bThreadRunning
, TRUE
);
700 // We need to create CStoreSelection on the heap or else
701 // the variable will run out of the scope before the
702 // thread ends. Therefore we let the thread delete
704 m_pStoreSelection
= new CStoreSelection(this);
706 // since we fetch the log from the last revision we already have,
707 // we have to remove that revision entry to avoid getting it twice
708 m_logEntries
.pop_back();
709 if (AfxBeginThread(LogThreadEntry
, this)==NULL
)
711 InterlockedExchange(&m_bThreadRunning
, FALSE
);
712 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
714 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
715 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
719 BOOL
CLogDlg::Cancel()
724 void CLogDlg::SaveSplitterPos()
728 CRegDWORD regPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
729 CRegDWORD regPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
731 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
732 ScreenToClient(&rectSplitter
);
733 regPos1
= rectSplitter
.top
;
734 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
735 ScreenToClient(&rectSplitter
);
736 regPos2
= rectSplitter
.top
;
740 void CLogDlg::OnCancel()
742 // canceling means stopping the working thread if it's still running.
743 // we do this by using the Subversion cancel callback.
744 // But canceling can also mean just to close the dialog, depending on the
745 // text shown on the cancel button (it could simply read "OK").
747 GetDlgItemText(IDOK
, temp
);
748 temp2
.LoadString(IDS_MSGBOX_CANCEL
);
749 if ((temp
.Compare(temp2
)==0)||(this->IsThreadRunning()))
751 //m_bCancelled = true;
753 m_LogList
.TerminateThread();
757 m_regLastStrict
= m_bStrict
;
758 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
759 reg
= m_btnShow
.GetCurrentEntry();
764 CString
CLogDlg::MakeShortMessage(const CString
& message
)
766 bool bFoundShort
= true;
767 CString sShortMessage
= m_ProjectProperties
.GetLogSummary(message
);
768 if (sShortMessage
.IsEmpty())
771 sShortMessage
= message
;
773 // Remove newlines and tabs 'cause those are not shown nicely in the list control
774 sShortMessage
.Replace(_T("\r"), _T(""));
775 sShortMessage
.Replace(_T("\t"), _T(" "));
777 // Suppose the first empty line separates 'summary' from the rest of the message.
778 int found
= sShortMessage
.Find(_T("\n\n"));
779 // To avoid too short 'short' messages
780 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
781 // only use the empty newline as a separator if it comes after at least 15 chars.
782 if ((!bFoundShort
)&&(found
>= 15))
784 sShortMessage
= sShortMessage
.Left(found
);
786 sShortMessage
.Replace('\n', ' ');
787 return sShortMessage
;
790 BOOL
CLogDlg::Log(git_revnum_t rev
, const CString
& author
, const CString
& date
, const CString
& message
, LogChangedPathArray
* cpaths
, int filechanges
, BOOL copies
, DWORD actions
, BOOL haschildren
)
793 if (rev
== SVN_INVALID_REVNUM
)
799 // this is the callback function which receives the data for every revision we ask the log for
800 // we store this information here one by one.
802 if (m_startrev
== -1)
807 m_LogProgress
.SetPos(m_limit
- m_limitcounter
);
809 else if (m_startrev
.IsNumber() && m_startrev
.IsNumber())
810 m_LogProgress
.SetPos((git_revnum_t
)m_startrev
-rev
+(git_revnum_t
)m_endrev
);
811 __time64_t ttime
= time
/1000000L;
812 if (m_tTo
< (DWORD
)ttime
)
813 m_tTo
= (DWORD
)ttime
;
814 if (m_tFrom
> (DWORD
)ttime
)
815 m_tFrom
= (DWORD
)ttime
;
816 if ((m_lowestRev
> rev
)||(m_lowestRev
< 0))
818 // Add as many characters from the log message to the list control
819 PLOGENTRYDATA pLogItem
= new LOGENTRYDATA
;
820 pLogItem
->bCopies
= !!copies
;
822 // find out if this item was copied in the revision
823 BOOL copiedself
= FALSE
;
826 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< cpaths
->GetCount(); ++cpPathIndex
)
828 LogChangedPath
* cpath
= cpaths
->GetAt(cpPathIndex
);
829 if (!cpath
->sCopyFromPath
.IsEmpty() && (cpath
->sPath
.Compare(m_sSelfRelativeURL
) == 0))
831 // note: this only works if the log is fetched top-to-bottom
832 // but since we do that, it shouldn't be a problem
833 m_sSelfRelativeURL
= cpath
->sCopyFromPath
;
839 pLogItem
->bCopiedSelf
= copiedself
;
840 pLogItem
->tmDate
= ttime
;
841 pLogItem
->sAuthor
= author
;
842 pLogItem
->sDate
= date
;
843 pLogItem
->sShortMessage
= MakeShortMessage(message
);
844 pLogItem
->dwFileChanges
= filechanges
;
845 pLogItem
->actions
= actions
;
846 pLogItem
->haschildren
= haschildren
;
847 pLogItem
->childStackDepth
= m_childCounter
;
848 m_maxChild
= max(m_childCounter
, m_maxChild
);
851 pLogItem
->sBugIDs
= m_ProjectProperties
.FindBugID(message
).Trim();
853 // split multi line log entries and concatenate them
854 // again but this time with \r\n as line separators
855 // so that the edit control recognizes them
858 if (message
.GetLength()>0)
860 m_sMessageBuf
= message
;
861 m_sMessageBuf
.Replace(_T("\n\r"), _T("\n"));
862 m_sMessageBuf
.Replace(_T("\r\n"), _T("\n"));
863 if (m_sMessageBuf
.Right(1).Compare(_T("\n"))==0)
864 m_sMessageBuf
= m_sMessageBuf
.Left(m_sMessageBuf
.GetLength()-1);
867 m_sMessageBuf
.Empty();
868 pLogItem
->sMessage
= m_sMessageBuf
;
871 // move-construct path array
873 pLogItem
->pArChangedPaths
= new LogChangedPathArray (*cpaths
);
876 catch (CException
* e
)
878 ::MessageBox(NULL
, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR
);
882 m_logEntries
.push_back(pLogItem
);
883 m_arShownList
.Add(pLogItem
);
889 //this is the thread function which calls the subversion function
894 void CLogDlg::CopyChangedSelectionToClipBoard()
897 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
899 return; // nothing is selected, get out of here
903 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
906 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
909 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
910 sPaths
+= m_currentChangedPathList
[nItem
].GetGitPathString();
911 sPaths
+= _T("\r\n");
916 // only one revision is selected in the log dialog top pane
917 // but multiple items could be selected in the changed items list
918 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
921 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
922 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(nItem
);
924 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
926 // some items are hidden! So find out which item the user really selected
927 INT_PTR selRealIndex
= -1;
928 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
930 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
932 if (selRealIndex
== nItem
)
934 changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
);
941 sPaths
+= changedlogpath
->sPath
;
942 sPaths
+= _T("\r\n");
947 CStringUtils::WriteAsciiStringToClipboard(sPaths
, GetSafeHwnd());
951 BOOL
CLogDlg::IsDiffPossible(LogChangedPath
* changedpath
, git_revnum_t rev
)
954 CString added
, deleted
;
955 if (changedpath
== NULL
)
958 if ((rev
> 1)&&(changedpath
->action
!= LOGACTIONS_DELETED
))
960 if (changedpath
->action
== LOGACTIONS_ADDED
) // file is added
962 if (changedpath
->lCopyFromRev
== 0)
963 return FALSE
; // but file was not added with history
971 void CLogDlg::OnContextMenu(CWnd
* pWnd
, CPoint point
)
973 // we have two separate context menus:
974 // one shown on the log message list control,
975 // the other shown in the changed-files list control
976 int selCount
= m_LogList
.GetSelectedCount();
977 if (pWnd
== &m_LogList
)
979 //ShowContextMenuForRevisions(pWnd, point);
981 else if (pWnd
== &m_ChangedFileListCtrl
)
983 //ShowContextMenuForChangedpaths(pWnd, point);
985 else if ((selCount
== 1)&&(pWnd
== GetDlgItem(IDC_MSGVIEW
)))
987 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
990 selIndex
= m_LogList
.GetNextSelectedItem(pos
);
991 if ((point
.x
== -1) && (point
.y
== -1))
994 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(&rect
);
995 ClientToScreen(&rect
);
996 point
= rect
.CenterPoint();
998 CString sMenuItemText
;
1000 if (popup
.CreatePopupMenu())
1002 // add the 'default' entries
1003 sMenuItemText
.LoadString(IDS_SCIEDIT_COPY
);
1004 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, WM_COPY
, sMenuItemText
);
1005 sMenuItemText
.LoadString(IDS_SCIEDIT_SELECTALL
);
1006 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, EM_SETSEL
, sMenuItemText
);
1008 //if (selIndex >= 0)
1010 // popup.AppendMenu(MF_SEPARATOR);
1011 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
1012 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
1015 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1019 break; // no command selected
1022 ::SendMessage(GetDlgItem(IDC_MSGVIEW
)->GetSafeHwnd(), cmd
, 0, -1);
1024 case CGitLogList::ID_EDITAUTHOR
:
1025 EditLogMessage(selIndex
);
1033 LRESULT
CLogDlg::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1036 ASSERT(m_pFindDialog
!= NULL
);
1038 if (m_pFindDialog
->IsTerminating())
1040 // invalidate the handle identifying the dialog box.
1041 m_pFindDialog
= NULL
;
1045 if(m_pFindDialog
->FindNext())
1047 //read data from dialog
1048 CString FindText
= m_pFindDialog
->GetFindString();
1049 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
1050 bool bFound
= false;
1052 bool bRegex
= ValidateRegexp(FindText
, pat
, bMatchCase
);
1054 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_not_null
;
1057 for (i
= this->m_nSearchIndex
; i
<m_arShownList
.GetCount()&&!bFound
; i
++)
1061 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1063 if (regex_search(wstring((LPCTSTR
)pLogEntry
->sMessage
), pat
, flags
))
1068 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
1069 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
1071 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
1072 if (regex_search(wstring((LPCTSTR
)cpath
->sCopyFromPath
), pat
, flags
))
1078 if (regex_search(wstring((LPCTSTR
)cpath
->sPath
), pat
, flags
))
1090 if (m_logEntries
[i
]->sMessage
.Find(FindText
) >= 0)
1095 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1096 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
1097 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
1099 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
1100 if (cpath
->sCopyFromPath
.Find(FindText
)>=0)
1106 if (cpath
->sPath
.Find(FindText
)>=0)
1116 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1117 CString msg
= pLogEntry
->sMessage
;
1118 msg
= msg
.MakeLower();
1119 CString find
= FindText
.MakeLower();
1120 if (msg
.Find(find
) >= 0)
1125 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
1126 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
1128 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
1129 CString lowerpath
= cpath
->sCopyFromPath
;
1130 lowerpath
.MakeLower();
1131 if (lowerpath
.Find(find
)>=0)
1137 lowerpath
= cpath
->sPath
;
1138 lowerpath
.MakeLower();
1139 if (lowerpath
.Find(find
)>=0)
1148 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
1151 this->m_nSearchIndex
= (i
+1);
1152 m_LogList
.EnsureVisible(i
, FALSE
);
1153 m_LogList
.SetItemState(m_LogList
.GetSelectionMark(), 0, LVIS_SELECTED
);
1154 m_LogList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
1155 m_LogList
.SetSelectionMark(i
);
1156 FillLogMessageCtrl();
1159 if (m_nSearchIndex
>= m_arShownList
.GetCount())
1160 m_nSearchIndex
= (int)m_arShownList
.GetCount()-1;
1162 } // if(m_pFindDialog->FindNext())
1163 UpdateLogInfoLabel();
1168 void CLogDlg::OnOK()
1171 // since the log dialog is also used to select revisions for other
1172 // dialogs, we have to do some work before closing this dialog
1173 if (GetFocus() != GetDlgItem(IDOK
))
1174 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
1175 if (!GetDlgItem(IDOK
)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL
))
1176 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
1180 GetDlgItemText(IDOK
, buttontext
);
1181 temp
.LoadString(IDS_MSGBOX_CANCEL
);
1182 if (temp
.Compare(buttontext
) != 0)
1183 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
1184 m_bCancelled
= TRUE
;
1185 m_selectedRevs
.Clear();
1186 m_selectedRevsOneRange
.Clear();
1187 if (m_pNotifyWindow
)
1189 int selIndex
= m_LogList
.GetSelectionMark();
1192 PLOGENTRYDATA pLogEntry
= NULL
;
1193 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1194 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1195 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1196 git_revnum_t lowerRev
= pLogEntry
->Rev
;
1197 git_revnum_t higherRev
= lowerRev
;
1200 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1201 git_revnum_t rev
= pLogEntry
->Rev
;
1202 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1205 if (higherRev
< rev
)
1208 if (m_sFilterText
.IsEmpty() && m_nSortColumn
== 0 && IsSelectionContinuous())
1210 m_selectedRevsOneRange
.AddRevRange(lowerRev
, higherRev
);
1212 BOOL bSentMessage
= FALSE
;
1213 if (m_LogList
.GetSelectedCount() == 1)
1215 // if only one revision is selected, check if the path/url with which the dialog was started
1216 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
1217 // if it was copied, use the copy from revision as lowerRev
1218 if ((pLogEntry
)&&(pLogEntry
->pArChangedPaths
)&&(lowerRev
== higherRev
))
1220 CString sUrl
= m_path
.GetGitPathString();
1221 if (!m_path
.IsUrl())
1223 sUrl
= GetURLFromPath(m_path
);
1225 sUrl
= sUrl
.Mid(m_sRepositoryRoot
.GetLength());
1226 for (int cp
= 0; cp
< pLogEntry
->pArChangedPaths
->GetCount(); ++cp
)
1228 LogChangedPath
* pData
= pLogEntry
->pArChangedPaths
->GetAt(cp
);
1231 if (sUrl
.Compare(pData
->sPath
) == 0)
1233 if (!pData
->sCopyFromPath
.IsEmpty())
1235 lowerRev
= pData
->lCopyFromRev
;
1236 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
), lowerRev
);
1237 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
), higherRev
);
1238 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1239 bSentMessage
= TRUE
;
1246 if ( !bSentMessage
)
1248 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
| MERGE_REVSELECTMINUSONE
), lowerRev
);
1249 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
| MERGE_REVSELECTMINUSONE
), higherRev
);
1250 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1251 if (m_selectedRevsOneRange
.GetCount())
1252 m_pNotifyWindow
->SendMessage(WM_REVLISTONERANGE
, 0, (LPARAM
)&m_selectedRevsOneRange
);
1258 m_regLastStrict
= m_bStrict
;
1259 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
1260 reg
= m_btnShow
.GetCurrentEntry();
1265 void CLogDlg::OnNMDblclkChangedFileList(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
1267 // a double click on an entry in the changed-files list has happened
1273 void CLogDlg::DiffSelectedFile()
1276 if (m_bThreadRunning
)
1278 UpdateLogInfoLabel();
1279 INT_PTR selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
1282 if (m_ChangedFileListCtrl
.GetSelectedCount() == 0)
1284 // find out if there's an entry selected in the log list
1285 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1286 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1287 git_revnum_t rev1
= pLogEntry
->Rev
;
1288 git_revnum_t rev2
= rev1
;
1293 // there's at least a second entry selected in the log list: several revisions selected!
1294 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1297 rev1
= max(rev1
,(long)pLogEntry
->Rev
);
1298 rev2
= min(rev2
,(long)pLogEntry
->Rev
);
1302 // now we have both revisions selected in the log list, so we can do a diff of the selected
1303 // entry in the changed files list with these two revisions.
1304 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1309 // nothing or only one revision selected in the log list
1310 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1312 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
1314 // some items are hidden! So find out which item the user really clicked on
1315 INT_PTR selRealIndex
= -1;
1316 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
1318 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
1320 if (selRealIndex
== selIndex
)
1322 selIndex
= hiddenindex
;
1323 changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1329 if (IsDiffPossible(changedpath
, rev1
))
1331 // diffs with renamed files are possible
1332 if ((changedpath
)&&(!changedpath
->sCopyFromPath
.IsEmpty()))
1333 rev2
= changedpath
->lCopyFromRev
;
1336 // if the path was modified but the parent path was 'added with history'
1337 // then we have to use the copy from revision of the parent path
1338 CTGitPath cpath
= CTGitPath(changedpath
->sPath
);
1339 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
1341 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->GetAt(flist
)->sPath
);
1342 if (p
.IsAncestorOf(cpath
))
1344 if (!pLogEntry
->pArChangedPaths
->GetAt(flist
)->sCopyFromPath
.IsEmpty())
1345 rev2
= pLogEntry
->pArChangedPaths
->GetAt(flist
)->lCopyFromRev
;
1349 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1353 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1354 CTGitPath tempfile2
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1356 // deleted files must be opened from the revision before the deletion
1357 if (changedpath
->action
== LOGACTIONS_DELETED
)
1359 m_bCancelled
= false;
1361 CProgressDlg progDlg
;
1362 progDlg
.SetTitle(IDS_APPNAME
);
1363 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1365 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)(m_sRepositoryRoot
+ changedpath
->sPath
), (LPCTSTR
)r
.ToString());
1366 progDlg
.SetLine(1, sInfoLine
, true);
1367 SetAndClearProgressInfo(&progDlg
);
1368 progDlg
.ShowModeless(m_hWnd
);
1370 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), r
, r
, tempfile
))
1372 m_bCancelled
= false;
1373 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), GitRev::REV_HEAD
, r
, tempfile
))
1376 SetAndClearProgressInfo((HWND
)NULL
);
1377 CMessageBox::Show(m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1382 SetAndClearProgressInfo((HWND
)NULL
);
1384 CString sName1
, sName2
;
1385 sName1
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
);
1386 sName2
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
-1);
1387 CAppUtils::DiffFlags flags
;
1388 flags
.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1389 if (changedpath
->action
== LOGACTIONS_DELETED
)
1390 CAppUtils::StartExtDiff(tempfile
, tempfile2
, sName2
, sName1
, flags
);
1392 CAppUtils::StartExtDiff(tempfile2
, tempfile
, sName2
, sName1
, flags
);
1399 void CLogDlg::DoDiffFromLog(INT_PTR selIndex
, GitRev
* rev1
, GitRev
* rev2
, bool blame
, bool unified
)
1401 DialogEnableWindow(IDOK
, FALSE
);
1402 // SetPromptApp(&theApp);
1403 theApp
.DoWaitCursor(1);
1406 GetTempPath(temppath
);
1409 file1
.Format(_T("%s%s_%s%s"),
1411 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1412 rev1
->m_CommitHash
.Left(6),
1413 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1416 file2
.Format(_T("%s\\%s_%s%s"),
1418 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1419 rev2
->m_CommitHash
.Left(6),
1420 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1424 cmd
.Format(_T("git.exe cat-file -p %s:%s"),rev1
->m_CommitHash
,(*m_currentChangedArray
)[selIndex
].GetGitPathString());
1425 g_Git
.RunLogFile(cmd
,file1
);
1426 cmd
.Format(_T("git.exe cat-file -p %s:%s"),rev2
->m_CommitHash
,(*m_currentChangedArray
)[selIndex
].GetGitPathString());
1427 g_Git
.RunLogFile(cmd
,file2
);
1429 CAppUtils::DiffFlags flags
;
1430 CAppUtils::StartExtDiff(file1
,file2
,_T("A"),_T("B"),flags
);
1435 if (Git::PathIsURL(m_path
))
1437 filepath
= m_path
.GetGitPathString();
1441 filepath
= GetURLFromPath(m_path
);
1442 if (filepath
.IsEmpty())
1444 theApp
.DoWaitCursor(-1);
1446 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1447 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1448 TRACE(_T("could not retrieve the URL of the file!\n"));
1450 theApp
.DoWaitCursor(-11);
1454 m_bCancelled
= FALSE
;
1455 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1457 CString firstfile
, secondfile
;
1458 if (m_LogList
.GetSelectedCount()==1)
1460 int s
= m_LogList
.GetSelectionMark();
1461 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(s
));
1462 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1463 firstfile
= changedpath
->sPath
;
1464 secondfile
= firstfile
;
1465 if ((rev2
== rev1
-1)&&(changedpath
->lCopyFromRev
> 0)) // is it an added file with history?
1467 secondfile
= changedpath
->sCopyFromPath
;
1468 rev2
= changedpath
->lCopyFromRev
;
1473 firstfile
= m_currentChangedPathList
[selIndex
].GetGitPathString();
1474 secondfile
= firstfile
;
1477 firstfile
= filepath
+ firstfile
.Trim();
1478 secondfile
= filepath
+ secondfile
.Trim();
1480 GitDiff
diff(this, this->m_hWnd
, true);
1481 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1482 diff
.SetHEADPeg(m_LogRevision
);
1486 diff
.ShowUnifiedDiff(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
);
1488 CAppUtils::StartShowUnifiedDiff(m_hWnd
, CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), m_LogRevision
);
1492 if (diff
.ShowCompare(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), false, blame
))
1494 if (firstfile
.Compare(secondfile
)==0)
1496 git_revnum_t baseRev
= 0;
1497 diff
.DiffProps(CTGitPath(firstfile
), rev2
, rev1
, baseRev
);
1504 theApp
.DoWaitCursor(-1);
1508 BOOL
CLogDlg::Open(bool bOpenWith
,CString changedpath
, git_revnum_t rev
)
1511 DialogEnableWindow(IDOK
, FALSE
);
1512 SetPromptApp(&theApp
);
1513 theApp
.DoWaitCursor(1);
1515 if (Git::PathIsURL(m_path
))
1517 filepath
= m_path
.GetGitPathString();
1521 filepath
= GetURLFromPath(m_path
);
1522 if (filepath
.IsEmpty())
1524 theApp
.DoWaitCursor(-1);
1526 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1527 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1528 TRACE(_T("could not retrieve the URL of the file!\n"));
1533 m_bCancelled
= false;
1534 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1535 filepath
+= changedpath
;
1537 CProgressDlg progDlg
;
1538 progDlg
.SetTitle(IDS_APPNAME
);
1539 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1541 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)GitRev(rev
).ToString());
1542 progDlg
.SetLine(1, sInfoLine
, true);
1543 SetAndClearProgressInfo(&progDlg
);
1544 progDlg
.ShowModeless(m_hWnd
);
1546 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath
), rev
);
1547 m_bCancelled
= false;
1548 if (!Cat(CTGitPath(filepath
), GitRev(rev
), rev
, tempfile
))
1551 SetAndClearProgressInfo((HWND
)NULL
);
1552 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1554 theApp
.DoWaitCursor(-1);
1558 SetAndClearProgressInfo((HWND
)NULL
);
1559 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1562 int ret
= (int)ShellExecute(this->m_hWnd
, NULL
, tempfile
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1563 if (ret
<= HINSTANCE_ERROR
)
1568 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1569 cmd
+= tempfile
.GetWinPathString() + _T(" ");
1570 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1573 theApp
.DoWaitCursor(-1);
1578 void CLogDlg::EditAuthor(const CLogDataVector
& logs
)
1583 if (logs
.size() == 0)
1585 DialogEnableWindow(IDOK
, FALSE
);
1586 SetPromptApp(&theApp
);
1587 theApp
.DoWaitCursor(1);
1588 if (Git::PathIsURL(m_path
))
1589 url
= m_path
.GetGitPathString();
1592 url
= GetURLFromPath(m_path
);
1594 name
= Git_PROP_REVISION_AUTHOR
;
1596 CString value
= RevPropertyGet(name
, CTGitPath(url
), logs
[0]->Rev
);
1597 CString sOldValue
= value
;
1598 value
.Replace(_T("\n"), _T("\r\n"));
1599 CInputDlg
dlg(this);
1600 dlg
.m_sHintText
.LoadString(IDS_LOG_AUTHOR
);
1601 dlg
.m_sInputText
= value
;
1602 dlg
.m_sTitle
.LoadString(IDS_LOG_AUTHOREDITTITLE
);
1603 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1604 dlg
.m_bUseLogWidth
= false;
1605 if (dlg
.DoModal() == IDOK
)
1607 dlg
.m_sInputText
.Replace(_T("\r"), _T(""));
1609 LogCache::CCachedLogInfo
* toUpdate
1610 = GetLogCache (CTGitPath (m_sRepositoryRoot
));
1612 CProgressDlg progDlg
;
1613 progDlg
.SetTitle(IDS_APPNAME
);
1614 progDlg
.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT
)));
1615 progDlg
.SetTime(true);
1616 progDlg
.SetShowProgressBar(true);
1617 progDlg
.ShowModeless(m_hWnd
);
1618 for (DWORD i
=0; i
<logs
.size(); ++i
)
1620 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), logs
[i
]->Rev
))
1623 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1629 logs
[i
]->sAuthor
= dlg
.m_sInputText
;
1630 m_LogList
.Invalidate();
1632 // update the log cache
1634 if (toUpdate
!= NULL
)
1636 // log caching is active
1638 LogCache::CCachedLogInfo newInfo
;
1639 newInfo
.Insert ( logs
[i
]->Rev
1640 , (const char*) CUnicodeUtils::GetUTF8 (logs
[i
]->sAuthor
)
1643 , LogCache::CRevisionInfoContainer::HAS_AUTHOR
);
1645 toUpdate
->Update (newInfo
);
1648 progDlg
.SetProgress64(i
, logs
.size());
1652 theApp
.DoWaitCursor(-1);
1657 void CLogDlg::EditLogMessage(int index
)
1662 DialogEnableWindow(IDOK
, FALSE
);
1663 SetPromptApp(&theApp
);
1664 theApp
.DoWaitCursor(1);
1665 if (Git::PathIsURL(m_path
))
1666 url
= m_path
.GetGitPathString();
1669 url
= GetURLFromPath(m_path
);
1671 name
= Git_PROP_REVISION_LOG
;
1673 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(index
));
1674 m_bCancelled
= FALSE
;
1675 CString value
= RevPropertyGet(name
, CTGitPath(url
), pLogEntry
->Rev
);
1676 CString sOldValue
= value
;
1677 value
.Replace(_T("\n"), _T("\r\n"));
1678 CInputDlg
dlg(this);
1679 dlg
.m_sHintText
.LoadString(IDS_LOG_MESSAGE
);
1680 dlg
.m_sInputText
= value
;
1681 dlg
.m_sTitle
.LoadString(IDS_LOG_MESSAGEEDITTITLE
);
1682 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1683 dlg
.m_bUseLogWidth
= true;
1684 if (dlg
.DoModal() == IDOK
)
1686 dlg
.m_sInputText
.Replace(_T("\r"), _T(""));
1687 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), pLogEntry
->Rev
))
1689 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1693 pLogEntry
->sShortMessage
= MakeShortMessage(dlg
.m_sInputText
);
1694 // split multi line log entries and concatenate them
1695 // again but this time with \r\n as line separators
1696 // so that the edit control recognizes them
1697 if (dlg
.m_sInputText
.GetLength()>0)
1699 m_sMessageBuf
= dlg
.m_sInputText
;
1700 dlg
.m_sInputText
.Replace(_T("\n\r"), _T("\n"));
1701 dlg
.m_sInputText
.Replace(_T("\r\n"), _T("\n"));
1702 if (dlg
.m_sInputText
.Right(1).Compare(_T("\n"))==0)
1703 dlg
.m_sInputText
= dlg
.m_sInputText
.Left(dlg
.m_sInputText
.GetLength()-1);
1706 dlg
.m_sInputText
.Empty();
1707 pLogEntry
->sMessage
= dlg
.m_sInputText
;
1708 pLogEntry
->sBugIDs
= m_ProjectProperties
.FindBugID(dlg
.m_sInputText
);
1709 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
1710 pMsgView
->SetWindowText(_T(" "));
1711 pMsgView
->SetWindowText(dlg
.m_sInputText
);
1712 m_ProjectProperties
.FindBugID(dlg
.m_sInputText
, pMsgView
);
1713 m_LogList
.Invalidate();
1715 // update the log cache
1717 LogCache::CCachedLogInfo
* toUpdate
1718 = GetLogCache (CTGitPath (m_sRepositoryRoot
));
1719 if (toUpdate
!= NULL
)
1721 // log caching is active
1723 LogCache::CCachedLogInfo newInfo
;
1724 newInfo
.Insert ( pLogEntry
->Rev
1726 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry
->sMessage
)
1728 , LogCache::CRevisionInfoContainer::HAS_COMMENT
);
1730 toUpdate
->Update (newInfo
);
1734 theApp
.DoWaitCursor(-1);
1739 BOOL
CLogDlg::PreTranslateMessage(MSG
* pMsg
)
1741 // Skip Ctrl-C when copying text out of the log message or search filter
1742 BOOL bSkipAccelerator
= ( pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW
) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT
) ) && GetKeyState(VK_CONTROL
)&0x8000 );
1743 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
1745 if (GetFocus()==GetDlgItem(IDC_LOGLIST
))
1747 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1749 DiffSelectedRevWithPrevious();
1753 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
1759 if (m_hAccel
&& !bSkipAccelerator
)
1761 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
1766 m_tooltips
.RelayEvent(pMsg
);
1767 return __super::PreTranslateMessage(pMsg
);
1771 BOOL
CLogDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1773 //if (this->IsThreadRunning())
1774 if(m_LogList
.m_bNoDispUpdates
)
1776 // only show the wait cursor over the list control
1778 ((pWnd
== GetDlgItem(IDC_LOGLIST
))||
1779 (pWnd
== GetDlgItem(IDC_MSGVIEW
))||
1780 (pWnd
== GetDlgItem(IDC_LOGMSG
))))
1782 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1787 if ((pWnd
) && (pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1788 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1790 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1792 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1795 void CLogDlg::OnBnClickedHelp()
1800 void CLogDlg::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1802 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1804 //if (this->IsThreadRunning())
1805 if(m_LogList
.m_bNoDispUpdates
)
1807 if (pNMLV
->iItem
>= 0)
1809 m_nSearchIndex
= pNMLV
->iItem
;
1810 if (pNMLV
->iSubItem
!= 0)
1812 if ((pNMLV
->iItem
== m_LogList
.m_arShownList
.GetCount())&&(m_bStrict
)&&(1/*m_bStrictStopped*/))
1814 // remove the selected state
1815 if (pNMLV
->uChanged
& LVIF_STATE
)
1817 m_LogList
.SetItemState(pNMLV
->iItem
, 0, LVIS_SELECTED
);
1818 FillLogMessageCtrl();
1820 UpdateLogInfoLabel();
1824 if (pNMLV
->uChanged
& LVIF_STATE
)
1826 FillLogMessageCtrl();
1832 FillLogMessageCtrl();
1836 UpdateLogInfoLabel();
1839 void CLogDlg::OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1841 ENLINK
*pEnLink
= reinterpret_cast<ENLINK
*>(pNMHDR
);
1842 if (pEnLink
->msg
== WM_LBUTTONUP
)
1845 GetDlgItemText(IDC_MSGVIEW
, msg
);
1846 msg
.Replace(_T("\r\n"), _T("\n"));
1847 url
= msg
.Mid(pEnLink
->chrg
.cpMin
, pEnLink
->chrg
.cpMax
-pEnLink
->chrg
.cpMin
);
1848 if (!::PathIsURL(url
))
1850 url
= m_ProjectProperties
.GetBugIDUrl(url
);
1851 url
= GetAbsoluteUrlFromRelativeUrl(url
);
1854 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
1859 void CLogDlg::OnBnClickedStatbutton()
1862 if (this->IsThreadRunning())
1864 if (m_LogList
.m_arShownList
.IsEmpty())
1865 return; // nothing is shown, so no statistics.
1866 // the statistics dialog expects the log entries to be sorted by date
1867 SortByColumn(3, false);
1868 CPtrArray shownlist
;
1869 m_LogList
.RecalculateShownList(&shownlist
);
1870 // create arrays which are aware of the current filter
1871 CStringArray m_arAuthorsFiltered
;
1872 CDWordArray m_arDatesFiltered
;
1873 CDWordArray m_arFileChangesFiltered
;
1874 for (INT_PTR i
=0; i
<shownlist
.GetCount(); ++i
)
1876 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(shownlist
.GetAt(i
));
1877 CString strAuthor
= pLogEntry
->m_AuthorName
;
1878 if ( strAuthor
.IsEmpty() )
1880 strAuthor
.LoadString(IDS_STATGRAPH_EMPTYAUTHOR
);
1882 m_arAuthorsFiltered
.Add(strAuthor
);
1883 m_arDatesFiltered
.Add(pLogEntry
->m_AuthorDate
.GetTime());
1884 m_arFileChangesFiltered
.Add(pLogEntry
->m_Files
.GetCount());
1887 dlg
.m_parAuthors
= &m_arAuthorsFiltered
;
1888 dlg
.m_parDates
= &m_arDatesFiltered
;
1889 dlg
.m_parFileChanges
= &m_arFileChangesFiltered
;
1890 dlg
.m_path
= m_path
;
1892 // restore the previous sorting
1893 SortByColumn(m_nSortColumn
, m_bAscending
);
1894 OnTimer(LOGFILTER_TIMER
);
1899 void CLogDlg::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1902 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1903 // Take the default processing unless we set this to something else below.
1904 *pResult
= CDRF_DODEFAULT
;
1906 if (m_bNoDispUpdates
)
1909 switch (pLVCD
->nmcd
.dwDrawStage
)
1913 *pResult
= CDRF_NOTIFYITEMDRAW
;
1917 case CDDS_ITEMPREPAINT
:
1919 // This is the prepaint stage for an item. Here's where we set the
1920 // item's text color.
1922 // Tell Windows to send draw notifications for each subitem.
1923 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
1925 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
1927 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1929 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
1933 if (data
->bCopiedSelf
)
1935 // only change the background color if the item is not 'hot' (on vista with themes enabled)
1936 if (!theme
.IsAppThemed() || !m_bVista
|| ((pLVCD
->nmcd
.uItemState
& CDIS_HOT
)==0))
1937 pLVCD
->clrTextBk
= GetSysColor(COLOR_MENU
);
1941 crText
= m_Colors
.GetColor(CColors::Modified
);
1943 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1944 // crText = GetSysColor(COLOR_GRAYTEXT);
1945 // if (data->Rev == m_wcRev)
1947 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1948 // We changed the font, so we're returning CDRF_NEWFONT. This
1949 // tells the control to recalculate the extent of the text.
1950 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1954 if (m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1956 if (m_bStrictStopped
)
1957 crText
= GetSysColor(COLOR_GRAYTEXT
);
1959 // Store the color back in the NMLVCUSTOMDRAW struct.
1960 pLVCD
->clrText
= crText
;
1964 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
1966 if ((m_bStrictStopped
)&&(m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
1968 pLVCD
->nmcd
.uItemState
&= ~(CDIS_SELECTED
|CDIS_FOCUS
);
1970 if (pLVCD
->iSubItem
== 1)
1972 *pResult
= CDRF_DODEFAULT
;
1974 if (m_arShownList
.GetCount() <= (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1978 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1979 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1981 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
));
1983 // Get the selected state of the
1984 // item being drawn.
1986 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
1987 rItem
.mask
= LVIF_STATE
;
1988 rItem
.iItem
= pLVCD
->nmcd
.dwItemSpec
;
1989 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
1990 m_LogList
.GetItem(&rItem
);
1993 m_LogList
.GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1995 // Fill the background
1996 if (theme
.IsAppThemed() && m_bVista
)
1998 theme
.Open(m_hWnd
, L
"Explorer");
1999 int state
= LISS_NORMAL
;
2000 if (rItem
.state
& LVIS_SELECTED
)
2002 if (::GetFocus() == m_LogList
.m_hWnd
)
2003 state
|= LISS_SELECTED
;
2005 state
|= LISS_SELECTEDNOTFOCUS
;
2010 if (pLogEntry
->bCopiedSelf
)
2012 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
2013 // information at this drawing stage. But we can check the whether the
2014 // previous stage changed the background color of the item
2015 if (pLVCD
->clrTextBk
== GetSysColor(COLOR_MENU
))
2018 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_MENU
));
2021 ::FillRect(pLVCD
->nmcd
.hdc
, &rect
, brush
);
2022 ::DeleteObject(brush
);
2029 if (theme
.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL
, state
))
2030 theme
.DrawParentBackground(m_hWnd
, pLVCD
->nmcd
.hdc
, &rect
);
2032 theme
.DrawBackground(pLVCD
->nmcd
.hdc
, LVP_LISTDETAIL
, state
, &rect
, NULL
);
2037 if (rItem
.state
& LVIS_SELECTED
)
2039 if (::GetFocus() == m_LogList
.m_hWnd
)
2040 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT
));
2042 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE
));
2046 //if (pLogEntry->bCopiedSelf)
2047 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
2049 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW
));
2054 ::FillRect(pLVCD
->nmcd
.hdc
, &rect
, brush
);
2055 ::DeleteObject(brush
);
2058 // Draw the icon(s) into the compatible DC
2059 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_MODIFIED
)
2060 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2063 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_ADDED
)
2064 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2067 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
2068 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2071 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
2072 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2074 *pResult
= CDRF_SKIPDEFAULT
;
2080 *pResult
= CDRF_DODEFAULT
;
2085 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2088 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
2089 // Take the default processing unless we set this to something else below.
2090 *pResult
= CDRF_DODEFAULT
;
2092 // if (m_bNoDispUpdates)
2095 // First thing - check the draw stage. If it's the control's prepaint
2096 // stage, then tell Windows we want messages for every item.
2098 if ( CDDS_PREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
2100 *pResult
= CDRF_NOTIFYITEMDRAW
;
2102 else if ( CDDS_ITEMPREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
2104 // This is the prepaint stage for an item. Here's where we set the
2105 // item's text color. Our return value will tell Windows to draw the
2106 // item itself, but it will use the new color we set here.
2108 // Tell Windows to paint the control itself.
2109 *pResult
= CDRF_DODEFAULT
;
2111 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
2112 bool bGrayed
= false;
2114 if ((m_cHidePaths
.GetState() & 0x0003)==BST_INDETERMINATE
)
2116 if ((m_currentChangedArray
)&&((m_currentChangedArray
->GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)))
2118 //if ((*m_currentChangedArray)[(pLVCD->nmcd.dwItemSpec)]sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
2120 crText
= GetSysColor(COLOR_GRAYTEXT
);
2124 else if (m_currentChangedPathList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
2126 //if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
2128 crText
= GetSysColor(COLOR_GRAYTEXT
);
2135 if ((!bGrayed
)&&(m_currentChangedArray
)&&(m_currentChangedArray
->GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
2137 DWORD action
= ((*m_currentChangedArray
)[pLVCD
->nmcd
.dwItemSpec
]).m_Action
;
2138 if (action
== CTGitPath::LOGACTIONS_MODIFIED
)
2139 crText
= m_Colors
.GetColor(CColors::Modified
);
2140 if (action
== CTGitPath::LOGACTIONS_REPLACED
)
2141 crText
= m_Colors
.GetColor(CColors::Deleted
);
2142 if (action
== CTGitPath::LOGACTIONS_ADDED
)
2143 crText
= m_Colors
.GetColor(CColors::Added
);
2144 if (action
== CTGitPath::LOGACTIONS_DELETED
)
2145 crText
= m_Colors
.GetColor(CColors::Deleted
);
2148 // Store the color back in the NMLVCUSTOMDRAW struct.
2149 pLVCD
->clrText
= crText
;
2153 void CLogDlg::DoSizeV1(int delta
)
2156 RemoveAnchor(IDC_LOGLIST
);
2157 RemoveAnchor(IDC_SPLITTERTOP
);
2158 RemoveAnchor(IDC_MSGVIEW
);
2159 RemoveAnchor(IDC_SPLITTERBOTTOM
);
2160 RemoveAnchor(IDC_LOGMSG
);
2161 CSplitterControl::ChangeHeight(&m_LogList
, delta
, CW_TOPALIGN
);
2162 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), -delta
, CW_BOTTOMALIGN
);
2163 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
2164 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
2165 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
2166 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2167 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2171 m_LogList
.Invalidate();
2172 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
2176 void CLogDlg::DoSizeV2(int delta
)
2179 RemoveAnchor(IDC_LOGLIST
);
2180 RemoveAnchor(IDC_SPLITTERTOP
);
2181 RemoveAnchor(IDC_MSGVIEW
);
2182 RemoveAnchor(IDC_SPLITTERBOTTOM
);
2183 RemoveAnchor(IDC_LOGMSG
);
2184 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), delta
, CW_TOPALIGN
);
2185 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl
, -delta
, CW_BOTTOMALIGN
);
2186 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
2187 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
2188 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
2189 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2190 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2194 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
2195 m_ChangedFileListCtrl
.Invalidate();
2199 void CLogDlg::AdjustMinSize()
2201 // adjust the minimum size of the dialog to prevent the resizing from
2202 // moving the list control too far down.
2203 CRect rcChgListView
;
2204 m_ChangedFileListCtrl
.GetClientRect(rcChgListView
);
2206 m_LogList
.GetClientRect(rcLogList
);
2208 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(),
2209 m_DlgOrigRect
.Height()-m_ChgOrigRect
.Height()-m_LogListOrigRect
.Height()-m_MsgViewOrigRect
.Height()
2210 +rcChgListView
.Height()+rcLogList
.Height()+60));
2213 LRESULT
CLogDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
2217 if (wParam
== IDC_SPLITTERTOP
)
2219 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
2220 DoSizeV1(pHdr
->delta
);
2222 else if (wParam
== IDC_SPLITTERBOTTOM
)
2224 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
2225 DoSizeV2(pHdr
->delta
);
2230 return CResizableDialog::DefWindowProc(message
, wParam
, lParam
);
2233 void CLogDlg::SetSplitterRange()
2235 if ((m_LogList
)&&(m_ChangedFileListCtrl
))
2238 m_LogList
.GetWindowRect(rcTop
);
2239 ScreenToClient(rcTop
);
2241 GetDlgItem(IDC_MSGVIEW
)->GetWindowRect(rcMiddle
);
2242 ScreenToClient(rcMiddle
);
2243 m_wndSplitter1
.SetRange(rcTop
.top
+30, rcMiddle
.bottom
-20);
2245 m_ChangedFileListCtrl
.GetWindowRect(rcBottom
);
2246 ScreenToClient(rcBottom
);
2247 m_wndSplitter2
.SetRange(rcMiddle
.top
+30, rcBottom
.bottom
-20);
2251 LRESULT
CLogDlg::OnClickedInfoIcon(WPARAM
/*wParam*/, LPARAM lParam
)
2253 RECT
* rect
= (LPRECT
)lParam
;
2256 point
= CPoint(rect
->left
, rect
->bottom
);
2257 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
2259 if (popup
.CreatePopupMenu())
2261 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2262 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL
), LOGFILTER_ALL
, temp
);
2264 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2266 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2267 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES
), LOGFILTER_MESSAGES
, temp
);
2268 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2269 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS
), LOGFILTER_PATHS
, temp
);
2270 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2271 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS
), LOGFILTER_AUTHORS
, temp
);
2272 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2273 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS
), LOGFILTER_REVS
, temp
);
2274 temp
.LoadString(IDS_LOG_FILTER_BUGIDS
);
2275 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID
), LOGFILTER_BUGID
, temp
);
2277 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2279 temp
.LoadString(IDS_LOG_FILTER_REGEX
);
2280 popup
.AppendMenu(MF_STRING
| MF_ENABLED
| (m_bFilterWithRegex
? MF_CHECKED
: MF_UNCHECKED
), LOGFILTER_REGEX
, temp
);
2283 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2287 if (selection
== LOGFILTER_REGEX
)
2289 m_bFilterWithRegex
= !m_bFilterWithRegex
;
2290 CRegDWORD b
= CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
2291 b
= m_bFilterWithRegex
;
2292 CheckRegexpTooltip();
2296 m_LogList
.m_nSelectedFilter
= selection
;
2299 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2305 LRESULT
CLogDlg::OnClickedCancelFilter(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2308 KillTimer(LOGFILTER_TIMER
);
2310 m_LogList
.m_sFilterText
.Empty();
2312 theApp
.DoWaitCursor(1);
2313 CStoreSelection
storeselection(this);
2314 FillLogMessageCtrl(false);
2316 m_LogList
.RemoveFilter();
2319 m_LogList
.GetTimeRange(begin
,end
);
2320 m_DateFrom
.SetTime(&begin
);
2321 m_DateTo
.SetTime(&end
);
2323 theApp
.DoWaitCursor(-1);
2324 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2325 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2326 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2327 UpdateLogInfoLabel();
2333 void CLogDlg::SetFilterCueText()
2336 switch (m_LogList
.m_nSelectedFilter
)
2339 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2341 case LOGFILTER_MESSAGES
:
2342 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2344 case LOGFILTER_PATHS
:
2345 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2347 case LOGFILTER_AUTHORS
:
2348 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2350 case LOGFILTER_REVS
:
2351 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2354 // to make the cue banner text appear more to the right of the edit control
2355 temp
= _T(" ")+temp
;
2356 m_cFilter
.SetCueBanner(temp
);
2359 bool CLogDlg::Validate(LPCTSTR string
)
2361 if (!m_bFilterWithRegex
)
2364 return m_LogList
.ValidateRegexp(string
, pat
, false);
2368 void CLogDlg::OnTimer(UINT_PTR nIDEvent
)
2370 if (nIDEvent
== LOGFILTER_TIMER
)
2372 if (this->IsThreadRunning())
2374 // thread still running! So just restart the timer.
2375 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2378 CWnd
* focusWnd
= GetFocus();
2379 bool bSetFocusToFilterControl
= ((focusWnd
!= GetDlgItem(IDC_DATEFROM
))&&(focusWnd
!= GetDlgItem(IDC_DATETO
))
2380 && (focusWnd
!= GetDlgItem(IDC_LOGLIST
)));
2381 if (m_LogList
.m_sFilterText
.IsEmpty())
2383 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2384 // do not return here!
2385 // we also need to run the filter if the filter text is empty:
2386 // 1. to clear an existing filter
2387 // 2. to rebuild the m_arShownList after sorting
2389 theApp
.DoWaitCursor(1);
2390 CStoreSelection
storeselection(this);
2391 KillTimer(LOGFILTER_TIMER
);
2392 FillLogMessageCtrl(false);
2394 // now start filter the log list
2395 m_LogList
.StartFilter();
2397 if ( m_LogList
.GetItemCount()==1 )
2399 m_LogList
.SetSelectionMark(0);
2400 m_LogList
.SetItemState(0, LVIS_SELECTED
, LVIS_SELECTED
);
2402 theApp
.DoWaitCursor(-1);
2403 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2404 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2405 if (bSetFocusToFilterControl
)
2406 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2407 UpdateLogInfoLabel();
2408 } // if (nIDEvent == LOGFILTER_TIMER)
2409 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2410 __super::OnTimer(nIDEvent
);
2413 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2416 m_DateTo
.GetTime(_time
);
2419 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 23, 59, 59);
2420 if (time
.GetTime() != m_LogList
.m_To
.GetTime())
2422 m_LogList
.m_To
= (DWORD
)time
.GetTime();
2423 SetTimer(LOGFILTER_TIMER
, 10, NULL
);
2426 catch (CAtlException
)
2433 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2436 m_DateFrom
.GetTime(_time
);
2439 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 0, 0, 0);
2440 if (time
.GetTime() != m_LogList
.m_From
.GetTime())
2442 m_LogList
.m_From
= (DWORD
)time
.GetTime();
2443 SetTimer(LOGFILTER_TIMER
, 10, NULL
);
2446 catch (CAtlException
)
2455 CTGitPathList
CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths
/* = false */, bool bUseFilter
/* = true */)
2457 CTGitPathList pathList
;
2460 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2462 m_sRepositoryRoot
= GetRepositoryRoot(m_path
);
2464 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2467 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2472 int nextpos
= m_LogList
.GetNextSelectedItem(pos
);
2473 if (nextpos
>= m_arShownList
.GetCount())
2475 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(nextpos
));
2476 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
2477 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
2479 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
2483 if (!bRelativePaths
)
2484 path
.SetFromGit(m_sRepositoryRoot
);
2485 path
.AppendPathString(cpath
->sPath
);
2487 ((m_cHidePaths
.GetState() & 0x0003)!=BST_CHECKED
)||
2488 (cpath
->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0))
2489 pathList
.AddPath(path
);
2494 pathList
.RemoveDuplicates();
2499 void CLogDlg::SortByColumn(int nSortColumn
, bool bAscending
)
2507 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscRevSort());
2509 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescRevSort());
2515 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscActionSort());
2517 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescActionSort());
2523 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscAuthorSort());
2525 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescAuthorSort());
2531 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscDateSort());
2533 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescDateSort());
2536 case 4: // Message or bug id
2537 if (m_bShowBugtraqColumn
)
2540 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscBugIDSort());
2542 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescBugIDSort());
2545 // fall through here
2549 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscMessageSort());
2551 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescMessageSort());
2561 void CLogDlg::OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2563 if (this->IsThreadRunning())
2564 return; //no sorting while the arrays are filled
2565 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2566 const int nColumn
= pNMLV
->iSubItem
;
2567 m_bAscending
= nColumn
== m_nSortColumn
? !m_bAscending
: TRUE
;
2568 m_nSortColumn
= nColumn
;
2569 SortByColumn(m_nSortColumn
, m_bAscending
);
2570 SetSortArrow(&m_LogList
, m_nSortColumn
, !!m_bAscending
);
2571 SortShownListArray();
2572 m_LogList
.Invalidate();
2573 UpdateLogInfoLabel();
2574 // the "next 100" button only makes sense if the log messages
2575 // are sorted by revision in descending order
2576 if ((m_nSortColumn
)||(m_bAscending
))
2578 DialogEnableWindow(IDC_NEXTHUNDRED
, false);
2582 DialogEnableWindow(IDC_NEXTHUNDRED
, true);
2587 void CLogDlg::SortShownListArray()
2589 // make sure the shown list still matches the filter after sorting.
2590 OnTimer(LOGFILTER_TIMER
);
2591 // clear the selection states
2592 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2595 m_LogList
.SetItemState(m_LogList
.GetNextSelectedItem(pos
), 0, LVIS_SELECTED
);
2597 m_LogList
.SetSelectionMark(-1);
2600 void CLogDlg::SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
)
2602 if (control
== NULL
)
2604 // set the sort arrow
2605 CHeaderCtrl
* pHeader
= control
->GetHeaderCtrl();
2606 HDITEM HeaderItem
= {0};
2607 HeaderItem
.mask
= HDI_FORMAT
;
2608 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
2610 pHeader
->GetItem(i
, &HeaderItem
);
2611 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
2612 pHeader
->SetItem(i
, &HeaderItem
);
2616 pHeader
->GetItem(nColumn
, &HeaderItem
);
2617 HeaderItem
.fmt
|= (bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
2618 pHeader
->SetItem(nColumn
, &HeaderItem
);
2621 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2624 if (this->IsThreadRunning())
2625 return; //no sorting while the arrays are filled
2626 if (m_currentChangedArray
== NULL
)
2628 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2629 const int nColumn
= pNMLV
->iSubItem
;
2630 m_bAscendingPathList
= nColumn
== m_nSortColumnPathList
? !m_bAscendingPathList
: TRUE
;
2631 m_nSortColumnPathList
= nColumn
;
2632 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
2634 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
2635 m_ChangedFileListCtrl
.Invalidate();
2640 int CLogDlg::m_nSortColumnPathList
= 0;
2641 bool CLogDlg::m_bAscendingPathList
= false;
2643 int CLogDlg::SortCompare(const void * pElem1
, const void * pElem2
)
2646 LogChangedPath
* cpath1
= *((LogChangedPath
**)pElem1
);
2647 LogChangedPath
* cpath2
= *((LogChangedPath
**)pElem2
);
2649 if (m_bAscendingPathList
)
2650 std::swap (cpath1
, cpath2
);
2653 switch (m_nSortColumnPathList
)
2656 cmp
= cpath2
->GetAction().Compare(cpath1
->GetAction());
2661 cmp
= cpath2
->sPath
.CompareNoCase(cpath1
->sPath
);
2665 case 2: // copy from path
2666 cmp
= cpath2
->sCopyFromPath
.Compare(cpath1
->sCopyFromPath
);
2670 case 3: // copy from revision
2671 return cpath2
->lCopyFromRev
> cpath1
->lCopyFromRev
;
2678 void CLogDlg::ResizeAllListCtrlCols()
2681 const int nMinimumWidth
= ICONITEMBORDER
+16*4;
2682 int maxcol
= ((CHeaderCtrl
*)(m_LogList
.GetDlgItem(0)))->GetItemCount()-1;
2683 int nItemCount
= m_LogList
.GetItemCount();
2684 TCHAR textbuf
[MAX_PATH
];
2685 CHeaderCtrl
* pHdrCtrl
= (CHeaderCtrl
*)(m_LogList
.GetDlgItem(0));
2688 for (int col
= 0; col
<= maxcol
; col
++)
2691 hdi
.mask
= HDI_TEXT
;
2692 hdi
.pszText
= textbuf
;
2693 hdi
.cchTextMax
= sizeof(textbuf
);
2694 pHdrCtrl
->GetItem(col
, &hdi
);
2695 int cx
= m_LogList
.GetStringWidth(hdi
.pszText
)+20; // 20 pixels for col separator and margin
2696 for (int index
= 0; index
<nItemCount
; ++index
)
2698 // get the width of the string and add 14 pixels for the column separator and margins
2699 int linewidth
= m_LogList
.GetStringWidth(m_LogList
.GetItemText(index
, col
)) + 14;
2700 if (index
< m_arShownList
.GetCount())
2702 GitRev
* pCurLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(index
));
2703 if ((pCurLogEntry
)&&(pCurLogEntry
->m_CommitHash
== m_wcRev
.m_CommitHash
))
2705 // set the bold font and ask for the string width again
2706 m_LogList
.SendMessage(WM_SETFONT
, (WPARAM
)m_boldFont
, NULL
);
2707 linewidth
= m_LogList
.GetStringWidth(m_LogList
.GetItemText(index
, col
)) + 14;
2708 // restore the system font
2709 m_LogList
.SendMessage(WM_SETFONT
, NULL
, NULL
);
2714 // add the image size
2715 CImageList
* pImgList
= m_LogList
.GetImageList(LVSIL_SMALL
);
2716 if ((pImgList
)&&(pImgList
->GetImageCount()))
2719 pImgList
->GetImageInfo(0, &imginfo
);
2720 linewidth
+= (imginfo
.rcImage
.right
- imginfo
.rcImage
.left
);
2721 linewidth
+= 3; // 3 pixels between icon and text
2727 // Adjust columns "Actions" containing icons
2728 if (col
== this->LOGLIST_ACTION
)
2730 if (cx
< nMinimumWidth
)
2736 if (col
== this->LOGLIST_MESSAGE
)
2738 if (cx
> LOGLIST_MESSAGE_MAX
)
2740 cx
= LOGLIST_MESSAGE_MAX
;
2744 // keep the bug id column small
2745 if ((col
== 4)&&(m_bShowBugtraqColumn
))
2747 if (cx
> (int)(DWORD
)m_regMaxBugIDColWidth
)
2749 cx
= (int)(DWORD
)m_regMaxBugIDColWidth
;
2753 m_LogList
.SetColumnWidth(col
, cx
);
2760 void CLogDlg::OnBnClickedHidepaths()
2762 FillLogMessageCtrl();
2763 m_ChangedFileListCtrl
.Invalidate();
2768 void CLogDlg::OnBnClickedCheckStoponcopy()
2771 if (!GetDlgItem(IDC_GETALL
)->IsWindowEnabled())
2774 // ignore old fetch limits when switching
2775 // between copy-following and stop-on-copy
2776 // (otherwise stop-on-copy will limit what
2777 // we see immediately after switching to
2782 // now, restart the query
2787 void CLogDlg::OnBnClickedIncludemerge()
2797 void CLogDlg::UpdateLogInfoLabel()
2803 int count
=m_LogList
.m_arShownList
.GetCount();
2806 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(0)))->m_CommitHash
;
2807 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
2808 rev2
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(count
-1)))->m_CommitHash
;
2809 selectedrevs
= m_LogList
.GetSelectedCount();
2812 sTemp
.Format(_T("Showing %ld revision(s), from revision %s to revision %s - %ld revision(s) selected"), count
, rev2
.Left(6), rev1
.Left(6), selectedrevs
);
2819 void CLogDlg::ShowContextMenuForChangedpaths(CWnd
* /*pWnd*/, CPoint point
)
2822 int selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
2823 if ((point
.x
== -1) && (point
.y
== -1))
2826 m_ChangedFileListCtrl
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
2827 m_ChangedFileListCtrl
.ClientToScreen(&rect
);
2828 point
= rect
.CenterPoint();
2832 int s
= m_LogList
.GetSelectionMark();
2835 std::vector
<CString
> changedpaths
;
2836 std::vector
<LogChangedPath
*> changedlogpaths
;
2837 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2839 return; // nothing is selected, get out of here
2841 bool bOneRev
= true;
2842 int sel
=m_LogList
.GetNextSelectedItem(pos
);
2843 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(sel
));
2844 GitRev
* rev1
= pLogEntry
;
2845 GitRev
* rev2
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(sel
+1));
2847 bool bOneRev
= true;
2852 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
2855 rev1
= max(rev1
,(git_revnum_t
)pLogEntry
->Rev
);
2856 rev2
= min(rev2
,(git_revnum_t
)pLogEntry
->Rev
);
2862 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2865 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2866 changedpaths
.push_back(m_currentChangedPathList
[nItem
].GetGitPathString());
2871 // only one revision is selected in the log dialog top pane
2872 // but multiple items could be selected in the changed items list
2875 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2878 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2879 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(nItem
);
2881 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2883 if ((changedlogpath
)&&(!changedlogpath
->sCopyFromPath
.IsEmpty()))
2884 rev2
= changedlogpath
->lCopyFromRev
;
2887 // if the path was modified but the parent path was 'added with history'
2888 // then we have to use the copy from revision of the parent path
2889 CTGitPath cpath
= CTGitPath(changedlogpath
->sPath
);
2890 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
2892 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->GetAt(flist
)->sPath
);
2893 if (p
.IsAncestorOf(cpath
))
2895 if (!pLogEntry
->pArChangedPaths
->GetAt(flist
)->sCopyFromPath
.IsEmpty())
2896 rev2
= pLogEntry
->pArChangedPaths
->GetAt(flist
)->lCopyFromRev
;
2901 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
2903 // some items are hidden! So find out which item the user really clicked on
2904 INT_PTR selRealIndex
= -1;
2905 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
2907 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
2909 if (selRealIndex
== nItem
)
2911 selIndex
= hiddenindex
;
2912 changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
2919 changedpaths
.push_back(changedlogpath
->sPath
);
2920 changedlogpaths
.push_back(changedlogpath
);
2925 //entry is selected, now show the popup menu
2927 if (popup
.CreatePopupMenu())
2929 bool bEntryAdded
= false;
2930 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2932 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
2934 popup
.AppendMenuIcon(CGitLogList::ID_DIFF
, IDS_LOG_POPUP_DIFF
, IDI_DIFF
);
2935 popup
.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF
, IDS_LOG_POPUP_BLAMEDIFF
, IDI_BLAME
);
2936 popup
.SetDefaultItem(CGitLogList::ID_DIFF
, FALSE
);
2937 popup
.AppendMenuIcon(CGitLogList::ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
2940 // if (rev2 == rev1-1)
2943 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2944 popup
.AppendMenuIcon(CGitLogList::ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
2945 popup
.AppendMenuIcon(CGitLogList::ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
2946 popup
.AppendMenuIcon(CGitLogList::ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
2947 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2949 popup
.AppendMenuIcon(CGitLogList::ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
2950 popup
.AppendMenuIcon(CGitLogList::ID_POPPROPS
, IDS_REPOBROWSE_SHOWPROP
, IDI_PROPERTIES
); // "Show Properties"
2951 popup
.AppendMenuIcon(CGitLogList::ID_LOG
, IDS_MENULOG
, IDI_LOG
); // "Show Log"
2952 popup
.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS
, IDS_LOG_POPUP_GETMERGELOGS
, IDI_LOG
); // "Show merge log"
2953 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
, IDI_SAVEAS
);
2955 if (!m_ProjectProperties
.sWebViewerPathRev
.IsEmpty())
2957 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2958 popup
.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV
, IDS_LOG_POPUP_VIEWPATHREV
);
2960 if (popup
.GetDefaultItem(0,FALSE
)==-1)
2961 popup
.SetDefaultItem(CGitLogList::ID_OPEN
, FALSE
);
2964 else if (changedlogpaths
.size())
2966 // more than one entry is selected
2967 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
);
2973 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2974 bool bOpenWith
= false;
2975 bool bMergeLog
= false;
2976 m_bCancelled
= false;
2980 case CGitLogList::ID_DIFF
:
2982 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
2988 DoDiffFromLog(selIndex
, rev1
, rev2
, true, false);
2993 DoDiffFromLog(selIndex
, rev1
, rev2
, false, true);
2998 SetPromptApp(&theApp
);
2999 theApp
.DoWaitCursor(1);
3001 if (Git::PathIsURL(m_path
))
3003 sUrl
= m_path
.GetGitPathString();
3007 sUrl
= GetURLFromPath(m_path
);
3010 theApp
.DoWaitCursor(-1);
3012 temp
.Format(IDS_ERR_NOURLOFFILE
, m_path
.GetWinPath());
3013 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3015 theApp
.DoWaitCursor(-1);
3019 // find the working copy path of the selected item from the URL
3020 m_bCancelled
= false;
3021 CString sUrlRoot
= GetRepositoryRoot(CTGitPath(sUrl
));
3023 CString fileURL
= changedpaths
[0];
3024 fileURL
= sUrlRoot
+ fileURL
.Trim();
3025 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
3026 // sUrl = http://mydomain.com/repos/trunk/folder
3027 CString sUnescapedUrl
= CPathUtils::PathUnescape(sUrl
);
3028 // find out until which char the urls are identical
3030 while ((i
<fileURL
.GetLength())&&(i
<sUnescapedUrl
.GetLength())&&(fileURL
[i
]==sUnescapedUrl
[i
]))
3032 int leftcount
= m_path
.GetWinPathString().GetLength()-(sUnescapedUrl
.GetLength()-i
);
3033 CString wcPath
= m_path
.GetWinPathString().Left(leftcount
);
3034 wcPath
+= fileURL
.Mid(i
);
3035 wcPath
.Replace('/', '\\');
3036 CGitProgressDlg dlg
;
3037 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
3039 // a deleted path! Since the path isn't there anymore, merge
3040 // won't work. So just do a copy url->wc
3041 dlg
.SetCommand(CGitProgressDlg::GitProgress_Copy
);
3042 dlg
.SetPathList(CTGitPathList(CTGitPath(fileURL
)));
3044 dlg
.SetRevision(rev2
);
3048 if (!PathFileExists(wcPath
))
3050 // seems the path got renamed
3051 // tell the user how to work around this.
3052 CMessageBox::Show(this->m_hWnd
, IDS_LOG_REVERTREV_ERROR
, IDS_APPNAME
, MB_ICONERROR
);
3054 theApp
.DoWaitCursor(-1);
3057 dlg
.SetCommand(CGitProgressDlg::GitProgress_Merge
);
3058 dlg
.SetPathList(CTGitPathList(CTGitPath(wcPath
)));
3059 dlg
.SetUrl(fileURL
);
3060 dlg
.SetSecondUrl(fileURL
);
3061 GitRevRangeArray revarray
;
3062 revarray
.AddRevRange(rev1
, rev2
);
3063 dlg
.SetRevisionRanges(revarray
);
3066 msg
.Format(IDS_LOG_REVERT_CONFIRM
, (LPCTSTR
)wcPath
);
3067 if (CMessageBox::Show(this->m_hWnd
, msg
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
3071 theApp
.DoWaitCursor(-1);
3076 DialogEnableWindow(IDOK
, FALSE
);
3077 SetPromptApp(&theApp
);
3078 theApp
.DoWaitCursor(1);
3080 if (Git::PathIsURL(m_path
))
3082 filepath
= m_path
.GetGitPathString();
3086 filepath
= GetURLFromPath(m_path
);
3087 if (filepath
.IsEmpty())
3089 theApp
.DoWaitCursor(-1);
3091 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3092 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3093 TRACE(_T("could not retrieve the URL of the file!\n"));
3098 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
3099 filepath
+= changedpaths
[0];
3102 dlg
.m_Path
= CTGitPath(filepath
);
3105 theApp
.DoWaitCursor(-1);
3110 DialogEnableWindow(IDOK
, FALSE
);
3111 SetPromptApp(&theApp
);
3112 theApp
.DoWaitCursor(1);
3114 if (Git::PathIsURL(m_path
))
3116 filepath
= m_path
.GetGitPathString();
3120 filepath
= GetURLFromPath(m_path
);
3121 if (filepath
.IsEmpty())
3123 theApp
.DoWaitCursor(-1);
3125 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3126 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3127 TRACE(_T("could not retrieve the URL of the file!\n"));
3132 m_bCancelled
= false;
3133 CString sRoot
= GetRepositoryRoot(CTGitPath(filepath
));
3134 // if more than one entry is selected, we save them
3135 // one by one into a folder the user has selected
3136 bool bTargetSelected
= false;
3137 CTGitPath TargetPath
;
3138 if (m_ChangedFileListCtrl
.GetSelectedCount() > 1)
3140 CBrowseFolder browseFolder
;
3141 browseFolder
.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT
)));
3142 browseFolder
.m_style
= BIF_EDITBOX
| BIF_NEWDIALOGSTYLE
| BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
;
3143 CString strSaveAsDirectory
;
3144 if (browseFolder
.Show(GetSafeHwnd(), strSaveAsDirectory
) == CBrowseFolder::OK
)
3146 TargetPath
= CTGitPath(strSaveAsDirectory
);
3147 bTargetSelected
= true;
3152 // Display the Open dialog box.
3153 CString revFilename
;
3155 temp
= CPathUtils::GetFileNameFromPath(changedpaths
[0]);
3156 int rfind
= temp
.ReverseFind('.');
3158 revFilename
.Format(_T("%s-%ld%s"), (LPCTSTR
)temp
.Left(rfind
), rev1
, (LPCTSTR
)temp
.Mid(rfind
));
3160 revFilename
.Format(_T("%s-%ld"), (LPCTSTR
)temp
, rev1
);
3161 bTargetSelected
= CAppUtils::FileOpenSave(revFilename
, NULL
, IDS_LOG_POPUP_SAVE
, IDS_COMMONFILEFILTER
, false, m_hWnd
);
3162 TargetPath
.SetFromWin(revFilename
);
3164 if (bTargetSelected
)
3166 CProgressDlg progDlg
;
3167 progDlg
.SetTitle(IDS_APPNAME
);
3168 progDlg
.SetAnimation(IDR_DOWNLOAD
);
3169 for (std::vector
<LogChangedPath
*>::iterator it
= changedlogpaths
.begin(); it
!= changedlogpaths
.end(); ++it
)
3171 GitRev getrev
= ((*it
)->action
== LOGACTIONS_DELETED
) ? rev2
: rev1
;
3174 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)getrev
.ToString());
3175 progDlg
.SetLine(1, sInfoLine
, true);
3176 SetAndClearProgressInfo(&progDlg
);
3177 progDlg
.ShowModeless(m_hWnd
);
3179 CTGitPath tempfile
= TargetPath
;
3180 if (changedpaths
.size() > 1)
3182 // if multiple items are selected, then the TargetPath
3183 // points to a folder and we have to append the filename
3184 // to save to to that folder.
3185 CString sName
= (*it
)->sPath
;
3186 int slashpos
= sName
.ReverseFind('/');
3188 sName
= sName
.Mid(slashpos
);
3189 tempfile
.AppendPathString(sName
);
3190 // one problem here:
3191 // a user could have selected multiple items which
3192 // have the same filename but reside in different
3193 // directories, e.g.
3196 // in that case, the second 'file1' will overwrite
3197 // the already saved 'file1'.
3199 // we could maybe find the common root of all selected
3200 // items and then create sub folders to save those files
3202 // But I think we should just leave it that way: to check
3203 // out multiple items at once, the better way is still to
3204 // use the export command from the top pane of the log dialog.
3206 filepath
= sRoot
+ (*it
)->sPath
;
3207 if (!Cat(CTGitPath(filepath
), getrev
, getrev
, tempfile
))
3210 SetAndClearProgressInfo((HWND
)NULL
);
3211 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3213 theApp
.DoWaitCursor(-1);
3218 SetAndClearProgressInfo((HWND
)NULL
);
3221 theApp
.DoWaitCursor(-1);
3228 GitRev getrev
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
)->action
== LOGACTIONS_DELETED
? rev2
: rev1
;
3229 Open(bOpenWith
,changedpaths
[0],getrev
);
3235 if (Git::PathIsURL(m_path
))
3237 filepath
= m_path
.GetGitPathString();
3241 filepath
= GetURLFromPath(m_path
);
3242 if (filepath
.IsEmpty())
3244 theApp
.DoWaitCursor(-1);
3246 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3247 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3248 TRACE(_T("could not retrieve the URL of the file!\n"));
3253 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
3254 filepath
+= changedpaths
[0];
3257 if (dlg
.DoModal() == IDOK
)
3262 tempfile
= blame
.BlameToTempFile(CTGitPath(filepath
), dlg
.StartRev
, dlg
.EndRev
, dlg
.EndRev
, logfile
, _T(""), dlg
.m_bIncludeMerge
, TRUE
, TRUE
);
3263 if (!tempfile
.IsEmpty())
3265 if (dlg
.m_bTextView
)
3267 //open the default text editor for the result file
3268 CAppUtils::StartTextViewer(tempfile
);
3272 CString sParams
= _T("/path:\"") + filepath
+ _T("\" ");
3273 if(!CAppUtils::LaunchTortoiseBlame(tempfile
, logfile
, CPathUtils::GetFileNameFromPath(filepath
),sParams
))
3281 CMessageBox::Show(this->m_hWnd
, blame
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3286 case ID_GETMERGELOGS
:
3291 DialogEnableWindow(IDOK
, FALSE
);
3292 SetPromptApp(&theApp
);
3293 theApp
.DoWaitCursor(1);
3295 if (Git::PathIsURL(m_path
))
3297 filepath
= m_path
.GetGitPathString();
3301 filepath
= GetURLFromPath(m_path
);
3302 if (filepath
.IsEmpty())
3304 theApp
.DoWaitCursor(-1);
3306 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3307 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3308 TRACE(_T("could not retrieve the URL of the file!\n"));
3313 m_bCancelled
= false;
3314 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
3315 filepath
+= changedpaths
[0];
3316 git_revnum_t logrev
= rev1
;
3317 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
3319 // if the item got deleted in this revision,
3320 // fetch the log from the previous revision where it
3325 sCmd
.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR
)filepath
, logrev
);
3327 sCmd
+= _T(" /merge");
3328 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
3330 theApp
.DoWaitCursor(-1);
3333 case ID_VIEWPATHREV
:
3335 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetSelectionMark()));
3336 GitRev rev
= pLogEntry
->Rev
;
3337 CString relurl
= changedpaths
[0];
3338 CString url
= m_ProjectProperties
.sWebViewerPathRev
;
3339 url
.Replace(_T("%REVISION%"), rev
.ToString());
3340 url
.Replace(_T("%PATH%"), relurl
);
3341 relurl
= relurl
.Mid(relurl
.Find('/'));
3342 url
.Replace(_T("%PATH1%"), relurl
);
3344 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
3352 } // if (popup.CreatePopupMenu())
3356 void CLogDlg::OnDtnDropdownDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3358 // the date control should not show the "today" button
3359 CMonthCalCtrl
* pCtrl
= m_DateFrom
.GetMonthCalCtrl();
3361 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3365 void CLogDlg::OnDtnDropdownDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3367 // the date control should not show the "today" button
3368 CMonthCalCtrl
* pCtrl
= m_DateTo
.GetMonthCalCtrl();
3370 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3374 void CLogDlg::OnSize(UINT nType
, int cx
, int cy
)
3376 __super::OnSize(nType
, cx
, cy
);
3381 void CLogDlg::OnRefresh()
3383 if (GetDlgItem(IDC_GETALL
)->IsWindowEnabled())
3390 void CLogDlg::OnFind()
3394 m_pFindDialog
= new CFindReplaceDialog();
3395 m_pFindDialog
->Create(TRUE
, NULL
, NULL
, FR_HIDEUPDOWN
| FR_HIDEWHOLEWORD
, this);
3399 void CLogDlg::OnFocusFilter()
3401 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3404 void CLogDlg::OnEditCopy()
3406 if (GetFocus() == &m_ChangedFileListCtrl
)
3407 CopyChangedSelectionToClipBoard();
3409 m_LogList
.CopySelectionToClipBoard();
3412 CString
CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString
& url
)
3414 // is the URL a relative one?
3415 if (url
.Left(2).Compare(_T("^/")) == 0)
3417 // URL is relative to the repository root
3418 CString url1
= m_sRepositoryRoot
+ url
.Mid(1);
3419 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3420 DWORD len
= url
.GetLength();
3421 if (UrlCanonicalize((LPCTSTR
)url1
, buf
, &len
, 0) == S_OK
)
3422 return CString(buf
, len
);
3425 else if (url
[0] == '/')
3427 // URL is relative to the server's hostname
3429 // find the server's hostname
3430 int schemepos
= m_sRepositoryRoot
.Find(_T("//"));
3433 sHost
= m_sRepositoryRoot
.Left(m_sRepositoryRoot
.Find('/', schemepos
+3));
3434 CString url1
= sHost
+ url
;
3435 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3436 DWORD len
= url
.GetLength();
3437 if (UrlCanonicalize((LPCTSTR
)url
, buf
, &len
, 0) == S_OK
)
3438 return CString(buf
, len
);
3446 void CLogDlg::OnEnChangeSearchedit()
3449 if (m_LogList
.m_sFilterText
.IsEmpty())
3451 CStoreSelection
storeselection(this);
3452 // clear the filter, i.e. make all entries appear
3453 theApp
.DoWaitCursor(1);
3454 KillTimer(LOGFILTER_TIMER
);
3455 FillLogMessageCtrl(false);
3456 m_LogList
.StartFilter();
3458 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3459 m_arShownList
.RemoveAll();
3460 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3462 if (IsEntryInDateRange(i
))
3463 m_arShownList
.Add(m_logEntries
[i
]);
3465 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3466 m_LogList
.DeleteAllItems();
3467 m_LogList
.SetItemCountEx(ShownCountWithStopped());
3468 m_LogList
.RedrawItems(0, ShownCountWithStopped());
3469 m_LogList
.SetRedraw(false);
3470 ResizeAllListCtrlCols();
3471 m_LogList
.SetRedraw(true);
3473 theApp
.DoWaitCursor(-1);
3474 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
3475 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
3476 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3477 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
3480 if (Validate(m_LogList
.m_sFilterText
))
3481 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
3483 KillTimer(LOGFILTER_TIMER
);