1 // TortoiseGit - a Windows shell extension for easy version control
\r
2 // Copyright (C) 2003-2008 - TortoiseGit
\r
3 // This program is free software; you can redistribute it and/or
\r
4 // modify it under the terms of the GNU General Public License
\r
5 // as published by the Free Software Foundation; either version 2
\r
6 // of the License, or (at your option) any later version.
\r
7 // This program is distributed in the hope that it will be useful,
\r
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
10 // GNU General Public License for more details.
\r
12 // You should have received a copy of the GNU General Public License
\r
13 // along with this program; if not, write to the Free Software Foundation,
\r
14 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
17 #include "TortoiseProc.h"
\r
19 #include "InputDlg.h"
\r
20 #include "PropDlg.h"
\r
21 #include "SVNProgressDlg.h"
\r
22 #include "ProgressDlg.h"
\r
23 //#include "RepositoryBrowser.h"
\r
24 //#include "CopyDlg.h"
\r
25 #include "StatGraphDlg.h"
\r
27 #include "MessageBox.h"
\r
28 #include "Registry.h"
\r
29 #include "AppUtils.h"
\r
30 #include "PathUtils.h"
\r
31 #include "StringUtils.h"
\r
32 #include "UnicodeUtils.h"
\r
33 #include "TempFile.h"
\r
34 //#include "GitInfo.h"
\r
35 //#include "GitDiff.h"
\r
36 #include "IconMenu.h"
\r
37 //#include "RevisionRangeDlg.h"
\r
38 //#include "BrowseFolder.h"
\r
39 //#include "BlameDlg.h"
\r
40 //#include "Blame.h"
\r
41 //#include "GitHelpers.h"
\r
42 #include "GitStatus.h"
\r
43 //#include "LogDlgHelper.h"
\r
44 //#include "CachedLogInfo.h"
\r
45 //#include "RepositoryInfo.h"
\r
46 //#include "EditPropertiesDlg.h"
\r
47 #include "FileDiffDlg.h"
\r
50 const UINT CLogDlg::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING);
\r
53 IMPLEMENT_DYNAMIC(CLogDlg, CResizableStandAloneDialog)
\r
54 CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)
\r
55 : CResizableStandAloneDialog(CLogDlg::IDD, pParent)
\r
59 , m_currentChangedArray(NULL)
\r
61 , m_bShowedAll(false)
\r
63 , m_regLastStrict(_T("Software\\TortoiseGit\\LastLogStrict"), FALSE)
\r
65 , m_bSelectionMustBeContinuous(false)
\r
66 , m_bShowBugtraqColumn(false)
\r
67 , m_lowestRev(_T(""))
\r
69 , m_sLogInfo(_T(""))
\r
70 , m_pFindDialog(NULL)
\r
71 , m_bCancelled(FALSE)
\r
72 , m_pNotifyWindow(NULL)
\r
74 , m_bAscending(FALSE)
\r
79 , m_bIncludeMerges(FALSE)
\r
83 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
90 m_CurrentFilteredChangedArray.RemoveAll();
\r
94 void CLogDlg::DoDataExchange(CDataExchange* pDX)
\r
96 CResizableStandAloneDialog::DoDataExchange(pDX);
\r
97 DDX_Control(pDX, IDC_LOGLIST, m_LogList);
\r
98 DDX_Control(pDX, IDC_LOGMSG, m_ChangedFileListCtrl);
\r
99 DDX_Control(pDX, IDC_PROGRESS, m_LogProgress);
\r
100 DDX_Control(pDX, IDC_SPLITTERTOP, m_wndSplitter1);
\r
101 DDX_Control(pDX, IDC_SPLITTERBOTTOM, m_wndSplitter2);
\r
102 DDX_Check(pDX, IDC_CHECK_STOPONCOPY, m_bStrict);
\r
103 DDX_Text(pDX, IDC_SEARCHEDIT, m_LogList.m_sFilterText);
\r
104 DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);
\r
105 DDX_Control(pDX, IDC_DATETO, m_DateTo);
\r
106 DDX_Control(pDX, IDC_HIDEPATHS, m_cHidePaths);
\r
107 DDX_Control(pDX, IDC_GETALL, m_btnShow);
\r
108 DDX_Text(pDX, IDC_LOGINFO, m_sLogInfo);
\r
109 DDX_Check(pDX, IDC_INCLUDEMERGE, m_bIncludeMerges);
\r
110 DDX_Control(pDX, IDC_SEARCHEDIT, m_cFilter);
\r
113 BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)
\r
114 ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage)
\r
115 ON_BN_CLICKED(IDC_GETALL, OnBnClickedGetall)
\r
116 //ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)
\r
117 ON_WM_CONTEXTMENU()
\r
119 ON_BN_CLICKED(IDHELP, OnBnClickedHelp)
\r
120 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGLIST, OnLvnItemchangedLoglist)
\r
121 ON_NOTIFY(EN_LINK, IDC_MSGVIEW, OnEnLinkMsgview)
\r
122 ON_BN_CLICKED(IDC_STATBUTTON, OnBnClickedStatbutton)
\r
124 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)
\r
125 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)
\r
127 ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)
\r
129 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)
\r
130 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)
\r
131 ON_BN_CLICKED(IDC_NEXTHUNDRED, OnBnClickedNexthundred)
\r
132 //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
\r
133 //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
\r
134 ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST , OnLvnColumnclick)
\r
135 //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
\r
136 ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)
\r
138 ON_BN_CLICKED(IDC_CHECK_STOPONCOPY, &CLogDlg::OnBnClickedCheckStoponcopy)
\r
139 ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)
\r
140 ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)
\r
142 ON_BN_CLICKED(IDC_INCLUDEMERGE, &CLogDlg::OnBnClickedIncludemerge)
\r
143 ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)
\r
144 ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)
\r
145 ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)
\r
146 ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)
\r
147 ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)
\r
150 void CLogDlg::SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit, BOOL bStrict /* = FALSE */, BOOL bSaveStrict /* = TRUE */)
\r
154 m_startrev = startrev;
\r
155 m_LogRevision = startrev;
\r
157 m_hasWC = !path.IsUrl();
\r
158 m_bStrict = bStrict;
\r
159 m_bSaveStrict = bSaveStrict;
\r
161 if (::IsWindow(m_hWnd))
\r
165 BOOL CLogDlg::OnInitDialog()
\r
167 CResizableStandAloneDialog::OnInitDialog();
\r
169 m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));
\r
171 OSVERSIONINFOEX inf;
\r
172 SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
\r
173 inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
\r
174 GetVersionEx((OSVERSIONINFO *)&inf);
\r
175 WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);
\r
176 m_bVista = (fullver >= 0x0600);
\r
178 // use the state of the "stop on copy/rename" option from the last time
\r
180 m_bStrict = m_regLastStrict;
\r
184 temp.Format(IDS_LOG_SHOWNEXT, m_limit);
\r
186 temp.Format(IDS_LOG_SHOWNEXT, (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100));
\r
188 SetDlgItemText(IDC_NEXTHUNDRED, temp);
\r
190 // set the font to use in the log message view, configured in the settings dialog
\r
191 CAppUtils::CreateFontForLogs(m_logFont);
\r
192 GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);
\r
193 // automatically detect URLs in the log message and turn them into links
\r
194 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);
\r
195 // make the log message rich edit control send a message when the mouse pointer is over a link
\r
196 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);
\r
197 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
199 // the "hide unrelated paths" checkbox should be indeterminate
\r
200 m_cHidePaths.SetCheck(BST_INDETERMINATE);
\r
203 // if there is a working copy, load the project properties
\r
204 // to get information about the bugtraq: integration
\r
206 m_ProjectProperties.ReadProps(m_path);
\r
208 // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set
\r
209 if ((!m_ProjectProperties.sUrl.IsEmpty())||(!m_ProjectProperties.sCheckRe.IsEmpty()))
\r
210 m_bShowBugtraqColumn = true;
\r
212 //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
\r
213 //theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
\r
215 // set up the columns
\r
216 m_LogList.DeleteAllItems();
\r
217 m_LogList.InsertGitColumn();
\r
219 m_ChangedFileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |IDS_STATUSLIST_COLADD|IDS_STATUSLIST_COLDEL , _T("LogDlg"));
\r
221 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
224 m_sMessageBuf.Preallocate(100000);
\r
226 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
\r
227 SetDlgTitle(false);
\r
229 m_tooltips.Create(this);
\r
230 CheckRegexpTooltip();
\r
232 SetSplitterRange();
\r
234 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
\r
235 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
\r
236 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
\r
237 m_cFilter.SetValidator(this);
\r
239 AdjustControlSize(IDC_HIDEPATHS);
\r
240 AdjustControlSize(IDC_CHECK_STOPONCOPY);
\r
241 AdjustControlSize(IDC_INCLUDEMERGE);
\r
243 GetClientRect(m_DlgOrigRect);
\r
244 m_LogList.GetClientRect(m_LogListOrigRect);
\r
245 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
\r
246 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
\r
248 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
249 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
252 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
\r
253 AddAnchor(IDC_DATEFROM, TOP_LEFT);
\r
254 AddAnchor(IDC_TOLABEL, TOP_LEFT);
\r
255 AddAnchor(IDC_DATETO, TOP_LEFT);
\r
257 SetFilterCueText();
\r
258 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
\r
260 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
261 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
262 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
263 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
264 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
266 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
267 AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);
\r
268 AddAnchor(IDC_CHECK_STOPONCOPY, BOTTOM_LEFT);
\r
269 AddAnchor(IDC_INCLUDEMERGE, BOTTOM_LEFT);
\r
270 AddAnchor(IDC_GETALL, BOTTOM_LEFT);
\r
271 AddAnchor(IDC_NEXTHUNDRED, BOTTOM_LEFT);
\r
272 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
\r
273 AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);
\r
274 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
275 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
276 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
277 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
279 // SetPromptParentWindow(m_hWnd);
\r
282 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
283 EnableSaveRestore(_T("LogDlg"));
\r
285 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
286 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
287 RECT rcDlg, rcLogList, rcChgMsg;
\r
288 GetClientRect(&rcDlg);
\r
289 m_LogList.GetWindowRect(&rcLogList);
\r
290 ScreenToClient(&rcLogList);
\r
291 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
\r
292 ScreenToClient(&rcChgMsg);
\r
296 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
297 ScreenToClient(&rectSplitter);
\r
298 int delta = yPos1 - rectSplitter.top;
\r
300 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
\r
302 m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);
\r
309 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
310 ScreenToClient(&rectSplitter);
\r
311 int delta = yPos2 - rectSplitter.top;
\r
313 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
\r
315 m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);
\r
323 // the dialog is used to select revisions
\r
324 if (m_bSelectionMustBeContinuous)
\r
325 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
\r
327 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
331 // the dialog is used to just view log messages
\r
332 GetDlgItemText(IDOK, temp);
\r
333 SetDlgItemText(IDCANCEL, temp);
\r
334 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
\r
337 // set the choices for the "Show All" button
\r
338 temp.LoadString(IDS_LOG_SHOWALL);
\r
339 m_btnShow.AddEntry(temp);
\r
340 temp.LoadString(IDS_LOG_SHOWRANGE);
\r
341 m_btnShow.AddEntry(temp);
\r
342 m_btnShow.SetCurrentEntry((LONG)CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry")));
\r
344 m_mergedRevs.clear();
\r
346 // first start a thread to obtain the log messages without
\r
347 // blocking the dialog
\r
349 //m_tFrom = (DWORD)-1;
\r
351 m_LogList.FetchLogAsync(LogCallBack,this);
\r
353 GetDlgItem(IDC_LOGLIST)->SetFocus();
\r
357 void CLogDlg::LogRunStatus(int cur)
\r
359 if( cur == GITLOG_START )
\r
362 temp.LoadString(IDS_PROGRESSWAIT);
\r
364 // change the text of the close button to "Cancel" since now the thread
\r
365 // is running, and simply closing the dialog doesn't work.
\r
366 if (!GetDlgItem(IDOK)->IsWindowVisible())
\r
368 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
369 SetDlgItemText(IDCANCEL, temp);
\r
372 // We use a progress bar while getting the logs
\r
373 m_LogProgress.SetRange32(0, 100);
\r
374 m_LogProgress.SetPos(0);
\r
376 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
\r
378 DialogEnableWindow(IDC_GETALL, FALSE);
\r
379 DialogEnableWindow(IDC_NEXTHUNDRED, FALSE);
\r
380 DialogEnableWindow(IDC_CHECK_STOPONCOPY, FALSE);
\r
381 DialogEnableWindow(IDC_INCLUDEMERGE, FALSE);
\r
382 DialogEnableWindow(IDC_STATBUTTON, FALSE);
\r
383 DialogEnableWindow(IDC_REFRESH, FALSE);
\r
384 DialogEnableWindow(IDC_HIDEPATHS,FALSE);
\r
387 if( cur == GITLOG_END)
\r
391 DialogEnableWindow(IDC_NEXTHUNDRED, TRUE);
\r
393 //DialogEnableWindow(IDC_CHECK_STOPONCOPY, TRUE);
\r
394 //DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);
\r
395 DialogEnableWindow(IDC_STATBUTTON, TRUE);
\r
396 DialogEnableWindow(IDC_REFRESH, TRUE);
\r
398 PostMessage(WM_TIMER, LOGFILTER_TIMER);
\r
400 //CTime time=m_LogList.GetOldestTime();
\r
402 m_LogList.GetTimeRange(begin,end);
\r
403 m_DateFrom.SetTime(&begin);
\r
404 m_DateTo.SetTime(&end);
\r
407 m_LogProgress.SetPos(cur);
\r
409 void CLogDlg::SetDlgTitle(bool bOffline)
\r
411 if (m_sTitle.IsEmpty())
\r
412 GetWindowText(m_sTitle);
\r
417 if (m_path.IsUrl())
\r
418 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());
\r
419 else if (m_path.IsDirectory())
\r
420 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());
\r
422 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());
\r
423 SetWindowText(sTemp);
\r
427 if (m_path.IsUrl())
\r
428 SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());
\r
429 else if (m_path.IsDirectory())
\r
430 SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());
\r
432 SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());
\r
436 void CLogDlg::CheckRegexpTooltip()
\r
438 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
\r
439 // Since tooltip describes regexp features, show it only if regexps are enabled.
\r
440 if (m_bFilterWithRegex)
\r
442 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
\r
445 m_tooltips.DelTool(pWnd);
\r
448 void CLogDlg::EnableOKButton()
\r
452 // the dialog is used to select revisions
\r
453 if (m_bSelectionMustBeContinuous)
\r
454 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
\r
456 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
459 DialogEnableWindow(IDOK, TRUE);
\r
462 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
\r
464 // we fill here the log message rich edit control,
\r
465 // and also populate the changed files list control
\r
466 // according to the selected revision(s).
\r
468 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
469 // empty the log message view
\r
470 pMsgView->SetWindowText(_T(" "));
\r
471 // empty the changed files list
\r
472 m_ChangedFileListCtrl.SetRedraw(FALSE);
\r
473 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
474 m_currentChangedArray = NULL;
\r
475 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
476 m_ChangedFileListCtrl.DeleteAllItems();
\r
478 // if we're not here to really show a selected revision, just
\r
479 // get out of here after clearing the views, which is what is intended
\r
480 // if that flag is not set.
\r
484 m_ChangedFileListCtrl.Invalidate();
\r
485 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
486 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
490 // depending on how many revisions are selected, we have to do different
\r
492 int selCount = m_LogList.GetSelectedCount();
\r
495 // if nothing is selected, we have nothing more to do
\r
496 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
497 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
500 else if (selCount == 1)
\r
502 // if one revision is selected, we have to fill the log message view
\r
503 // with the corresponding log message, and also fill the changed files
\r
505 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
506 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
507 if (selIndex >= m_LogList.m_arShownList.GetCount())
\r
509 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
510 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
513 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));
\r
515 if(!pLogEntry->m_IsFull)
\r
517 pMsgView->SetWindowText(_T("load ..."));
\r
520 // set the log message text
\r
521 pMsgView->SetWindowText(_T("Commit:")+pLogEntry->m_CommitHash+_T("\r\n\r\n*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);
\r
522 // turn bug ID's into links if the bugtraq: properties have been set
\r
523 // and we can find a match of those in the log message
\r
524 m_ProjectProperties.FindBugID(pLogEntry->m_Body, pMsgView);
\r
525 CAppUtils::FormatTextInRichEditControl(pMsgView);
\r
527 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->m_Files);
\r
528 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;
\r
529 m_ChangedFileListCtrl.Show(SVNSLC_SHOWVERSIONED);
\r
531 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
535 // fill in the changed files list control
\r
536 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
538 m_CurrentFilteredChangedArray.RemoveAll();
\r
539 for (INT_PTR c = 0; c < m_currentChangedArray->GetCount(); ++c)
\r
541 LogChangedPath * cpath = m_currentChangedArray->GetAt(c);
\r
544 if (m_currentChangedArray->GetAt(c)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
546 m_CurrentFilteredChangedArray.Add(cpath);
\r
549 m_currentChangedArray = &m_CurrentFilteredChangedArray;
\r
555 // more than one revision is selected:
\r
556 // the log message view must be emptied
\r
557 // the changed files list contains all the changed paths from all
\r
558 // selected revisions, with 'doubles' removed
\r
559 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
\r
562 // redraw the views
\r
563 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
565 if (m_currentChangedArray)
\r
567 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
\r
568 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
\r
570 else if (m_currentChangedPathList.GetCount())
\r
572 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
\r
573 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
\r
577 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
578 m_ChangedFileListCtrl.Invalidate();
\r
581 CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);
\r
582 // sort according to the settings
\r
583 if (m_nSortColumnPathList > 0)
\r
584 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
586 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
\r
587 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
591 void CLogDlg::OnBnClickedGetall()
\r
596 void CLogDlg::GetAll(bool bForceAll /* = false */)
\r
599 // fetch all requested log messages, either the specified range or
\r
600 // really *all* available log messages.
\r
602 INT_PTR entry = m_btnShow.GetCurrentEntry();
\r
608 case 0: // show all
\r
611 m_startrev = m_LogRevision;
\r
613 m_bShowedAll = true;
\r
616 case 1: // show range
\r
619 // ask for a revision range
\r
620 CRevisionRangeDlg dlg;
\r
621 dlg.SetStartRevision(m_startrev);
\r
622 dlg.SetEndRevision( (m_endrev>=0) ? m_endrev : 0);
\r
623 if (dlg.DoModal()!=IDOK)
\r
627 m_endrev = dlg.GetEndRevision();
\r
628 m_startrev = dlg.GetStartRevision();
\r
629 if (((m_endrev.IsNumber())&&(m_startrev.IsNumber()))||
\r
630 (m_endrev.IsHead()||m_startrev.IsHead()))
\r
632 if (((LONG)m_startrev < (LONG)m_endrev)||
\r
633 (m_endrev.IsHead()))
\r
635 git_revnum_t temp = m_startrev;
\r
636 m_startrev = m_endrev;
\r
640 m_bShowedAll = false;
\r
645 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
646 m_ChangedFileListCtrl.Invalidate();
\r
647 // We need to create CStoreSelection on the heap or else
\r
648 // the variable will run out of the scope before the
\r
649 // thread ends. Therefore we let the thread delete
\r
651 m_pStoreSelection = new CStoreSelection(this);
\r
652 m_LogList.SetItemCountEx(0);
\r
653 m_LogList.Invalidate();
\r
654 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
655 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
656 pMsgView->SetWindowText(_T(""));
\r
658 SetSortArrow(&m_LogList, -1, true);
\r
660 m_LogList.DeleteAllItems();
\r
661 m_arShownList.RemoveAll();
\r
662 m_logEntries.ClearAll();
\r
665 m_bCancelled = FALSE;
\r
667 m_tFrom = (DWORD)-1;
\r
670 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
671 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
673 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
674 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
676 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
677 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
681 void CLogDlg::OnBnClickedRefresh()
\r
687 void CLogDlg::Refresh (bool autoGoOnline)
\r
689 m_LogList.Refresh();
\r
692 void CLogDlg::OnBnClickedNexthundred()
\r
696 // we have to fetch the next X log messages.
\r
697 if (m_logEntries.size() < 1)
\r
699 // since there weren't any log messages fetched before, just
\r
700 // fetch all since we don't have an 'anchor' to fetch the 'next'
\r
702 return GetAll(true);
\r
704 git_revnum_t rev = m_logEntries[m_logEntries.size()-1]->Rev;
\r
707 return; // do nothing! No more revisions to get
\r
711 m_bCancelled = FALSE;
\r
713 // rev is is revision we already have and we will receive it again
\r
714 // -> fetch one extra revision to get NumberOfLogs *new* revisions
\r
716 m_limit = (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;
\r
717 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
718 SetSortArrow(&m_LogList, -1, true);
\r
719 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
720 // We need to create CStoreSelection on the heap or else
\r
721 // the variable will run out of the scope before the
\r
722 // thread ends. Therefore we let the thread delete
\r
724 m_pStoreSelection = new CStoreSelection(this);
\r
726 // since we fetch the log from the last revision we already have,
\r
727 // we have to remove that revision entry to avoid getting it twice
\r
728 m_logEntries.pop_back();
\r
729 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
731 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
732 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
734 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
735 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
739 BOOL CLogDlg::Cancel()
\r
741 return m_bCancelled;
\r
744 void CLogDlg::SaveSplitterPos()
\r
748 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
749 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
751 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
752 ScreenToClient(&rectSplitter);
\r
753 regPos1 = rectSplitter.top;
\r
754 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
755 ScreenToClient(&rectSplitter);
\r
756 regPos2 = rectSplitter.top;
\r
760 void CLogDlg::OnCancel()
\r
762 // canceling means stopping the working thread if it's still running.
\r
763 // we do this by using the Subversion cancel callback.
\r
764 // But canceling can also mean just to close the dialog, depending on the
\r
765 // text shown on the cancel button (it could simply read "OK").
\r
766 CString temp, temp2;
\r
767 GetDlgItemText(IDOK, temp);
\r
768 temp2.LoadString(IDS_MSGBOX_CANCEL);
\r
769 if ((temp.Compare(temp2)==0)||(this->IsThreadRunning()))
\r
771 m_bCancelled = true;
\r
776 m_regLastStrict = m_bStrict;
\r
777 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
778 reg = m_btnShow.GetCurrentEntry();
\r
780 __super::OnCancel();
\r
783 CString CLogDlg::MakeShortMessage(const CString& message)
\r
785 bool bFoundShort = true;
\r
786 CString sShortMessage = m_ProjectProperties.GetLogSummary(message);
\r
787 if (sShortMessage.IsEmpty())
\r
789 bFoundShort = false;
\r
790 sShortMessage = message;
\r
792 // Remove newlines and tabs 'cause those are not shown nicely in the list control
\r
793 sShortMessage.Replace(_T("\r"), _T(""));
\r
794 sShortMessage.Replace(_T("\t"), _T(" "));
\r
796 // Suppose the first empty line separates 'summary' from the rest of the message.
\r
797 int found = sShortMessage.Find(_T("\n\n"));
\r
798 // To avoid too short 'short' messages
\r
799 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
\r
800 // only use the empty newline as a separator if it comes after at least 15 chars.
\r
801 if ((!bFoundShort)&&(found >= 15))
\r
803 sShortMessage = sShortMessage.Left(found);
\r
805 sShortMessage.Replace('\n', ' ');
\r
806 return sShortMessage;
\r
809 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)
\r
812 if (rev == SVN_INVALID_REVNUM)
\r
818 // this is the callback function which receives the data for every revision we ask the log for
\r
819 // we store this information here one by one.
\r
821 if (m_startrev == -1)
\r
826 m_LogProgress.SetPos(m_limit - m_limitcounter);
\r
828 else if (m_startrev.IsNumber() && m_startrev.IsNumber())
\r
829 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);
\r
830 __time64_t ttime = time/1000000L;
\r
831 if (m_tTo < (DWORD)ttime)
\r
832 m_tTo = (DWORD)ttime;
\r
833 if (m_tFrom > (DWORD)ttime)
\r
834 m_tFrom = (DWORD)ttime;
\r
835 if ((m_lowestRev > rev)||(m_lowestRev < 0))
\r
837 // Add as many characters from the log message to the list control
\r
838 PLOGENTRYDATA pLogItem = new LOGENTRYDATA;
\r
839 pLogItem->bCopies = !!copies;
\r
841 // find out if this item was copied in the revision
\r
842 BOOL copiedself = FALSE;
\r
845 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)
\r
847 LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);
\r
848 if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))
\r
850 // note: this only works if the log is fetched top-to-bottom
\r
851 // but since we do that, it shouldn't be a problem
\r
852 m_sSelfRelativeURL = cpath->sCopyFromPath;
\r
858 pLogItem->bCopiedSelf = copiedself;
\r
859 pLogItem->tmDate = ttime;
\r
860 pLogItem->sAuthor = author;
\r
861 pLogItem->sDate = date;
\r
862 pLogItem->sShortMessage = MakeShortMessage(message);
\r
863 pLogItem->dwFileChanges = filechanges;
\r
864 pLogItem->actions = actions;
\r
865 pLogItem->haschildren = haschildren;
\r
866 pLogItem->childStackDepth = m_childCounter;
\r
867 m_maxChild = max(m_childCounter, m_maxChild);
\r
870 pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();
\r
872 // split multi line log entries and concatenate them
\r
873 // again but this time with \r\n as line separators
\r
874 // so that the edit control recognizes them
\r
877 if (message.GetLength()>0)
\r
879 m_sMessageBuf = message;
\r
880 m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));
\r
881 m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));
\r
882 if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)
\r
883 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);
\r
886 m_sMessageBuf.Empty();
\r
887 pLogItem->sMessage = m_sMessageBuf;
\r
888 pLogItem->Rev = rev;
\r
890 // move-construct path array
\r
892 pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);
\r
893 cpaths->RemoveAll();
\r
895 catch (CException * e)
\r
897 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);
\r
899 m_bCancelled = TRUE;
\r
901 m_logEntries.push_back(pLogItem);
\r
902 m_arShownList.Add(pLogItem);
\r
908 //this is the thread function which calls the subversion function
\r
913 void CLogDlg::CopyChangedSelectionToClipBoard()
\r
916 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
918 return; // nothing is selected, get out of here
\r
922 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
925 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
928 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
929 sPaths += m_currentChangedPathList[nItem].GetGitPathString();
\r
930 sPaths += _T("\r\n");
\r
935 // only one revision is selected in the log dialog top pane
\r
936 // but multiple items could be selected in the changed items list
\r
937 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
940 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
941 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
943 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
945 // some items are hidden! So find out which item the user really selected
\r
946 INT_PTR selRealIndex = -1;
\r
947 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
949 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
951 if (selRealIndex == nItem)
\r
953 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);
\r
958 if (changedlogpath)
\r
960 sPaths += changedlogpath->sPath;
\r
961 sPaths += _T("\r\n");
\r
966 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
\r
970 BOOL CLogDlg::IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev)
\r
973 CString added, deleted;
\r
974 if (changedpath == NULL)
\r
977 if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))
\r
979 if (changedpath->action == LOGACTIONS_ADDED) // file is added
\r
981 if (changedpath->lCopyFromRev == 0)
\r
982 return FALSE; // but file was not added with history
\r
990 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
992 // we have two separate context menus:
\r
993 // one shown on the log message list control,
\r
994 // the other shown in the changed-files list control
\r
995 int selCount = m_LogList.GetSelectedCount();
\r
996 if (pWnd == &m_LogList)
\r
998 //ShowContextMenuForRevisions(pWnd, point);
\r
1000 else if (pWnd == &m_ChangedFileListCtrl)
\r
1002 //ShowContextMenuForChangedpaths(pWnd, point);
\r
1004 else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1006 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1007 int selIndex = -1;
\r
1009 selIndex = m_LogList.GetNextSelectedItem(pos);
\r
1010 if ((point.x == -1) && (point.y == -1))
\r
1013 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
\r
1014 ClientToScreen(&rect);
\r
1015 point = rect.CenterPoint();
\r
1017 CString sMenuItemText;
\r
1019 if (popup.CreatePopupMenu())
\r
1021 // add the 'default' entries
\r
1022 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
\r
1023 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
\r
1024 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
\r
1025 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
\r
1027 //if (selIndex >= 0)
\r
1029 // popup.AppendMenu(MF_SEPARATOR);
\r
1030 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
\r
1031 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
\r
1034 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1038 break; // no command selected
\r
1041 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
\r
1043 case CGitLogList::ID_EDITAUTHOR:
\r
1044 EditLogMessage(selIndex);
\r
1052 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
1055 ASSERT(m_pFindDialog != NULL);
\r
1057 if (m_pFindDialog->IsTerminating())
\r
1059 // invalidate the handle identifying the dialog box.
\r
1060 m_pFindDialog = NULL;
\r
1064 if(m_pFindDialog->FindNext())
\r
1066 //read data from dialog
\r
1067 CString FindText = m_pFindDialog->GetFindString();
\r
1068 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
\r
1069 bool bFound = false;
\r
1071 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
\r
1073 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
\r
1076 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
\r
1080 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1082 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))
\r
1087 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1088 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1090 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1091 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))
\r
1097 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))
\r
1109 if (m_logEntries[i]->sMessage.Find(FindText) >= 0)
\r
1114 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1115 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1116 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1118 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1119 if (cpath->sCopyFromPath.Find(FindText)>=0)
\r
1125 if (cpath->sPath.Find(FindText)>=0)
\r
1135 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1136 CString msg = pLogEntry->sMessage;
\r
1137 msg = msg.MakeLower();
\r
1138 CString find = FindText.MakeLower();
\r
1139 if (msg.Find(find) >= 0)
\r
1144 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1145 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1147 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1148 CString lowerpath = cpath->sCopyFromPath;
\r
1149 lowerpath.MakeLower();
\r
1150 if (lowerpath.Find(find)>=0)
\r
1156 lowerpath = cpath->sPath;
\r
1157 lowerpath.MakeLower();
\r
1158 if (lowerpath.Find(find)>=0)
\r
1167 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
\r
1170 this->m_nSearchIndex = (i+1);
\r
1171 m_LogList.EnsureVisible(i, FALSE);
\r
1172 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);
\r
1173 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1174 m_LogList.SetSelectionMark(i);
\r
1175 FillLogMessageCtrl();
\r
1176 UpdateData(FALSE);
\r
1178 if (m_nSearchIndex >= m_arShownList.GetCount())
\r
1179 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
\r
1181 } // if(m_pFindDialog->FindNext())
\r
1182 UpdateLogInfoLabel();
\r
1187 void CLogDlg::OnOK()
\r
1190 // since the log dialog is also used to select revisions for other
\r
1191 // dialogs, we have to do some work before closing this dialog
\r
1192 if (GetFocus() != GetDlgItem(IDOK))
\r
1193 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
\r
1194 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
\r
1195 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
\r
1198 CString buttontext;
\r
1199 GetDlgItemText(IDOK, buttontext);
\r
1200 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1201 if (temp.Compare(buttontext) != 0)
\r
1202 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
\r
1203 m_bCancelled = TRUE;
\r
1204 m_selectedRevs.Clear();
\r
1205 m_selectedRevsOneRange.Clear();
\r
1206 if (m_pNotifyWindow)
\r
1208 int selIndex = m_LogList.GetSelectionMark();
\r
1209 if (selIndex >= 0)
\r
1211 PLOGENTRYDATA pLogEntry = NULL;
\r
1212 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1213 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1214 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1215 git_revnum_t lowerRev = pLogEntry->Rev;
\r
1216 git_revnum_t higherRev = lowerRev;
\r
1219 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1220 git_revnum_t rev = pLogEntry->Rev;
\r
1221 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1222 if (lowerRev > rev)
\r
1224 if (higherRev < rev)
\r
1227 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
\r
1229 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
\r
1231 BOOL bSentMessage = FALSE;
\r
1232 if (m_LogList.GetSelectedCount() == 1)
\r
1234 // if only one revision is selected, check if the path/url with which the dialog was started
\r
1235 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
\r
1236 // if it was copied, use the copy from revision as lowerRev
\r
1237 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
\r
1239 CString sUrl = m_path.GetGitPathString();
\r
1240 if (!m_path.IsUrl())
\r
1242 sUrl = GetURLFromPath(m_path);
\r
1244 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
\r
1245 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
\r
1247 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);
\r
1250 if (sUrl.Compare(pData->sPath) == 0)
\r
1252 if (!pData->sCopyFromPath.IsEmpty())
\r
1254 lowerRev = pData->lCopyFromRev;
\r
1255 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
\r
1256 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
\r
1257 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1258 bSentMessage = TRUE;
\r
1265 if ( !bSentMessage )
\r
1267 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
\r
1268 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
\r
1269 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1270 if (m_selectedRevsOneRange.GetCount())
\r
1271 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
\r
1276 if (m_bSaveStrict)
\r
1277 m_regLastStrict = m_bStrict;
\r
1278 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
1279 reg = m_btnShow.GetCurrentEntry();
\r
1280 SaveSplitterPos();
\r
1284 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1286 // a double click on an entry in the changed-files list has happened
\r
1289 DiffSelectedFile();
\r
1292 void CLogDlg::DiffSelectedFile()
\r
1295 if (m_bThreadRunning)
\r
1297 UpdateLogInfoLabel();
\r
1298 INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
1301 if (m_ChangedFileListCtrl.GetSelectedCount() == 0)
\r
1303 // find out if there's an entry selected in the log list
\r
1304 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1305 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1306 git_revnum_t rev1 = pLogEntry->Rev;
\r
1307 git_revnum_t rev2 = rev1;
\r
1312 // there's at least a second entry selected in the log list: several revisions selected!
\r
1313 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1316 rev1 = max(rev1,(long)pLogEntry->Rev);
\r
1317 rev2 = min(rev2,(long)pLogEntry->Rev);
\r
1321 // now we have both revisions selected in the log list, so we can do a diff of the selected
\r
1322 // entry in the changed files list with these two revisions.
\r
1323 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1328 // nothing or only one revision selected in the log list
\r
1329 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1331 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1333 // some items are hidden! So find out which item the user really clicked on
\r
1334 INT_PTR selRealIndex = -1;
\r
1335 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1337 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1339 if (selRealIndex == selIndex)
\r
1341 selIndex = hiddenindex;
\r
1342 changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1348 if (IsDiffPossible(changedpath, rev1))
\r
1350 // diffs with renamed files are possible
\r
1351 if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))
\r
1352 rev2 = changedpath->lCopyFromRev;
\r
1355 // if the path was modified but the parent path was 'added with history'
\r
1356 // then we have to use the copy from revision of the parent path
\r
1357 CTGitPath cpath = CTGitPath(changedpath->sPath);
\r
1358 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
1360 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
1361 if (p.IsAncestorOf(cpath))
\r
1363 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
1364 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
1368 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1372 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1373 CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1375 // deleted files must be opened from the revision before the deletion
\r
1376 if (changedpath->action == LOGACTIONS_DELETED)
\r
1378 m_bCancelled = false;
\r
1380 CProgressDlg progDlg;
\r
1381 progDlg.SetTitle(IDS_APPNAME);
\r
1382 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1383 CString sInfoLine;
\r
1384 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());
\r
1385 progDlg.SetLine(1, sInfoLine, true);
\r
1386 SetAndClearProgressInfo(&progDlg);
\r
1387 progDlg.ShowModeless(m_hWnd);
\r
1389 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))
\r
1391 m_bCancelled = false;
\r
1392 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))
\r
1395 SetAndClearProgressInfo((HWND)NULL);
\r
1396 CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1401 SetAndClearProgressInfo((HWND)NULL);
\r
1403 CString sName1, sName2;
\r
1404 sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);
\r
1405 sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);
\r
1406 CAppUtils::DiffFlags flags;
\r
1407 flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1408 if (changedpath->action == LOGACTIONS_DELETED)
\r
1409 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);
\r
1411 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);
\r
1418 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)
\r
1420 DialogEnableWindow(IDOK, FALSE);
\r
1421 // SetPromptApp(&theApp);
\r
1422 theApp.DoWaitCursor(1);
\r
1425 GetTempPath(temppath);
\r
1428 file1.Format(_T("%s%s_%s%s"),
\r
1430 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1431 rev1->m_CommitHash.Left(6),
\r
1432 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1435 file2.Format(_T("%s\\%s_%s%s"),
\r
1437 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1438 rev2->m_CommitHash.Left(6),
\r
1439 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1443 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1444 g_Git.RunLogFile(cmd,file1);
\r
1445 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1446 g_Git.RunLogFile(cmd,file2);
\r
1448 CAppUtils::DiffFlags flags;
\r
1449 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);
\r
1452 //get the filename
\r
1454 if (Git::PathIsURL(m_path))
\r
1456 filepath = m_path.GetGitPathString();
\r
1460 filepath = GetURLFromPath(m_path);
\r
1461 if (filepath.IsEmpty())
\r
1463 theApp.DoWaitCursor(-1);
\r
1465 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1466 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1467 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1469 theApp.DoWaitCursor(-11);
\r
1473 m_bCancelled = FALSE;
\r
1474 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1476 CString firstfile, secondfile;
\r
1477 if (m_LogList.GetSelectedCount()==1)
\r
1479 int s = m_LogList.GetSelectionMark();
\r
1480 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));
\r
1481 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1482 firstfile = changedpath->sPath;
\r
1483 secondfile = firstfile;
\r
1484 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?
\r
1486 secondfile = changedpath->sCopyFromPath;
\r
1487 rev2 = changedpath->lCopyFromRev;
\r
1492 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();
\r
1493 secondfile = firstfile;
\r
1496 firstfile = filepath + firstfile.Trim();
\r
1497 secondfile = filepath + secondfile.Trim();
\r
1499 GitDiff diff(this, this->m_hWnd, true);
\r
1500 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1501 diff.SetHEADPeg(m_LogRevision);
\r
1504 if (PromptShown())
\r
1505 diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);
\r
1507 CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);
\r
1511 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))
\r
1513 if (firstfile.Compare(secondfile)==0)
\r
1515 git_revnum_t baseRev = 0;
\r
1516 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);
\r
1523 theApp.DoWaitCursor(-1);
\r
1527 BOOL CLogDlg::Open(bool bOpenWith,CString changedpath, git_revnum_t rev)
\r
1530 DialogEnableWindow(IDOK, FALSE);
\r
1531 SetPromptApp(&theApp);
\r
1532 theApp.DoWaitCursor(1);
\r
1534 if (Git::PathIsURL(m_path))
\r
1536 filepath = m_path.GetGitPathString();
\r
1540 filepath = GetURLFromPath(m_path);
\r
1541 if (filepath.IsEmpty())
\r
1543 theApp.DoWaitCursor(-1);
\r
1545 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1546 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1547 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1552 m_bCancelled = false;
\r
1553 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1554 filepath += changedpath;
\r
1556 CProgressDlg progDlg;
\r
1557 progDlg.SetTitle(IDS_APPNAME);
\r
1558 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1559 CString sInfoLine;
\r
1560 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());
\r
1561 progDlg.SetLine(1, sInfoLine, true);
\r
1562 SetAndClearProgressInfo(&progDlg);
\r
1563 progDlg.ShowModeless(m_hWnd);
\r
1565 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);
\r
1566 m_bCancelled = false;
\r
1567 if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))
\r
1570 SetAndClearProgressInfo((HWND)NULL);
\r
1571 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1573 theApp.DoWaitCursor(-1);
\r
1577 SetAndClearProgressInfo((HWND)NULL);
\r
1578 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1581 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1582 if (ret <= HINSTANCE_ERROR)
\r
1587 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1588 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1589 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1592 theApp.DoWaitCursor(-1);
\r
1597 void CLogDlg::EditAuthor(const CLogDataVector& logs)
\r
1602 if (logs.size() == 0)
\r
1604 DialogEnableWindow(IDOK, FALSE);
\r
1605 SetPromptApp(&theApp);
\r
1606 theApp.DoWaitCursor(1);
\r
1607 if (Git::PathIsURL(m_path))
\r
1608 url = m_path.GetGitPathString();
\r
1611 url = GetURLFromPath(m_path);
\r
1613 name = Git_PROP_REVISION_AUTHOR;
\r
1615 CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);
\r
1616 CString sOldValue = value;
\r
1617 value.Replace(_T("\n"), _T("\r\n"));
\r
1618 CInputDlg dlg(this);
\r
1619 dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);
\r
1620 dlg.m_sInputText = value;
\r
1621 dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);
\r
1622 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1623 dlg.m_bUseLogWidth = false;
\r
1624 if (dlg.DoModal() == IDOK)
\r
1626 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1628 LogCache::CCachedLogInfo* toUpdate
\r
1629 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1631 CProgressDlg progDlg;
\r
1632 progDlg.SetTitle(IDS_APPNAME);
\r
1633 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
\r
1634 progDlg.SetTime(true);
\r
1635 progDlg.SetShowProgressBar(true);
\r
1636 progDlg.ShowModeless(m_hWnd);
\r
1637 for (DWORD i=0; i<logs.size(); ++i)
\r
1639 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))
\r
1642 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1648 logs[i]->sAuthor = dlg.m_sInputText;
\r
1649 m_LogList.Invalidate();
\r
1651 // update the log cache
\r
1653 if (toUpdate != NULL)
\r
1655 // log caching is active
\r
1657 LogCache::CCachedLogInfo newInfo;
\r
1658 newInfo.Insert ( logs[i]->Rev
\r
1659 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)
\r
1662 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);
\r
1664 toUpdate->Update (newInfo);
\r
1667 progDlg.SetProgress64(i, logs.size());
\r
1671 theApp.DoWaitCursor(-1);
\r
1676 void CLogDlg::EditLogMessage(int index)
\r
1681 DialogEnableWindow(IDOK, FALSE);
\r
1682 SetPromptApp(&theApp);
\r
1683 theApp.DoWaitCursor(1);
\r
1684 if (Git::PathIsURL(m_path))
\r
1685 url = m_path.GetGitPathString();
\r
1688 url = GetURLFromPath(m_path);
\r
1690 name = Git_PROP_REVISION_LOG;
\r
1692 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
1693 m_bCancelled = FALSE;
\r
1694 CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);
\r
1695 CString sOldValue = value;
\r
1696 value.Replace(_T("\n"), _T("\r\n"));
\r
1697 CInputDlg dlg(this);
\r
1698 dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);
\r
1699 dlg.m_sInputText = value;
\r
1700 dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);
\r
1701 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1702 dlg.m_bUseLogWidth = true;
\r
1703 if (dlg.DoModal() == IDOK)
\r
1705 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1706 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))
\r
1708 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1712 pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);
\r
1713 // split multi line log entries and concatenate them
\r
1714 // again but this time with \r\n as line separators
\r
1715 // so that the edit control recognizes them
\r
1716 if (dlg.m_sInputText.GetLength()>0)
\r
1718 m_sMessageBuf = dlg.m_sInputText;
\r
1719 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));
\r
1720 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));
\r
1721 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)
\r
1722 dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);
\r
1725 dlg.m_sInputText.Empty();
\r
1726 pLogEntry->sMessage = dlg.m_sInputText;
\r
1727 pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);
\r
1728 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
1729 pMsgView->SetWindowText(_T(" "));
\r
1730 pMsgView->SetWindowText(dlg.m_sInputText);
\r
1731 m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);
\r
1732 m_LogList.Invalidate();
\r
1734 // update the log cache
\r
1736 LogCache::CCachedLogInfo* toUpdate
\r
1737 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1738 if (toUpdate != NULL)
\r
1740 // log caching is active
\r
1742 LogCache::CCachedLogInfo newInfo;
\r
1743 newInfo.Insert ( pLogEntry->Rev
\r
1745 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)
\r
1747 , LogCache::CRevisionInfoContainer::HAS_COMMENT);
\r
1749 toUpdate->Update (newInfo);
\r
1753 theApp.DoWaitCursor(-1);
\r
1758 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
\r
1760 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1761 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1762 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1764 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1766 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1768 DiffSelectedRevWithPrevious();
\r
1772 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1774 DiffSelectedFile();
\r
1778 if (m_hAccel && !bSkipAccelerator)
\r
1780 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1785 m_tooltips.RelayEvent(pMsg);
\r
1786 return __super::PreTranslateMessage(pMsg);
\r
1790 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
1792 //if (this->IsThreadRunning())
\r
1793 if(m_LogList.m_bNoDispUpdates)
\r
1795 // only show the wait cursor over the list control
\r
1797 ((pWnd == GetDlgItem(IDC_LOGLIST))||
\r
1798 (pWnd == GetDlgItem(IDC_MSGVIEW))||
\r
1799 (pWnd == GetDlgItem(IDC_LOGMSG))))
\r
1801 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
1806 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1807 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1809 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
1811 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1814 void CLogDlg::OnBnClickedHelp()
\r
1819 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1821 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
1823 //if (this->IsThreadRunning())
\r
1824 if(m_LogList.m_bNoDispUpdates)
\r
1826 if (pNMLV->iItem >= 0)
\r
1828 m_nSearchIndex = pNMLV->iItem;
\r
1829 if (pNMLV->iSubItem != 0)
\r
1831 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount())&&(m_bStrict)&&(1/*m_bStrictStopped*/))
\r
1833 // remove the selected state
\r
1834 if (pNMLV->uChanged & LVIF_STATE)
\r
1836 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
\r
1837 FillLogMessageCtrl();
\r
1838 UpdateData(FALSE);
\r
1839 UpdateLogInfoLabel();
\r
1843 if (pNMLV->uChanged & LVIF_STATE)
\r
1845 FillLogMessageCtrl();
\r
1846 UpdateData(FALSE);
\r
1851 FillLogMessageCtrl();
\r
1852 UpdateData(FALSE);
\r
1855 UpdateLogInfoLabel();
\r
1858 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
\r
1860 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
\r
1861 if (pEnLink->msg == WM_LBUTTONUP)
\r
1864 GetDlgItemText(IDC_MSGVIEW, msg);
\r
1865 msg.Replace(_T("\r\n"), _T("\n"));
\r
1866 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
\r
1867 if (!::PathIsURL(url))
\r
1869 url = m_ProjectProperties.GetBugIDUrl(url);
\r
1870 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1872 if (!url.IsEmpty())
\r
1873 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1878 void CLogDlg::OnBnClickedStatbutton()
\r
1881 if (this->IsThreadRunning())
\r
1883 if (m_LogList.m_arShownList.IsEmpty())
\r
1884 return; // nothing is shown, so no statistics.
\r
1885 // the statistics dialog expects the log entries to be sorted by date
\r
1886 SortByColumn(3, false);
\r
1887 CPtrArray shownlist;
\r
1888 m_LogList.RecalculateShownList(&shownlist);
\r
1889 // create arrays which are aware of the current filter
\r
1890 CStringArray m_arAuthorsFiltered;
\r
1891 CDWordArray m_arDatesFiltered;
\r
1892 CDWordArray m_arFileChangesFiltered;
\r
1893 for (INT_PTR i=0; i<shownlist.GetCount(); ++i)
\r
1895 GitRev* pLogEntry = reinterpret_cast<GitRev*>(shownlist.GetAt(i));
\r
1896 CString strAuthor = pLogEntry->m_AuthorName;
\r
1897 if ( strAuthor.IsEmpty() )
\r
1899 strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);
\r
1901 m_arAuthorsFiltered.Add(strAuthor);
\r
1902 m_arDatesFiltered.Add(pLogEntry->m_AuthorDate.GetTime());
\r
1903 m_arFileChangesFiltered.Add(pLogEntry->m_Files.GetCount());
\r
1905 CStatGraphDlg dlg;
\r
1906 dlg.m_parAuthors = &m_arAuthorsFiltered;
\r
1907 dlg.m_parDates = &m_arDatesFiltered;
\r
1908 dlg.m_parFileChanges = &m_arFileChangesFiltered;
\r
1909 dlg.m_path = m_path;
\r
1911 // restore the previous sorting
\r
1912 SortByColumn(m_nSortColumn, m_bAscending);
\r
1913 OnTimer(LOGFILTER_TIMER);
\r
1918 void CLogDlg::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1921 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
1922 // Take the default processing unless we set this to something else below.
\r
1923 *pResult = CDRF_DODEFAULT;
\r
1925 if (m_bNoDispUpdates)
\r
1928 switch (pLVCD->nmcd.dwDrawStage)
\r
1930 case CDDS_PREPAINT:
\r
1932 *pResult = CDRF_NOTIFYITEMDRAW;
\r
1936 case CDDS_ITEMPREPAINT:
\r
1938 // This is the prepaint stage for an item. Here's where we set the
\r
1939 // item's text color.
\r
1941 // Tell Windows to send draw notifications for each subitem.
\r
1942 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
1944 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
1946 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1948 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
1952 if (data->bCopiedSelf)
\r
1954 // only change the background color if the item is not 'hot' (on vista with themes enabled)
\r
1955 if (!theme.IsAppThemed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
1956 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
1959 if (data->bCopies)
\r
1960 crText = m_Colors.GetColor(CColors::Modified);
\r
1962 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
1963 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
1964 // if (data->Rev == m_wcRev)
\r
1966 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
1967 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
1968 // tells the control to recalculate the extent of the text.
\r
1969 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
1973 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1975 if (m_bStrictStopped)
\r
1976 crText = GetSysColor(COLOR_GRAYTEXT);
\r
1978 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
1979 pLVCD->clrText = crText;
\r
1983 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
1985 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
1987 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
1989 if (pLVCD->iSubItem == 1)
\r
1991 *pResult = CDRF_DODEFAULT;
\r
1993 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1997 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
1998 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
2000 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
2002 // Get the selected state of the
\r
2003 // item being drawn.
\r
2005 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
2006 rItem.mask = LVIF_STATE;
\r
2007 rItem.iItem = pLVCD->nmcd.dwItemSpec;
\r
2008 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
2009 m_LogList.GetItem(&rItem);
\r
2012 m_LogList.GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
2014 // Fill the background
\r
2015 if (theme.IsAppThemed() && m_bVista)
\r
2017 theme.Open(m_hWnd, L"Explorer");
\r
2018 int state = LISS_NORMAL;
\r
2019 if (rItem.state & LVIS_SELECTED)
\r
2021 if (::GetFocus() == m_LogList.m_hWnd)
\r
2022 state |= LISS_SELECTED;
\r
2024 state |= LISS_SELECTEDNOTFOCUS;
\r
2029 if (pLogEntry->bCopiedSelf)
\r
2031 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
2032 // information at this drawing stage. But we can check the whether the
\r
2033 // previous stage changed the background color of the item
\r
2034 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
2037 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2040 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2041 ::DeleteObject(brush);
\r
2048 if (theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
2049 theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);
\r
2051 theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
2056 if (rItem.state & LVIS_SELECTED)
\r
2058 if (::GetFocus() == m_LogList.m_hWnd)
\r
2059 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
2061 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
2065 //if (pLogEntry->bCopiedSelf)
\r
2066 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2068 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
2070 if (brush == NULL)
\r
2073 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2074 ::DeleteObject(brush);
\r
2077 // Draw the icon(s) into the compatible DC
\r
2078 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
2079 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2082 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
2083 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2086 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
2087 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2090 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
2091 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2093 *pResult = CDRF_SKIPDEFAULT;
\r
2099 *pResult = CDRF_DODEFAULT;
\r
2104 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2107 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
2108 // Take the default processing unless we set this to something else below.
\r
2109 *pResult = CDRF_DODEFAULT;
\r
2111 // if (m_bNoDispUpdates)
\r
2114 // First thing - check the draw stage. If it's the control's prepaint
\r
2115 // stage, then tell Windows we want messages for every item.
\r
2117 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2119 *pResult = CDRF_NOTIFYITEMDRAW;
\r
2121 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2123 // This is the prepaint stage for an item. Here's where we set the
\r
2124 // item's text color. Our return value will tell Windows to draw the
\r
2125 // item itself, but it will use the new color we set here.
\r
2127 // Tell Windows to paint the control itself.
\r
2128 *pResult = CDRF_DODEFAULT;
\r
2130 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
2131 bool bGrayed = false;
\r
2133 if ((m_cHidePaths.GetState() & 0x0003)==BST_INDETERMINATE)
\r
2135 if ((m_currentChangedArray)&&((m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)))
\r
2137 //if ((*m_currentChangedArray)[(pLVCD->nmcd.dwItemSpec)]sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2139 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2143 else if (m_currentChangedPathList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2145 //if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2147 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2154 if ((!bGrayed)&&(m_currentChangedArray)&&(m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
2156 DWORD action = ((*m_currentChangedArray)[pLVCD->nmcd.dwItemSpec]).m_Action;
\r
2157 if (action == CTGitPath::LOGACTIONS_MODIFIED)
\r
2158 crText = m_Colors.GetColor(CColors::Modified);
\r
2159 if (action == CTGitPath::LOGACTIONS_REPLACED)
\r
2160 crText = m_Colors.GetColor(CColors::Deleted);
\r
2161 if (action == CTGitPath::LOGACTIONS_ADDED)
\r
2162 crText = m_Colors.GetColor(CColors::Added);
\r
2163 if (action == CTGitPath::LOGACTIONS_DELETED)
\r
2164 crText = m_Colors.GetColor(CColors::Deleted);
\r
2167 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
2168 pLVCD->clrText = crText;
\r
2172 void CLogDlg::DoSizeV1(int delta)
\r
2175 RemoveAnchor(IDC_LOGLIST);
\r
2176 RemoveAnchor(IDC_SPLITTERTOP);
\r
2177 RemoveAnchor(IDC_MSGVIEW);
\r
2178 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2179 RemoveAnchor(IDC_LOGMSG);
\r
2180 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
\r
2181 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
\r
2182 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2183 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2184 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2185 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2186 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2189 SetSplitterRange();
\r
2190 m_LogList.Invalidate();
\r
2191 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2195 void CLogDlg::DoSizeV2(int delta)
\r
2198 RemoveAnchor(IDC_LOGLIST);
\r
2199 RemoveAnchor(IDC_SPLITTERTOP);
\r
2200 RemoveAnchor(IDC_MSGVIEW);
\r
2201 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2202 RemoveAnchor(IDC_LOGMSG);
\r
2203 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
\r
2204 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
\r
2205 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2206 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2207 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2208 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2209 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2212 SetSplitterRange();
\r
2213 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2214 m_ChangedFileListCtrl.Invalidate();
\r
2218 void CLogDlg::AdjustMinSize()
\r
2220 // adjust the minimum size of the dialog to prevent the resizing from
\r
2221 // moving the list control too far down.
\r
2222 CRect rcChgListView;
\r
2223 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
\r
2225 m_LogList.GetClientRect(rcLogList);
\r
2227 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
\r
2228 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
\r
2229 +rcChgListView.Height()+rcLogList.Height()+60));
\r
2232 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
2234 switch (message) {
\r
2236 if (wParam == IDC_SPLITTERTOP)
\r
2238 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2239 DoSizeV1(pHdr->delta);
\r
2241 else if (wParam == IDC_SPLITTERBOTTOM)
\r
2243 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2244 DoSizeV2(pHdr->delta);
\r
2249 return CResizableDialog::DefWindowProc(message, wParam, lParam);
\r
2252 void CLogDlg::SetSplitterRange()
\r
2254 if ((m_LogList)&&(m_ChangedFileListCtrl))
\r
2257 m_LogList.GetWindowRect(rcTop);
\r
2258 ScreenToClient(rcTop);
\r
2260 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
\r
2261 ScreenToClient(rcMiddle);
\r
2262 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
\r
2264 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
\r
2265 ScreenToClient(rcBottom);
\r
2266 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
\r
2270 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
\r
2272 RECT * rect = (LPRECT)lParam;
\r
2275 point = CPoint(rect->left, rect->bottom);
\r
2276 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
\r
2278 if (popup.CreatePopupMenu())
\r
2280 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2281 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);
\r
2283 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2285 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2286 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
\r
2287 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2288 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
\r
2289 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2290 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
\r
2291 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2292 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
\r
2293 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
\r
2294 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
\r
2296 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2298 temp.LoadString(IDS_LOG_FILTER_REGEX);
\r
2299 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
\r
2302 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2303 if (selection != 0)
\r
2306 if (selection == LOGFILTER_REGEX)
\r
2308 m_bFilterWithRegex = !m_bFilterWithRegex;
\r
2309 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
2310 b = m_bFilterWithRegex;
\r
2311 CheckRegexpTooltip();
\r
2315 m_LogList.m_nSelectedFilter = selection;
\r
2316 SetFilterCueText();
\r
2318 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2324 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
2327 KillTimer(LOGFILTER_TIMER);
\r
2329 m_LogList.m_sFilterText.Empty();
\r
2330 UpdateData(FALSE);
\r
2331 theApp.DoWaitCursor(1);
\r
2332 CStoreSelection storeselection(this);
\r
2333 FillLogMessageCtrl(false);
\r
2335 m_LogList.RemoveFilter();
\r
2338 m_LogList.GetTimeRange(begin,end);
\r
2339 m_DateFrom.SetTime(&begin);
\r
2340 m_DateTo.SetTime(&end);
\r
2342 theApp.DoWaitCursor(-1);
\r
2343 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2344 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2345 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2346 UpdateLogInfoLabel();
\r
2352 void CLogDlg::SetFilterCueText()
\r
2355 switch (m_LogList.m_nSelectedFilter)
\r
2357 case LOGFILTER_ALL:
\r
2358 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2360 case LOGFILTER_MESSAGES:
\r
2361 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2363 case LOGFILTER_PATHS:
\r
2364 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2366 case LOGFILTER_AUTHORS:
\r
2367 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2369 case LOGFILTER_REVS:
\r
2370 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2373 // to make the cue banner text appear more to the right of the edit control
\r
2374 temp = _T(" ")+temp;
\r
2375 m_cFilter.SetCueBanner(temp);
\r
2378 bool CLogDlg::Validate(LPCTSTR string)
\r
2380 if (!m_bFilterWithRegex)
\r
2383 return m_LogList.ValidateRegexp(string, pat, false);
\r
2387 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
\r
2389 if (nIDEvent == LOGFILTER_TIMER)
\r
2391 if (this->IsThreadRunning())
\r
2393 // thread still running! So just restart the timer.
\r
2394 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2397 CWnd * focusWnd = GetFocus();
\r
2398 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
\r
2399 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
\r
2400 if (m_LogList.m_sFilterText.IsEmpty())
\r
2402 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2403 // do not return here!
\r
2404 // we also need to run the filter if the filter text is empty:
\r
2405 // 1. to clear an existing filter
\r
2406 // 2. to rebuild the m_arShownList after sorting
\r
2408 theApp.DoWaitCursor(1);
\r
2409 CStoreSelection storeselection(this);
\r
2410 KillTimer(LOGFILTER_TIMER);
\r
2411 FillLogMessageCtrl(false);
\r
2413 // now start filter the log list
\r
2414 m_LogList.StartFilter();
\r
2416 if ( m_LogList.GetItemCount()==1 )
\r
2418 m_LogList.SetSelectionMark(0);
\r
2419 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
2421 theApp.DoWaitCursor(-1);
\r
2422 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2423 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2424 if (bSetFocusToFilterControl)
\r
2425 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2426 UpdateLogInfoLabel();
\r
2427 } // if (nIDEvent == LOGFILTER_TIMER)
\r
2428 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2429 __super::OnTimer(nIDEvent);
\r
2432 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2435 m_DateTo.GetTime(_time);
\r
2438 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
\r
2439 if (time.GetTime() != m_LogList.m_To.GetTime())
\r
2441 m_LogList.m_To = (DWORD)time.GetTime();
\r
2442 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2445 catch (CAtlException)
\r
2452 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2455 m_DateFrom.GetTime(_time);
\r
2458 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
\r
2459 if (time.GetTime() != m_LogList.m_From.GetTime())
\r
2461 m_LogList.m_From = (DWORD)time.GetTime();
\r
2462 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2465 catch (CAtlException)
\r
2474 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths /* = false */, bool bUseFilter /* = true */)
\r
2476 CTGitPathList pathList;
\r
2479 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2481 m_sRepositoryRoot = GetRepositoryRoot(m_path);
\r
2483 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2486 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2491 int nextpos = m_LogList.GetNextSelectedItem(pos);
\r
2492 if (nextpos >= m_arShownList.GetCount())
\r
2494 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));
\r
2495 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
2496 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
2498 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2499 if (cpath == NULL)
\r
2502 if (!bRelativePaths)
\r
2503 path.SetFromGit(m_sRepositoryRoot);
\r
2504 path.AppendPathString(cpath->sPath);
\r
2505 if ((!bUseFilter)||
\r
2506 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
\r
2507 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
\r
2508 pathList.AddPath(path);
\r
2513 pathList.RemoveDuplicates();
\r
2518 void CLogDlg::SortByColumn(int nSortColumn, bool bAscending)
\r
2521 switch(nSortColumn)
\r
2523 case 0: // Revision
\r
2526 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
\r
2528 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
\r
2534 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
\r
2536 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
\r
2542 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
\r
2544 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
\r
2550 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
\r
2552 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
\r
2555 case 4: // Message or bug id
\r
2556 if (m_bShowBugtraqColumn)
\r
2559 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
\r
2561 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
\r
2564 // fall through here
\r
2565 case 5: // Message
\r
2568 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
\r
2570 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
\r
2580 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
\r
2582 if (this->IsThreadRunning())
\r
2583 return; //no sorting while the arrays are filled
\r
2584 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2585 const int nColumn = pNMLV->iSubItem;
\r
2586 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
\r
2587 m_nSortColumn = nColumn;
\r
2588 SortByColumn(m_nSortColumn, m_bAscending);
\r
2589 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
\r
2590 SortShownListArray();
\r
2591 m_LogList.Invalidate();
\r
2592 UpdateLogInfoLabel();
\r
2593 // the "next 100" button only makes sense if the log messages
\r
2594 // are sorted by revision in descending order
\r
2595 if ((m_nSortColumn)||(m_bAscending))
\r
2597 DialogEnableWindow(IDC_NEXTHUNDRED, false);
\r
2601 DialogEnableWindow(IDC_NEXTHUNDRED, true);
\r
2606 void CLogDlg::SortShownListArray()
\r
2608 // make sure the shown list still matches the filter after sorting.
\r
2609 OnTimer(LOGFILTER_TIMER);
\r
2610 // clear the selection states
\r
2611 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2614 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
\r
2616 m_LogList.SetSelectionMark(-1);
\r
2619 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
\r
2621 if (control == NULL)
\r
2623 // set the sort arrow
\r
2624 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
\r
2625 HDITEM HeaderItem = {0};
\r
2626 HeaderItem.mask = HDI_FORMAT;
\r
2627 for (int i=0; i<pHeader->GetItemCount(); ++i)
\r
2629 pHeader->GetItem(i, &HeaderItem);
\r
2630 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
\r
2631 pHeader->SetItem(i, &HeaderItem);
\r
2635 pHeader->GetItem(nColumn, &HeaderItem);
\r
2636 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
\r
2637 pHeader->SetItem(nColumn, &HeaderItem);
\r
2640 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2643 if (this->IsThreadRunning())
\r
2644 return; //no sorting while the arrays are filled
\r
2645 if (m_currentChangedArray == NULL)
\r
2647 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2648 const int nColumn = pNMLV->iSubItem;
\r
2649 m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;
\r
2650 m_nSortColumnPathList = nColumn;
\r
2651 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
\r
2653 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
2654 m_ChangedFileListCtrl.Invalidate();
\r
2659 int CLogDlg::m_nSortColumnPathList = 0;
\r
2660 bool CLogDlg::m_bAscendingPathList = false;
\r
2662 int CLogDlg::SortCompare(const void * pElem1, const void * pElem2)
\r
2665 LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);
\r
2666 LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);
\r
2668 if (m_bAscendingPathList)
\r
2669 std::swap (cpath1, cpath2);
\r
2672 switch (m_nSortColumnPathList)
\r
2675 cmp = cpath2->GetAction().Compare(cpath1->GetAction());
\r
2680 cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);
\r
2684 case 2: // copy from path
\r
2685 cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);
\r
2689 case 3: // copy from revision
\r
2690 return cpath2->lCopyFromRev > cpath1->lCopyFromRev;
\r
2697 void CLogDlg::ResizeAllListCtrlCols()
\r
2700 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
2701 int maxcol = ((CHeaderCtrl*)(m_LogList.GetDlgItem(0)))->GetItemCount()-1;
\r
2702 int nItemCount = m_LogList.GetItemCount();
\r
2703 TCHAR textbuf[MAX_PATH];
\r
2704 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(m_LogList.GetDlgItem(0));
\r
2707 for (int col = 0; col <= maxcol; col++)
\r
2710 hdi.mask = HDI_TEXT;
\r
2711 hdi.pszText = textbuf;
\r
2712 hdi.cchTextMax = sizeof(textbuf);
\r
2713 pHdrCtrl->GetItem(col, &hdi);
\r
2714 int cx = m_LogList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
2715 for (int index = 0; index<nItemCount; ++index)
\r
2717 // get the width of the string and add 14 pixels for the column separator and margins
\r
2718 int linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;
\r
2719 if (index < m_arShownList.GetCount())
\r
2721 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
2722 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
2724 // set the bold font and ask for the string width again
\r
2725 m_LogList.SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
2726 linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;
\r
2727 // restore the system font
\r
2728 m_LogList.SendMessage(WM_SETFONT, NULL, NULL);
\r
2733 // add the image size
\r
2734 CImageList * pImgList = m_LogList.GetImageList(LVSIL_SMALL);
\r
2735 if ((pImgList)&&(pImgList->GetImageCount()))
\r
2737 IMAGEINFO imginfo;
\r
2738 pImgList->GetImageInfo(0, &imginfo);
\r
2739 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
2740 linewidth += 3; // 3 pixels between icon and text
\r
2743 if (cx < linewidth)
\r
2746 // Adjust columns "Actions" containing icons
\r
2747 if (col == this->LOGLIST_ACTION)
\r
2749 if (cx < nMinimumWidth)
\r
2751 cx = nMinimumWidth;
\r
2755 if (col == this->LOGLIST_MESSAGE)
\r
2757 if (cx > LOGLIST_MESSAGE_MAX)
\r
2759 cx = LOGLIST_MESSAGE_MAX;
\r
2763 // keep the bug id column small
\r
2764 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
2766 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
2768 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
2772 m_LogList.SetColumnWidth(col, cx);
\r
2779 void CLogDlg::OnBnClickedHidepaths()
\r
2781 FillLogMessageCtrl();
\r
2782 m_ChangedFileListCtrl.Invalidate();
\r
2787 void CLogDlg::OnBnClickedCheckStoponcopy()
\r
2790 if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
2793 // ignore old fetch limits when switching
\r
2794 // between copy-following and stop-on-copy
\r
2795 // (otherwise stop-on-copy will limit what
\r
2796 // we see immediately after switching to
\r
2797 // copy-following)
\r
2801 // now, restart the query
\r
2806 void CLogDlg::OnBnClickedIncludemerge()
\r
2816 void CLogDlg::UpdateLogInfoLabel()
\r
2819 git_revnum_t rev1 ;
\r
2820 git_revnum_t rev2 ;
\r
2821 long selectedrevs ;
\r
2822 int count =m_LogList.m_arShownList.GetCount();
\r
2825 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(0)))->m_CommitHash;
\r
2826 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
\r
2827 rev2 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;
\r
2828 selectedrevs = m_LogList.GetSelectedCount();
\r
2831 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);
\r
2832 m_sLogInfo = sTemp;
\r
2834 UpdateData(FALSE);
\r
2838 void CLogDlg::ShowContextMenuForChangedpaths(CWnd* /*pWnd*/, CPoint point)
\r
2841 int selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
2842 if ((point.x == -1) && (point.y == -1))
\r
2845 m_ChangedFileListCtrl.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
2846 m_ChangedFileListCtrl.ClientToScreen(&rect);
\r
2847 point = rect.CenterPoint();
\r
2851 int s = m_LogList.GetSelectionMark();
\r
2854 std::vector<CString> changedpaths;
\r
2855 std::vector<LogChangedPath*> changedlogpaths;
\r
2856 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2858 return; // nothing is selected, get out of here
\r
2860 bool bOneRev = true;
\r
2861 int sel=m_LogList.GetNextSelectedItem(pos);
\r
2862 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel));
\r
2863 GitRev * rev1 = pLogEntry;
\r
2864 GitRev * rev2 = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel+1));
\r
2866 bool bOneRev = true;
\r
2871 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
2874 rev1 = max(rev1,(git_revnum_t)pLogEntry->Rev);
\r
2875 rev2 = min(rev2,(git_revnum_t)pLogEntry->Rev);
\r
2881 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2884 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2885 changedpaths.push_back(m_currentChangedPathList[nItem].GetGitPathString());
\r
2890 // only one revision is selected in the log dialog top pane
\r
2891 // but multiple items could be selected in the changed items list
\r
2894 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2897 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2898 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
2900 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2902 if ((changedlogpath)&&(!changedlogpath->sCopyFromPath.IsEmpty()))
\r
2903 rev2 = changedlogpath->lCopyFromRev;
\r
2906 // if the path was modified but the parent path was 'added with history'
\r
2907 // then we have to use the copy from revision of the parent path
\r
2908 CTGitPath cpath = CTGitPath(changedlogpath->sPath);
\r
2909 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
2911 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
2912 if (p.IsAncestorOf(cpath))
\r
2914 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
2915 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
2920 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
2922 // some items are hidden! So find out which item the user really clicked on
\r
2923 INT_PTR selRealIndex = -1;
\r
2924 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
2926 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
2928 if (selRealIndex == nItem)
\r
2930 selIndex = hiddenindex;
\r
2931 changedlogpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
2936 if (changedlogpath)
\r
2938 changedpaths.push_back(changedlogpath->sPath);
\r
2939 changedlogpaths.push_back(changedlogpath);
\r
2944 //entry is selected, now show the popup menu
\r
2946 if (popup.CreatePopupMenu())
\r
2948 bool bEntryAdded = false;
\r
2949 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2951 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
\r
2953 popup.AppendMenuIcon(CGitLogList::ID_DIFF, IDS_LOG_POPUP_DIFF, IDI_DIFF);
\r
2954 popup.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF, IDS_LOG_POPUP_BLAMEDIFF, IDI_BLAME);
\r
2955 popup.SetDefaultItem(CGitLogList::ID_DIFF, FALSE);
\r
2956 popup.AppendMenuIcon(CGitLogList::ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
2957 bEntryAdded = true;
\r
2959 // if (rev2 == rev1-1)
\r
2962 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2963 popup.AppendMenuIcon(CGitLogList::ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
2964 popup.AppendMenuIcon(CGitLogList::ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
2965 popup.AppendMenuIcon(CGitLogList::ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
2966 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2968 popup.AppendMenuIcon(CGitLogList::ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
2969 popup.AppendMenuIcon(CGitLogList::ID_POPPROPS, IDS_REPOBROWSE_SHOWPROP, IDI_PROPERTIES); // "Show Properties"
\r
2970 popup.AppendMenuIcon(CGitLogList::ID_LOG, IDS_MENULOG, IDI_LOG); // "Show Log"
\r
2971 popup.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS, IDS_LOG_POPUP_GETMERGELOGS, IDI_LOG); // "Show merge log"
\r
2972 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
2973 bEntryAdded = true;
\r
2974 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
2976 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2977 popup.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
2979 if (popup.GetDefaultItem(0,FALSE)==-1)
\r
2980 popup.SetDefaultItem(CGitLogList::ID_OPEN, FALSE);
\r
2983 else if (changedlogpaths.size())
\r
2985 // more than one entry is selected
\r
2986 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE);
\r
2987 bEntryAdded = true;
\r
2992 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2993 bool bOpenWith = false;
\r
2994 bool bMergeLog = false;
\r
2995 m_bCancelled = false;
\r
2999 case CGitLogList::ID_DIFF:
\r
3001 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
3005 case ID_BLAMEDIFF:
\r
3007 DoDiffFromLog(selIndex, rev1, rev2, true, false);
\r
3012 DoDiffFromLog(selIndex, rev1, rev2, false, true);
\r
3015 case ID_REVERTREV:
\r
3017 SetPromptApp(&theApp);
\r
3018 theApp.DoWaitCursor(1);
\r
3020 if (Git::PathIsURL(m_path))
\r
3022 sUrl = m_path.GetGitPathString();
\r
3026 sUrl = GetURLFromPath(m_path);
\r
3027 if (sUrl.IsEmpty())
\r
3029 theApp.DoWaitCursor(-1);
\r
3031 temp.Format(IDS_ERR_NOURLOFFILE, m_path.GetWinPath());
\r
3032 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3034 theApp.DoWaitCursor(-1);
\r
3038 // find the working copy path of the selected item from the URL
\r
3039 m_bCancelled = false;
\r
3040 CString sUrlRoot = GetRepositoryRoot(CTGitPath(sUrl));
\r
3042 CString fileURL = changedpaths[0];
\r
3043 fileURL = sUrlRoot + fileURL.Trim();
\r
3044 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
\r
3045 // sUrl = http://mydomain.com/repos/trunk/folder
\r
3046 CString sUnescapedUrl = CPathUtils::PathUnescape(sUrl);
\r
3047 // find out until which char the urls are identical
\r
3049 while ((i<fileURL.GetLength())&&(i<sUnescapedUrl.GetLength())&&(fileURL[i]==sUnescapedUrl[i]))
\r
3051 int leftcount = m_path.GetWinPathString().GetLength()-(sUnescapedUrl.GetLength()-i);
\r
3052 CString wcPath = m_path.GetWinPathString().Left(leftcount);
\r
3053 wcPath += fileURL.Mid(i);
\r
3054 wcPath.Replace('/', '\\');
\r
3055 CGitProgressDlg dlg;
\r
3056 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
3058 // a deleted path! Since the path isn't there anymore, merge
\r
3059 // won't work. So just do a copy url->wc
\r
3060 dlg.SetCommand(CGitProgressDlg::GitProgress_Copy);
\r
3061 dlg.SetPathList(CTGitPathList(CTGitPath(fileURL)));
\r
3062 dlg.SetUrl(wcPath);
\r
3063 dlg.SetRevision(rev2);
\r
3067 if (!PathFileExists(wcPath))
\r
3069 // seems the path got renamed
\r
3070 // tell the user how to work around this.
\r
3071 CMessageBox::Show(this->m_hWnd, IDS_LOG_REVERTREV_ERROR, IDS_APPNAME, MB_ICONERROR);
\r
3073 theApp.DoWaitCursor(-1);
\r
3076 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
3077 dlg.SetPathList(CTGitPathList(CTGitPath(wcPath)));
\r
3078 dlg.SetUrl(fileURL);
\r
3079 dlg.SetSecondUrl(fileURL);
\r
3080 GitRevRangeArray revarray;
\r
3081 revarray.AddRevRange(rev1, rev2);
\r
3082 dlg.SetRevisionRanges(revarray);
\r
3085 msg.Format(IDS_LOG_REVERT_CONFIRM, (LPCTSTR)wcPath);
\r
3086 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
3090 theApp.DoWaitCursor(-1);
\r
3095 DialogEnableWindow(IDOK, FALSE);
\r
3096 SetPromptApp(&theApp);
\r
3097 theApp.DoWaitCursor(1);
\r
3099 if (Git::PathIsURL(m_path))
\r
3101 filepath = m_path.GetGitPathString();
\r
3105 filepath = GetURLFromPath(m_path);
\r
3106 if (filepath.IsEmpty())
\r
3108 theApp.DoWaitCursor(-1);
\r
3110 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3111 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3112 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3117 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
3118 filepath += changedpaths[0];
\r
3121 dlg.m_Path = CTGitPath(filepath);
\r
3124 theApp.DoWaitCursor(-1);
\r
3129 DialogEnableWindow(IDOK, FALSE);
\r
3130 SetPromptApp(&theApp);
\r
3131 theApp.DoWaitCursor(1);
\r
3133 if (Git::PathIsURL(m_path))
\r
3135 filepath = m_path.GetGitPathString();
\r
3139 filepath = GetURLFromPath(m_path);
\r
3140 if (filepath.IsEmpty())
\r
3142 theApp.DoWaitCursor(-1);
\r
3144 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3145 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3146 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3151 m_bCancelled = false;
\r
3152 CString sRoot = GetRepositoryRoot(CTGitPath(filepath));
\r
3153 // if more than one entry is selected, we save them
\r
3154 // one by one into a folder the user has selected
\r
3155 bool bTargetSelected = false;
\r
3156 CTGitPath TargetPath;
\r
3157 if (m_ChangedFileListCtrl.GetSelectedCount() > 1)
\r
3159 CBrowseFolder browseFolder;
\r
3160 browseFolder.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT)));
\r
3161 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
\r
3162 CString strSaveAsDirectory;
\r
3163 if (browseFolder.Show(GetSafeHwnd(), strSaveAsDirectory) == CBrowseFolder::OK)
\r
3165 TargetPath = CTGitPath(strSaveAsDirectory);
\r
3166 bTargetSelected = true;
\r
3171 // Display the Open dialog box.
\r
3172 CString revFilename;
\r
3174 temp = CPathUtils::GetFileNameFromPath(changedpaths[0]);
\r
3175 int rfind = temp.ReverseFind('.');
\r
3177 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)temp.Left(rfind), rev1, (LPCTSTR)temp.Mid(rfind));
\r
3179 revFilename.Format(_T("%s-%ld"), (LPCTSTR)temp, rev1);
\r
3180 bTargetSelected = CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd);
\r
3181 TargetPath.SetFromWin(revFilename);
\r
3183 if (bTargetSelected)
\r
3185 CProgressDlg progDlg;
\r
3186 progDlg.SetTitle(IDS_APPNAME);
\r
3187 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
3188 for (std::vector<LogChangedPath*>::iterator it = changedlogpaths.begin(); it!= changedlogpaths.end(); ++it)
\r
3190 GitRev getrev = ((*it)->action == LOGACTIONS_DELETED) ? rev2 : rev1;
\r
3192 CString sInfoLine;
\r
3193 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)getrev.ToString());
\r
3194 progDlg.SetLine(1, sInfoLine, true);
\r
3195 SetAndClearProgressInfo(&progDlg);
\r
3196 progDlg.ShowModeless(m_hWnd);
\r
3198 CTGitPath tempfile = TargetPath;
\r
3199 if (changedpaths.size() > 1)
\r
3201 // if multiple items are selected, then the TargetPath
\r
3202 // points to a folder and we have to append the filename
\r
3203 // to save to to that folder.
\r
3204 CString sName = (*it)->sPath;
\r
3205 int slashpos = sName.ReverseFind('/');
\r
3206 if (slashpos >= 0)
\r
3207 sName = sName.Mid(slashpos);
\r
3208 tempfile.AppendPathString(sName);
\r
3209 // one problem here:
\r
3210 // a user could have selected multiple items which
\r
3211 // have the same filename but reside in different
\r
3212 // directories, e.g.
\r
3215 // in that case, the second 'file1' will overwrite
\r
3216 // the already saved 'file1'.
\r
3218 // we could maybe find the common root of all selected
\r
3219 // items and then create sub folders to save those files
\r
3221 // But I think we should just leave it that way: to check
\r
3222 // out multiple items at once, the better way is still to
\r
3223 // use the export command from the top pane of the log dialog.
\r
3225 filepath = sRoot + (*it)->sPath;
\r
3226 if (!Cat(CTGitPath(filepath), getrev, getrev, tempfile))
\r
3229 SetAndClearProgressInfo((HWND)NULL);
\r
3230 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
3232 theApp.DoWaitCursor(-1);
\r
3237 SetAndClearProgressInfo((HWND)NULL);
\r
3240 theApp.DoWaitCursor(-1);
\r
3247 GitRev getrev = pLogEntry->pArChangedPaths->GetAt(selIndex)->action == LOGACTIONS_DELETED ? rev2 : rev1;
\r
3248 Open(bOpenWith,changedpaths[0],getrev);
\r
3254 if (Git::PathIsURL(m_path))
\r
3256 filepath = m_path.GetGitPathString();
\r
3260 filepath = GetURLFromPath(m_path);
\r
3261 if (filepath.IsEmpty())
\r
3263 theApp.DoWaitCursor(-1);
\r
3265 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3266 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3267 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3272 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
3273 filepath += changedpaths[0];
\r
3275 dlg.EndRev = rev1;
\r
3276 if (dlg.DoModal() == IDOK)
\r
3281 tempfile = blame.BlameToTempFile(CTGitPath(filepath), dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
3282 if (!tempfile.IsEmpty())
\r
3284 if (dlg.m_bTextView)
\r
3286 //open the default text editor for the result file
\r
3287 CAppUtils::StartTextViewer(tempfile);
\r
3291 CString sParams = _T("/path:\"") + filepath + _T("\" ");
\r
3292 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(filepath),sParams))
\r
3300 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
3305 case ID_GETMERGELOGS:
\r
3310 DialogEnableWindow(IDOK, FALSE);
\r
3311 SetPromptApp(&theApp);
\r
3312 theApp.DoWaitCursor(1);
\r
3314 if (Git::PathIsURL(m_path))
\r
3316 filepath = m_path.GetGitPathString();
\r
3320 filepath = GetURLFromPath(m_path);
\r
3321 if (filepath.IsEmpty())
\r
3323 theApp.DoWaitCursor(-1);
\r
3325 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3326 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3327 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3332 m_bCancelled = false;
\r
3333 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
3334 filepath += changedpaths[0];
\r
3335 git_revnum_t logrev = rev1;
\r
3336 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
3338 // if the item got deleted in this revision,
\r
3339 // fetch the log from the previous revision where it
\r
3344 sCmd.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR)filepath, logrev);
\r
3346 sCmd += _T(" /merge");
\r
3347 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
3349 theApp.DoWaitCursor(-1);
\r
3352 case ID_VIEWPATHREV:
\r
3354 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetSelectionMark()));
\r
3355 GitRev rev = pLogEntry->Rev;
\r
3356 CString relurl = changedpaths[0];
\r
3357 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
3358 url.Replace(_T("%REVISION%"), rev.ToString());
\r
3359 url.Replace(_T("%PATH%"), relurl);
\r
3360 relurl = relurl.Mid(relurl.Find('/'));
\r
3361 url.Replace(_T("%PATH1%"), relurl);
\r
3362 if (!url.IsEmpty())
\r
3363 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
3371 } // if (popup.CreatePopupMenu())
\r
3375 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3377 // the date control should not show the "today" button
\r
3378 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
\r
3380 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
3384 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3386 // the date control should not show the "today" button
\r
3387 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
\r
3389 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
3393 void CLogDlg::OnSize(UINT nType, int cx, int cy)
\r
3395 __super::OnSize(nType, cx, cy);
\r
3397 SetSplitterRange();
\r
3400 void CLogDlg::OnRefresh()
\r
3402 if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
3409 void CLogDlg::OnFind()
\r
3411 if (!m_pFindDialog)
\r
3413 m_pFindDialog = new CFindReplaceDialog();
\r
3414 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
3418 void CLogDlg::OnFocusFilter()
\r
3420 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3423 void CLogDlg::OnEditCopy()
\r
3425 if (GetFocus() == &m_ChangedFileListCtrl)
\r
3426 CopyChangedSelectionToClipBoard();
\r
3428 m_LogList.CopySelectionToClipBoard();
\r
3431 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
\r
3433 // is the URL a relative one?
\r
3434 if (url.Left(2).Compare(_T("^/")) == 0)
\r
3436 // URL is relative to the repository root
\r
3437 CString url1 = m_sRepositoryRoot + url.Mid(1);
\r
3438 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
3439 DWORD len = url.GetLength();
\r
3440 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
\r
3441 return CString(buf, len);
\r
3444 else if (url[0] == '/')
\r
3446 // URL is relative to the server's hostname
\r
3448 // find the server's hostname
\r
3449 int schemepos = m_sRepositoryRoot.Find(_T("//"));
\r
3450 if (schemepos >= 0)
\r
3452 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
\r
3453 CString url1 = sHost + url;
\r
3454 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
3455 DWORD len = url.GetLength();
\r
3456 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
\r
3457 return CString(buf, len);
\r
3465 void CLogDlg::OnEnChangeSearchedit()
\r
3468 if (m_LogList.m_sFilterText.IsEmpty())
\r
3470 CStoreSelection storeselection(this);
\r
3471 // clear the filter, i.e. make all entries appear
\r
3472 theApp.DoWaitCursor(1);
\r
3473 KillTimer(LOGFILTER_TIMER);
\r
3474 FillLogMessageCtrl(false);
\r
3475 m_LogList.StartFilter();
\r
3477 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3478 m_arShownList.RemoveAll();
\r
3479 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3481 if (IsEntryInDateRange(i))
\r
3482 m_arShownList.Add(m_logEntries[i]);
\r
3484 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3485 m_LogList.DeleteAllItems();
\r
3486 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3487 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3488 m_LogList.SetRedraw(false);
\r
3489 ResizeAllListCtrlCols();
\r
3490 m_LogList.SetRedraw(true);
\r
3492 theApp.DoWaitCursor(-1);
\r
3493 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3494 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3495 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3496 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
3499 if (Validate(m_LogList.m_sFilterText))
\r
3500 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3502 KillTimer(LOGFILTER_TIMER);
\r