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_MESSAGE(MSG_LOAD_PERCENTAGE,OnLogListLoading)
\r
129 ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)
\r
131 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)
\r
132 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)
\r
133 ON_BN_CLICKED(IDC_NEXTHUNDRED, OnBnClickedNexthundred)
\r
134 //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
\r
135 //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
\r
136 ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST , OnLvnColumnclick)
\r
137 //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
\r
138 ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)
\r
140 ON_BN_CLICKED(IDC_CHECK_STOPONCOPY, &CLogDlg::OnBnClickedCheckStoponcopy)
\r
141 ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)
\r
142 ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)
\r
144 ON_BN_CLICKED(IDC_INCLUDEMERGE, &CLogDlg::OnBnClickedIncludemerge)
\r
145 ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)
\r
146 ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)
\r
147 ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)
\r
148 ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)
\r
149 ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)
\r
152 void CLogDlg::SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit, BOOL bStrict /* = FALSE */, BOOL bSaveStrict /* = TRUE */)
\r
156 m_startrev = startrev;
\r
157 m_LogRevision = startrev;
\r
159 m_hasWC = !path.IsUrl();
\r
160 m_bStrict = bStrict;
\r
161 m_bSaveStrict = bSaveStrict;
\r
163 if (::IsWindow(m_hWnd))
\r
167 BOOL CLogDlg::OnInitDialog()
\r
169 CResizableStandAloneDialog::OnInitDialog();
\r
171 m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));
\r
173 OSVERSIONINFOEX inf;
\r
174 SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
\r
175 inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
\r
176 GetVersionEx((OSVERSIONINFO *)&inf);
\r
177 WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);
\r
178 m_bVista = (fullver >= 0x0600);
\r
180 // use the state of the "stop on copy/rename" option from the last time
\r
182 m_bStrict = m_regLastStrict;
\r
186 temp.Format(IDS_LOG_SHOWNEXT, m_limit);
\r
188 temp.Format(IDS_LOG_SHOWNEXT, (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100));
\r
190 SetDlgItemText(IDC_NEXTHUNDRED, temp);
\r
192 // set the font to use in the log message view, configured in the settings dialog
\r
193 CAppUtils::CreateFontForLogs(m_logFont);
\r
194 GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);
\r
195 // automatically detect URLs in the log message and turn them into links
\r
196 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);
\r
197 // make the log message rich edit control send a message when the mouse pointer is over a link
\r
198 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);
\r
199 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
201 // the "hide unrelated paths" checkbox should be indeterminate
\r
202 m_cHidePaths.SetCheck(BST_INDETERMINATE);
\r
205 // if there is a working copy, load the project properties
\r
206 // to get information about the bugtraq: integration
\r
208 m_ProjectProperties.ReadProps(m_path);
\r
210 // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set
\r
211 if ((!m_ProjectProperties.sUrl.IsEmpty())||(!m_ProjectProperties.sCheckRe.IsEmpty()))
\r
212 m_bShowBugtraqColumn = true;
\r
214 //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
\r
215 //theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
\r
217 // set up the columns
\r
218 m_LogList.DeleteAllItems();
\r
219 m_LogList.InsertGitColumn();
\r
221 m_ChangedFileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |IDS_STATUSLIST_COLADD|IDS_STATUSLIST_COLDEL , _T("LogDlg"),(SVNSLC_POPALL ^ SVNSLC_POPCOMMIT),false);
\r
223 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
226 m_sMessageBuf.Preallocate(100000);
\r
228 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
\r
229 SetDlgTitle(false);
\r
231 m_tooltips.Create(this);
\r
232 CheckRegexpTooltip();
\r
234 SetSplitterRange();
\r
236 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
\r
237 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
\r
238 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
\r
239 m_cFilter.SetValidator(this);
\r
241 AdjustControlSize(IDC_HIDEPATHS);
\r
242 AdjustControlSize(IDC_CHECK_STOPONCOPY);
\r
243 AdjustControlSize(IDC_INCLUDEMERGE);
\r
245 GetClientRect(m_DlgOrigRect);
\r
246 m_LogList.GetClientRect(m_LogListOrigRect);
\r
247 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
\r
248 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
\r
250 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
251 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
254 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
\r
255 AddAnchor(IDC_DATEFROM, TOP_LEFT);
\r
256 AddAnchor(IDC_TOLABEL, TOP_LEFT);
\r
257 AddAnchor(IDC_DATETO, TOP_LEFT);
\r
259 SetFilterCueText();
\r
260 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
\r
262 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
263 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
264 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
265 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
266 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
268 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
269 AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);
\r
270 AddAnchor(IDC_CHECK_STOPONCOPY, BOTTOM_LEFT);
\r
271 AddAnchor(IDC_INCLUDEMERGE, BOTTOM_LEFT);
\r
272 AddAnchor(IDC_GETALL, BOTTOM_LEFT);
\r
273 AddAnchor(IDC_NEXTHUNDRED, BOTTOM_LEFT);
\r
274 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
\r
275 AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);
\r
276 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
277 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
278 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
279 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
281 // SetPromptParentWindow(m_hWnd);
\r
284 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
285 EnableSaveRestore(_T("LogDlg"));
\r
287 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
288 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
289 RECT rcDlg, rcLogList, rcChgMsg;
\r
290 GetClientRect(&rcDlg);
\r
291 m_LogList.GetWindowRect(&rcLogList);
\r
292 ScreenToClient(&rcLogList);
\r
293 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
\r
294 ScreenToClient(&rcChgMsg);
\r
298 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
299 ScreenToClient(&rectSplitter);
\r
300 int delta = yPos1 - rectSplitter.top;
\r
302 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
\r
304 m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);
\r
311 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
312 ScreenToClient(&rectSplitter);
\r
313 int delta = yPos2 - rectSplitter.top;
\r
315 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
\r
317 m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);
\r
325 // the dialog is used to select revisions
\r
326 if (m_bSelectionMustBeContinuous)
\r
327 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
\r
329 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
333 // the dialog is used to just view log messages
\r
334 GetDlgItemText(IDOK, temp);
\r
335 SetDlgItemText(IDCANCEL, temp);
\r
336 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
\r
339 // set the choices for the "Show All" button
\r
340 temp.LoadString(IDS_LOG_SHOWALL);
\r
341 m_btnShow.AddEntry(temp);
\r
342 temp.LoadString(IDS_LOG_SHOW_WHOLE);
\r
343 m_btnShow.AddEntry(temp);
\r
344 m_btnShow.SetCurrentEntry((LONG)CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry")));
\r
346 m_mergedRevs.clear();
\r
348 // first start a thread to obtain the log messages without
\r
349 // blocking the dialog
\r
351 //m_tFrom = (DWORD)-1;
\r
353 m_LogList.m_Path=m_path;
\r
354 m_LogList.FetchLogAsync(this);
\r
356 GetDlgItem(IDC_LOGLIST)->SetFocus();
\r
360 LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM lParam)
\r
362 int cur=(int)wParam;
\r
364 if( cur == GITLOG_START )
\r
367 temp.LoadString(IDS_PROGRESSWAIT);
\r
369 // change the text of the close button to "Cancel" since now the thread
\r
370 // is running, and simply closing the dialog doesn't work.
\r
371 if (!GetDlgItem(IDOK)->IsWindowVisible())
\r
373 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
374 SetDlgItemText(IDCANCEL, temp);
\r
377 // We use a progress bar while getting the logs
\r
378 m_LogProgress.SetRange32(0, 100);
\r
379 m_LogProgress.SetPos(0);
\r
381 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
\r
383 //DialogEnableWindow(IDC_GETALL, FALSE);
\r
384 DialogEnableWindow(IDC_NEXTHUNDRED, FALSE);
\r
385 DialogEnableWindow(IDC_CHECK_STOPONCOPY, FALSE);
\r
386 DialogEnableWindow(IDC_INCLUDEMERGE, FALSE);
\r
387 DialogEnableWindow(IDC_STATBUTTON, FALSE);
\r
388 DialogEnableWindow(IDC_REFRESH, FALSE);
\r
389 DialogEnableWindow(IDC_HIDEPATHS,FALSE);
\r
392 if( cur == GITLOG_END)
\r
396 DialogEnableWindow(IDC_NEXTHUNDRED, TRUE);
\r
398 DialogEnableWindow(IDC_GETALL, TRUE);
\r
399 //DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);
\r
400 DialogEnableWindow(IDC_STATBUTTON, TRUE);
\r
401 DialogEnableWindow(IDC_REFRESH, TRUE);
\r
403 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
\r
405 //CTime time=m_LogList.GetOldestTime();
\r
407 m_LogList.GetTimeRange(begin,end);
\r
408 m_DateFrom.SetTime(&begin);
\r
409 m_DateTo.SetTime(&end);
\r
412 m_LogProgress.SetPos(cur);
\r
415 void CLogDlg::SetDlgTitle(bool bOffline)
\r
417 if (m_sTitle.IsEmpty())
\r
418 GetWindowText(m_sTitle);
\r
423 if (m_path.IsUrl())
\r
424 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());
\r
425 else if (m_path.IsDirectory())
\r
426 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());
\r
428 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());
\r
429 SetWindowText(sTemp);
\r
433 if (m_path.IsUrl())
\r
434 SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());
\r
435 else if (m_path.IsEmpty())
\r
436 SetWindowText(m_sTitle + _T(" - ") + CString(_T("Whole Project")));
\r
437 else if (m_path.IsDirectory())
\r
438 SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());
\r
440 SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());
\r
444 void CLogDlg::CheckRegexpTooltip()
\r
446 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
\r
447 // Since tooltip describes regexp features, show it only if regexps are enabled.
\r
448 if (m_bFilterWithRegex)
\r
450 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
\r
453 m_tooltips.DelTool(pWnd);
\r
456 void CLogDlg::EnableOKButton()
\r
460 // the dialog is used to select revisions
\r
461 if (m_bSelectionMustBeContinuous)
\r
462 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
\r
464 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
467 DialogEnableWindow(IDOK, TRUE);
\r
470 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
\r
472 // we fill here the log message rich edit control,
\r
473 // and also populate the changed files list control
\r
474 // according to the selected revision(s).
\r
476 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
477 // empty the log message view
\r
478 pMsgView->SetWindowText(_T(" "));
\r
479 // empty the changed files list
\r
480 m_ChangedFileListCtrl.SetRedraw(FALSE);
\r
481 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
482 m_currentChangedArray = NULL;
\r
483 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
484 m_ChangedFileListCtrl.DeleteAllItems();
\r
486 // if we're not here to really show a selected revision, just
\r
487 // get out of here after clearing the views, which is what is intended
\r
488 // if that flag is not set.
\r
492 m_ChangedFileListCtrl.Invalidate();
\r
493 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
494 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
498 // depending on how many revisions are selected, we have to do different
\r
500 int selCount = m_LogList.GetSelectedCount();
\r
503 // if nothing is selected, we have nothing more to do
\r
504 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
505 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
508 else if (selCount == 1)
\r
510 // if one revision is selected, we have to fill the log message view
\r
511 // with the corresponding log message, and also fill the changed files
\r
513 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
514 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
515 if (selIndex >= m_LogList.m_arShownList.GetCount())
\r
517 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
518 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
521 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));
\r
523 if(!pLogEntry->m_IsFull)
\r
525 pMsgView->SetWindowText(_T("load ..."));
\r
528 // set the log message text
\r
529 pMsgView->SetWindowText(_T("Commit:")+pLogEntry->m_CommitHash+_T("\r\n\r\n*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);
\r
530 // turn bug ID's into links if the bugtraq: properties have been set
\r
531 // and we can find a match of those in the log message
\r
532 m_ProjectProperties.FindBugID(pLogEntry->m_Body, pMsgView);
\r
533 CAppUtils::FormatTextInRichEditControl(pMsgView);
\r
535 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->m_Files);
\r
536 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;
\r
537 m_ChangedFileListCtrl.Show(SVNSLC_SHOWVERSIONED);
\r
539 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
543 // fill in the changed files list control
\r
544 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
546 m_CurrentFilteredChangedArray.RemoveAll();
\r
547 for (INT_PTR c = 0; c < m_currentChangedArray->GetCount(); ++c)
\r
549 LogChangedPath * cpath = m_currentChangedArray->GetAt(c);
\r
552 if (m_currentChangedArray->GetAt(c)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
554 m_CurrentFilteredChangedArray.Add(cpath);
\r
557 m_currentChangedArray = &m_CurrentFilteredChangedArray;
\r
563 // more than one revision is selected:
\r
564 // the log message view must be emptied
\r
565 // the changed files list contains all the changed paths from all
\r
566 // selected revisions, with 'doubles' removed
\r
567 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
\r
570 // redraw the views
\r
571 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
573 if (m_currentChangedArray)
\r
575 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
\r
576 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
\r
578 else if (m_currentChangedPathList.GetCount())
\r
580 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
\r
581 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
\r
585 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
586 m_ChangedFileListCtrl.Invalidate();
\r
589 // sort according to the settings
\r
590 if (m_nSortColumnPathList > 0)
\r
591 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
593 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
\r
594 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
598 void CLogDlg::OnBnClickedGetall()
\r
603 void CLogDlg::GetAll(bool bForceAll /* = false */)
\r
606 // fetch all requested log messages, either the specified range or
\r
607 // really *all* available log messages.
\r
609 INT_PTR entry = m_btnShow.GetCurrentEntry();
\r
615 case 0: // show all branch;
\r
616 m_LogList.m_bAllBranch=true;
\r
618 case 1: // show whole project
\r
619 m_LogList.m_Path.Reset();
\r
620 SetWindowText(m_sTitle + _T(" - "));
\r
623 m_LogList.m_bExitThread=TRUE;
\r
624 DWORD ret =::WaitForSingleObject(m_LogList.m_LoadingThread->m_hThread,20000);
\r
625 if(ret == WAIT_TIMEOUT)
\r
626 m_LogList.TerminateThread();
\r
629 m_LogList.FetchLogAsync(this);
\r
633 void CLogDlg::OnBnClickedRefresh()
\r
639 void CLogDlg::Refresh (bool autoGoOnline)
\r
641 m_LogList.Refresh();
\r
644 void CLogDlg::OnBnClickedNexthundred()
\r
648 // we have to fetch the next X log messages.
\r
649 if (m_logEntries.size() < 1)
\r
651 // since there weren't any log messages fetched before, just
\r
652 // fetch all since we don't have an 'anchor' to fetch the 'next'
\r
654 return GetAll(true);
\r
656 git_revnum_t rev = m_logEntries[m_logEntries.size()-1]->Rev;
\r
659 return; // do nothing! No more revisions to get
\r
663 m_bCancelled = FALSE;
\r
665 // rev is is revision we already have and we will receive it again
\r
666 // -> fetch one extra revision to get NumberOfLogs *new* revisions
\r
668 m_limit = (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;
\r
669 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
670 SetSortArrow(&m_LogList, -1, true);
\r
671 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
672 // We need to create CStoreSelection on the heap or else
\r
673 // the variable will run out of the scope before the
\r
674 // thread ends. Therefore we let the thread delete
\r
676 m_pStoreSelection = new CStoreSelection(this);
\r
678 // since we fetch the log from the last revision we already have,
\r
679 // we have to remove that revision entry to avoid getting it twice
\r
680 m_logEntries.pop_back();
\r
681 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
683 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
684 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
686 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
687 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
691 BOOL CLogDlg::Cancel()
\r
693 return m_bCancelled;
\r
696 void CLogDlg::SaveSplitterPos()
\r
700 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
701 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
703 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
704 ScreenToClient(&rectSplitter);
\r
705 regPos1 = rectSplitter.top;
\r
706 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
707 ScreenToClient(&rectSplitter);
\r
708 regPos2 = rectSplitter.top;
\r
712 void CLogDlg::OnCancel()
\r
714 // canceling means stopping the working thread if it's still running.
\r
715 // we do this by using the Subversion cancel callback.
\r
716 // But canceling can also mean just to close the dialog, depending on the
\r
717 // text shown on the cancel button (it could simply read "OK").
\r
718 CString temp, temp2;
\r
719 GetDlgItemText(IDOK, temp);
\r
720 temp2.LoadString(IDS_MSGBOX_CANCEL);
\r
721 if ((temp.Compare(temp2)==0)||(this->IsThreadRunning()))
\r
723 //m_bCancelled = true;
\r
725 if(m_LogList.m_bThreadRunning)
\r
727 //m_LogList.m_bExitThread=true;
\r
728 //WaitForSingleObject(m_LogList.m_LoadingThread->m_hThread,INFINITE);
\r
729 m_LogList.TerminateThread();
\r
732 //m_LogList.TerminateThread();
\r
736 m_regLastStrict = m_bStrict;
\r
737 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
738 reg = m_btnShow.GetCurrentEntry();
\r
740 __super::OnCancel();
\r
743 CString CLogDlg::MakeShortMessage(const CString& message)
\r
745 bool bFoundShort = true;
\r
746 CString sShortMessage = m_ProjectProperties.GetLogSummary(message);
\r
747 if (sShortMessage.IsEmpty())
\r
749 bFoundShort = false;
\r
750 sShortMessage = message;
\r
752 // Remove newlines and tabs 'cause those are not shown nicely in the list control
\r
753 sShortMessage.Replace(_T("\r"), _T(""));
\r
754 sShortMessage.Replace(_T("\t"), _T(" "));
\r
756 // Suppose the first empty line separates 'summary' from the rest of the message.
\r
757 int found = sShortMessage.Find(_T("\n\n"));
\r
758 // To avoid too short 'short' messages
\r
759 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
\r
760 // only use the empty newline as a separator if it comes after at least 15 chars.
\r
761 if ((!bFoundShort)&&(found >= 15))
\r
763 sShortMessage = sShortMessage.Left(found);
\r
765 sShortMessage.Replace('\n', ' ');
\r
766 return sShortMessage;
\r
769 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
772 if (rev == SVN_INVALID_REVNUM)
\r
778 // this is the callback function which receives the data for every revision we ask the log for
\r
779 // we store this information here one by one.
\r
781 if (m_startrev == -1)
\r
786 m_LogProgress.SetPos(m_limit - m_limitcounter);
\r
788 else if (m_startrev.IsNumber() && m_startrev.IsNumber())
\r
789 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);
\r
790 __time64_t ttime = time/1000000L;
\r
791 if (m_tTo < (DWORD)ttime)
\r
792 m_tTo = (DWORD)ttime;
\r
793 if (m_tFrom > (DWORD)ttime)
\r
794 m_tFrom = (DWORD)ttime;
\r
795 if ((m_lowestRev > rev)||(m_lowestRev < 0))
\r
797 // Add as many characters from the log message to the list control
\r
798 PLOGENTRYDATA pLogItem = new LOGENTRYDATA;
\r
799 pLogItem->bCopies = !!copies;
\r
801 // find out if this item was copied in the revision
\r
802 BOOL copiedself = FALSE;
\r
805 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)
\r
807 LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);
\r
808 if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))
\r
810 // note: this only works if the log is fetched top-to-bottom
\r
811 // but since we do that, it shouldn't be a problem
\r
812 m_sSelfRelativeURL = cpath->sCopyFromPath;
\r
818 pLogItem->bCopiedSelf = copiedself;
\r
819 pLogItem->tmDate = ttime;
\r
820 pLogItem->sAuthor = author;
\r
821 pLogItem->sDate = date;
\r
822 pLogItem->sShortMessage = MakeShortMessage(message);
\r
823 pLogItem->dwFileChanges = filechanges;
\r
824 pLogItem->actions = actions;
\r
825 pLogItem->haschildren = haschildren;
\r
826 pLogItem->childStackDepth = m_childCounter;
\r
827 m_maxChild = max(m_childCounter, m_maxChild);
\r
830 pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();
\r
832 // split multi line log entries and concatenate them
\r
833 // again but this time with \r\n as line separators
\r
834 // so that the edit control recognizes them
\r
837 if (message.GetLength()>0)
\r
839 m_sMessageBuf = message;
\r
840 m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));
\r
841 m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));
\r
842 if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)
\r
843 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);
\r
846 m_sMessageBuf.Empty();
\r
847 pLogItem->sMessage = m_sMessageBuf;
\r
848 pLogItem->Rev = rev;
\r
850 // move-construct path array
\r
852 pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);
\r
853 cpaths->RemoveAll();
\r
855 catch (CException * e)
\r
857 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);
\r
859 m_bCancelled = TRUE;
\r
861 m_logEntries.push_back(pLogItem);
\r
862 m_arShownList.Add(pLogItem);
\r
868 //this is the thread function which calls the subversion function
\r
873 void CLogDlg::CopyChangedSelectionToClipBoard()
\r
876 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
878 return; // nothing is selected, get out of here
\r
882 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
885 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
888 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
889 sPaths += m_currentChangedPathList[nItem].GetGitPathString();
\r
890 sPaths += _T("\r\n");
\r
895 // only one revision is selected in the log dialog top pane
\r
896 // but multiple items could be selected in the changed items list
\r
897 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
900 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
901 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
903 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
905 // some items are hidden! So find out which item the user really selected
\r
906 INT_PTR selRealIndex = -1;
\r
907 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
909 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
911 if (selRealIndex == nItem)
\r
913 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);
\r
918 if (changedlogpath)
\r
920 sPaths += changedlogpath->sPath;
\r
921 sPaths += _T("\r\n");
\r
926 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
\r
930 BOOL CLogDlg::IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev)
\r
933 CString added, deleted;
\r
934 if (changedpath == NULL)
\r
937 if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))
\r
939 if (changedpath->action == LOGACTIONS_ADDED) // file is added
\r
941 if (changedpath->lCopyFromRev == 0)
\r
942 return FALSE; // but file was not added with history
\r
950 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
952 // we have two separate context menus:
\r
953 // one shown on the log message list control,
\r
954 // the other shown in the changed-files list control
\r
955 int selCount = m_LogList.GetSelectedCount();
\r
956 if (pWnd == &m_LogList)
\r
958 //ShowContextMenuForRevisions(pWnd, point);
\r
960 else if (pWnd == &m_ChangedFileListCtrl)
\r
962 //ShowContextMenuForChangedpaths(pWnd, point);
\r
964 else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
966 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
969 selIndex = m_LogList.GetNextSelectedItem(pos);
\r
970 if ((point.x == -1) && (point.y == -1))
\r
973 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
\r
974 ClientToScreen(&rect);
\r
975 point = rect.CenterPoint();
\r
977 CString sMenuItemText;
\r
979 if (popup.CreatePopupMenu())
\r
981 // add the 'default' entries
\r
982 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
\r
983 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
\r
984 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
\r
985 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
\r
987 //if (selIndex >= 0)
\r
989 // popup.AppendMenu(MF_SEPARATOR);
\r
990 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
\r
991 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
\r
994 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
998 break; // no command selected
\r
1001 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
\r
1003 case CGitLogList::ID_EDITAUTHOR:
\r
1004 EditLogMessage(selIndex);
\r
1012 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
1015 ASSERT(m_pFindDialog != NULL);
\r
1017 if (m_pFindDialog->IsTerminating())
\r
1019 // invalidate the handle identifying the dialog box.
\r
1020 m_pFindDialog = NULL;
\r
1024 if(m_pFindDialog->FindNext())
\r
1026 //read data from dialog
\r
1027 CString FindText = m_pFindDialog->GetFindString();
\r
1028 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
\r
1029 bool bFound = false;
\r
1031 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
\r
1033 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
\r
1036 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
\r
1040 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1042 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))
\r
1047 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1048 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1050 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1051 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))
\r
1057 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))
\r
1069 if (m_logEntries[i]->sMessage.Find(FindText) >= 0)
\r
1074 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1075 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1076 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1078 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1079 if (cpath->sCopyFromPath.Find(FindText)>=0)
\r
1085 if (cpath->sPath.Find(FindText)>=0)
\r
1095 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1096 CString msg = pLogEntry->sMessage;
\r
1097 msg = msg.MakeLower();
\r
1098 CString find = FindText.MakeLower();
\r
1099 if (msg.Find(find) >= 0)
\r
1104 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1105 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1107 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1108 CString lowerpath = cpath->sCopyFromPath;
\r
1109 lowerpath.MakeLower();
\r
1110 if (lowerpath.Find(find)>=0)
\r
1116 lowerpath = cpath->sPath;
\r
1117 lowerpath.MakeLower();
\r
1118 if (lowerpath.Find(find)>=0)
\r
1127 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
\r
1130 this->m_nSearchIndex = (i+1);
\r
1131 m_LogList.EnsureVisible(i, FALSE);
\r
1132 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);
\r
1133 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1134 m_LogList.SetSelectionMark(i);
\r
1135 FillLogMessageCtrl();
\r
1136 UpdateData(FALSE);
\r
1138 if (m_nSearchIndex >= m_arShownList.GetCount())
\r
1139 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
\r
1141 } // if(m_pFindDialog->FindNext())
\r
1142 UpdateLogInfoLabel();
\r
1147 void CLogDlg::OnOK()
\r
1150 // since the log dialog is also used to select revisions for other
\r
1151 // dialogs, we have to do some work before closing this dialog
\r
1152 if (GetFocus() != GetDlgItem(IDOK))
\r
1153 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
\r
1154 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
\r
1155 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
\r
1158 CString buttontext;
\r
1159 GetDlgItemText(IDOK, buttontext);
\r
1160 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1161 if (temp.Compare(buttontext) != 0)
\r
1162 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
\r
1163 m_bCancelled = TRUE;
\r
1164 m_selectedRevs.Clear();
\r
1165 m_selectedRevsOneRange.Clear();
\r
1166 if (m_pNotifyWindow)
\r
1168 int selIndex = m_LogList.GetSelectionMark();
\r
1169 if (selIndex >= 0)
\r
1171 PLOGENTRYDATA pLogEntry = NULL;
\r
1172 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1173 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1174 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1175 git_revnum_t lowerRev = pLogEntry->Rev;
\r
1176 git_revnum_t higherRev = lowerRev;
\r
1179 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1180 git_revnum_t rev = pLogEntry->Rev;
\r
1181 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1182 if (lowerRev > rev)
\r
1184 if (higherRev < rev)
\r
1187 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
\r
1189 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
\r
1191 BOOL bSentMessage = FALSE;
\r
1192 if (m_LogList.GetSelectedCount() == 1)
\r
1194 // if only one revision is selected, check if the path/url with which the dialog was started
\r
1195 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
\r
1196 // if it was copied, use the copy from revision as lowerRev
\r
1197 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
\r
1199 CString sUrl = m_path.GetGitPathString();
\r
1200 if (!m_path.IsUrl())
\r
1202 sUrl = GetURLFromPath(m_path);
\r
1204 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
\r
1205 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
\r
1207 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);
\r
1210 if (sUrl.Compare(pData->sPath) == 0)
\r
1212 if (!pData->sCopyFromPath.IsEmpty())
\r
1214 lowerRev = pData->lCopyFromRev;
\r
1215 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
\r
1216 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
\r
1217 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1218 bSentMessage = TRUE;
\r
1225 if ( !bSentMessage )
\r
1227 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
\r
1228 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
\r
1229 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1230 if (m_selectedRevsOneRange.GetCount())
\r
1231 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
\r
1236 if (m_bSaveStrict)
\r
1237 m_regLastStrict = m_bStrict;
\r
1238 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
1239 reg = m_btnShow.GetCurrentEntry();
\r
1240 SaveSplitterPos();
\r
1244 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1246 // a double click on an entry in the changed-files list has happened
\r
1249 DiffSelectedFile();
\r
1252 void CLogDlg::DiffSelectedFile()
\r
1255 if (m_bThreadRunning)
\r
1257 UpdateLogInfoLabel();
\r
1258 INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
1261 if (m_ChangedFileListCtrl.GetSelectedCount() == 0)
\r
1263 // find out if there's an entry selected in the log list
\r
1264 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1265 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1266 git_revnum_t rev1 = pLogEntry->Rev;
\r
1267 git_revnum_t rev2 = rev1;
\r
1272 // there's at least a second entry selected in the log list: several revisions selected!
\r
1273 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1276 rev1 = max(rev1,(long)pLogEntry->Rev);
\r
1277 rev2 = min(rev2,(long)pLogEntry->Rev);
\r
1281 // now we have both revisions selected in the log list, so we can do a diff of the selected
\r
1282 // entry in the changed files list with these two revisions.
\r
1283 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1288 // nothing or only one revision selected in the log list
\r
1289 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1291 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1293 // some items are hidden! So find out which item the user really clicked on
\r
1294 INT_PTR selRealIndex = -1;
\r
1295 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1297 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1299 if (selRealIndex == selIndex)
\r
1301 selIndex = hiddenindex;
\r
1302 changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1308 if (IsDiffPossible(changedpath, rev1))
\r
1310 // diffs with renamed files are possible
\r
1311 if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))
\r
1312 rev2 = changedpath->lCopyFromRev;
\r
1315 // if the path was modified but the parent path was 'added with history'
\r
1316 // then we have to use the copy from revision of the parent path
\r
1317 CTGitPath cpath = CTGitPath(changedpath->sPath);
\r
1318 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
1320 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
1321 if (p.IsAncestorOf(cpath))
\r
1323 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
1324 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
1328 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1332 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1333 CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1335 // deleted files must be opened from the revision before the deletion
\r
1336 if (changedpath->action == LOGACTIONS_DELETED)
\r
1338 m_bCancelled = false;
\r
1340 CProgressDlg progDlg;
\r
1341 progDlg.SetTitle(IDS_APPNAME);
\r
1342 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1343 CString sInfoLine;
\r
1344 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());
\r
1345 progDlg.SetLine(1, sInfoLine, true);
\r
1346 SetAndClearProgressInfo(&progDlg);
\r
1347 progDlg.ShowModeless(m_hWnd);
\r
1349 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))
\r
1351 m_bCancelled = false;
\r
1352 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))
\r
1355 SetAndClearProgressInfo((HWND)NULL);
\r
1356 CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1361 SetAndClearProgressInfo((HWND)NULL);
\r
1363 CString sName1, sName2;
\r
1364 sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);
\r
1365 sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);
\r
1366 CAppUtils::DiffFlags flags;
\r
1367 flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1368 if (changedpath->action == LOGACTIONS_DELETED)
\r
1369 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);
\r
1371 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);
\r
1378 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)
\r
1380 DialogEnableWindow(IDOK, FALSE);
\r
1381 // SetPromptApp(&theApp);
\r
1382 theApp.DoWaitCursor(1);
\r
1385 GetTempPath(temppath);
\r
1388 file1.Format(_T("%s%s_%s%s"),
\r
1390 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1391 rev1->m_CommitHash.Left(6),
\r
1392 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1395 file2.Format(_T("%s\\%s_%s%s"),
\r
1397 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1398 rev2->m_CommitHash.Left(6),
\r
1399 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1403 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1404 g_Git.RunLogFile(cmd,file1);
\r
1405 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1406 g_Git.RunLogFile(cmd,file2);
\r
1408 CAppUtils::DiffFlags flags;
\r
1409 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);
\r
1412 //get the filename
\r
1414 if (Git::PathIsURL(m_path))
\r
1416 filepath = m_path.GetGitPathString();
\r
1420 filepath = GetURLFromPath(m_path);
\r
1421 if (filepath.IsEmpty())
\r
1423 theApp.DoWaitCursor(-1);
\r
1425 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1426 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1427 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1429 theApp.DoWaitCursor(-11);
\r
1433 m_bCancelled = FALSE;
\r
1434 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1436 CString firstfile, secondfile;
\r
1437 if (m_LogList.GetSelectedCount()==1)
\r
1439 int s = m_LogList.GetSelectionMark();
\r
1440 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));
\r
1441 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1442 firstfile = changedpath->sPath;
\r
1443 secondfile = firstfile;
\r
1444 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?
\r
1446 secondfile = changedpath->sCopyFromPath;
\r
1447 rev2 = changedpath->lCopyFromRev;
\r
1452 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();
\r
1453 secondfile = firstfile;
\r
1456 firstfile = filepath + firstfile.Trim();
\r
1457 secondfile = filepath + secondfile.Trim();
\r
1459 GitDiff diff(this, this->m_hWnd, true);
\r
1460 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1461 diff.SetHEADPeg(m_LogRevision);
\r
1464 if (PromptShown())
\r
1465 diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);
\r
1467 CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);
\r
1471 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))
\r
1473 if (firstfile.Compare(secondfile)==0)
\r
1475 git_revnum_t baseRev = 0;
\r
1476 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);
\r
1483 theApp.DoWaitCursor(-1);
\r
1487 BOOL CLogDlg::Open(bool bOpenWith,CString changedpath, git_revnum_t rev)
\r
1490 DialogEnableWindow(IDOK, FALSE);
\r
1491 SetPromptApp(&theApp);
\r
1492 theApp.DoWaitCursor(1);
\r
1494 if (Git::PathIsURL(m_path))
\r
1496 filepath = m_path.GetGitPathString();
\r
1500 filepath = GetURLFromPath(m_path);
\r
1501 if (filepath.IsEmpty())
\r
1503 theApp.DoWaitCursor(-1);
\r
1505 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1506 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1507 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1512 m_bCancelled = false;
\r
1513 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1514 filepath += changedpath;
\r
1516 CProgressDlg progDlg;
\r
1517 progDlg.SetTitle(IDS_APPNAME);
\r
1518 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1519 CString sInfoLine;
\r
1520 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());
\r
1521 progDlg.SetLine(1, sInfoLine, true);
\r
1522 SetAndClearProgressInfo(&progDlg);
\r
1523 progDlg.ShowModeless(m_hWnd);
\r
1525 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);
\r
1526 m_bCancelled = false;
\r
1527 if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))
\r
1530 SetAndClearProgressInfo((HWND)NULL);
\r
1531 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1533 theApp.DoWaitCursor(-1);
\r
1537 SetAndClearProgressInfo((HWND)NULL);
\r
1538 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1541 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1542 if (ret <= HINSTANCE_ERROR)
\r
1547 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1548 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1549 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1552 theApp.DoWaitCursor(-1);
\r
1557 void CLogDlg::EditAuthor(const CLogDataVector& logs)
\r
1562 if (logs.size() == 0)
\r
1564 DialogEnableWindow(IDOK, FALSE);
\r
1565 SetPromptApp(&theApp);
\r
1566 theApp.DoWaitCursor(1);
\r
1567 if (Git::PathIsURL(m_path))
\r
1568 url = m_path.GetGitPathString();
\r
1571 url = GetURLFromPath(m_path);
\r
1573 name = Git_PROP_REVISION_AUTHOR;
\r
1575 CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);
\r
1576 CString sOldValue = value;
\r
1577 value.Replace(_T("\n"), _T("\r\n"));
\r
1578 CInputDlg dlg(this);
\r
1579 dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);
\r
1580 dlg.m_sInputText = value;
\r
1581 dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);
\r
1582 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1583 dlg.m_bUseLogWidth = false;
\r
1584 if (dlg.DoModal() == IDOK)
\r
1586 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1588 LogCache::CCachedLogInfo* toUpdate
\r
1589 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1591 CProgressDlg progDlg;
\r
1592 progDlg.SetTitle(IDS_APPNAME);
\r
1593 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
\r
1594 progDlg.SetTime(true);
\r
1595 progDlg.SetShowProgressBar(true);
\r
1596 progDlg.ShowModeless(m_hWnd);
\r
1597 for (DWORD i=0; i<logs.size(); ++i)
\r
1599 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))
\r
1602 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1608 logs[i]->sAuthor = dlg.m_sInputText;
\r
1609 m_LogList.Invalidate();
\r
1611 // update the log cache
\r
1613 if (toUpdate != NULL)
\r
1615 // log caching is active
\r
1617 LogCache::CCachedLogInfo newInfo;
\r
1618 newInfo.Insert ( logs[i]->Rev
\r
1619 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)
\r
1622 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);
\r
1624 toUpdate->Update (newInfo);
\r
1627 progDlg.SetProgress64(i, logs.size());
\r
1631 theApp.DoWaitCursor(-1);
\r
1636 void CLogDlg::EditLogMessage(int index)
\r
1641 DialogEnableWindow(IDOK, FALSE);
\r
1642 SetPromptApp(&theApp);
\r
1643 theApp.DoWaitCursor(1);
\r
1644 if (Git::PathIsURL(m_path))
\r
1645 url = m_path.GetGitPathString();
\r
1648 url = GetURLFromPath(m_path);
\r
1650 name = Git_PROP_REVISION_LOG;
\r
1652 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
1653 m_bCancelled = FALSE;
\r
1654 CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);
\r
1655 CString sOldValue = value;
\r
1656 value.Replace(_T("\n"), _T("\r\n"));
\r
1657 CInputDlg dlg(this);
\r
1658 dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);
\r
1659 dlg.m_sInputText = value;
\r
1660 dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);
\r
1661 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1662 dlg.m_bUseLogWidth = true;
\r
1663 if (dlg.DoModal() == IDOK)
\r
1665 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1666 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))
\r
1668 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1672 pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);
\r
1673 // split multi line log entries and concatenate them
\r
1674 // again but this time with \r\n as line separators
\r
1675 // so that the edit control recognizes them
\r
1676 if (dlg.m_sInputText.GetLength()>0)
\r
1678 m_sMessageBuf = dlg.m_sInputText;
\r
1679 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));
\r
1680 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));
\r
1681 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)
\r
1682 dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);
\r
1685 dlg.m_sInputText.Empty();
\r
1686 pLogEntry->sMessage = dlg.m_sInputText;
\r
1687 pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);
\r
1688 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
1689 pMsgView->SetWindowText(_T(" "));
\r
1690 pMsgView->SetWindowText(dlg.m_sInputText);
\r
1691 m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);
\r
1692 m_LogList.Invalidate();
\r
1694 // update the log cache
\r
1696 LogCache::CCachedLogInfo* toUpdate
\r
1697 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1698 if (toUpdate != NULL)
\r
1700 // log caching is active
\r
1702 LogCache::CCachedLogInfo newInfo;
\r
1703 newInfo.Insert ( pLogEntry->Rev
\r
1705 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)
\r
1707 , LogCache::CRevisionInfoContainer::HAS_COMMENT);
\r
1709 toUpdate->Update (newInfo);
\r
1713 theApp.DoWaitCursor(-1);
\r
1718 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
\r
1720 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1721 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1722 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1724 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1726 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1728 DiffSelectedRevWithPrevious();
\r
1732 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1734 DiffSelectedFile();
\r
1738 if (m_hAccel && !bSkipAccelerator)
\r
1740 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1745 m_tooltips.RelayEvent(pMsg);
\r
1746 return __super::PreTranslateMessage(pMsg);
\r
1750 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
1752 //if (this->IsThreadRunning())
\r
1753 if(m_LogList.m_bNoDispUpdates)
\r
1755 // only show the wait cursor over the list control
\r
1757 ((pWnd == GetDlgItem(IDC_LOGLIST))||
\r
1758 (pWnd == GetDlgItem(IDC_MSGVIEW))||
\r
1759 (pWnd == GetDlgItem(IDC_LOGMSG))))
\r
1761 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
1766 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1767 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1769 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
1771 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1774 void CLogDlg::OnBnClickedHelp()
\r
1779 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1781 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
1783 //if (this->IsThreadRunning())
\r
1784 if(m_LogList.m_bNoDispUpdates)
\r
1786 if (pNMLV->iItem >= 0)
\r
1788 m_nSearchIndex = pNMLV->iItem;
\r
1789 if (pNMLV->iSubItem != 0)
\r
1791 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount())&&(m_bStrict)&&(1/*m_bStrictStopped*/))
\r
1793 // remove the selected state
\r
1794 if (pNMLV->uChanged & LVIF_STATE)
\r
1796 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
\r
1797 FillLogMessageCtrl();
\r
1798 UpdateData(FALSE);
\r
1799 UpdateLogInfoLabel();
\r
1803 if (pNMLV->uChanged & LVIF_STATE)
\r
1805 FillLogMessageCtrl();
\r
1806 UpdateData(FALSE);
\r
1811 FillLogMessageCtrl();
\r
1812 UpdateData(FALSE);
\r
1815 UpdateLogInfoLabel();
\r
1818 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
\r
1820 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
\r
1821 if (pEnLink->msg == WM_LBUTTONUP)
\r
1824 GetDlgItemText(IDC_MSGVIEW, msg);
\r
1825 msg.Replace(_T("\r\n"), _T("\n"));
\r
1826 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
\r
1827 if (!::PathIsURL(url))
\r
1829 url = m_ProjectProperties.GetBugIDUrl(url);
\r
1830 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1832 if (!url.IsEmpty())
\r
1833 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1838 void CLogDlg::OnBnClickedStatbutton()
\r
1841 if (this->IsThreadRunning())
\r
1843 if (m_LogList.m_arShownList.IsEmpty())
\r
1844 return; // nothing is shown, so no statistics.
\r
1845 // the statistics dialog expects the log entries to be sorted by date
\r
1846 SortByColumn(3, false);
\r
1847 CPtrArray shownlist;
\r
1848 m_LogList.RecalculateShownList(&shownlist);
\r
1849 // create arrays which are aware of the current filter
\r
1850 CStringArray m_arAuthorsFiltered;
\r
1851 CDWordArray m_arDatesFiltered;
\r
1852 CDWordArray m_arFileChangesFiltered;
\r
1853 for (INT_PTR i=0; i<shownlist.GetCount(); ++i)
\r
1855 GitRev* pLogEntry = reinterpret_cast<GitRev*>(shownlist.GetAt(i));
\r
1856 CString strAuthor = pLogEntry->m_AuthorName;
\r
1857 if ( strAuthor.IsEmpty() )
\r
1859 strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);
\r
1861 m_arAuthorsFiltered.Add(strAuthor);
\r
1862 m_arDatesFiltered.Add(pLogEntry->m_AuthorDate.GetTime());
\r
1863 m_arFileChangesFiltered.Add(pLogEntry->m_Files.GetCount());
\r
1865 CStatGraphDlg dlg;
\r
1866 dlg.m_parAuthors = &m_arAuthorsFiltered;
\r
1867 dlg.m_parDates = &m_arDatesFiltered;
\r
1868 dlg.m_parFileChanges = &m_arFileChangesFiltered;
\r
1869 dlg.m_path = m_path;
\r
1871 // restore the previous sorting
\r
1872 SortByColumn(m_nSortColumn, m_bAscending);
\r
1873 OnTimer(LOGFILTER_TIMER);
\r
1878 void CLogDlg::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1881 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
1882 // Take the default processing unless we set this to something else below.
\r
1883 *pResult = CDRF_DODEFAULT;
\r
1885 if (m_bNoDispUpdates)
\r
1888 switch (pLVCD->nmcd.dwDrawStage)
\r
1890 case CDDS_PREPAINT:
\r
1892 *pResult = CDRF_NOTIFYITEMDRAW;
\r
1896 case CDDS_ITEMPREPAINT:
\r
1898 // This is the prepaint stage for an item. Here's where we set the
\r
1899 // item's text color.
\r
1901 // Tell Windows to send draw notifications for each subitem.
\r
1902 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
1904 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
1906 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1908 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
1912 if (data->bCopiedSelf)
\r
1914 // only change the background color if the item is not 'hot' (on vista with themes enabled)
\r
1915 if (!theme.IsAppThemed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
1916 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
1919 if (data->bCopies)
\r
1920 crText = m_Colors.GetColor(CColors::Modified);
\r
1922 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
1923 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
1924 // if (data->Rev == m_wcRev)
\r
1926 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
1927 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
1928 // tells the control to recalculate the extent of the text.
\r
1929 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
1933 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1935 if (m_bStrictStopped)
\r
1936 crText = GetSysColor(COLOR_GRAYTEXT);
\r
1938 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
1939 pLVCD->clrText = crText;
\r
1943 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
1945 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
1947 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
1949 if (pLVCD->iSubItem == 1)
\r
1951 *pResult = CDRF_DODEFAULT;
\r
1953 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1957 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
1958 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
1960 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
1962 // Get the selected state of the
\r
1963 // item being drawn.
\r
1965 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
1966 rItem.mask = LVIF_STATE;
\r
1967 rItem.iItem = pLVCD->nmcd.dwItemSpec;
\r
1968 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
1969 m_LogList.GetItem(&rItem);
\r
1972 m_LogList.GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
1974 // Fill the background
\r
1975 if (theme.IsAppThemed() && m_bVista)
\r
1977 theme.Open(m_hWnd, L"Explorer");
\r
1978 int state = LISS_NORMAL;
\r
1979 if (rItem.state & LVIS_SELECTED)
\r
1981 if (::GetFocus() == m_LogList.m_hWnd)
\r
1982 state |= LISS_SELECTED;
\r
1984 state |= LISS_SELECTEDNOTFOCUS;
\r
1989 if (pLogEntry->bCopiedSelf)
\r
1991 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
1992 // information at this drawing stage. But we can check the whether the
\r
1993 // previous stage changed the background color of the item
\r
1994 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
1997 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2000 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2001 ::DeleteObject(brush);
\r
2008 if (theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
2009 theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);
\r
2011 theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
2016 if (rItem.state & LVIS_SELECTED)
\r
2018 if (::GetFocus() == m_LogList.m_hWnd)
\r
2019 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
2021 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
2025 //if (pLogEntry->bCopiedSelf)
\r
2026 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2028 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
2030 if (brush == NULL)
\r
2033 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2034 ::DeleteObject(brush);
\r
2037 // Draw the icon(s) into the compatible DC
\r
2038 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
2039 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2042 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
2043 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2046 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
2047 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2050 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
2051 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2053 *pResult = CDRF_SKIPDEFAULT;
\r
2059 *pResult = CDRF_DODEFAULT;
\r
2064 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2067 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
2068 // Take the default processing unless we set this to something else below.
\r
2069 *pResult = CDRF_DODEFAULT;
\r
2071 // if (m_bNoDispUpdates)
\r
2074 // First thing - check the draw stage. If it's the control's prepaint
\r
2075 // stage, then tell Windows we want messages for every item.
\r
2077 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2079 *pResult = CDRF_NOTIFYITEMDRAW;
\r
2081 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2083 // This is the prepaint stage for an item. Here's where we set the
\r
2084 // item's text color. Our return value will tell Windows to draw the
\r
2085 // item itself, but it will use the new color we set here.
\r
2087 // Tell Windows to paint the control itself.
\r
2088 *pResult = CDRF_DODEFAULT;
\r
2090 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
2091 bool bGrayed = false;
\r
2093 if ((m_cHidePaths.GetState() & 0x0003)==BST_INDETERMINATE)
\r
2095 if ((m_currentChangedArray)&&((m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)))
\r
2097 //if ((*m_currentChangedArray)[(pLVCD->nmcd.dwItemSpec)]sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2099 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2103 else if (m_currentChangedPathList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2105 //if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2107 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2114 if ((!bGrayed)&&(m_currentChangedArray)&&(m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
2116 DWORD action = ((*m_currentChangedArray)[pLVCD->nmcd.dwItemSpec]).m_Action;
\r
2117 if (action == CTGitPath::LOGACTIONS_MODIFIED)
\r
2118 crText = m_Colors.GetColor(CColors::Modified);
\r
2119 if (action == CTGitPath::LOGACTIONS_REPLACED)
\r
2120 crText = m_Colors.GetColor(CColors::Deleted);
\r
2121 if (action == CTGitPath::LOGACTIONS_ADDED)
\r
2122 crText = m_Colors.GetColor(CColors::Added);
\r
2123 if (action == CTGitPath::LOGACTIONS_DELETED)
\r
2124 crText = m_Colors.GetColor(CColors::Deleted);
\r
2127 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
2128 pLVCD->clrText = crText;
\r
2132 void CLogDlg::DoSizeV1(int delta)
\r
2135 RemoveAnchor(IDC_LOGLIST);
\r
2136 RemoveAnchor(IDC_SPLITTERTOP);
\r
2137 RemoveAnchor(IDC_MSGVIEW);
\r
2138 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2139 RemoveAnchor(IDC_LOGMSG);
\r
2140 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
\r
2141 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
\r
2142 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2143 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2144 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2145 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2146 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2149 SetSplitterRange();
\r
2150 m_LogList.Invalidate();
\r
2151 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2155 void CLogDlg::DoSizeV2(int delta)
\r
2158 RemoveAnchor(IDC_LOGLIST);
\r
2159 RemoveAnchor(IDC_SPLITTERTOP);
\r
2160 RemoveAnchor(IDC_MSGVIEW);
\r
2161 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2162 RemoveAnchor(IDC_LOGMSG);
\r
2163 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
\r
2164 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
\r
2165 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2166 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2167 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2168 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2169 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2172 SetSplitterRange();
\r
2173 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2174 m_ChangedFileListCtrl.Invalidate();
\r
2178 void CLogDlg::AdjustMinSize()
\r
2180 // adjust the minimum size of the dialog to prevent the resizing from
\r
2181 // moving the list control too far down.
\r
2182 CRect rcChgListView;
\r
2183 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
\r
2185 m_LogList.GetClientRect(rcLogList);
\r
2187 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
\r
2188 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
\r
2189 +rcChgListView.Height()+rcLogList.Height()+60));
\r
2192 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
2194 switch (message) {
\r
2196 if (wParam == IDC_SPLITTERTOP)
\r
2198 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2199 DoSizeV1(pHdr->delta);
\r
2201 else if (wParam == IDC_SPLITTERBOTTOM)
\r
2203 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2204 DoSizeV2(pHdr->delta);
\r
2209 return CResizableDialog::DefWindowProc(message, wParam, lParam);
\r
2212 void CLogDlg::SetSplitterRange()
\r
2214 if ((m_LogList)&&(m_ChangedFileListCtrl))
\r
2217 m_LogList.GetWindowRect(rcTop);
\r
2218 ScreenToClient(rcTop);
\r
2220 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
\r
2221 ScreenToClient(rcMiddle);
\r
2222 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
\r
2224 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
\r
2225 ScreenToClient(rcBottom);
\r
2226 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
\r
2230 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
\r
2232 RECT * rect = (LPRECT)lParam;
\r
2235 point = CPoint(rect->left, rect->bottom);
\r
2236 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
\r
2238 if (popup.CreatePopupMenu())
\r
2240 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2241 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);
\r
2243 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2245 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2246 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
\r
2247 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2248 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
\r
2249 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2250 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
\r
2251 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2252 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
\r
2253 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
\r
2254 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
\r
2256 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2258 temp.LoadString(IDS_LOG_FILTER_REGEX);
\r
2259 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
\r
2262 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2263 if (selection != 0)
\r
2266 if (selection == LOGFILTER_REGEX)
\r
2268 m_bFilterWithRegex = !m_bFilterWithRegex;
\r
2269 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
2270 b = m_bFilterWithRegex;
\r
2271 CheckRegexpTooltip();
\r
2275 m_LogList.m_nSelectedFilter = selection;
\r
2276 SetFilterCueText();
\r
2278 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2284 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
2287 KillTimer(LOGFILTER_TIMER);
\r
2289 m_LogList.m_sFilterText.Empty();
\r
2290 UpdateData(FALSE);
\r
2291 theApp.DoWaitCursor(1);
\r
2292 CStoreSelection storeselection(this);
\r
2293 FillLogMessageCtrl(false);
\r
2295 m_LogList.RemoveFilter();
\r
2298 m_LogList.GetTimeRange(begin,end);
\r
2299 m_DateFrom.SetTime(&begin);
\r
2300 m_DateTo.SetTime(&end);
\r
2302 theApp.DoWaitCursor(-1);
\r
2303 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2304 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2305 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2306 UpdateLogInfoLabel();
\r
2312 void CLogDlg::SetFilterCueText()
\r
2315 switch (m_LogList.m_nSelectedFilter)
\r
2317 case LOGFILTER_ALL:
\r
2318 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2320 case LOGFILTER_MESSAGES:
\r
2321 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2323 case LOGFILTER_PATHS:
\r
2324 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2326 case LOGFILTER_AUTHORS:
\r
2327 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2329 case LOGFILTER_REVS:
\r
2330 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2333 // to make the cue banner text appear more to the right of the edit control
\r
2334 temp = _T(" ")+temp;
\r
2335 m_cFilter.SetCueBanner(temp);
\r
2338 bool CLogDlg::Validate(LPCTSTR string)
\r
2340 if (!m_bFilterWithRegex)
\r
2343 return m_LogList.ValidateRegexp(string, pat, false);
\r
2347 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
\r
2349 if (nIDEvent == LOGFILTER_TIMER)
\r
2351 if (this->IsThreadRunning())
\r
2353 // thread still running! So just restart the timer.
\r
2354 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2357 CWnd * focusWnd = GetFocus();
\r
2358 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
\r
2359 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
\r
2360 if (m_LogList.m_sFilterText.IsEmpty())
\r
2362 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2363 // do not return here!
\r
2364 // we also need to run the filter if the filter text is empty:
\r
2365 // 1. to clear an existing filter
\r
2366 // 2. to rebuild the m_arShownList after sorting
\r
2368 theApp.DoWaitCursor(1);
\r
2369 CStoreSelection storeselection(this);
\r
2370 KillTimer(LOGFILTER_TIMER);
\r
2371 FillLogMessageCtrl(false);
\r
2373 // now start filter the log list
\r
2374 m_LogList.StartFilter();
\r
2376 if ( m_LogList.GetItemCount()==1 )
\r
2378 m_LogList.SetSelectionMark(0);
\r
2379 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
2381 theApp.DoWaitCursor(-1);
\r
2382 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2383 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2384 if (bSetFocusToFilterControl)
\r
2385 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2386 UpdateLogInfoLabel();
\r
2387 } // if (nIDEvent == LOGFILTER_TIMER)
\r
2388 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2389 __super::OnTimer(nIDEvent);
\r
2392 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2395 m_DateTo.GetTime(_time);
\r
2398 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
\r
2399 if (time.GetTime() != m_LogList.m_To.GetTime())
\r
2401 m_LogList.m_To = (DWORD)time.GetTime();
\r
2402 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2405 catch (CAtlException)
\r
2412 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2415 m_DateFrom.GetTime(_time);
\r
2418 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
\r
2419 if (time.GetTime() != m_LogList.m_From.GetTime())
\r
2421 m_LogList.m_From = (DWORD)time.GetTime();
\r
2422 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2425 catch (CAtlException)
\r
2434 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths /* = false */, bool bUseFilter /* = true */)
\r
2436 CTGitPathList pathList;
\r
2439 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2441 m_sRepositoryRoot = GetRepositoryRoot(m_path);
\r
2443 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2446 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2451 int nextpos = m_LogList.GetNextSelectedItem(pos);
\r
2452 if (nextpos >= m_arShownList.GetCount())
\r
2454 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));
\r
2455 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
2456 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
2458 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2459 if (cpath == NULL)
\r
2462 if (!bRelativePaths)
\r
2463 path.SetFromGit(m_sRepositoryRoot);
\r
2464 path.AppendPathString(cpath->sPath);
\r
2465 if ((!bUseFilter)||
\r
2466 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
\r
2467 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
\r
2468 pathList.AddPath(path);
\r
2473 pathList.RemoveDuplicates();
\r
2478 void CLogDlg::SortByColumn(int nSortColumn, bool bAscending)
\r
2481 switch(nSortColumn)
\r
2483 case 0: // Revision
\r
2486 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
\r
2488 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
\r
2494 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
\r
2496 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
\r
2502 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
\r
2504 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
\r
2510 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
\r
2512 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
\r
2515 case 4: // Message or bug id
\r
2516 if (m_bShowBugtraqColumn)
\r
2519 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
\r
2521 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
\r
2524 // fall through here
\r
2525 case 5: // Message
\r
2528 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
\r
2530 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
\r
2540 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
\r
2542 if (this->IsThreadRunning())
\r
2543 return; //no sorting while the arrays are filled
\r
2544 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2545 const int nColumn = pNMLV->iSubItem;
\r
2546 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
\r
2547 m_nSortColumn = nColumn;
\r
2548 SortByColumn(m_nSortColumn, m_bAscending);
\r
2549 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
\r
2550 SortShownListArray();
\r
2551 m_LogList.Invalidate();
\r
2552 UpdateLogInfoLabel();
\r
2553 // the "next 100" button only makes sense if the log messages
\r
2554 // are sorted by revision in descending order
\r
2555 if ((m_nSortColumn)||(m_bAscending))
\r
2557 DialogEnableWindow(IDC_NEXTHUNDRED, false);
\r
2561 DialogEnableWindow(IDC_NEXTHUNDRED, true);
\r
2566 void CLogDlg::SortShownListArray()
\r
2568 // make sure the shown list still matches the filter after sorting.
\r
2569 OnTimer(LOGFILTER_TIMER);
\r
2570 // clear the selection states
\r
2571 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2574 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
\r
2576 m_LogList.SetSelectionMark(-1);
\r
2579 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
\r
2581 if (control == NULL)
\r
2583 // set the sort arrow
\r
2584 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
\r
2585 HDITEM HeaderItem = {0};
\r
2586 HeaderItem.mask = HDI_FORMAT;
\r
2587 for (int i=0; i<pHeader->GetItemCount(); ++i)
\r
2589 pHeader->GetItem(i, &HeaderItem);
\r
2590 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
\r
2591 pHeader->SetItem(i, &HeaderItem);
\r
2595 pHeader->GetItem(nColumn, &HeaderItem);
\r
2596 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
\r
2597 pHeader->SetItem(nColumn, &HeaderItem);
\r
2600 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2603 if (this->IsThreadRunning())
\r
2604 return; //no sorting while the arrays are filled
\r
2605 if (m_currentChangedArray == NULL)
\r
2607 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2608 const int nColumn = pNMLV->iSubItem;
\r
2609 m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;
\r
2610 m_nSortColumnPathList = nColumn;
\r
2611 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
\r
2613 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
2614 m_ChangedFileListCtrl.Invalidate();
\r
2619 int CLogDlg::m_nSortColumnPathList = 0;
\r
2620 bool CLogDlg::m_bAscendingPathList = false;
\r
2622 int CLogDlg::SortCompare(const void * pElem1, const void * pElem2)
\r
2625 LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);
\r
2626 LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);
\r
2628 if (m_bAscendingPathList)
\r
2629 std::swap (cpath1, cpath2);
\r
2632 switch (m_nSortColumnPathList)
\r
2635 cmp = cpath2->GetAction().Compare(cpath1->GetAction());
\r
2640 cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);
\r
2644 case 2: // copy from path
\r
2645 cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);
\r
2649 case 3: // copy from revision
\r
2650 return cpath2->lCopyFromRev > cpath1->lCopyFromRev;
\r
2656 void CLogDlg::OnBnClickedHidepaths()
\r
2658 FillLogMessageCtrl();
\r
2659 m_ChangedFileListCtrl.Invalidate();
\r
2664 void CLogDlg::OnBnClickedCheckStoponcopy()
\r
2667 if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
2670 // ignore old fetch limits when switching
\r
2671 // between copy-following and stop-on-copy
\r
2672 // (otherwise stop-on-copy will limit what
\r
2673 // we see immediately after switching to
\r
2674 // copy-following)
\r
2678 // now, restart the query
\r
2683 void CLogDlg::OnBnClickedIncludemerge()
\r
2693 void CLogDlg::UpdateLogInfoLabel()
\r
2696 git_revnum_t rev1 ;
\r
2697 git_revnum_t rev2 ;
\r
2698 long selectedrevs = 0;
\r
2699 int count =m_LogList.m_arShownList.GetCount();
\r
2702 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(0)))->m_CommitHash;
\r
2703 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
\r
2704 rev2 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;
\r
2705 selectedrevs = m_LogList.GetSelectedCount();
\r
2708 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
2709 m_sLogInfo = sTemp;
\r
2711 UpdateData(FALSE);
\r
2715 void CLogDlg::ShowContextMenuForChangedpaths(CWnd* /*pWnd*/, CPoint point)
\r
2718 int selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
2719 if ((point.x == -1) && (point.y == -1))
\r
2722 m_ChangedFileListCtrl.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
2723 m_ChangedFileListCtrl.ClientToScreen(&rect);
\r
2724 point = rect.CenterPoint();
\r
2728 int s = m_LogList.GetSelectionMark();
\r
2731 std::vector<CString> changedpaths;
\r
2732 std::vector<LogChangedPath*> changedlogpaths;
\r
2733 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2735 return; // nothing is selected, get out of here
\r
2737 bool bOneRev = true;
\r
2738 int sel=m_LogList.GetNextSelectedItem(pos);
\r
2739 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel));
\r
2740 GitRev * rev1 = pLogEntry;
\r
2741 GitRev * rev2 = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel+1));
\r
2743 bool bOneRev = true;
\r
2748 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
2751 rev1 = max(rev1,(git_revnum_t)pLogEntry->Rev);
\r
2752 rev2 = min(rev2,(git_revnum_t)pLogEntry->Rev);
\r
2758 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2761 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2762 changedpaths.push_back(m_currentChangedPathList[nItem].GetGitPathString());
\r
2767 // only one revision is selected in the log dialog top pane
\r
2768 // but multiple items could be selected in the changed items list
\r
2771 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2774 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2775 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
2777 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2779 if ((changedlogpath)&&(!changedlogpath->sCopyFromPath.IsEmpty()))
\r
2780 rev2 = changedlogpath->lCopyFromRev;
\r
2783 // if the path was modified but the parent path was 'added with history'
\r
2784 // then we have to use the copy from revision of the parent path
\r
2785 CTGitPath cpath = CTGitPath(changedlogpath->sPath);
\r
2786 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
2788 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
2789 if (p.IsAncestorOf(cpath))
\r
2791 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
2792 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
2797 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
2799 // some items are hidden! So find out which item the user really clicked on
\r
2800 INT_PTR selRealIndex = -1;
\r
2801 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
2803 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
2805 if (selRealIndex == nItem)
\r
2807 selIndex = hiddenindex;
\r
2808 changedlogpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
2813 if (changedlogpath)
\r
2815 changedpaths.push_back(changedlogpath->sPath);
\r
2816 changedlogpaths.push_back(changedlogpath);
\r
2821 //entry is selected, now show the popup menu
\r
2823 if (popup.CreatePopupMenu())
\r
2825 bool bEntryAdded = false;
\r
2826 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2828 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
\r
2830 popup.AppendMenuIcon(CGitLogList::ID_DIFF, IDS_LOG_POPUP_DIFF, IDI_DIFF);
\r
2831 popup.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF, IDS_LOG_POPUP_BLAMEDIFF, IDI_BLAME);
\r
2832 popup.SetDefaultItem(CGitLogList::ID_DIFF, FALSE);
\r
2833 popup.AppendMenuIcon(CGitLogList::ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
2834 bEntryAdded = true;
\r
2836 // if (rev2 == rev1-1)
\r
2839 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2840 popup.AppendMenuIcon(CGitLogList::ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
2841 popup.AppendMenuIcon(CGitLogList::ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
2842 popup.AppendMenuIcon(CGitLogList::ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
2843 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2845 popup.AppendMenuIcon(CGitLogList::ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
2846 popup.AppendMenuIcon(CGitLogList::ID_POPPROPS, IDS_REPOBROWSE_SHOWPROP, IDI_PROPERTIES); // "Show Properties"
\r
2847 popup.AppendMenuIcon(CGitLogList::ID_LOG, IDS_MENULOG, IDI_LOG); // "Show Log"
\r
2848 popup.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS, IDS_LOG_POPUP_GETMERGELOGS, IDI_LOG); // "Show merge log"
\r
2849 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
2850 bEntryAdded = true;
\r
2851 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
2853 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2854 popup.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
2856 if (popup.GetDefaultItem(0,FALSE)==-1)
\r
2857 popup.SetDefaultItem(CGitLogList::ID_OPEN, FALSE);
\r
2860 else if (changedlogpaths.size())
\r
2862 // more than one entry is selected
\r
2863 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE);
\r
2864 bEntryAdded = true;
\r
2869 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2870 bool bOpenWith = false;
\r
2871 bool bMergeLog = false;
\r
2872 m_bCancelled = false;
\r
2876 case CGitLogList::ID_DIFF:
\r
2878 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
2882 case ID_BLAMEDIFF:
\r
2884 DoDiffFromLog(selIndex, rev1, rev2, true, false);
\r
2889 DoDiffFromLog(selIndex, rev1, rev2, false, true);
\r
2892 case ID_REVERTREV:
\r
2894 SetPromptApp(&theApp);
\r
2895 theApp.DoWaitCursor(1);
\r
2897 if (Git::PathIsURL(m_path))
\r
2899 sUrl = m_path.GetGitPathString();
\r
2903 sUrl = GetURLFromPath(m_path);
\r
2904 if (sUrl.IsEmpty())
\r
2906 theApp.DoWaitCursor(-1);
\r
2908 temp.Format(IDS_ERR_NOURLOFFILE, m_path.GetWinPath());
\r
2909 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2911 theApp.DoWaitCursor(-1);
\r
2915 // find the working copy path of the selected item from the URL
\r
2916 m_bCancelled = false;
\r
2917 CString sUrlRoot = GetRepositoryRoot(CTGitPath(sUrl));
\r
2919 CString fileURL = changedpaths[0];
\r
2920 fileURL = sUrlRoot + fileURL.Trim();
\r
2921 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
\r
2922 // sUrl = http://mydomain.com/repos/trunk/folder
\r
2923 CString sUnescapedUrl = CPathUtils::PathUnescape(sUrl);
\r
2924 // find out until which char the urls are identical
\r
2926 while ((i<fileURL.GetLength())&&(i<sUnescapedUrl.GetLength())&&(fileURL[i]==sUnescapedUrl[i]))
\r
2928 int leftcount = m_path.GetWinPathString().GetLength()-(sUnescapedUrl.GetLength()-i);
\r
2929 CString wcPath = m_path.GetWinPathString().Left(leftcount);
\r
2930 wcPath += fileURL.Mid(i);
\r
2931 wcPath.Replace('/', '\\');
\r
2932 CGitProgressDlg dlg;
\r
2933 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
2935 // a deleted path! Since the path isn't there anymore, merge
\r
2936 // won't work. So just do a copy url->wc
\r
2937 dlg.SetCommand(CGitProgressDlg::GitProgress_Copy);
\r
2938 dlg.SetPathList(CTGitPathList(CTGitPath(fileURL)));
\r
2939 dlg.SetUrl(wcPath);
\r
2940 dlg.SetRevision(rev2);
\r
2944 if (!PathFileExists(wcPath))
\r
2946 // seems the path got renamed
\r
2947 // tell the user how to work around this.
\r
2948 CMessageBox::Show(this->m_hWnd, IDS_LOG_REVERTREV_ERROR, IDS_APPNAME, MB_ICONERROR);
\r
2950 theApp.DoWaitCursor(-1);
\r
2953 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
2954 dlg.SetPathList(CTGitPathList(CTGitPath(wcPath)));
\r
2955 dlg.SetUrl(fileURL);
\r
2956 dlg.SetSecondUrl(fileURL);
\r
2957 GitRevRangeArray revarray;
\r
2958 revarray.AddRevRange(rev1, rev2);
\r
2959 dlg.SetRevisionRanges(revarray);
\r
2962 msg.Format(IDS_LOG_REVERT_CONFIRM, (LPCTSTR)wcPath);
\r
2963 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
2967 theApp.DoWaitCursor(-1);
\r
2972 DialogEnableWindow(IDOK, FALSE);
\r
2973 SetPromptApp(&theApp);
\r
2974 theApp.DoWaitCursor(1);
\r
2976 if (Git::PathIsURL(m_path))
\r
2978 filepath = m_path.GetGitPathString();
\r
2982 filepath = GetURLFromPath(m_path);
\r
2983 if (filepath.IsEmpty())
\r
2985 theApp.DoWaitCursor(-1);
\r
2987 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2988 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2989 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2994 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2995 filepath += changedpaths[0];
\r
2998 dlg.m_Path = CTGitPath(filepath);
\r
3001 theApp.DoWaitCursor(-1);
\r
3006 DialogEnableWindow(IDOK, FALSE);
\r
3007 SetPromptApp(&theApp);
\r
3008 theApp.DoWaitCursor(1);
\r
3010 if (Git::PathIsURL(m_path))
\r
3012 filepath = m_path.GetGitPathString();
\r
3016 filepath = GetURLFromPath(m_path);
\r
3017 if (filepath.IsEmpty())
\r
3019 theApp.DoWaitCursor(-1);
\r
3021 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3022 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3023 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3028 m_bCancelled = false;
\r
3029 CString sRoot = GetRepositoryRoot(CTGitPath(filepath));
\r
3030 // if more than one entry is selected, we save them
\r
3031 // one by one into a folder the user has selected
\r
3032 bool bTargetSelected = false;
\r
3033 CTGitPath TargetPath;
\r
3034 if (m_ChangedFileListCtrl.GetSelectedCount() > 1)
\r
3036 CBrowseFolder browseFolder;
\r
3037 browseFolder.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT)));
\r
3038 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
\r
3039 CString strSaveAsDirectory;
\r
3040 if (browseFolder.Show(GetSafeHwnd(), strSaveAsDirectory) == CBrowseFolder::OK)
\r
3042 TargetPath = CTGitPath(strSaveAsDirectory);
\r
3043 bTargetSelected = true;
\r
3048 // Display the Open dialog box.
\r
3049 CString revFilename;
\r
3051 temp = CPathUtils::GetFileNameFromPath(changedpaths[0]);
\r
3052 int rfind = temp.ReverseFind('.');
\r
3054 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)temp.Left(rfind), rev1, (LPCTSTR)temp.Mid(rfind));
\r
3056 revFilename.Format(_T("%s-%ld"), (LPCTSTR)temp, rev1);
\r
3057 bTargetSelected = CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd);
\r
3058 TargetPath.SetFromWin(revFilename);
\r
3060 if (bTargetSelected)
\r
3062 CProgressDlg progDlg;
\r
3063 progDlg.SetTitle(IDS_APPNAME);
\r
3064 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
3065 for (std::vector<LogChangedPath*>::iterator it = changedlogpaths.begin(); it!= changedlogpaths.end(); ++it)
\r
3067 GitRev getrev = ((*it)->action == LOGACTIONS_DELETED) ? rev2 : rev1;
\r
3069 CString sInfoLine;
\r
3070 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)getrev.ToString());
\r
3071 progDlg.SetLine(1, sInfoLine, true);
\r
3072 SetAndClearProgressInfo(&progDlg);
\r
3073 progDlg.ShowModeless(m_hWnd);
\r
3075 CTGitPath tempfile = TargetPath;
\r
3076 if (changedpaths.size() > 1)
\r
3078 // if multiple items are selected, then the TargetPath
\r
3079 // points to a folder and we have to append the filename
\r
3080 // to save to to that folder.
\r
3081 CString sName = (*it)->sPath;
\r
3082 int slashpos = sName.ReverseFind('/');
\r
3083 if (slashpos >= 0)
\r
3084 sName = sName.Mid(slashpos);
\r
3085 tempfile.AppendPathString(sName);
\r
3086 // one problem here:
\r
3087 // a user could have selected multiple items which
\r
3088 // have the same filename but reside in different
\r
3089 // directories, e.g.
\r
3092 // in that case, the second 'file1' will overwrite
\r
3093 // the already saved 'file1'.
\r
3095 // we could maybe find the common root of all selected
\r
3096 // items and then create sub folders to save those files
\r
3098 // But I think we should just leave it that way: to check
\r
3099 // out multiple items at once, the better way is still to
\r
3100 // use the export command from the top pane of the log dialog.
\r
3102 filepath = sRoot + (*it)->sPath;
\r
3103 if (!Cat(CTGitPath(filepath), getrev, getrev, tempfile))
\r
3106 SetAndClearProgressInfo((HWND)NULL);
\r
3107 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
3109 theApp.DoWaitCursor(-1);
\r
3114 SetAndClearProgressInfo((HWND)NULL);
\r
3117 theApp.DoWaitCursor(-1);
\r
3124 GitRev getrev = pLogEntry->pArChangedPaths->GetAt(selIndex)->action == LOGACTIONS_DELETED ? rev2 : rev1;
\r
3125 Open(bOpenWith,changedpaths[0],getrev);
\r
3131 if (Git::PathIsURL(m_path))
\r
3133 filepath = m_path.GetGitPathString();
\r
3137 filepath = GetURLFromPath(m_path);
\r
3138 if (filepath.IsEmpty())
\r
3140 theApp.DoWaitCursor(-1);
\r
3142 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3143 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3144 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3149 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
3150 filepath += changedpaths[0];
\r
3152 dlg.EndRev = rev1;
\r
3153 if (dlg.DoModal() == IDOK)
\r
3158 tempfile = blame.BlameToTempFile(CTGitPath(filepath), dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
3159 if (!tempfile.IsEmpty())
\r
3161 if (dlg.m_bTextView)
\r
3163 //open the default text editor for the result file
\r
3164 CAppUtils::StartTextViewer(tempfile);
\r
3168 CString sParams = _T("/path:\"") + filepath + _T("\" ");
\r
3169 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(filepath),sParams))
\r
3177 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
3182 case ID_GETMERGELOGS:
\r
3187 DialogEnableWindow(IDOK, FALSE);
\r
3188 SetPromptApp(&theApp);
\r
3189 theApp.DoWaitCursor(1);
\r
3191 if (Git::PathIsURL(m_path))
\r
3193 filepath = m_path.GetGitPathString();
\r
3197 filepath = GetURLFromPath(m_path);
\r
3198 if (filepath.IsEmpty())
\r
3200 theApp.DoWaitCursor(-1);
\r
3202 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3203 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3204 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3209 m_bCancelled = false;
\r
3210 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
3211 filepath += changedpaths[0];
\r
3212 git_revnum_t logrev = rev1;
\r
3213 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
3215 // if the item got deleted in this revision,
\r
3216 // fetch the log from the previous revision where it
\r
3221 sCmd.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR)filepath, logrev);
\r
3223 sCmd += _T(" /merge");
\r
3224 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
3226 theApp.DoWaitCursor(-1);
\r
3229 case ID_VIEWPATHREV:
\r
3231 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetSelectionMark()));
\r
3232 GitRev rev = pLogEntry->Rev;
\r
3233 CString relurl = changedpaths[0];
\r
3234 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
3235 url.Replace(_T("%REVISION%"), rev.ToString());
\r
3236 url.Replace(_T("%PATH%"), relurl);
\r
3237 relurl = relurl.Mid(relurl.Find('/'));
\r
3238 url.Replace(_T("%PATH1%"), relurl);
\r
3239 if (!url.IsEmpty())
\r
3240 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
3248 } // if (popup.CreatePopupMenu())
\r
3252 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3254 // the date control should not show the "today" button
\r
3255 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
\r
3257 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
3261 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3263 // the date control should not show the "today" button
\r
3264 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
\r
3266 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
3270 void CLogDlg::OnSize(UINT nType, int cx, int cy)
\r
3272 __super::OnSize(nType, cx, cy);
\r
3274 SetSplitterRange();
\r
3277 void CLogDlg::OnRefresh()
\r
3279 if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
3286 void CLogDlg::OnFind()
\r
3288 if (!m_pFindDialog)
\r
3290 m_pFindDialog = new CFindReplaceDialog();
\r
3291 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
3295 void CLogDlg::OnFocusFilter()
\r
3297 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3300 void CLogDlg::OnEditCopy()
\r
3302 if (GetFocus() == &m_ChangedFileListCtrl)
\r
3303 CopyChangedSelectionToClipBoard();
\r
3305 m_LogList.CopySelectionToClipBoard();
\r
3308 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
\r
3310 // is the URL a relative one?
\r
3311 if (url.Left(2).Compare(_T("^/")) == 0)
\r
3313 // URL is relative to the repository root
\r
3314 CString url1 = m_sRepositoryRoot + url.Mid(1);
\r
3315 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
3316 DWORD len = url.GetLength();
\r
3317 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
\r
3318 return CString(buf, len);
\r
3321 else if (url[0] == '/')
\r
3323 // URL is relative to the server's hostname
\r
3325 // find the server's hostname
\r
3326 int schemepos = m_sRepositoryRoot.Find(_T("//"));
\r
3327 if (schemepos >= 0)
\r
3329 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
\r
3330 CString url1 = sHost + url;
\r
3331 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
3332 DWORD len = url.GetLength();
\r
3333 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
\r
3334 return CString(buf, len);
\r
3342 void CLogDlg::OnEnChangeSearchedit()
\r
3345 if (m_LogList.m_sFilterText.IsEmpty())
\r
3347 CStoreSelection storeselection(this);
\r
3348 // clear the filter, i.e. make all entries appear
\r
3349 theApp.DoWaitCursor(1);
\r
3350 KillTimer(LOGFILTER_TIMER);
\r
3351 FillLogMessageCtrl(false);
\r
3352 m_LogList.StartFilter();
\r
3354 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3355 m_arShownList.RemoveAll();
\r
3356 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3358 if (IsEntryInDateRange(i))
\r
3359 m_arShownList.Add(m_logEntries[i]);
\r
3361 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3362 m_LogList.DeleteAllItems();
\r
3363 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3364 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3365 m_LogList.SetRedraw(false);
\r
3366 ResizeAllListCtrlCols();
\r
3367 m_LogList.SetRedraw(true);
\r
3369 theApp.DoWaitCursor(-1);
\r
3370 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3371 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3372 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3373 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
3376 if (Validate(m_LogList.m_sFilterText))
\r
3377 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3379 KillTimer(LOGFILTER_TIMER);
\r