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_SHOWRANGE
);
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
.FetchLogAsync(LogCallBack
,this);
353 GetDlgItem(IDC_LOGLIST
)->SetFocus();
357 void CLogDlg::LogRunStatus(int cur
)
359 if( cur
== GITLOG_START
)
362 temp
.LoadString(IDS_PROGRESSWAIT
);
364 // change the text of the close button to "Cancel" since now the thread
365 // is running, and simply closing the dialog doesn't work.
366 if (!GetDlgItem(IDOK
)->IsWindowVisible())
368 temp
.LoadString(IDS_MSGBOX_CANCEL
);
369 SetDlgItemText(IDCANCEL
, temp
);
372 // We use a progress bar while getting the logs
373 m_LogProgress
.SetRange32(0, 100);
374 m_LogProgress
.SetPos(0);
376 GetDlgItem(IDC_PROGRESS
)->ShowWindow(TRUE
);
378 DialogEnableWindow(IDC_GETALL
, FALSE
);
379 DialogEnableWindow(IDC_NEXTHUNDRED
, FALSE
);
380 DialogEnableWindow(IDC_CHECK_STOPONCOPY
, FALSE
);
381 DialogEnableWindow(IDC_INCLUDEMERGE
, FALSE
);
382 DialogEnableWindow(IDC_STATBUTTON
, FALSE
);
383 DialogEnableWindow(IDC_REFRESH
, FALSE
);
384 DialogEnableWindow(IDC_HIDEPATHS
,FALSE
);
387 if( cur
== GITLOG_END
)
391 DialogEnableWindow(IDC_NEXTHUNDRED
, TRUE
);
393 //DialogEnableWindow(IDC_CHECK_STOPONCOPY, TRUE);
394 //DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);
395 DialogEnableWindow(IDC_STATBUTTON
, TRUE
);
396 DialogEnableWindow(IDC_REFRESH
, TRUE
);
398 PostMessage(WM_TIMER
, LOGFILTER_TIMER
);
400 //CTime time=m_LogList.GetOldestTime();
402 m_LogList
.GetTimeRange(begin
,end
);
403 m_DateFrom
.SetTime(&begin
);
404 m_DateTo
.SetTime(&end
);
407 m_LogProgress
.SetPos(cur
);
409 void CLogDlg::SetDlgTitle(bool bOffline
)
411 if (m_sTitle
.IsEmpty())
412 GetWindowText(m_sTitle
);
418 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetUIPathString());
419 else if (m_path
.IsDirectory())
420 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetWinPathString());
422 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetFilename());
423 SetWindowText(sTemp
);
428 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetUIPathString());
429 else if (m_path
.IsDirectory())
430 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetWinPathString());
432 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetFilename());
436 void CLogDlg::CheckRegexpTooltip()
438 CWnd
*pWnd
= GetDlgItem(IDC_SEARCHEDIT
);
439 // Since tooltip describes regexp features, show it only if regexps are enabled.
440 if (m_bFilterWithRegex
)
442 m_tooltips
.AddTool(pWnd
, IDS_LOG_FILTER_REGEX_TT
);
445 m_tooltips
.DelTool(pWnd
);
448 void CLogDlg::EnableOKButton()
452 // the dialog is used to select revisions
453 if (m_bSelectionMustBeContinuous
)
454 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()!=0)&&(m_LogList
.IsSelectionContinuous()));
456 DialogEnableWindow(IDOK
, m_LogList
.GetSelectedCount()!=0);
459 DialogEnableWindow(IDOK
, TRUE
);
462 void CLogDlg::FillLogMessageCtrl(bool bShow
/* = true*/)
464 // we fill here the log message rich edit control,
465 // and also populate the changed files list control
466 // according to the selected revision(s).
468 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
469 // empty the log message view
470 pMsgView
->SetWindowText(_T(" "));
471 // empty the changed files list
472 m_ChangedFileListCtrl
.SetRedraw(FALSE
);
473 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
474 m_currentChangedArray
= NULL
;
475 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
476 m_ChangedFileListCtrl
.DeleteAllItems();
478 // if we're not here to really show a selected revision, just
479 // get out of here after clearing the views, which is what is intended
480 // if that flag is not set.
484 m_ChangedFileListCtrl
.Invalidate();
485 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
486 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
490 // depending on how many revisions are selected, we have to do different
492 int selCount
= m_LogList
.GetSelectedCount();
495 // if nothing is selected, we have nothing more to do
496 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
497 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
500 else if (selCount
== 1)
502 // if one revision is selected, we have to fill the log message view
503 // with the corresponding log message, and also fill the changed files
505 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
506 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
507 if (selIndex
>= m_LogList
.m_arShownList
.GetCount())
509 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
510 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
513 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(selIndex
));
515 if(!pLogEntry
->m_IsFull
)
517 pMsgView
->SetWindowText(_T("load ..."));
520 // set the log message text
521 pMsgView
->SetWindowText(_T("Commit:")+pLogEntry
->m_CommitHash
+_T("\r\n\r\n*")+pLogEntry
->m_Subject
+_T("\n\n")+pLogEntry
->m_Body
);
522 // turn bug ID's into links if the bugtraq: properties have been set
523 // and we can find a match of those in the log message
524 m_ProjectProperties
.FindBugID(pLogEntry
->m_Body
, pMsgView
);
525 CAppUtils::FormatTextInRichEditControl(pMsgView
);
527 m_ChangedFileListCtrl
.UpdateWithGitPathList(pLogEntry
->m_Files
);
528 m_ChangedFileListCtrl
.m_CurrentVersion
=pLogEntry
->m_CommitHash
;
529 m_ChangedFileListCtrl
.Show(SVNSLC_SHOWVERSIONED
);
531 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
535 // fill in the changed files list control
536 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
538 m_CurrentFilteredChangedArray
.RemoveAll();
539 for (INT_PTR c
= 0; c
< m_currentChangedArray
->GetCount(); ++c
)
541 LogChangedPath
* cpath
= m_currentChangedArray
->GetAt(c
);
544 if (m_currentChangedArray
->GetAt(c
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
546 m_CurrentFilteredChangedArray
.Add(cpath
);
549 m_currentChangedArray
= &m_CurrentFilteredChangedArray
;
555 // more than one revision is selected:
556 // the log message view must be emptied
557 // the changed files list contains all the changed paths from all
558 // selected revisions, with 'doubles' removed
559 m_currentChangedPathList
= GetChangedPathsFromSelectedRevisions(true);
563 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
564 if (m_currentChangedArray
)
566 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedArray
->GetCount());
567 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedArray
->GetCount());
569 else if (m_currentChangedPathList
.GetCount())
571 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedPathList
.GetCount());
572 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedPathList
.GetCount());
576 m_ChangedFileListCtrl
.SetItemCountEx(0);
577 m_ChangedFileListCtrl
.Invalidate();
579 CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl
);
580 // sort according to the settings
581 if (m_nSortColumnPathList
> 0)
582 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
584 SetSortArrow(&m_ChangedFileListCtrl
, -1, false);
585 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
589 void CLogDlg::OnBnClickedGetall()
594 void CLogDlg::GetAll(bool bForceAll
/* = false */)
597 // fetch all requested log messages, either the specified range or
598 // really *all* available log messages.
600 INT_PTR entry
= m_btnShow
.GetCurrentEntry();
609 m_startrev
= m_LogRevision
;
614 case 1: // show range
617 // ask for a revision range
618 CRevisionRangeDlg dlg
;
619 dlg
.SetStartRevision(m_startrev
);
620 dlg
.SetEndRevision( (m_endrev
>=0) ? m_endrev
: 0);
621 if (dlg
.DoModal()!=IDOK
)
625 m_endrev
= dlg
.GetEndRevision();
626 m_startrev
= dlg
.GetStartRevision();
627 if (((m_endrev
.IsNumber())&&(m_startrev
.IsNumber()))||
628 (m_endrev
.IsHead()||m_startrev
.IsHead()))
630 if (((LONG
)m_startrev
< (LONG
)m_endrev
)||
633 git_revnum_t temp
= m_startrev
;
634 m_startrev
= m_endrev
;
638 m_bShowedAll
= false;
643 m_ChangedFileListCtrl
.SetItemCountEx(0);
644 m_ChangedFileListCtrl
.Invalidate();
645 // We need to create CStoreSelection on the heap or else
646 // the variable will run out of the scope before the
647 // thread ends. Therefore we let the thread delete
649 m_pStoreSelection
= new CStoreSelection(this);
650 m_LogList
.SetItemCountEx(0);
651 m_LogList
.Invalidate();
652 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
653 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
654 pMsgView
->SetWindowText(_T(""));
656 SetSortArrow(&m_LogList
, -1, true);
658 m_LogList
.DeleteAllItems();
659 m_arShownList
.RemoveAll();
660 m_logEntries
.ClearAll();
663 m_bCancelled
= FALSE
;
668 InterlockedExchange(&m_bThreadRunning
, TRUE
);
669 if (AfxBeginThread(LogThreadEntry
, this)==NULL
)
671 InterlockedExchange(&m_bThreadRunning
, FALSE
);
672 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
674 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
675 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
679 void CLogDlg::OnBnClickedRefresh()
685 void CLogDlg::Refresh (bool autoGoOnline
)
690 void CLogDlg::OnBnClickedNexthundred()
694 // we have to fetch the next X log messages.
695 if (m_logEntries
.size() < 1)
697 // since there weren't any log messages fetched before, just
698 // fetch all since we don't have an 'anchor' to fetch the 'next'
702 git_revnum_t rev
= m_logEntries
[m_logEntries
.size()-1]->Rev
;
705 return; // do nothing! No more revisions to get
709 m_bCancelled
= FALSE
;
711 // rev is is revision we already have and we will receive it again
712 // -> fetch one extra revision to get NumberOfLogs *new* revisions
714 m_limit
= (int)(DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;
715 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
716 SetSortArrow(&m_LogList
, -1, true);
717 InterlockedExchange(&m_bThreadRunning
, TRUE
);
718 // We need to create CStoreSelection on the heap or else
719 // the variable will run out of the scope before the
720 // thread ends. Therefore we let the thread delete
722 m_pStoreSelection
= new CStoreSelection(this);
724 // since we fetch the log from the last revision we already have,
725 // we have to remove that revision entry to avoid getting it twice
726 m_logEntries
.pop_back();
727 if (AfxBeginThread(LogThreadEntry
, this)==NULL
)
729 InterlockedExchange(&m_bThreadRunning
, FALSE
);
730 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
732 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
733 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
737 BOOL
CLogDlg::Cancel()
742 void CLogDlg::SaveSplitterPos()
746 CRegDWORD regPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
747 CRegDWORD regPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
749 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
750 ScreenToClient(&rectSplitter
);
751 regPos1
= rectSplitter
.top
;
752 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
753 ScreenToClient(&rectSplitter
);
754 regPos2
= rectSplitter
.top
;
758 void CLogDlg::OnCancel()
760 // canceling means stopping the working thread if it's still running.
761 // we do this by using the Subversion cancel callback.
762 // But canceling can also mean just to close the dialog, depending on the
763 // text shown on the cancel button (it could simply read "OK").
765 GetDlgItemText(IDOK
, temp
);
766 temp2
.LoadString(IDS_MSGBOX_CANCEL
);
767 if ((temp
.Compare(temp2
)==0)||(this->IsThreadRunning()))
774 m_regLastStrict
= m_bStrict
;
775 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
776 reg
= m_btnShow
.GetCurrentEntry();
781 CString
CLogDlg::MakeShortMessage(const CString
& message
)
783 bool bFoundShort
= true;
784 CString sShortMessage
= m_ProjectProperties
.GetLogSummary(message
);
785 if (sShortMessage
.IsEmpty())
788 sShortMessage
= message
;
790 // Remove newlines and tabs 'cause those are not shown nicely in the list control
791 sShortMessage
.Replace(_T("\r"), _T(""));
792 sShortMessage
.Replace(_T("\t"), _T(" "));
794 // Suppose the first empty line separates 'summary' from the rest of the message.
795 int found
= sShortMessage
.Find(_T("\n\n"));
796 // To avoid too short 'short' messages
797 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
798 // only use the empty newline as a separator if it comes after at least 15 chars.
799 if ((!bFoundShort
)&&(found
>= 15))
801 sShortMessage
= sShortMessage
.Left(found
);
803 sShortMessage
.Replace('\n', ' ');
804 return sShortMessage
;
807 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
)
810 if (rev
== SVN_INVALID_REVNUM
)
816 // this is the callback function which receives the data for every revision we ask the log for
817 // we store this information here one by one.
819 if (m_startrev
== -1)
824 m_LogProgress
.SetPos(m_limit
- m_limitcounter
);
826 else if (m_startrev
.IsNumber() && m_startrev
.IsNumber())
827 m_LogProgress
.SetPos((git_revnum_t
)m_startrev
-rev
+(git_revnum_t
)m_endrev
);
828 __time64_t ttime
= time
/1000000L;
829 if (m_tTo
< (DWORD
)ttime
)
830 m_tTo
= (DWORD
)ttime
;
831 if (m_tFrom
> (DWORD
)ttime
)
832 m_tFrom
= (DWORD
)ttime
;
833 if ((m_lowestRev
> rev
)||(m_lowestRev
< 0))
835 // Add as many characters from the log message to the list control
836 PLOGENTRYDATA pLogItem
= new LOGENTRYDATA
;
837 pLogItem
->bCopies
= !!copies
;
839 // find out if this item was copied in the revision
840 BOOL copiedself
= FALSE
;
843 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< cpaths
->GetCount(); ++cpPathIndex
)
845 LogChangedPath
* cpath
= cpaths
->GetAt(cpPathIndex
);
846 if (!cpath
->sCopyFromPath
.IsEmpty() && (cpath
->sPath
.Compare(m_sSelfRelativeURL
) == 0))
848 // note: this only works if the log is fetched top-to-bottom
849 // but since we do that, it shouldn't be a problem
850 m_sSelfRelativeURL
= cpath
->sCopyFromPath
;
856 pLogItem
->bCopiedSelf
= copiedself
;
857 pLogItem
->tmDate
= ttime
;
858 pLogItem
->sAuthor
= author
;
859 pLogItem
->sDate
= date
;
860 pLogItem
->sShortMessage
= MakeShortMessage(message
);
861 pLogItem
->dwFileChanges
= filechanges
;
862 pLogItem
->actions
= actions
;
863 pLogItem
->haschildren
= haschildren
;
864 pLogItem
->childStackDepth
= m_childCounter
;
865 m_maxChild
= max(m_childCounter
, m_maxChild
);
868 pLogItem
->sBugIDs
= m_ProjectProperties
.FindBugID(message
).Trim();
870 // split multi line log entries and concatenate them
871 // again but this time with \r\n as line separators
872 // so that the edit control recognizes them
875 if (message
.GetLength()>0)
877 m_sMessageBuf
= message
;
878 m_sMessageBuf
.Replace(_T("\n\r"), _T("\n"));
879 m_sMessageBuf
.Replace(_T("\r\n"), _T("\n"));
880 if (m_sMessageBuf
.Right(1).Compare(_T("\n"))==0)
881 m_sMessageBuf
= m_sMessageBuf
.Left(m_sMessageBuf
.GetLength()-1);
884 m_sMessageBuf
.Empty();
885 pLogItem
->sMessage
= m_sMessageBuf
;
888 // move-construct path array
890 pLogItem
->pArChangedPaths
= new LogChangedPathArray (*cpaths
);
893 catch (CException
* e
)
895 ::MessageBox(NULL
, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR
);
899 m_logEntries
.push_back(pLogItem
);
900 m_arShownList
.Add(pLogItem
);
906 //this is the thread function which calls the subversion function
911 void CLogDlg::CopyChangedSelectionToClipBoard()
914 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
916 return; // nothing is selected, get out of here
920 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
923 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
926 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
927 sPaths
+= m_currentChangedPathList
[nItem
].GetGitPathString();
928 sPaths
+= _T("\r\n");
933 // only one revision is selected in the log dialog top pane
934 // but multiple items could be selected in the changed items list
935 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
938 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
939 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(nItem
);
941 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
943 // some items are hidden! So find out which item the user really selected
944 INT_PTR selRealIndex
= -1;
945 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
947 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
949 if (selRealIndex
== nItem
)
951 changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
);
958 sPaths
+= changedlogpath
->sPath
;
959 sPaths
+= _T("\r\n");
964 CStringUtils::WriteAsciiStringToClipboard(sPaths
, GetSafeHwnd());
968 BOOL
CLogDlg::IsDiffPossible(LogChangedPath
* changedpath
, git_revnum_t rev
)
971 CString added
, deleted
;
972 if (changedpath
== NULL
)
975 if ((rev
> 1)&&(changedpath
->action
!= LOGACTIONS_DELETED
))
977 if (changedpath
->action
== LOGACTIONS_ADDED
) // file is added
979 if (changedpath
->lCopyFromRev
== 0)
980 return FALSE
; // but file was not added with history
988 void CLogDlg::OnContextMenu(CWnd
* pWnd
, CPoint point
)
990 // we have two separate context menus:
991 // one shown on the log message list control,
992 // the other shown in the changed-files list control
993 int selCount
= m_LogList
.GetSelectedCount();
994 if (pWnd
== &m_LogList
)
996 //ShowContextMenuForRevisions(pWnd, point);
998 else if (pWnd
== &m_ChangedFileListCtrl
)
1000 //ShowContextMenuForChangedpaths(pWnd, point);
1002 else if ((selCount
== 1)&&(pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1004 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1007 selIndex
= m_LogList
.GetNextSelectedItem(pos
);
1008 if ((point
.x
== -1) && (point
.y
== -1))
1011 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(&rect
);
1012 ClientToScreen(&rect
);
1013 point
= rect
.CenterPoint();
1015 CString sMenuItemText
;
1017 if (popup
.CreatePopupMenu())
1019 // add the 'default' entries
1020 sMenuItemText
.LoadString(IDS_SCIEDIT_COPY
);
1021 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, WM_COPY
, sMenuItemText
);
1022 sMenuItemText
.LoadString(IDS_SCIEDIT_SELECTALL
);
1023 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, EM_SETSEL
, sMenuItemText
);
1025 //if (selIndex >= 0)
1027 // popup.AppendMenu(MF_SEPARATOR);
1028 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
1029 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
1032 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1036 break; // no command selected
1039 ::SendMessage(GetDlgItem(IDC_MSGVIEW
)->GetSafeHwnd(), cmd
, 0, -1);
1041 case CGitLogList::ID_EDITAUTHOR
:
1042 EditLogMessage(selIndex
);
1050 LRESULT
CLogDlg::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1053 ASSERT(m_pFindDialog
!= NULL
);
1055 if (m_pFindDialog
->IsTerminating())
1057 // invalidate the handle identifying the dialog box.
1058 m_pFindDialog
= NULL
;
1062 if(m_pFindDialog
->FindNext())
1064 //read data from dialog
1065 CString FindText
= m_pFindDialog
->GetFindString();
1066 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
1067 bool bFound
= false;
1069 bool bRegex
= ValidateRegexp(FindText
, pat
, bMatchCase
);
1071 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_not_null
;
1074 for (i
= this->m_nSearchIndex
; i
<m_arShownList
.GetCount()&&!bFound
; i
++)
1078 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1080 if (regex_search(wstring((LPCTSTR
)pLogEntry
->sMessage
), pat
, flags
))
1085 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
1086 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
1088 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
1089 if (regex_search(wstring((LPCTSTR
)cpath
->sCopyFromPath
), pat
, flags
))
1095 if (regex_search(wstring((LPCTSTR
)cpath
->sPath
), pat
, flags
))
1107 if (m_logEntries
[i
]->sMessage
.Find(FindText
) >= 0)
1112 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1113 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
1114 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
1116 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
1117 if (cpath
->sCopyFromPath
.Find(FindText
)>=0)
1123 if (cpath
->sPath
.Find(FindText
)>=0)
1133 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1134 CString msg
= pLogEntry
->sMessage
;
1135 msg
= msg
.MakeLower();
1136 CString find
= FindText
.MakeLower();
1137 if (msg
.Find(find
) >= 0)
1142 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
1143 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
1145 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
1146 CString lowerpath
= cpath
->sCopyFromPath
;
1147 lowerpath
.MakeLower();
1148 if (lowerpath
.Find(find
)>=0)
1154 lowerpath
= cpath
->sPath
;
1155 lowerpath
.MakeLower();
1156 if (lowerpath
.Find(find
)>=0)
1165 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
1168 this->m_nSearchIndex
= (i
+1);
1169 m_LogList
.EnsureVisible(i
, FALSE
);
1170 m_LogList
.SetItemState(m_LogList
.GetSelectionMark(), 0, LVIS_SELECTED
);
1171 m_LogList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
1172 m_LogList
.SetSelectionMark(i
);
1173 FillLogMessageCtrl();
1176 if (m_nSearchIndex
>= m_arShownList
.GetCount())
1177 m_nSearchIndex
= (int)m_arShownList
.GetCount()-1;
1179 } // if(m_pFindDialog->FindNext())
1180 UpdateLogInfoLabel();
1185 void CLogDlg::OnOK()
1188 // since the log dialog is also used to select revisions for other
1189 // dialogs, we have to do some work before closing this dialog
1190 if (GetFocus() != GetDlgItem(IDOK
))
1191 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
1192 if (!GetDlgItem(IDOK
)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL
))
1193 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
1197 GetDlgItemText(IDOK
, buttontext
);
1198 temp
.LoadString(IDS_MSGBOX_CANCEL
);
1199 if (temp
.Compare(buttontext
) != 0)
1200 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
1201 m_bCancelled
= TRUE
;
1202 m_selectedRevs
.Clear();
1203 m_selectedRevsOneRange
.Clear();
1204 if (m_pNotifyWindow
)
1206 int selIndex
= m_LogList
.GetSelectionMark();
1209 PLOGENTRYDATA pLogEntry
= NULL
;
1210 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1211 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1212 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1213 git_revnum_t lowerRev
= pLogEntry
->Rev
;
1214 git_revnum_t higherRev
= lowerRev
;
1217 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1218 git_revnum_t rev
= pLogEntry
->Rev
;
1219 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1222 if (higherRev
< rev
)
1225 if (m_sFilterText
.IsEmpty() && m_nSortColumn
== 0 && IsSelectionContinuous())
1227 m_selectedRevsOneRange
.AddRevRange(lowerRev
, higherRev
);
1229 BOOL bSentMessage
= FALSE
;
1230 if (m_LogList
.GetSelectedCount() == 1)
1232 // if only one revision is selected, check if the path/url with which the dialog was started
1233 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
1234 // if it was copied, use the copy from revision as lowerRev
1235 if ((pLogEntry
)&&(pLogEntry
->pArChangedPaths
)&&(lowerRev
== higherRev
))
1237 CString sUrl
= m_path
.GetGitPathString();
1238 if (!m_path
.IsUrl())
1240 sUrl
= GetURLFromPath(m_path
);
1242 sUrl
= sUrl
.Mid(m_sRepositoryRoot
.GetLength());
1243 for (int cp
= 0; cp
< pLogEntry
->pArChangedPaths
->GetCount(); ++cp
)
1245 LogChangedPath
* pData
= pLogEntry
->pArChangedPaths
->GetAt(cp
);
1248 if (sUrl
.Compare(pData
->sPath
) == 0)
1250 if (!pData
->sCopyFromPath
.IsEmpty())
1252 lowerRev
= pData
->lCopyFromRev
;
1253 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
), lowerRev
);
1254 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
), higherRev
);
1255 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1256 bSentMessage
= TRUE
;
1263 if ( !bSentMessage
)
1265 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
| MERGE_REVSELECTMINUSONE
), lowerRev
);
1266 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
| MERGE_REVSELECTMINUSONE
), higherRev
);
1267 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1268 if (m_selectedRevsOneRange
.GetCount())
1269 m_pNotifyWindow
->SendMessage(WM_REVLISTONERANGE
, 0, (LPARAM
)&m_selectedRevsOneRange
);
1275 m_regLastStrict
= m_bStrict
;
1276 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
1277 reg
= m_btnShow
.GetCurrentEntry();
1282 void CLogDlg::OnNMDblclkChangedFileList(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
1284 // a double click on an entry in the changed-files list has happened
1290 void CLogDlg::DiffSelectedFile()
1293 if (m_bThreadRunning
)
1295 UpdateLogInfoLabel();
1296 INT_PTR selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
1299 if (m_ChangedFileListCtrl
.GetSelectedCount() == 0)
1301 // find out if there's an entry selected in the log list
1302 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1303 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1304 git_revnum_t rev1
= pLogEntry
->Rev
;
1305 git_revnum_t rev2
= rev1
;
1310 // there's at least a second entry selected in the log list: several revisions selected!
1311 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1314 rev1
= max(rev1
,(long)pLogEntry
->Rev
);
1315 rev2
= min(rev2
,(long)pLogEntry
->Rev
);
1319 // now we have both revisions selected in the log list, so we can do a diff of the selected
1320 // entry in the changed files list with these two revisions.
1321 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1326 // nothing or only one revision selected in the log list
1327 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1329 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
1331 // some items are hidden! So find out which item the user really clicked on
1332 INT_PTR selRealIndex
= -1;
1333 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
1335 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
1337 if (selRealIndex
== selIndex
)
1339 selIndex
= hiddenindex
;
1340 changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1346 if (IsDiffPossible(changedpath
, rev1
))
1348 // diffs with renamed files are possible
1349 if ((changedpath
)&&(!changedpath
->sCopyFromPath
.IsEmpty()))
1350 rev2
= changedpath
->lCopyFromRev
;
1353 // if the path was modified but the parent path was 'added with history'
1354 // then we have to use the copy from revision of the parent path
1355 CTGitPath cpath
= CTGitPath(changedpath
->sPath
);
1356 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
1358 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->GetAt(flist
)->sPath
);
1359 if (p
.IsAncestorOf(cpath
))
1361 if (!pLogEntry
->pArChangedPaths
->GetAt(flist
)->sCopyFromPath
.IsEmpty())
1362 rev2
= pLogEntry
->pArChangedPaths
->GetAt(flist
)->lCopyFromRev
;
1366 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1370 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1371 CTGitPath tempfile2
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1373 // deleted files must be opened from the revision before the deletion
1374 if (changedpath
->action
== LOGACTIONS_DELETED
)
1376 m_bCancelled
= false;
1378 CProgressDlg progDlg
;
1379 progDlg
.SetTitle(IDS_APPNAME
);
1380 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1382 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)(m_sRepositoryRoot
+ changedpath
->sPath
), (LPCTSTR
)r
.ToString());
1383 progDlg
.SetLine(1, sInfoLine
, true);
1384 SetAndClearProgressInfo(&progDlg
);
1385 progDlg
.ShowModeless(m_hWnd
);
1387 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), r
, r
, tempfile
))
1389 m_bCancelled
= false;
1390 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), GitRev::REV_HEAD
, r
, tempfile
))
1393 SetAndClearProgressInfo((HWND
)NULL
);
1394 CMessageBox::Show(m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1399 SetAndClearProgressInfo((HWND
)NULL
);
1401 CString sName1
, sName2
;
1402 sName1
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
);
1403 sName2
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
-1);
1404 CAppUtils::DiffFlags flags
;
1405 flags
.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1406 if (changedpath
->action
== LOGACTIONS_DELETED
)
1407 CAppUtils::StartExtDiff(tempfile
, tempfile2
, sName2
, sName1
, flags
);
1409 CAppUtils::StartExtDiff(tempfile2
, tempfile
, sName2
, sName1
, flags
);
1416 void CLogDlg::DoDiffFromLog(INT_PTR selIndex
, GitRev
* rev1
, GitRev
* rev2
, bool blame
, bool unified
)
1418 DialogEnableWindow(IDOK
, FALSE
);
1419 // SetPromptApp(&theApp);
1420 theApp
.DoWaitCursor(1);
1423 GetTempPath(temppath
);
1426 file1
.Format(_T("%s%s_%s%s"),
1428 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1429 rev1
->m_CommitHash
.Left(6),
1430 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1433 file2
.Format(_T("%s\\%s_%s%s"),
1435 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1436 rev2
->m_CommitHash
.Left(6),
1437 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1441 cmd
.Format(_T("git.exe cat-file -p %s:%s"),rev1
->m_CommitHash
,(*m_currentChangedArray
)[selIndex
].GetGitPathString());
1442 g_Git
.RunLogFile(cmd
,file1
);
1443 cmd
.Format(_T("git.exe cat-file -p %s:%s"),rev2
->m_CommitHash
,(*m_currentChangedArray
)[selIndex
].GetGitPathString());
1444 g_Git
.RunLogFile(cmd
,file2
);
1446 CAppUtils::DiffFlags flags
;
1447 CAppUtils::StartExtDiff(file1
,file2
,_T("A"),_T("B"),flags
);
1452 if (Git::PathIsURL(m_path
))
1454 filepath
= m_path
.GetGitPathString();
1458 filepath
= GetURLFromPath(m_path
);
1459 if (filepath
.IsEmpty())
1461 theApp
.DoWaitCursor(-1);
1463 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1464 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1465 TRACE(_T("could not retrieve the URL of the file!\n"));
1467 theApp
.DoWaitCursor(-11);
1471 m_bCancelled
= FALSE
;
1472 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1474 CString firstfile
, secondfile
;
1475 if (m_LogList
.GetSelectedCount()==1)
1477 int s
= m_LogList
.GetSelectionMark();
1478 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(s
));
1479 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1480 firstfile
= changedpath
->sPath
;
1481 secondfile
= firstfile
;
1482 if ((rev2
== rev1
-1)&&(changedpath
->lCopyFromRev
> 0)) // is it an added file with history?
1484 secondfile
= changedpath
->sCopyFromPath
;
1485 rev2
= changedpath
->lCopyFromRev
;
1490 firstfile
= m_currentChangedPathList
[selIndex
].GetGitPathString();
1491 secondfile
= firstfile
;
1494 firstfile
= filepath
+ firstfile
.Trim();
1495 secondfile
= filepath
+ secondfile
.Trim();
1497 GitDiff
diff(this, this->m_hWnd
, true);
1498 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1499 diff
.SetHEADPeg(m_LogRevision
);
1503 diff
.ShowUnifiedDiff(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
);
1505 CAppUtils::StartShowUnifiedDiff(m_hWnd
, CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), m_LogRevision
);
1509 if (diff
.ShowCompare(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), false, blame
))
1511 if (firstfile
.Compare(secondfile
)==0)
1513 git_revnum_t baseRev
= 0;
1514 diff
.DiffProps(CTGitPath(firstfile
), rev2
, rev1
, baseRev
);
1521 theApp
.DoWaitCursor(-1);
1525 BOOL
CLogDlg::Open(bool bOpenWith
,CString changedpath
, git_revnum_t rev
)
1528 DialogEnableWindow(IDOK
, FALSE
);
1529 SetPromptApp(&theApp
);
1530 theApp
.DoWaitCursor(1);
1532 if (Git::PathIsURL(m_path
))
1534 filepath
= m_path
.GetGitPathString();
1538 filepath
= GetURLFromPath(m_path
);
1539 if (filepath
.IsEmpty())
1541 theApp
.DoWaitCursor(-1);
1543 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1544 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1545 TRACE(_T("could not retrieve the URL of the file!\n"));
1550 m_bCancelled
= false;
1551 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1552 filepath
+= changedpath
;
1554 CProgressDlg progDlg
;
1555 progDlg
.SetTitle(IDS_APPNAME
);
1556 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1558 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)GitRev(rev
).ToString());
1559 progDlg
.SetLine(1, sInfoLine
, true);
1560 SetAndClearProgressInfo(&progDlg
);
1561 progDlg
.ShowModeless(m_hWnd
);
1563 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath
), rev
);
1564 m_bCancelled
= false;
1565 if (!Cat(CTGitPath(filepath
), GitRev(rev
), rev
, tempfile
))
1568 SetAndClearProgressInfo((HWND
)NULL
);
1569 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1571 theApp
.DoWaitCursor(-1);
1575 SetAndClearProgressInfo((HWND
)NULL
);
1576 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1579 int ret
= (int)ShellExecute(this->m_hWnd
, NULL
, tempfile
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1580 if (ret
<= HINSTANCE_ERROR
)
1585 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1586 cmd
+= tempfile
.GetWinPathString() + _T(" ");
1587 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1590 theApp
.DoWaitCursor(-1);
1595 void CLogDlg::EditAuthor(const CLogDataVector
& logs
)
1600 if (logs
.size() == 0)
1602 DialogEnableWindow(IDOK
, FALSE
);
1603 SetPromptApp(&theApp
);
1604 theApp
.DoWaitCursor(1);
1605 if (Git::PathIsURL(m_path
))
1606 url
= m_path
.GetGitPathString();
1609 url
= GetURLFromPath(m_path
);
1611 name
= Git_PROP_REVISION_AUTHOR
;
1613 CString value
= RevPropertyGet(name
, CTGitPath(url
), logs
[0]->Rev
);
1614 CString sOldValue
= value
;
1615 value
.Replace(_T("\n"), _T("\r\n"));
1616 CInputDlg
dlg(this);
1617 dlg
.m_sHintText
.LoadString(IDS_LOG_AUTHOR
);
1618 dlg
.m_sInputText
= value
;
1619 dlg
.m_sTitle
.LoadString(IDS_LOG_AUTHOREDITTITLE
);
1620 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1621 dlg
.m_bUseLogWidth
= false;
1622 if (dlg
.DoModal() == IDOK
)
1624 dlg
.m_sInputText
.Replace(_T("\r"), _T(""));
1626 LogCache::CCachedLogInfo
* toUpdate
1627 = GetLogCache (CTGitPath (m_sRepositoryRoot
));
1629 CProgressDlg progDlg
;
1630 progDlg
.SetTitle(IDS_APPNAME
);
1631 progDlg
.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT
)));
1632 progDlg
.SetTime(true);
1633 progDlg
.SetShowProgressBar(true);
1634 progDlg
.ShowModeless(m_hWnd
);
1635 for (DWORD i
=0; i
<logs
.size(); ++i
)
1637 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), logs
[i
]->Rev
))
1640 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1646 logs
[i
]->sAuthor
= dlg
.m_sInputText
;
1647 m_LogList
.Invalidate();
1649 // update the log cache
1651 if (toUpdate
!= NULL
)
1653 // log caching is active
1655 LogCache::CCachedLogInfo newInfo
;
1656 newInfo
.Insert ( logs
[i
]->Rev
1657 , (const char*) CUnicodeUtils::GetUTF8 (logs
[i
]->sAuthor
)
1660 , LogCache::CRevisionInfoContainer::HAS_AUTHOR
);
1662 toUpdate
->Update (newInfo
);
1665 progDlg
.SetProgress64(i
, logs
.size());
1669 theApp
.DoWaitCursor(-1);
1674 void CLogDlg::EditLogMessage(int index
)
1679 DialogEnableWindow(IDOK
, FALSE
);
1680 SetPromptApp(&theApp
);
1681 theApp
.DoWaitCursor(1);
1682 if (Git::PathIsURL(m_path
))
1683 url
= m_path
.GetGitPathString();
1686 url
= GetURLFromPath(m_path
);
1688 name
= Git_PROP_REVISION_LOG
;
1690 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(index
));
1691 m_bCancelled
= FALSE
;
1692 CString value
= RevPropertyGet(name
, CTGitPath(url
), pLogEntry
->Rev
);
1693 CString sOldValue
= value
;
1694 value
.Replace(_T("\n"), _T("\r\n"));
1695 CInputDlg
dlg(this);
1696 dlg
.m_sHintText
.LoadString(IDS_LOG_MESSAGE
);
1697 dlg
.m_sInputText
= value
;
1698 dlg
.m_sTitle
.LoadString(IDS_LOG_MESSAGEEDITTITLE
);
1699 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1700 dlg
.m_bUseLogWidth
= true;
1701 if (dlg
.DoModal() == IDOK
)
1703 dlg
.m_sInputText
.Replace(_T("\r"), _T(""));
1704 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), pLogEntry
->Rev
))
1706 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1710 pLogEntry
->sShortMessage
= MakeShortMessage(dlg
.m_sInputText
);
1711 // split multi line log entries and concatenate them
1712 // again but this time with \r\n as line separators
1713 // so that the edit control recognizes them
1714 if (dlg
.m_sInputText
.GetLength()>0)
1716 m_sMessageBuf
= dlg
.m_sInputText
;
1717 dlg
.m_sInputText
.Replace(_T("\n\r"), _T("\n"));
1718 dlg
.m_sInputText
.Replace(_T("\r\n"), _T("\n"));
1719 if (dlg
.m_sInputText
.Right(1).Compare(_T("\n"))==0)
1720 dlg
.m_sInputText
= dlg
.m_sInputText
.Left(dlg
.m_sInputText
.GetLength()-1);
1723 dlg
.m_sInputText
.Empty();
1724 pLogEntry
->sMessage
= dlg
.m_sInputText
;
1725 pLogEntry
->sBugIDs
= m_ProjectProperties
.FindBugID(dlg
.m_sInputText
);
1726 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
1727 pMsgView
->SetWindowText(_T(" "));
1728 pMsgView
->SetWindowText(dlg
.m_sInputText
);
1729 m_ProjectProperties
.FindBugID(dlg
.m_sInputText
, pMsgView
);
1730 m_LogList
.Invalidate();
1732 // update the log cache
1734 LogCache::CCachedLogInfo
* toUpdate
1735 = GetLogCache (CTGitPath (m_sRepositoryRoot
));
1736 if (toUpdate
!= NULL
)
1738 // log caching is active
1740 LogCache::CCachedLogInfo newInfo
;
1741 newInfo
.Insert ( pLogEntry
->Rev
1743 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry
->sMessage
)
1745 , LogCache::CRevisionInfoContainer::HAS_COMMENT
);
1747 toUpdate
->Update (newInfo
);
1751 theApp
.DoWaitCursor(-1);
1756 BOOL
CLogDlg::PreTranslateMessage(MSG
* pMsg
)
1758 // Skip Ctrl-C when copying text out of the log message or search filter
1759 BOOL bSkipAccelerator
= ( pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW
) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT
) ) && GetKeyState(VK_CONTROL
)&0x8000 );
1760 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
1762 if (GetFocus()==GetDlgItem(IDC_LOGLIST
))
1764 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1766 DiffSelectedRevWithPrevious();
1770 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
1776 if (m_hAccel
&& !bSkipAccelerator
)
1778 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
1783 m_tooltips
.RelayEvent(pMsg
);
1784 return __super::PreTranslateMessage(pMsg
);
1788 BOOL
CLogDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1790 //if (this->IsThreadRunning())
1791 if(m_LogList
.m_bNoDispUpdates
)
1793 // only show the wait cursor over the list control
1795 ((pWnd
== GetDlgItem(IDC_LOGLIST
))||
1796 (pWnd
== GetDlgItem(IDC_MSGVIEW
))||
1797 (pWnd
== GetDlgItem(IDC_LOGMSG
))))
1799 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1804 if ((pWnd
) && (pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1805 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1807 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1809 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1812 void CLogDlg::OnBnClickedHelp()
1817 void CLogDlg::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1819 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1821 //if (this->IsThreadRunning())
1822 if(m_LogList
.m_bNoDispUpdates
)
1824 if (pNMLV
->iItem
>= 0)
1826 m_nSearchIndex
= pNMLV
->iItem
;
1827 if (pNMLV
->iSubItem
!= 0)
1829 if ((pNMLV
->iItem
== m_LogList
.m_arShownList
.GetCount())&&(m_bStrict
)&&(1/*m_bStrictStopped*/))
1831 // remove the selected state
1832 if (pNMLV
->uChanged
& LVIF_STATE
)
1834 m_LogList
.SetItemState(pNMLV
->iItem
, 0, LVIS_SELECTED
);
1835 FillLogMessageCtrl();
1837 UpdateLogInfoLabel();
1841 if (pNMLV
->uChanged
& LVIF_STATE
)
1843 FillLogMessageCtrl();
1849 FillLogMessageCtrl();
1853 UpdateLogInfoLabel();
1856 void CLogDlg::OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1858 ENLINK
*pEnLink
= reinterpret_cast<ENLINK
*>(pNMHDR
);
1859 if (pEnLink
->msg
== WM_LBUTTONUP
)
1862 GetDlgItemText(IDC_MSGVIEW
, msg
);
1863 msg
.Replace(_T("\r\n"), _T("\n"));
1864 url
= msg
.Mid(pEnLink
->chrg
.cpMin
, pEnLink
->chrg
.cpMax
-pEnLink
->chrg
.cpMin
);
1865 if (!::PathIsURL(url
))
1867 url
= m_ProjectProperties
.GetBugIDUrl(url
);
1868 url
= GetAbsoluteUrlFromRelativeUrl(url
);
1871 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
1876 void CLogDlg::OnBnClickedStatbutton()
1879 if (this->IsThreadRunning())
1881 if (m_LogList
.m_arShownList
.IsEmpty())
1882 return; // nothing is shown, so no statistics.
1883 // the statistics dialog expects the log entries to be sorted by date
1884 SortByColumn(3, false);
1885 CPtrArray shownlist
;
1886 m_LogList
.RecalculateShownList(&shownlist
);
1887 // create arrays which are aware of the current filter
1888 CStringArray m_arAuthorsFiltered
;
1889 CDWordArray m_arDatesFiltered
;
1890 CDWordArray m_arFileChangesFiltered
;
1891 for (INT_PTR i
=0; i
<shownlist
.GetCount(); ++i
)
1893 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(shownlist
.GetAt(i
));
1894 CString strAuthor
= pLogEntry
->m_AuthorName
;
1895 if ( strAuthor
.IsEmpty() )
1897 strAuthor
.LoadString(IDS_STATGRAPH_EMPTYAUTHOR
);
1899 m_arAuthorsFiltered
.Add(strAuthor
);
1900 m_arDatesFiltered
.Add(pLogEntry
->m_AuthorDate
.GetTime());
1901 m_arFileChangesFiltered
.Add(pLogEntry
->m_Files
.GetCount());
1904 dlg
.m_parAuthors
= &m_arAuthorsFiltered
;
1905 dlg
.m_parDates
= &m_arDatesFiltered
;
1906 dlg
.m_parFileChanges
= &m_arFileChangesFiltered
;
1907 dlg
.m_path
= m_path
;
1909 // restore the previous sorting
1910 SortByColumn(m_nSortColumn
, m_bAscending
);
1911 OnTimer(LOGFILTER_TIMER
);
1916 void CLogDlg::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1919 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1920 // Take the default processing unless we set this to something else below.
1921 *pResult
= CDRF_DODEFAULT
;
1923 if (m_bNoDispUpdates
)
1926 switch (pLVCD
->nmcd
.dwDrawStage
)
1930 *pResult
= CDRF_NOTIFYITEMDRAW
;
1934 case CDDS_ITEMPREPAINT
:
1936 // This is the prepaint stage for an item. Here's where we set the
1937 // item's text color.
1939 // Tell Windows to send draw notifications for each subitem.
1940 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
1942 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
1944 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1946 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
1950 if (data
->bCopiedSelf
)
1952 // only change the background color if the item is not 'hot' (on vista with themes enabled)
1953 if (!theme
.IsAppThemed() || !m_bVista
|| ((pLVCD
->nmcd
.uItemState
& CDIS_HOT
)==0))
1954 pLVCD
->clrTextBk
= GetSysColor(COLOR_MENU
);
1958 crText
= m_Colors
.GetColor(CColors::Modified
);
1960 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1961 // crText = GetSysColor(COLOR_GRAYTEXT);
1962 // if (data->Rev == m_wcRev)
1964 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1965 // We changed the font, so we're returning CDRF_NEWFONT. This
1966 // tells the control to recalculate the extent of the text.
1967 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1971 if (m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1973 if (m_bStrictStopped
)
1974 crText
= GetSysColor(COLOR_GRAYTEXT
);
1976 // Store the color back in the NMLVCUSTOMDRAW struct.
1977 pLVCD
->clrText
= crText
;
1981 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
1983 if ((m_bStrictStopped
)&&(m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
1985 pLVCD
->nmcd
.uItemState
&= ~(CDIS_SELECTED
|CDIS_FOCUS
);
1987 if (pLVCD
->iSubItem
== 1)
1989 *pResult
= CDRF_DODEFAULT
;
1991 if (m_arShownList
.GetCount() <= (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1995 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1996 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1998 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
));
2000 // Get the selected state of the
2001 // item being drawn.
2003 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
2004 rItem
.mask
= LVIF_STATE
;
2005 rItem
.iItem
= pLVCD
->nmcd
.dwItemSpec
;
2006 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
2007 m_LogList
.GetItem(&rItem
);
2010 m_LogList
.GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
2012 // Fill the background
2013 if (theme
.IsAppThemed() && m_bVista
)
2015 theme
.Open(m_hWnd
, L
"Explorer");
2016 int state
= LISS_NORMAL
;
2017 if (rItem
.state
& LVIS_SELECTED
)
2019 if (::GetFocus() == m_LogList
.m_hWnd
)
2020 state
|= LISS_SELECTED
;
2022 state
|= LISS_SELECTEDNOTFOCUS
;
2027 if (pLogEntry
->bCopiedSelf
)
2029 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
2030 // information at this drawing stage. But we can check the whether the
2031 // previous stage changed the background color of the item
2032 if (pLVCD
->clrTextBk
== GetSysColor(COLOR_MENU
))
2035 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_MENU
));
2038 ::FillRect(pLVCD
->nmcd
.hdc
, &rect
, brush
);
2039 ::DeleteObject(brush
);
2046 if (theme
.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL
, state
))
2047 theme
.DrawParentBackground(m_hWnd
, pLVCD
->nmcd
.hdc
, &rect
);
2049 theme
.DrawBackground(pLVCD
->nmcd
.hdc
, LVP_LISTDETAIL
, state
, &rect
, NULL
);
2054 if (rItem
.state
& LVIS_SELECTED
)
2056 if (::GetFocus() == m_LogList
.m_hWnd
)
2057 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT
));
2059 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE
));
2063 //if (pLogEntry->bCopiedSelf)
2064 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
2066 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW
));
2071 ::FillRect(pLVCD
->nmcd
.hdc
, &rect
, brush
);
2072 ::DeleteObject(brush
);
2075 // Draw the icon(s) into the compatible DC
2076 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_MODIFIED
)
2077 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2080 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_ADDED
)
2081 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2084 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
2085 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2088 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
2089 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
2091 *pResult
= CDRF_SKIPDEFAULT
;
2097 *pResult
= CDRF_DODEFAULT
;
2102 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2105 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
2106 // Take the default processing unless we set this to something else below.
2107 *pResult
= CDRF_DODEFAULT
;
2109 // if (m_bNoDispUpdates)
2112 // First thing - check the draw stage. If it's the control's prepaint
2113 // stage, then tell Windows we want messages for every item.
2115 if ( CDDS_PREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
2117 *pResult
= CDRF_NOTIFYITEMDRAW
;
2119 else if ( CDDS_ITEMPREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
2121 // This is the prepaint stage for an item. Here's where we set the
2122 // item's text color. Our return value will tell Windows to draw the
2123 // item itself, but it will use the new color we set here.
2125 // Tell Windows to paint the control itself.
2126 *pResult
= CDRF_DODEFAULT
;
2128 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
2129 bool bGrayed
= false;
2131 if ((m_cHidePaths
.GetState() & 0x0003)==BST_INDETERMINATE
)
2133 if ((m_currentChangedArray
)&&((m_currentChangedArray
->GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)))
2135 //if ((*m_currentChangedArray)[(pLVCD->nmcd.dwItemSpec)]sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
2137 crText
= GetSysColor(COLOR_GRAYTEXT
);
2141 else if (m_currentChangedPathList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
2143 //if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
2145 crText
= GetSysColor(COLOR_GRAYTEXT
);
2152 if ((!bGrayed
)&&(m_currentChangedArray
)&&(m_currentChangedArray
->GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
2154 DWORD action
= ((*m_currentChangedArray
)[pLVCD
->nmcd
.dwItemSpec
]).m_Action
;
2155 if (action
== CTGitPath::LOGACTIONS_MODIFIED
)
2156 crText
= m_Colors
.GetColor(CColors::Modified
);
2157 if (action
== CTGitPath::LOGACTIONS_REPLACED
)
2158 crText
= m_Colors
.GetColor(CColors::Deleted
);
2159 if (action
== CTGitPath::LOGACTIONS_ADDED
)
2160 crText
= m_Colors
.GetColor(CColors::Added
);
2161 if (action
== CTGitPath::LOGACTIONS_DELETED
)
2162 crText
= m_Colors
.GetColor(CColors::Deleted
);
2165 // Store the color back in the NMLVCUSTOMDRAW struct.
2166 pLVCD
->clrText
= crText
;
2170 void CLogDlg::DoSizeV1(int delta
)
2173 RemoveAnchor(IDC_LOGLIST
);
2174 RemoveAnchor(IDC_SPLITTERTOP
);
2175 RemoveAnchor(IDC_MSGVIEW
);
2176 RemoveAnchor(IDC_SPLITTERBOTTOM
);
2177 RemoveAnchor(IDC_LOGMSG
);
2178 CSplitterControl::ChangeHeight(&m_LogList
, delta
, CW_TOPALIGN
);
2179 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), -delta
, CW_BOTTOMALIGN
);
2180 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
2181 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
2182 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
2183 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2184 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2188 m_LogList
.Invalidate();
2189 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
2193 void CLogDlg::DoSizeV2(int delta
)
2196 RemoveAnchor(IDC_LOGLIST
);
2197 RemoveAnchor(IDC_SPLITTERTOP
);
2198 RemoveAnchor(IDC_MSGVIEW
);
2199 RemoveAnchor(IDC_SPLITTERBOTTOM
);
2200 RemoveAnchor(IDC_LOGMSG
);
2201 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), delta
, CW_TOPALIGN
);
2202 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl
, -delta
, CW_BOTTOMALIGN
);
2203 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
2204 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
2205 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
2206 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2207 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
2211 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
2212 m_ChangedFileListCtrl
.Invalidate();
2216 void CLogDlg::AdjustMinSize()
2218 // adjust the minimum size of the dialog to prevent the resizing from
2219 // moving the list control too far down.
2220 CRect rcChgListView
;
2221 m_ChangedFileListCtrl
.GetClientRect(rcChgListView
);
2223 m_LogList
.GetClientRect(rcLogList
);
2225 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(),
2226 m_DlgOrigRect
.Height()-m_ChgOrigRect
.Height()-m_LogListOrigRect
.Height()-m_MsgViewOrigRect
.Height()
2227 +rcChgListView
.Height()+rcLogList
.Height()+60));
2230 LRESULT
CLogDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
2234 if (wParam
== IDC_SPLITTERTOP
)
2236 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
2237 DoSizeV1(pHdr
->delta
);
2239 else if (wParam
== IDC_SPLITTERBOTTOM
)
2241 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
2242 DoSizeV2(pHdr
->delta
);
2247 return CResizableDialog::DefWindowProc(message
, wParam
, lParam
);
2250 void CLogDlg::SetSplitterRange()
2252 if ((m_LogList
)&&(m_ChangedFileListCtrl
))
2255 m_LogList
.GetWindowRect(rcTop
);
2256 ScreenToClient(rcTop
);
2258 GetDlgItem(IDC_MSGVIEW
)->GetWindowRect(rcMiddle
);
2259 ScreenToClient(rcMiddle
);
2260 m_wndSplitter1
.SetRange(rcTop
.top
+30, rcMiddle
.bottom
-20);
2262 m_ChangedFileListCtrl
.GetWindowRect(rcBottom
);
2263 ScreenToClient(rcBottom
);
2264 m_wndSplitter2
.SetRange(rcMiddle
.top
+30, rcBottom
.bottom
-20);
2268 LRESULT
CLogDlg::OnClickedInfoIcon(WPARAM
/*wParam*/, LPARAM lParam
)
2270 RECT
* rect
= (LPRECT
)lParam
;
2273 point
= CPoint(rect
->left
, rect
->bottom
);
2274 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
2276 if (popup
.CreatePopupMenu())
2278 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2279 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL
), LOGFILTER_ALL
, temp
);
2281 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2283 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2284 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES
), LOGFILTER_MESSAGES
, temp
);
2285 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2286 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS
), LOGFILTER_PATHS
, temp
);
2287 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2288 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS
), LOGFILTER_AUTHORS
, temp
);
2289 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2290 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS
), LOGFILTER_REVS
, temp
);
2291 temp
.LoadString(IDS_LOG_FILTER_BUGIDS
);
2292 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID
), LOGFILTER_BUGID
, temp
);
2294 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2296 temp
.LoadString(IDS_LOG_FILTER_REGEX
);
2297 popup
.AppendMenu(MF_STRING
| MF_ENABLED
| (m_bFilterWithRegex
? MF_CHECKED
: MF_UNCHECKED
), LOGFILTER_REGEX
, temp
);
2300 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2304 if (selection
== LOGFILTER_REGEX
)
2306 m_bFilterWithRegex
= !m_bFilterWithRegex
;
2307 CRegDWORD b
= CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
2308 b
= m_bFilterWithRegex
;
2309 CheckRegexpTooltip();
2313 m_LogList
.m_nSelectedFilter
= selection
;
2316 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2322 LRESULT
CLogDlg::OnClickedCancelFilter(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2325 KillTimer(LOGFILTER_TIMER
);
2327 m_LogList
.m_sFilterText
.Empty();
2329 theApp
.DoWaitCursor(1);
2330 CStoreSelection
storeselection(this);
2331 FillLogMessageCtrl(false);
2333 m_LogList
.RemoveFilter();
2336 m_LogList
.GetTimeRange(begin
,end
);
2337 m_DateFrom
.SetTime(&begin
);
2338 m_DateTo
.SetTime(&end
);
2340 theApp
.DoWaitCursor(-1);
2341 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2342 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2343 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2344 UpdateLogInfoLabel();
2350 void CLogDlg::SetFilterCueText()
2353 switch (m_LogList
.m_nSelectedFilter
)
2356 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2358 case LOGFILTER_MESSAGES
:
2359 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2361 case LOGFILTER_PATHS
:
2362 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2364 case LOGFILTER_AUTHORS
:
2365 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2367 case LOGFILTER_REVS
:
2368 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2371 // to make the cue banner text appear more to the right of the edit control
2372 temp
= _T(" ")+temp
;
2373 m_cFilter
.SetCueBanner(temp
);
2376 bool CLogDlg::Validate(LPCTSTR string
)
2378 if (!m_bFilterWithRegex
)
2381 return m_LogList
.ValidateRegexp(string
, pat
, false);
2385 void CLogDlg::OnTimer(UINT_PTR nIDEvent
)
2387 if (nIDEvent
== LOGFILTER_TIMER
)
2389 if (this->IsThreadRunning())
2391 // thread still running! So just restart the timer.
2392 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2395 CWnd
* focusWnd
= GetFocus();
2396 bool bSetFocusToFilterControl
= ((focusWnd
!= GetDlgItem(IDC_DATEFROM
))&&(focusWnd
!= GetDlgItem(IDC_DATETO
))
2397 && (focusWnd
!= GetDlgItem(IDC_LOGLIST
)));
2398 if (m_LogList
.m_sFilterText
.IsEmpty())
2400 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2401 // do not return here!
2402 // we also need to run the filter if the filter text is empty:
2403 // 1. to clear an existing filter
2404 // 2. to rebuild the m_arShownList after sorting
2406 theApp
.DoWaitCursor(1);
2407 CStoreSelection
storeselection(this);
2408 KillTimer(LOGFILTER_TIMER
);
2409 FillLogMessageCtrl(false);
2411 // now start filter the log list
2412 m_LogList
.StartFilter();
2414 if ( m_LogList
.GetItemCount()==1 )
2416 m_LogList
.SetSelectionMark(0);
2417 m_LogList
.SetItemState(0, LVIS_SELECTED
, LVIS_SELECTED
);
2419 theApp
.DoWaitCursor(-1);
2420 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2421 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2422 if (bSetFocusToFilterControl
)
2423 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2424 UpdateLogInfoLabel();
2425 } // if (nIDEvent == LOGFILTER_TIMER)
2426 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2427 __super::OnTimer(nIDEvent
);
2430 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2433 m_DateTo
.GetTime(_time
);
2436 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 23, 59, 59);
2437 if (time
.GetTime() != m_LogList
.m_To
.GetTime())
2439 m_LogList
.m_To
= (DWORD
)time
.GetTime();
2440 SetTimer(LOGFILTER_TIMER
, 10, NULL
);
2443 catch (CAtlException
)
2450 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2453 m_DateFrom
.GetTime(_time
);
2456 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 0, 0, 0);
2457 if (time
.GetTime() != m_LogList
.m_From
.GetTime())
2459 m_LogList
.m_From
= (DWORD
)time
.GetTime();
2460 SetTimer(LOGFILTER_TIMER
, 10, NULL
);
2463 catch (CAtlException
)
2472 CTGitPathList
CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths
/* = false */, bool bUseFilter
/* = true */)
2474 CTGitPathList pathList
;
2477 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2479 m_sRepositoryRoot
= GetRepositoryRoot(m_path
);
2481 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2484 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2489 int nextpos
= m_LogList
.GetNextSelectedItem(pos
);
2490 if (nextpos
>= m_arShownList
.GetCount())
2492 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(nextpos
));
2493 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
2494 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
2496 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
2500 if (!bRelativePaths
)
2501 path
.SetFromGit(m_sRepositoryRoot
);
2502 path
.AppendPathString(cpath
->sPath
);
2504 ((m_cHidePaths
.GetState() & 0x0003)!=BST_CHECKED
)||
2505 (cpath
->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0))
2506 pathList
.AddPath(path
);
2511 pathList
.RemoveDuplicates();
2516 void CLogDlg::SortByColumn(int nSortColumn
, bool bAscending
)
2524 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscRevSort());
2526 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescRevSort());
2532 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscActionSort());
2534 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescActionSort());
2540 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscAuthorSort());
2542 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescAuthorSort());
2548 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscDateSort());
2550 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescDateSort());
2553 case 4: // Message or bug id
2554 if (m_bShowBugtraqColumn
)
2557 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscBugIDSort());
2559 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescBugIDSort());
2562 // fall through here
2566 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscMessageSort());
2568 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescMessageSort());
2578 void CLogDlg::OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2580 if (this->IsThreadRunning())
2581 return; //no sorting while the arrays are filled
2582 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2583 const int nColumn
= pNMLV
->iSubItem
;
2584 m_bAscending
= nColumn
== m_nSortColumn
? !m_bAscending
: TRUE
;
2585 m_nSortColumn
= nColumn
;
2586 SortByColumn(m_nSortColumn
, m_bAscending
);
2587 SetSortArrow(&m_LogList
, m_nSortColumn
, !!m_bAscending
);
2588 SortShownListArray();
2589 m_LogList
.Invalidate();
2590 UpdateLogInfoLabel();
2591 // the "next 100" button only makes sense if the log messages
2592 // are sorted by revision in descending order
2593 if ((m_nSortColumn
)||(m_bAscending
))
2595 DialogEnableWindow(IDC_NEXTHUNDRED
, false);
2599 DialogEnableWindow(IDC_NEXTHUNDRED
, true);
2604 void CLogDlg::SortShownListArray()
2606 // make sure the shown list still matches the filter after sorting.
2607 OnTimer(LOGFILTER_TIMER
);
2608 // clear the selection states
2609 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2612 m_LogList
.SetItemState(m_LogList
.GetNextSelectedItem(pos
), 0, LVIS_SELECTED
);
2614 m_LogList
.SetSelectionMark(-1);
2617 void CLogDlg::SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
)
2619 if (control
== NULL
)
2621 // set the sort arrow
2622 CHeaderCtrl
* pHeader
= control
->GetHeaderCtrl();
2623 HDITEM HeaderItem
= {0};
2624 HeaderItem
.mask
= HDI_FORMAT
;
2625 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
2627 pHeader
->GetItem(i
, &HeaderItem
);
2628 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
2629 pHeader
->SetItem(i
, &HeaderItem
);
2633 pHeader
->GetItem(nColumn
, &HeaderItem
);
2634 HeaderItem
.fmt
|= (bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
2635 pHeader
->SetItem(nColumn
, &HeaderItem
);
2638 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2641 if (this->IsThreadRunning())
2642 return; //no sorting while the arrays are filled
2643 if (m_currentChangedArray
== NULL
)
2645 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2646 const int nColumn
= pNMLV
->iSubItem
;
2647 m_bAscendingPathList
= nColumn
== m_nSortColumnPathList
? !m_bAscendingPathList
: TRUE
;
2648 m_nSortColumnPathList
= nColumn
;
2649 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
2651 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
2652 m_ChangedFileListCtrl
.Invalidate();
2657 int CLogDlg::m_nSortColumnPathList
= 0;
2658 bool CLogDlg::m_bAscendingPathList
= false;
2660 int CLogDlg::SortCompare(const void * pElem1
, const void * pElem2
)
2663 LogChangedPath
* cpath1
= *((LogChangedPath
**)pElem1
);
2664 LogChangedPath
* cpath2
= *((LogChangedPath
**)pElem2
);
2666 if (m_bAscendingPathList
)
2667 std::swap (cpath1
, cpath2
);
2670 switch (m_nSortColumnPathList
)
2673 cmp
= cpath2
->GetAction().Compare(cpath1
->GetAction());
2678 cmp
= cpath2
->sPath
.CompareNoCase(cpath1
->sPath
);
2682 case 2: // copy from path
2683 cmp
= cpath2
->sCopyFromPath
.Compare(cpath1
->sCopyFromPath
);
2687 case 3: // copy from revision
2688 return cpath2
->lCopyFromRev
> cpath1
->lCopyFromRev
;
2695 void CLogDlg::ResizeAllListCtrlCols()
2698 const int nMinimumWidth
= ICONITEMBORDER
+16*4;
2699 int maxcol
= ((CHeaderCtrl
*)(m_LogList
.GetDlgItem(0)))->GetItemCount()-1;
2700 int nItemCount
= m_LogList
.GetItemCount();
2701 TCHAR textbuf
[MAX_PATH
];
2702 CHeaderCtrl
* pHdrCtrl
= (CHeaderCtrl
*)(m_LogList
.GetDlgItem(0));
2705 for (int col
= 0; col
<= maxcol
; col
++)
2708 hdi
.mask
= HDI_TEXT
;
2709 hdi
.pszText
= textbuf
;
2710 hdi
.cchTextMax
= sizeof(textbuf
);
2711 pHdrCtrl
->GetItem(col
, &hdi
);
2712 int cx
= m_LogList
.GetStringWidth(hdi
.pszText
)+20; // 20 pixels for col separator and margin
2713 for (int index
= 0; index
<nItemCount
; ++index
)
2715 // get the width of the string and add 14 pixels for the column separator and margins
2716 int linewidth
= m_LogList
.GetStringWidth(m_LogList
.GetItemText(index
, col
)) + 14;
2717 if (index
< m_arShownList
.GetCount())
2719 GitRev
* pCurLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(index
));
2720 if ((pCurLogEntry
)&&(pCurLogEntry
->m_CommitHash
== m_wcRev
.m_CommitHash
))
2722 // set the bold font and ask for the string width again
2723 m_LogList
.SendMessage(WM_SETFONT
, (WPARAM
)m_boldFont
, NULL
);
2724 linewidth
= m_LogList
.GetStringWidth(m_LogList
.GetItemText(index
, col
)) + 14;
2725 // restore the system font
2726 m_LogList
.SendMessage(WM_SETFONT
, NULL
, NULL
);
2731 // add the image size
2732 CImageList
* pImgList
= m_LogList
.GetImageList(LVSIL_SMALL
);
2733 if ((pImgList
)&&(pImgList
->GetImageCount()))
2736 pImgList
->GetImageInfo(0, &imginfo
);
2737 linewidth
+= (imginfo
.rcImage
.right
- imginfo
.rcImage
.left
);
2738 linewidth
+= 3; // 3 pixels between icon and text
2744 // Adjust columns "Actions" containing icons
2745 if (col
== this->LOGLIST_ACTION
)
2747 if (cx
< nMinimumWidth
)
2753 if (col
== this->LOGLIST_MESSAGE
)
2755 if (cx
> LOGLIST_MESSAGE_MAX
)
2757 cx
= LOGLIST_MESSAGE_MAX
;
2761 // keep the bug id column small
2762 if ((col
== 4)&&(m_bShowBugtraqColumn
))
2764 if (cx
> (int)(DWORD
)m_regMaxBugIDColWidth
)
2766 cx
= (int)(DWORD
)m_regMaxBugIDColWidth
;
2770 m_LogList
.SetColumnWidth(col
, cx
);
2777 void CLogDlg::OnBnClickedHidepaths()
2779 FillLogMessageCtrl();
2780 m_ChangedFileListCtrl
.Invalidate();
2785 void CLogDlg::OnBnClickedCheckStoponcopy()
2788 if (!GetDlgItem(IDC_GETALL
)->IsWindowEnabled())
2791 // ignore old fetch limits when switching
2792 // between copy-following and stop-on-copy
2793 // (otherwise stop-on-copy will limit what
2794 // we see immediately after switching to
2799 // now, restart the query
2804 void CLogDlg::OnBnClickedIncludemerge()
2814 void CLogDlg::UpdateLogInfoLabel()
2820 int count
=m_LogList
.m_arShownList
.GetCount();
2823 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(0)))->m_CommitHash
;
2824 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
2825 rev2
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(count
-1)))->m_CommitHash
;
2826 selectedrevs
= m_LogList
.GetSelectedCount();
2829 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
);
2836 void CLogDlg::ShowContextMenuForChangedpaths(CWnd
* /*pWnd*/, CPoint point
)
2839 int selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
2840 if ((point
.x
== -1) && (point
.y
== -1))
2843 m_ChangedFileListCtrl
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
2844 m_ChangedFileListCtrl
.ClientToScreen(&rect
);
2845 point
= rect
.CenterPoint();
2849 int s
= m_LogList
.GetSelectionMark();
2852 std::vector
<CString
> changedpaths
;
2853 std::vector
<LogChangedPath
*> changedlogpaths
;
2854 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2856 return; // nothing is selected, get out of here
2858 bool bOneRev
= true;
2859 int sel
=m_LogList
.GetNextSelectedItem(pos
);
2860 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(sel
));
2861 GitRev
* rev1
= pLogEntry
;
2862 GitRev
* rev2
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(sel
+1));
2864 bool bOneRev
= true;
2869 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
2872 rev1
= max(rev1
,(git_revnum_t
)pLogEntry
->Rev
);
2873 rev2
= min(rev2
,(git_revnum_t
)pLogEntry
->Rev
);
2879 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2882 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2883 changedpaths
.push_back(m_currentChangedPathList
[nItem
].GetGitPathString());
2888 // only one revision is selected in the log dialog top pane
2889 // but multiple items could be selected in the changed items list
2892 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2895 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2896 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(nItem
);
2898 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2900 if ((changedlogpath
)&&(!changedlogpath
->sCopyFromPath
.IsEmpty()))
2901 rev2
= changedlogpath
->lCopyFromRev
;
2904 // if the path was modified but the parent path was 'added with history'
2905 // then we have to use the copy from revision of the parent path
2906 CTGitPath cpath
= CTGitPath(changedlogpath
->sPath
);
2907 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
2909 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->GetAt(flist
)->sPath
);
2910 if (p
.IsAncestorOf(cpath
))
2912 if (!pLogEntry
->pArChangedPaths
->GetAt(flist
)->sCopyFromPath
.IsEmpty())
2913 rev2
= pLogEntry
->pArChangedPaths
->GetAt(flist
)->lCopyFromRev
;
2918 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
2920 // some items are hidden! So find out which item the user really clicked on
2921 INT_PTR selRealIndex
= -1;
2922 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
2924 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
2926 if (selRealIndex
== nItem
)
2928 selIndex
= hiddenindex
;
2929 changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
2936 changedpaths
.push_back(changedlogpath
->sPath
);
2937 changedlogpaths
.push_back(changedlogpath
);
2942 //entry is selected, now show the popup menu
2944 if (popup
.CreatePopupMenu())
2946 bool bEntryAdded
= false;
2947 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2949 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
2951 popup
.AppendMenuIcon(CGitLogList::ID_DIFF
, IDS_LOG_POPUP_DIFF
, IDI_DIFF
);
2952 popup
.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF
, IDS_LOG_POPUP_BLAMEDIFF
, IDI_BLAME
);
2953 popup
.SetDefaultItem(CGitLogList::ID_DIFF
, FALSE
);
2954 popup
.AppendMenuIcon(CGitLogList::ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
2957 // if (rev2 == rev1-1)
2960 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2961 popup
.AppendMenuIcon(CGitLogList::ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
2962 popup
.AppendMenuIcon(CGitLogList::ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
2963 popup
.AppendMenuIcon(CGitLogList::ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
2964 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2966 popup
.AppendMenuIcon(CGitLogList::ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
2967 popup
.AppendMenuIcon(CGitLogList::ID_POPPROPS
, IDS_REPOBROWSE_SHOWPROP
, IDI_PROPERTIES
); // "Show Properties"
2968 popup
.AppendMenuIcon(CGitLogList::ID_LOG
, IDS_MENULOG
, IDI_LOG
); // "Show Log"
2969 popup
.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS
, IDS_LOG_POPUP_GETMERGELOGS
, IDI_LOG
); // "Show merge log"
2970 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
, IDI_SAVEAS
);
2972 if (!m_ProjectProperties
.sWebViewerPathRev
.IsEmpty())
2974 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2975 popup
.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV
, IDS_LOG_POPUP_VIEWPATHREV
);
2977 if (popup
.GetDefaultItem(0,FALSE
)==-1)
2978 popup
.SetDefaultItem(CGitLogList::ID_OPEN
, FALSE
);
2981 else if (changedlogpaths
.size())
2983 // more than one entry is selected
2984 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
);
2990 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2991 bool bOpenWith
= false;
2992 bool bMergeLog
= false;
2993 m_bCancelled
= false;
2997 case CGitLogList::ID_DIFF
:
2999 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
3005 DoDiffFromLog(selIndex
, rev1
, rev2
, true, false);
3010 DoDiffFromLog(selIndex
, rev1
, rev2
, false, true);
3015 SetPromptApp(&theApp
);
3016 theApp
.DoWaitCursor(1);
3018 if (Git::PathIsURL(m_path
))
3020 sUrl
= m_path
.GetGitPathString();
3024 sUrl
= GetURLFromPath(m_path
);
3027 theApp
.DoWaitCursor(-1);
3029 temp
.Format(IDS_ERR_NOURLOFFILE
, m_path
.GetWinPath());
3030 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3032 theApp
.DoWaitCursor(-1);
3036 // find the working copy path of the selected item from the URL
3037 m_bCancelled
= false;
3038 CString sUrlRoot
= GetRepositoryRoot(CTGitPath(sUrl
));
3040 CString fileURL
= changedpaths
[0];
3041 fileURL
= sUrlRoot
+ fileURL
.Trim();
3042 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
3043 // sUrl = http://mydomain.com/repos/trunk/folder
3044 CString sUnescapedUrl
= CPathUtils::PathUnescape(sUrl
);
3045 // find out until which char the urls are identical
3047 while ((i
<fileURL
.GetLength())&&(i
<sUnescapedUrl
.GetLength())&&(fileURL
[i
]==sUnescapedUrl
[i
]))
3049 int leftcount
= m_path
.GetWinPathString().GetLength()-(sUnescapedUrl
.GetLength()-i
);
3050 CString wcPath
= m_path
.GetWinPathString().Left(leftcount
);
3051 wcPath
+= fileURL
.Mid(i
);
3052 wcPath
.Replace('/', '\\');
3053 CGitProgressDlg dlg
;
3054 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
3056 // a deleted path! Since the path isn't there anymore, merge
3057 // won't work. So just do a copy url->wc
3058 dlg
.SetCommand(CGitProgressDlg::GitProgress_Copy
);
3059 dlg
.SetPathList(CTGitPathList(CTGitPath(fileURL
)));
3061 dlg
.SetRevision(rev2
);
3065 if (!PathFileExists(wcPath
))
3067 // seems the path got renamed
3068 // tell the user how to work around this.
3069 CMessageBox::Show(this->m_hWnd
, IDS_LOG_REVERTREV_ERROR
, IDS_APPNAME
, MB_ICONERROR
);
3071 theApp
.DoWaitCursor(-1);
3074 dlg
.SetCommand(CGitProgressDlg::GitProgress_Merge
);
3075 dlg
.SetPathList(CTGitPathList(CTGitPath(wcPath
)));
3076 dlg
.SetUrl(fileURL
);
3077 dlg
.SetSecondUrl(fileURL
);
3078 GitRevRangeArray revarray
;
3079 revarray
.AddRevRange(rev1
, rev2
);
3080 dlg
.SetRevisionRanges(revarray
);
3083 msg
.Format(IDS_LOG_REVERT_CONFIRM
, (LPCTSTR
)wcPath
);
3084 if (CMessageBox::Show(this->m_hWnd
, msg
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
3088 theApp
.DoWaitCursor(-1);
3093 DialogEnableWindow(IDOK
, FALSE
);
3094 SetPromptApp(&theApp
);
3095 theApp
.DoWaitCursor(1);
3097 if (Git::PathIsURL(m_path
))
3099 filepath
= m_path
.GetGitPathString();
3103 filepath
= GetURLFromPath(m_path
);
3104 if (filepath
.IsEmpty())
3106 theApp
.DoWaitCursor(-1);
3108 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3109 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3110 TRACE(_T("could not retrieve the URL of the file!\n"));
3115 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
3116 filepath
+= changedpaths
[0];
3119 dlg
.m_Path
= CTGitPath(filepath
);
3122 theApp
.DoWaitCursor(-1);
3127 DialogEnableWindow(IDOK
, FALSE
);
3128 SetPromptApp(&theApp
);
3129 theApp
.DoWaitCursor(1);
3131 if (Git::PathIsURL(m_path
))
3133 filepath
= m_path
.GetGitPathString();
3137 filepath
= GetURLFromPath(m_path
);
3138 if (filepath
.IsEmpty())
3140 theApp
.DoWaitCursor(-1);
3142 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3143 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3144 TRACE(_T("could not retrieve the URL of the file!\n"));
3149 m_bCancelled
= false;
3150 CString sRoot
= GetRepositoryRoot(CTGitPath(filepath
));
3151 // if more than one entry is selected, we save them
3152 // one by one into a folder the user has selected
3153 bool bTargetSelected
= false;
3154 CTGitPath TargetPath
;
3155 if (m_ChangedFileListCtrl
.GetSelectedCount() > 1)
3157 CBrowseFolder browseFolder
;
3158 browseFolder
.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT
)));
3159 browseFolder
.m_style
= BIF_EDITBOX
| BIF_NEWDIALOGSTYLE
| BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
;
3160 CString strSaveAsDirectory
;
3161 if (browseFolder
.Show(GetSafeHwnd(), strSaveAsDirectory
) == CBrowseFolder::OK
)
3163 TargetPath
= CTGitPath(strSaveAsDirectory
);
3164 bTargetSelected
= true;
3169 // Display the Open dialog box.
3170 CString revFilename
;
3172 temp
= CPathUtils::GetFileNameFromPath(changedpaths
[0]);
3173 int rfind
= temp
.ReverseFind('.');
3175 revFilename
.Format(_T("%s-%ld%s"), (LPCTSTR
)temp
.Left(rfind
), rev1
, (LPCTSTR
)temp
.Mid(rfind
));
3177 revFilename
.Format(_T("%s-%ld"), (LPCTSTR
)temp
, rev1
);
3178 bTargetSelected
= CAppUtils::FileOpenSave(revFilename
, NULL
, IDS_LOG_POPUP_SAVE
, IDS_COMMONFILEFILTER
, false, m_hWnd
);
3179 TargetPath
.SetFromWin(revFilename
);
3181 if (bTargetSelected
)
3183 CProgressDlg progDlg
;
3184 progDlg
.SetTitle(IDS_APPNAME
);
3185 progDlg
.SetAnimation(IDR_DOWNLOAD
);
3186 for (std::vector
<LogChangedPath
*>::iterator it
= changedlogpaths
.begin(); it
!= changedlogpaths
.end(); ++it
)
3188 GitRev getrev
= ((*it
)->action
== LOGACTIONS_DELETED
) ? rev2
: rev1
;
3191 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)getrev
.ToString());
3192 progDlg
.SetLine(1, sInfoLine
, true);
3193 SetAndClearProgressInfo(&progDlg
);
3194 progDlg
.ShowModeless(m_hWnd
);
3196 CTGitPath tempfile
= TargetPath
;
3197 if (changedpaths
.size() > 1)
3199 // if multiple items are selected, then the TargetPath
3200 // points to a folder and we have to append the filename
3201 // to save to to that folder.
3202 CString sName
= (*it
)->sPath
;
3203 int slashpos
= sName
.ReverseFind('/');
3205 sName
= sName
.Mid(slashpos
);
3206 tempfile
.AppendPathString(sName
);
3207 // one problem here:
3208 // a user could have selected multiple items which
3209 // have the same filename but reside in different
3210 // directories, e.g.
3213 // in that case, the second 'file1' will overwrite
3214 // the already saved 'file1'.
3216 // we could maybe find the common root of all selected
3217 // items and then create sub folders to save those files
3219 // But I think we should just leave it that way: to check
3220 // out multiple items at once, the better way is still to
3221 // use the export command from the top pane of the log dialog.
3223 filepath
= sRoot
+ (*it
)->sPath
;
3224 if (!Cat(CTGitPath(filepath
), getrev
, getrev
, tempfile
))
3227 SetAndClearProgressInfo((HWND
)NULL
);
3228 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3230 theApp
.DoWaitCursor(-1);
3235 SetAndClearProgressInfo((HWND
)NULL
);
3238 theApp
.DoWaitCursor(-1);
3245 GitRev getrev
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
)->action
== LOGACTIONS_DELETED
? rev2
: rev1
;
3246 Open(bOpenWith
,changedpaths
[0],getrev
);
3252 if (Git::PathIsURL(m_path
))
3254 filepath
= m_path
.GetGitPathString();
3258 filepath
= GetURLFromPath(m_path
);
3259 if (filepath
.IsEmpty())
3261 theApp
.DoWaitCursor(-1);
3263 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3264 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3265 TRACE(_T("could not retrieve the URL of the file!\n"));
3270 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
3271 filepath
+= changedpaths
[0];
3274 if (dlg
.DoModal() == IDOK
)
3279 tempfile
= blame
.BlameToTempFile(CTGitPath(filepath
), dlg
.StartRev
, dlg
.EndRev
, dlg
.EndRev
, logfile
, _T(""), dlg
.m_bIncludeMerge
, TRUE
, TRUE
);
3280 if (!tempfile
.IsEmpty())
3282 if (dlg
.m_bTextView
)
3284 //open the default text editor for the result file
3285 CAppUtils::StartTextViewer(tempfile
);
3289 CString sParams
= _T("/path:\"") + filepath
+ _T("\" ");
3290 if(!CAppUtils::LaunchTortoiseBlame(tempfile
, logfile
, CPathUtils::GetFileNameFromPath(filepath
),sParams
))
3298 CMessageBox::Show(this->m_hWnd
, blame
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3303 case ID_GETMERGELOGS
:
3308 DialogEnableWindow(IDOK
, FALSE
);
3309 SetPromptApp(&theApp
);
3310 theApp
.DoWaitCursor(1);
3312 if (Git::PathIsURL(m_path
))
3314 filepath
= m_path
.GetGitPathString();
3318 filepath
= GetURLFromPath(m_path
);
3319 if (filepath
.IsEmpty())
3321 theApp
.DoWaitCursor(-1);
3323 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3324 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3325 TRACE(_T("could not retrieve the URL of the file!\n"));
3330 m_bCancelled
= false;
3331 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
3332 filepath
+= changedpaths
[0];
3333 git_revnum_t logrev
= rev1
;
3334 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
3336 // if the item got deleted in this revision,
3337 // fetch the log from the previous revision where it
3342 sCmd
.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR
)filepath
, logrev
);
3344 sCmd
+= _T(" /merge");
3345 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
3347 theApp
.DoWaitCursor(-1);
3350 case ID_VIEWPATHREV
:
3352 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetSelectionMark()));
3353 GitRev rev
= pLogEntry
->Rev
;
3354 CString relurl
= changedpaths
[0];
3355 CString url
= m_ProjectProperties
.sWebViewerPathRev
;
3356 url
.Replace(_T("%REVISION%"), rev
.ToString());
3357 url
.Replace(_T("%PATH%"), relurl
);
3358 relurl
= relurl
.Mid(relurl
.Find('/'));
3359 url
.Replace(_T("%PATH1%"), relurl
);
3361 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
3369 } // if (popup.CreatePopupMenu())
3373 void CLogDlg::OnDtnDropdownDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3375 // the date control should not show the "today" button
3376 CMonthCalCtrl
* pCtrl
= m_DateFrom
.GetMonthCalCtrl();
3378 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3382 void CLogDlg::OnDtnDropdownDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3384 // the date control should not show the "today" button
3385 CMonthCalCtrl
* pCtrl
= m_DateTo
.GetMonthCalCtrl();
3387 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3391 void CLogDlg::OnSize(UINT nType
, int cx
, int cy
)
3393 __super::OnSize(nType
, cx
, cy
);
3398 void CLogDlg::OnRefresh()
3400 if (GetDlgItem(IDC_GETALL
)->IsWindowEnabled())
3407 void CLogDlg::OnFind()
3411 m_pFindDialog
= new CFindReplaceDialog();
3412 m_pFindDialog
->Create(TRUE
, NULL
, NULL
, FR_HIDEUPDOWN
| FR_HIDEWHOLEWORD
, this);
3416 void CLogDlg::OnFocusFilter()
3418 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3421 void CLogDlg::OnEditCopy()
3423 if (GetFocus() == &m_ChangedFileListCtrl
)
3424 CopyChangedSelectionToClipBoard();
3426 m_LogList
.CopySelectionToClipBoard();
3429 CString
CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString
& url
)
3431 // is the URL a relative one?
3432 if (url
.Left(2).Compare(_T("^/")) == 0)
3434 // URL is relative to the repository root
3435 CString url1
= m_sRepositoryRoot
+ url
.Mid(1);
3436 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3437 DWORD len
= url
.GetLength();
3438 if (UrlCanonicalize((LPCTSTR
)url1
, buf
, &len
, 0) == S_OK
)
3439 return CString(buf
, len
);
3442 else if (url
[0] == '/')
3444 // URL is relative to the server's hostname
3446 // find the server's hostname
3447 int schemepos
= m_sRepositoryRoot
.Find(_T("//"));
3450 sHost
= m_sRepositoryRoot
.Left(m_sRepositoryRoot
.Find('/', schemepos
+3));
3451 CString url1
= sHost
+ url
;
3452 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3453 DWORD len
= url
.GetLength();
3454 if (UrlCanonicalize((LPCTSTR
)url
, buf
, &len
, 0) == S_OK
)
3455 return CString(buf
, len
);
3463 void CLogDlg::OnEnChangeSearchedit()
3466 if (m_LogList
.m_sFilterText
.IsEmpty())
3468 CStoreSelection
storeselection(this);
3469 // clear the filter, i.e. make all entries appear
3470 theApp
.DoWaitCursor(1);
3471 KillTimer(LOGFILTER_TIMER
);
3472 FillLogMessageCtrl(false);
3473 m_LogList
.StartFilter();
3475 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3476 m_arShownList
.RemoveAll();
3477 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3479 if (IsEntryInDateRange(i
))
3480 m_arShownList
.Add(m_logEntries
[i
]);
3482 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3483 m_LogList
.DeleteAllItems();
3484 m_LogList
.SetItemCountEx(ShownCountWithStopped());
3485 m_LogList
.RedrawItems(0, ShownCountWithStopped());
3486 m_LogList
.SetRedraw(false);
3487 ResizeAllListCtrlCols();
3488 m_LogList
.SetRedraw(true);
3490 theApp
.DoWaitCursor(-1);
3491 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
3492 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
3493 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3494 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
3497 if (Validate(m_LogList
.m_sFilterText
))
3498 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
3500 KillTimer(LOGFILTER_TIMER
);