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
48 #include "BrowseRefsDlg.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
64 , m_bSelectionMustBeContinuous(false)
\r
65 , m_bShowBugtraqColumn(false)
\r
66 , m_lowestRev(_T(""))
\r
68 , m_sLogInfo(_T(""))
\r
69 , m_pFindDialog(NULL)
\r
70 , m_bCancelled(FALSE)
\r
71 , m_pNotifyWindow(NULL)
\r
73 , m_bAscending(FALSE)
\r
78 , m_bIncludeMerges(FALSE)
\r
81 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
83 m_bFirstParent=FALSE;
\r
84 m_bWholeProject=FALSE;
\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_Text(pDX, IDC_SEARCHEDIT, m_LogList.m_sFilterText);
\r
103 DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);
\r
104 DDX_Control(pDX, IDC_DATETO, m_DateTo);
\r
105 DDX_Control(pDX, IDC_HIDEPATHS, m_cHidePaths);
\r
106 DDX_Text(pDX, IDC_LOGINFO, m_sLogInfo);
\r
107 DDX_Check(pDX, IDC_LOG_FIRSTPARENT, m_bFirstParent);
\r
108 DDX_Check(pDX, IDC_LOG_ALLBRANCH,m_bAllBranch);
\r
109 DDX_Check(pDX, IDC_SHOWWHOLEPROJECT,m_bWholeProject);
\r
110 DDX_Control(pDX, IDC_SEARCHEDIT, m_cFilter);
\r
111 DDX_Control(pDX, IDC_STATIC_REF, m_staticRef);
\r
114 BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)
\r
115 ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage)
\r
116 //ON_BN_CLICKED(IDC_GETALL, OnBnClickedGetall)
\r
117 //ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)
\r
118 ON_WM_CONTEXTMENU()
\r
120 ON_BN_CLICKED(IDHELP, OnBnClickedHelp)
\r
121 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGLIST, OnLvnItemchangedLoglist)
\r
122 ON_NOTIFY(EN_LINK, IDC_MSGVIEW, OnEnLinkMsgview)
\r
123 ON_BN_CLICKED(IDC_STATBUTTON, OnBnClickedStatbutton)
\r
126 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)
\r
127 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)
\r
129 ON_MESSAGE(MSG_LOAD_PERCENTAGE,OnLogListLoading)
\r
131 ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)
\r
133 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)
\r
134 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)
\r
135 ON_BN_CLICKED(IDC_SHOWWHOLEPROJECT, OnBnClickShowWholeProject)
\r
136 //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
\r
137 //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
\r
138 ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST , OnLvnColumnclick)
\r
139 //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
\r
140 ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)
\r
141 ON_BN_CLICKED(IDC_LOG_ALLBRANCH,OnBnClickedAllBranch)
\r
143 ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)
\r
144 ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)
\r
146 ON_BN_CLICKED(IDC_LOG_FIRSTPARENT, &CLogDlg::OnBnClickedFirstParent)
\r
147 ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)
\r
148 // ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CLogDlg::OnBnClickedBrowseRef)
\r
149 ON_STN_CLICKED(IDC_STATIC_REF, &CLogDlg::OnBnClickedBrowseRef)
\r
150 ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)
\r
151 ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)
\r
152 ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)
\r
153 ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)
\r
156 void CLogDlg::SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit /* = FALSE */)
\r
160 m_startrev = startrev;
\r
161 m_LogRevision = startrev;
\r
163 m_hasWC = !path.IsUrl();
\r
165 if (::IsWindow(m_hWnd))
\r
169 BOOL CLogDlg::OnInitDialog()
\r
172 CResizableStandAloneDialog::OnInitDialog();
\r
174 m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));
\r
177 // use the state of the "stop on copy/rename" option from the last time
\r
180 // set the font to use in the log message view, configured in the settings dialog
\r
181 CAppUtils::CreateFontForLogs(m_logFont);
\r
182 GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);
\r
183 // automatically detect URLs in the log message and turn them into links
\r
184 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);
\r
185 // make the log message rich edit control send a message when the mouse pointer is over a link
\r
186 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);
\r
187 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
189 // the "hide unrelated paths" checkbox should be indeterminate
\r
190 m_cHidePaths.SetCheck(BST_INDETERMINATE);
\r
193 // if there is a working copy, load the project properties
\r
194 // to get information about the bugtraq: integration
\r
196 m_ProjectProperties.ReadProps(m_path);
\r
198 // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set
\r
199 if ((!m_ProjectProperties.sUrl.IsEmpty())||(!m_ProjectProperties.sCheckRe.IsEmpty()))
\r
200 m_bShowBugtraqColumn = true;
\r
202 //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
\r
203 //theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
\r
205 // set up the columns
\r
206 m_LogList.DeleteAllItems();
\r
207 m_LogList.InsertGitColumn();
\r
209 m_ChangedFileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("LogDlg"),(SVNSLC_POPALL ^ (SVNSLC_POPCOMMIT|SVNSLC_POPREVERT)),false);
\r
211 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
214 m_sMessageBuf.Preallocate(100000);
\r
216 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
\r
217 SetDlgTitle(false);
\r
219 m_tooltips.Create(this);
\r
220 CheckRegexpTooltip();
\r
222 SetSplitterRange();
\r
224 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
\r
225 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
\r
226 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
\r
227 m_cFilter.SetValidator(this);
\r
229 AdjustControlSize(IDC_HIDEPATHS);
\r
230 AdjustControlSize(IDC_LOG_FIRSTPARENT);
\r
231 AdjustControlSize(IDC_LOG_ALLBRANCH);
\r
233 GetClientRect(m_DlgOrigRect);
\r
234 m_LogList.GetClientRect(m_LogListOrigRect);
\r
235 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
\r
236 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
\r
238 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
239 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
241 m_staticRef.SetURL(CString());
\r
244 AddAnchor(IDC_STATIC_REF, TOP_LEFT);
\r
245 //AddAnchor(IDC_BUTTON_BROWSE_REF, TOP_LEFT);
\r
246 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
\r
247 AddAnchor(IDC_DATEFROM, TOP_LEFT);
\r
248 AddAnchor(IDC_TOLABEL, TOP_LEFT);
\r
249 AddAnchor(IDC_DATETO, TOP_LEFT);
\r
251 SetFilterCueText();
\r
252 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
\r
254 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
255 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
256 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
257 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
258 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
260 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
261 AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);
\r
262 AddAnchor(IDC_LOG_ALLBRANCH,BOTTOM_LEFT);
\r
263 AddAnchor(IDC_LOG_FIRSTPARENT, BOTTOM_LEFT);
\r
264 //AddAnchor(IDC_GETALL, BOTTOM_LEFT);
\r
265 AddAnchor(IDC_SHOWWHOLEPROJECT, BOTTOM_LEFT);
\r
266 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
\r
267 AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);
\r
268 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
269 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
270 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
271 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
273 // SetPromptParentWindow(m_hWnd);
\r
276 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
277 EnableSaveRestore(_T("LogDlg"));
\r
279 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
280 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
281 RECT rcDlg, rcLogList, rcChgMsg;
\r
282 GetClientRect(&rcDlg);
\r
283 m_LogList.GetWindowRect(&rcLogList);
\r
284 ScreenToClient(&rcLogList);
\r
285 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
\r
286 ScreenToClient(&rcChgMsg);
\r
290 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
291 ScreenToClient(&rectSplitter);
\r
292 int delta = yPos1 - rectSplitter.top;
\r
294 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
\r
296 m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);
\r
303 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
304 ScreenToClient(&rectSplitter);
\r
305 int delta = yPos2 - rectSplitter.top;
\r
307 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
\r
309 m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);
\r
317 // the dialog is used to select revisions
\r
318 // enable the OK button if appropriate
\r
323 // the dialog is used to just view log messages
\r
324 // hide the OK button and set text on Cancel button to OK
\r
325 GetDlgItemText(IDOK, temp);
\r
326 SetDlgItemText(IDCANCEL, temp);
\r
327 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
\r
330 m_mergedRevs.clear();
\r
332 // first start a thread to obtain the log messages without
\r
333 // blocking the dialog
\r
335 //m_tFrom = (DWORD)-1;
\r
337 m_LogList.m_Path=m_path;
\r
338 m_LogList.FetchLogAsync(this);
\r
340 GetDlgItem(IDC_LOGLIST)->SetFocus();
\r
346 LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM /*lParam*/)
\r
348 int cur=(int)wParam;
\r
350 if( cur == GITLOG_START )
\r
353 temp.LoadString(IDS_PROGRESSWAIT);
\r
355 this->m_LogList.ShowText(temp, true);
\r
357 // We use a progress bar while getting the logs
\r
358 m_LogProgress.SetRange32(0, 100);
\r
359 m_LogProgress.SetPos(0);
\r
361 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
\r
363 //DialogEnableWindow(IDC_GETALL, FALSE);
\r
364 //DialogEnableWindow(IDC_SHOWWHOLEPROJECT, FALSE);
\r
365 //DialogEnableWindow(IDC_LOG_FIRSTPARENT, FALSE);
\r
366 DialogEnableWindow(IDC_STATBUTTON, FALSE);
\r
367 DialogEnableWindow(IDC_REFRESH, FALSE);
\r
368 DialogEnableWindow(IDC_HIDEPATHS,FALSE);
\r
370 }else if( cur == GITLOG_END)
\r
373 //if (!m_bShowedAll)
\r
374 DialogEnableWindow(IDC_SHOWWHOLEPROJECT, TRUE);
\r
376 //DialogEnableWindow(IDC_GETALL, TRUE);
\r
377 DialogEnableWindow(IDC_LOG_FIRSTPARENT, TRUE);
\r
378 DialogEnableWindow(IDC_STATBUTTON, TRUE);
\r
379 DialogEnableWindow(IDC_REFRESH, TRUE);
\r
380 DialogEnableWindow(IDC_HIDEPATHS,TRUE);
\r
382 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
\r
383 GetDlgItem(IDC_PROGRESS)->ShowWindow(FALSE);
\r
384 //CTime time=m_LogList.GetOldestTime();
\r
386 m_LogList.GetTimeRange(begin,end);
\r
387 m_DateFrom.SetTime(&begin);
\r
388 m_DateTo.SetTime(&end);
\r
394 if(this->m_LogList.HasText())
\r
396 this->m_LogList.ClearText();
\r
397 UpdateLogInfoLabel();
\r
399 m_LogProgress.SetPos(cur);
\r
403 void CLogDlg::SetDlgTitle(bool bOffline)
\r
405 if (m_sTitle.IsEmpty())
\r
406 GetWindowText(m_sTitle);
\r
411 if (m_path.IsUrl())
\r
412 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());
\r
413 else if (m_path.IsDirectory())
\r
414 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());
\r
416 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());
\r
417 SetWindowText(sTemp);
\r
421 if (m_path.IsUrl())
\r
422 SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());
\r
423 else if (m_path.IsEmpty())
\r
424 SetWindowText(m_sTitle + _T(" - ") + CString(_T("Whole Project")));
\r
425 else if (m_path.IsDirectory())
\r
426 SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());
\r
428 SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());
\r
432 void CLogDlg::CheckRegexpTooltip()
\r
434 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
\r
435 // Since tooltip describes regexp features, show it only if regexps are enabled.
\r
436 if (m_bFilterWithRegex)
\r
438 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
\r
441 m_tooltips.DelTool(pWnd);
\r
444 void CLogDlg::EnableOKButton()
\r
448 // the dialog is used to select revisions
\r
449 if (m_bSelectionMustBeSingle)
\r
451 // enable OK button if only a single revision is selected
\r
452 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()==1));
\r
454 else if (m_bSelectionMustBeContinuous)
\r
455 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
\r
457 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
460 DialogEnableWindow(IDOK, TRUE);
\r
463 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
\r
465 // we fill here the log message rich edit control,
\r
466 // and also populate the changed files list control
\r
467 // according to the selected revision(s).
\r
469 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
470 // empty the log message view
\r
471 pMsgView->SetWindowText(_T(" "));
\r
472 // empty the changed files list
\r
473 m_ChangedFileListCtrl.SetRedraw(FALSE);
\r
474 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
475 m_currentChangedArray = NULL;
\r
476 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
477 m_ChangedFileListCtrl.DeleteAllItems();
\r
479 // if we're not here to really show a selected revision, just
\r
480 // get out of here after clearing the views, which is what is intended
\r
481 // if that flag is not set.
\r
485 m_ChangedFileListCtrl.Invalidate();
\r
486 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
487 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
491 // depending on how many revisions are selected, we have to do different
\r
493 int selCount = m_LogList.GetSelectedCount();
\r
496 // if nothing is selected, we have nothing more to do
\r
497 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
498 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
501 else if (selCount == 1)
\r
503 // if one revision is selected, we have to fill the log message view
\r
504 // with the corresponding log message, and also fill the changed files
\r
506 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
507 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
508 if (selIndex >= m_LogList.m_arShownList.GetCount())
\r
510 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
511 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
514 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));
\r
516 if(!pLogEntry->m_IsFull)
\r
518 pMsgView->SetWindowText(_T("load ..."));
\r
521 // set the log message text
\r
522 pMsgView->SetWindowText(_T("Commit:")+pLogEntry->m_CommitHash+_T("\r\n\r\n* ")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);
\r
523 // turn bug ID's into links if the bugtraq: properties have been set
\r
524 // and we can find a match of those in the log message
\r
527 pMsgView->GetWindowText(text);
\r
528 // the rich edit control doesn't count the CR char!
\r
529 // to be exact: CRLF is treated as one char.
\r
530 text.Replace(_T("\r"), _T(""));
\r
532 m_ProjectProperties.FindBugID(text, pMsgView);
\r
533 CAppUtils::FormatTextInRichEditControl(pMsgView);
\r
535 int HidePaths=m_cHidePaths.GetState() & 0x0003;
\r
536 CString matchpath=this->m_path.GetGitPathString();
\r
538 for(int i=0;i<pLogEntry->m_Files.GetCount() && (!matchpath.IsEmpty());i++)
\r
540 if( m_bWholeProject )
\r
543 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action &= ~(CTGitPath::LOGACTIONS_HIDE|CTGitPath::LOGACTIONS_GRAY);
\r
545 if(pLogEntry->m_Files[i].GetGitPathString().Left(matchpath.GetLength()) != matchpath)
\r
547 if(HidePaths==BST_CHECKED)
\r
548 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action |= CTGitPath::LOGACTIONS_HIDE;
\r
549 if(HidePaths==BST_INDETERMINATE)
\r
550 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action |= CTGitPath::LOGACTIONS_GRAY;
\r
553 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->m_Files);
\r
554 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;
\r
555 m_ChangedFileListCtrl.Show(SVNSLC_SHOWVERSIONED);
\r
557 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
564 // more than one revision is selected:
\r
565 // the log message view must be emptied
\r
566 // the changed files list contains all the changed paths from all
\r
567 // selected revisions, with 'doubles' removed
\r
568 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
\r
571 // redraw the views
\r
572 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
574 if (m_currentChangedArray)
\r
576 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
\r
577 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
\r
579 else if (m_currentChangedPathList.GetCount())
\r
581 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
\r
582 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
\r
586 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
587 m_ChangedFileListCtrl.Invalidate();
\r
590 // sort according to the settings
\r
591 if (m_nSortColumnPathList > 0)
\r
592 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
594 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
\r
595 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
599 void CLogDlg::OnBnClickedRefresh()
\r
605 void CLogDlg::Refresh (bool /*autoGoOnline*/)
\r
607 m_LogList.Refresh();
\r
612 BOOL CLogDlg::Cancel()
\r
614 return m_bCancelled;
\r
617 void CLogDlg::SaveSplitterPos()
\r
621 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
622 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
624 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
625 ScreenToClient(&rectSplitter);
\r
626 regPos1 = rectSplitter.top;
\r
627 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
628 ScreenToClient(&rectSplitter);
\r
629 regPos2 = rectSplitter.top;
\r
633 void CLogDlg::OnCancel()
\r
635 // canceling means stopping the working thread if it's still running.
\r
636 if (this->IsThreadRunning())
\r
638 m_LogList.TerminateThread();
\r
643 __super::OnCancel();
\r
646 CString CLogDlg::MakeShortMessage(const CString& message)
\r
648 bool bFoundShort = true;
\r
649 CString sShortMessage = m_ProjectProperties.GetLogSummary(message);
\r
650 if (sShortMessage.IsEmpty())
\r
652 bFoundShort = false;
\r
653 sShortMessage = message;
\r
655 // Remove newlines and tabs 'cause those are not shown nicely in the list control
\r
656 sShortMessage.Replace(_T("\r"), _T(""));
\r
657 sShortMessage.Replace(_T("\t"), _T(" "));
\r
659 // Suppose the first empty line separates 'summary' from the rest of the message.
\r
660 int found = sShortMessage.Find(_T("\n\n"));
\r
661 // To avoid too short 'short' messages
\r
662 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
\r
663 // only use the empty newline as a separator if it comes after at least 15 chars.
\r
664 if ((!bFoundShort)&&(found >= 15))
\r
666 sShortMessage = sShortMessage.Left(found);
\r
668 sShortMessage.Replace('\n', ' ');
\r
669 return sShortMessage;
\r
672 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
675 if (rev == SVN_INVALID_REVNUM)
\r
681 // this is the callback function which receives the data for every revision we ask the log for
\r
682 // we store this information here one by one.
\r
684 if (m_startrev == -1)
\r
689 m_LogProgress.SetPos(m_limit - m_limitcounter);
\r
691 else if (m_startrev.IsNumber() && m_startrev.IsNumber())
\r
692 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);
\r
693 __time64_t ttime = time/1000000L;
\r
694 if (m_tTo < (DWORD)ttime)
\r
695 m_tTo = (DWORD)ttime;
\r
696 if (m_tFrom > (DWORD)ttime)
\r
697 m_tFrom = (DWORD)ttime;
\r
698 if ((m_lowestRev > rev)||(m_lowestRev < 0))
\r
700 // Add as many characters from the log message to the list control
\r
701 PLOGENTRYDATA pLogItem = new LOGENTRYDATA;
\r
702 pLogItem->bCopies = !!copies;
\r
704 // find out if this item was copied in the revision
\r
705 BOOL copiedself = FALSE;
\r
708 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)
\r
710 LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);
\r
711 if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))
\r
713 // note: this only works if the log is fetched top-to-bottom
\r
714 // but since we do that, it shouldn't be a problem
\r
715 m_sSelfRelativeURL = cpath->sCopyFromPath;
\r
721 pLogItem->bCopiedSelf = copiedself;
\r
722 pLogItem->tmDate = ttime;
\r
723 pLogItem->sAuthor = author;
\r
724 pLogItem->sDate = date;
\r
725 pLogItem->sShortMessage = MakeShortMessage(message);
\r
726 pLogItem->dwFileChanges = filechanges;
\r
727 pLogItem->actions = actions;
\r
728 pLogItem->haschildren = haschildren;
\r
729 pLogItem->childStackDepth = m_childCounter;
\r
730 m_maxChild = max(m_childCounter, m_maxChild);
\r
733 pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();
\r
735 // split multi line log entries and concatenate them
\r
736 // again but this time with \r\n as line separators
\r
737 // so that the edit control recognizes them
\r
740 if (message.GetLength()>0)
\r
742 m_sMessageBuf = message;
\r
743 m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));
\r
744 m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));
\r
745 if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)
\r
746 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);
\r
749 m_sMessageBuf.Empty();
\r
750 pLogItem->sMessage = m_sMessageBuf;
\r
751 pLogItem->Rev = rev;
\r
753 // move-construct path array
\r
755 pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);
\r
756 cpaths->RemoveAll();
\r
758 catch (CException * e)
\r
760 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);
\r
762 m_bCancelled = TRUE;
\r
764 m_logEntries.push_back(pLogItem);
\r
765 m_arShownList.Add(pLogItem);
\r
771 //this is the thread function which calls the subversion function
\r
776 void CLogDlg::CopyChangedSelectionToClipBoard()
\r
779 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
781 return; // nothing is selected, get out of here
\r
785 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
788 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
791 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
792 CTGitPath *path = (CTGitPath*)m_ChangedFileListCtrl.GetItemData(nItem);
\r
794 sPaths += path->GetGitPathString();
\r
795 sPaths += _T("\r\n");
\r
801 // only one revision is selected in the log dialog top pane
\r
802 // but multiple items could be selected in the changed items list
\r
803 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
806 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
807 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
809 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
811 // some items are hidden! So find out which item the user really selected
\r
812 INT_PTR selRealIndex = -1;
\r
813 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
815 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
817 if (selRealIndex == nItem)
\r
819 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);
\r
824 if (changedlogpath)
\r
826 sPaths += changedlogpath->sPath;
\r
827 sPaths += _T("\r\n");
\r
833 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
\r
837 BOOL CLogDlg::IsDiffPossible(LogChangedPath * /*changedpath*/, git_revnum_t rev)
\r
840 CString added, deleted;
\r
841 if (changedpath == NULL)
\r
844 if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))
\r
846 if (changedpath->action == LOGACTIONS_ADDED) // file is added
\r
848 if (changedpath->lCopyFromRev == 0)
\r
849 return FALSE; // but file was not added with history
\r
857 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
859 // we have two separate context menus:
\r
860 // one shown on the log message list control,
\r
861 // the other shown in the changed-files list control
\r
862 int selCount = m_LogList.GetSelectedCount();
\r
863 if (pWnd == &m_LogList)
\r
865 //ShowContextMenuForRevisions(pWnd, point);
\r
867 else if (pWnd == &m_ChangedFileListCtrl)
\r
869 //ShowContextMenuForChangedpaths(pWnd, point);
\r
871 else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
873 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
876 selIndex = m_LogList.GetNextSelectedItem(pos);
\r
877 if ((point.x == -1) && (point.y == -1))
\r
880 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
\r
881 ClientToScreen(&rect);
\r
882 point = rect.CenterPoint();
\r
884 CString sMenuItemText;
\r
886 if (popup.CreatePopupMenu())
\r
888 // add the 'default' entries
\r
889 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
\r
890 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
\r
891 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
\r
892 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
\r
894 //if (selIndex >= 0)
\r
896 // popup.AppendMenu(MF_SEPARATOR);
\r
897 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
\r
898 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
\r
901 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
905 break; // no command selected
\r
908 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
\r
910 case CGitLogList::ID_EDITAUTHOR:
\r
911 EditLogMessage(selIndex);
\r
919 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
922 ASSERT(m_pFindDialog != NULL);
\r
924 if (m_pFindDialog->IsTerminating())
\r
926 // invalidate the handle identifying the dialog box.
\r
927 m_pFindDialog = NULL;
\r
931 if(m_pFindDialog->FindNext())
\r
933 //read data from dialog
\r
934 CString FindText = m_pFindDialog->GetFindString();
\r
935 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
\r
936 bool bFound = false;
\r
938 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
\r
940 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
\r
943 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
\r
947 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
949 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))
\r
954 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
955 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
957 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
958 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))
\r
964 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))
\r
976 if (m_logEntries[i]->sMessage.Find(FindText) >= 0)
\r
981 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
982 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
983 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
985 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
986 if (cpath->sCopyFromPath.Find(FindText)>=0)
\r
992 if (cpath->sPath.Find(FindText)>=0)
\r
1002 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1003 CString msg = pLogEntry->sMessage;
\r
1004 msg = msg.MakeLower();
\r
1005 CString find = FindText.MakeLower();
\r
1006 if (msg.Find(find) >= 0)
\r
1011 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1012 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1014 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1015 CString lowerpath = cpath->sCopyFromPath;
\r
1016 lowerpath.MakeLower();
\r
1017 if (lowerpath.Find(find)>=0)
\r
1023 lowerpath = cpath->sPath;
\r
1024 lowerpath.MakeLower();
\r
1025 if (lowerpath.Find(find)>=0)
\r
1034 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
\r
1037 this->m_nSearchIndex = (i+1);
\r
1038 m_LogList.EnsureVisible(i, FALSE);
\r
1039 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);
\r
1040 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1041 m_LogList.SetSelectionMark(i);
\r
1042 FillLogMessageCtrl();
\r
1043 UpdateData(FALSE);
\r
1045 if (m_nSearchIndex >= m_arShownList.GetCount())
\r
1046 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
\r
1048 } // if(m_pFindDialog->FindNext())
\r
1049 UpdateLogInfoLabel();
\r
1054 void CLogDlg::OnOK()
\r
1056 // since the log dialog is also used to select revisions for other
\r
1057 // dialogs, we have to do some work before closing this dialog
\r
1058 if (GetFocus() != GetDlgItem(IDOK))
\r
1059 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
\r
1062 if (this->IsThreadRunning())
\r
1064 m_LogList.TerminateThread();
\r
1067 // check that one and only one row is selected
\r
1068 if (m_LogList.GetSelectedCount() == 1)
\r
1070 // get the selected row
\r
1071 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1072 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
1073 if (selIndex < m_LogList.m_arShownList.GetCount())
\r
1075 // all ok, pick up the revision
\r
1076 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));
\r
1077 // extract the hash
\r
1078 m_sSelectedHash = pLogEntry->m_CommitHash;
\r
1081 UpdateData(FALSE);
\r
1082 SaveSplitterPos();
\r
1086 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
\r
1087 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
\r
1090 CString buttontext;
\r
1091 GetDlgItemText(IDOK, buttontext);
\r
1092 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1093 if (temp.Compare(buttontext) != 0)
\r
1094 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
\r
1095 m_bCancelled = TRUE;
\r
1096 m_selectedRevs.Clear();
\r
1097 m_selectedRevsOneRange.Clear();
\r
1098 if (m_pNotifyWindow)
\r
1100 int selIndex = m_LogList.GetSelectionMark();
\r
1101 if (selIndex >= 0)
\r
1103 PLOGENTRYDATA pLogEntry = NULL;
\r
1104 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1105 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1106 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1107 git_revnum_t lowerRev = pLogEntry->Rev;
\r
1108 git_revnum_t higherRev = lowerRev;
\r
1111 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1112 git_revnum_t rev = pLogEntry->Rev;
\r
1113 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1114 if (lowerRev > rev)
\r
1116 if (higherRev < rev)
\r
1119 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
\r
1121 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
\r
1123 BOOL bSentMessage = FALSE;
\r
1124 if (m_LogList.GetSelectedCount() == 1)
\r
1126 // if only one revision is selected, check if the path/url with which the dialog was started
\r
1127 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
\r
1128 // if it was copied, use the copy from revision as lowerRev
\r
1129 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
\r
1131 CString sUrl = m_path.GetGitPathString();
\r
1132 if (!m_path.IsUrl())
\r
1134 sUrl = GetURLFromPath(m_path);
\r
1136 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
\r
1137 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
\r
1139 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);
\r
1142 if (sUrl.Compare(pData->sPath) == 0)
\r
1144 if (!pData->sCopyFromPath.IsEmpty())
\r
1146 lowerRev = pData->lCopyFromRev;
\r
1147 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
\r
1148 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
\r
1149 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1150 bSentMessage = TRUE;
\r
1157 if ( !bSentMessage )
\r
1159 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
\r
1160 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
\r
1161 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1162 if (m_selectedRevsOneRange.GetCount())
\r
1163 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
\r
1168 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
1169 reg = m_btnShow.GetCurrentEntry();
\r
1170 SaveSplitterPos();
\r
1174 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1176 // a double click on an entry in the changed-files list has happened
\r
1179 DiffSelectedFile();
\r
1182 void CLogDlg::DiffSelectedFile()
\r
1185 if (m_bThreadRunning)
\r
1187 UpdateLogInfoLabel();
\r
1188 INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
1191 if (m_ChangedFileListCtrl.GetSelectedCount() == 0)
\r
1193 // find out if there's an entry selected in the log list
\r
1194 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1195 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1196 git_revnum_t rev1 = pLogEntry->Rev;
\r
1197 git_revnum_t rev2 = rev1;
\r
1202 // there's at least a second entry selected in the log list: several revisions selected!
\r
1203 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1206 rev1 = max(rev1,(long)pLogEntry->Rev);
\r
1207 rev2 = min(rev2,(long)pLogEntry->Rev);
\r
1211 // now we have both revisions selected in the log list, so we can do a diff of the selected
\r
1212 // entry in the changed files list with these two revisions.
\r
1213 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1218 // nothing or only one revision selected in the log list
\r
1219 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1221 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1223 // some items are hidden! So find out which item the user really clicked on
\r
1224 INT_PTR selRealIndex = -1;
\r
1225 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1227 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1229 if (selRealIndex == selIndex)
\r
1231 selIndex = hiddenindex;
\r
1232 changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1238 if (IsDiffPossible(changedpath, rev1))
\r
1240 // diffs with renamed files are possible
\r
1241 if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))
\r
1242 rev2 = changedpath->lCopyFromRev;
\r
1245 // if the path was modified but the parent path was 'added with history'
\r
1246 // then we have to use the copy from revision of the parent path
\r
1247 CTGitPath cpath = CTGitPath(changedpath->sPath);
\r
1248 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
1250 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
1251 if (p.IsAncestorOf(cpath))
\r
1253 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
1254 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
1258 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1262 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1263 CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1265 // deleted files must be opened from the revision before the deletion
\r
1266 if (changedpath->action == LOGACTIONS_DELETED)
\r
1268 m_bCancelled = false;
\r
1270 CProgressDlg progDlg;
\r
1271 progDlg.SetTitle(IDS_APPNAME);
\r
1272 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1273 CString sInfoLine;
\r
1274 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());
\r
1275 progDlg.SetLine(1, sInfoLine, true);
\r
1276 SetAndClearProgressInfo(&progDlg);
\r
1277 progDlg.ShowModeless(m_hWnd);
\r
1279 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))
\r
1281 m_bCancelled = false;
\r
1282 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))
\r
1285 SetAndClearProgressInfo((HWND)NULL);
\r
1286 CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1291 SetAndClearProgressInfo((HWND)NULL);
\r
1293 CString sName1, sName2;
\r
1294 sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);
\r
1295 sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);
\r
1296 CAppUtils::DiffFlags flags;
\r
1297 flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1298 if (changedpath->action == LOGACTIONS_DELETED)
\r
1299 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);
\r
1301 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);
\r
1308 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)
\r
1310 DialogEnableWindow(IDOK, FALSE);
\r
1311 // SetPromptApp(&theApp);
\r
1312 theApp.DoWaitCursor(1);
\r
1315 GetTempPath(temppath);
\r
1318 file1.Format(_T("%s%s_%s%s"),
\r
1320 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1321 rev1->m_CommitHash.Left(6),
\r
1322 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1325 file2.Format(_T("%s\\%s_%s%s"),
\r
1327 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1328 rev2->m_CommitHash.Left(6),
\r
1329 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1333 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1334 g_Git.RunLogFile(cmd,file1);
\r
1335 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1336 g_Git.RunLogFile(cmd,file2);
\r
1338 CAppUtils::DiffFlags flags;
\r
1339 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);
\r
1342 //get the filename
\r
1344 if (Git::PathIsURL(m_path))
\r
1346 filepath = m_path.GetGitPathString();
\r
1350 filepath = GetURLFromPath(m_path);
\r
1351 if (filepath.IsEmpty())
\r
1353 theApp.DoWaitCursor(-1);
\r
1355 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1356 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1357 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1359 theApp.DoWaitCursor(-11);
\r
1363 m_bCancelled = FALSE;
\r
1364 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1366 CString firstfile, secondfile;
\r
1367 if (m_LogList.GetSelectedCount()==1)
\r
1369 int s = m_LogList.GetSelectionMark();
\r
1370 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));
\r
1371 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1372 firstfile = changedpath->sPath;
\r
1373 secondfile = firstfile;
\r
1374 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?
\r
1376 secondfile = changedpath->sCopyFromPath;
\r
1377 rev2 = changedpath->lCopyFromRev;
\r
1382 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();
\r
1383 secondfile = firstfile;
\r
1386 firstfile = filepath + firstfile.Trim();
\r
1387 secondfile = filepath + secondfile.Trim();
\r
1389 GitDiff diff(this, this->m_hWnd, true);
\r
1390 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1391 diff.SetHEADPeg(m_LogRevision);
\r
1394 if (PromptShown())
\r
1395 diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);
\r
1397 CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);
\r
1401 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))
\r
1403 if (firstfile.Compare(secondfile)==0)
\r
1405 git_revnum_t baseRev = 0;
\r
1406 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);
\r
1413 theApp.DoWaitCursor(-1);
\r
1417 BOOL CLogDlg::Open(bool /*bOpenWith*/,CString changedpath, git_revnum_t rev)
\r
1420 DialogEnableWindow(IDOK, FALSE);
\r
1421 SetPromptApp(&theApp);
\r
1422 theApp.DoWaitCursor(1);
\r
1424 if (Git::PathIsURL(m_path))
\r
1426 filepath = m_path.GetGitPathString();
\r
1430 filepath = GetURLFromPath(m_path);
\r
1431 if (filepath.IsEmpty())
\r
1433 theApp.DoWaitCursor(-1);
\r
1435 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1436 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1437 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1442 m_bCancelled = false;
\r
1443 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1444 filepath += changedpath;
\r
1446 CProgressDlg progDlg;
\r
1447 progDlg.SetTitle(IDS_APPNAME);
\r
1448 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1449 CString sInfoLine;
\r
1450 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());
\r
1451 progDlg.SetLine(1, sInfoLine, true);
\r
1452 SetAndClearProgressInfo(&progDlg);
\r
1453 progDlg.ShowModeless(m_hWnd);
\r
1455 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);
\r
1456 m_bCancelled = false;
\r
1457 if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))
\r
1460 SetAndClearProgressInfo((HWND)NULL);
\r
1461 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1463 theApp.DoWaitCursor(-1);
\r
1467 SetAndClearProgressInfo((HWND)NULL);
\r
1468 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1471 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1472 if (ret <= HINSTANCE_ERROR)
\r
1477 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1478 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1479 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1482 theApp.DoWaitCursor(-1);
\r
1487 void CLogDlg::EditAuthor(const CLogDataVector& /*logs*/)
\r
1492 if (logs.size() == 0)
\r
1494 DialogEnableWindow(IDOK, FALSE);
\r
1495 SetPromptApp(&theApp);
\r
1496 theApp.DoWaitCursor(1);
\r
1497 if (Git::PathIsURL(m_path))
\r
1498 url = m_path.GetGitPathString();
\r
1501 url = GetURLFromPath(m_path);
\r
1503 name = Git_PROP_REVISION_AUTHOR;
\r
1505 CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);
\r
1506 CString sOldValue = value;
\r
1507 value.Replace(_T("\n"), _T("\r\n"));
\r
1508 CInputDlg dlg(this);
\r
1509 dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);
\r
1510 dlg.m_sInputText = value;
\r
1511 dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);
\r
1512 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1513 dlg.m_bUseLogWidth = false;
\r
1514 if (dlg.DoModal() == IDOK)
\r
1516 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1518 LogCache::CCachedLogInfo* toUpdate
\r
1519 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1521 CProgressDlg progDlg;
\r
1522 progDlg.SetTitle(IDS_APPNAME);
\r
1523 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
\r
1524 progDlg.SetTime(true);
\r
1525 progDlg.SetShowProgressBar(true);
\r
1526 progDlg.ShowModeless(m_hWnd);
\r
1527 for (DWORD i=0; i<logs.size(); ++i)
\r
1529 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))
\r
1532 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1538 logs[i]->sAuthor = dlg.m_sInputText;
\r
1539 m_LogList.Invalidate();
\r
1541 // update the log cache
\r
1543 if (toUpdate != NULL)
\r
1545 // log caching is active
\r
1547 LogCache::CCachedLogInfo newInfo;
\r
1548 newInfo.Insert ( logs[i]->Rev
\r
1549 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)
\r
1552 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);
\r
1554 toUpdate->Update (newInfo);
\r
1557 progDlg.SetProgress64(i, logs.size());
\r
1561 theApp.DoWaitCursor(-1);
\r
1566 void CLogDlg::EditLogMessage(int /*index*/)
\r
1571 DialogEnableWindow(IDOK, FALSE);
\r
1572 SetPromptApp(&theApp);
\r
1573 theApp.DoWaitCursor(1);
\r
1574 if (Git::PathIsURL(m_path))
\r
1575 url = m_path.GetGitPathString();
\r
1578 url = GetURLFromPath(m_path);
\r
1580 name = Git_PROP_REVISION_LOG;
\r
1582 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
1583 m_bCancelled = FALSE;
\r
1584 CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);
\r
1585 CString sOldValue = value;
\r
1586 value.Replace(_T("\n"), _T("\r\n"));
\r
1587 CInputDlg dlg(this);
\r
1588 dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);
\r
1589 dlg.m_sInputText = value;
\r
1590 dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);
\r
1591 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1592 dlg.m_bUseLogWidth = true;
\r
1593 if (dlg.DoModal() == IDOK)
\r
1595 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1596 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))
\r
1598 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1602 pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);
\r
1603 // split multi line log entries and concatenate them
\r
1604 // again but this time with \r\n as line separators
\r
1605 // so that the edit control recognizes them
\r
1606 if (dlg.m_sInputText.GetLength()>0)
\r
1608 m_sMessageBuf = dlg.m_sInputText;
\r
1609 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));
\r
1610 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));
\r
1611 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)
\r
1612 dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);
\r
1615 dlg.m_sInputText.Empty();
\r
1616 pLogEntry->sMessage = dlg.m_sInputText;
\r
1617 pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);
\r
1618 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
1619 pMsgView->SetWindowText(_T(" "));
\r
1620 pMsgView->SetWindowText(dlg.m_sInputText);
\r
1621 m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);
\r
1622 m_LogList.Invalidate();
\r
1624 // update the log cache
\r
1626 LogCache::CCachedLogInfo* toUpdate
\r
1627 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1628 if (toUpdate != NULL)
\r
1630 // log caching is active
\r
1632 LogCache::CCachedLogInfo newInfo;
\r
1633 newInfo.Insert ( pLogEntry->Rev
\r
1635 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)
\r
1637 , LogCache::CRevisionInfoContainer::HAS_COMMENT);
\r
1639 toUpdate->Update (newInfo);
\r
1643 theApp.DoWaitCursor(-1);
\r
1648 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
\r
1650 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1651 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1652 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1654 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1656 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1658 m_LogList.DiffSelectedRevWithPrevious();
\r
1662 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1664 DiffSelectedFile();
\r
1668 if (m_hAccel && !bSkipAccelerator)
\r
1670 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1675 if(::IsWindow(m_tooltips.m_hWnd))
\r
1676 m_tooltips.RelayEvent(pMsg);
\r
1677 return __super::PreTranslateMessage(pMsg);
\r
1681 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
1683 //if (this->IsThreadRunning())
\r
1684 if(m_LogList.m_bNoDispUpdates)
\r
1686 // only show the wait cursor over the list control
\r
1688 ((pWnd == GetDlgItem(IDC_LOGLIST))||
\r
1689 (pWnd == GetDlgItem(IDC_MSGVIEW))||
\r
1690 (pWnd == GetDlgItem(IDC_LOGMSG))))
\r
1692 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
1697 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1698 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1700 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
1702 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1705 void CLogDlg::OnBnClickedHelp()
\r
1710 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1712 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
1714 //if (this->IsThreadRunning())
\r
1715 if(m_LogList.m_bNoDispUpdates)
\r
1717 if (pNMLV->iItem >= 0)
\r
1719 m_nSearchIndex = pNMLV->iItem;
\r
1720 if (pNMLV->iSubItem != 0)
\r
1722 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount()))
\r
1724 // remove the selected state
\r
1725 if (pNMLV->uChanged & LVIF_STATE)
\r
1727 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
\r
1728 FillLogMessageCtrl();
\r
1729 UpdateData(FALSE);
\r
1730 UpdateLogInfoLabel();
\r
1734 if (pNMLV->uChanged & LVIF_STATE)
\r
1736 FillLogMessageCtrl();
\r
1737 UpdateData(FALSE);
\r
1742 FillLogMessageCtrl();
\r
1743 UpdateData(FALSE);
\r
1746 UpdateLogInfoLabel();
\r
1749 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
\r
1751 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
\r
1752 if (pEnLink->msg == WM_LBUTTONUP)
\r
1755 GetDlgItemText(IDC_MSGVIEW, msg);
\r
1756 msg.Replace(_T("\r\n"), _T("\n"));
\r
1757 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
\r
1758 if (!::PathIsURL(url))
\r
1760 url = m_ProjectProperties.GetBugIDUrl(url);
\r
1761 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1763 if (!url.IsEmpty())
\r
1764 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1769 void CLogDlg::OnBnClickedStatbutton()
\r
1772 if (this->IsThreadRunning())
\r
1774 if (m_LogList.m_arShownList.IsEmpty())
\r
1775 return; // nothing is shown, so no statistics.
\r
1776 // the statistics dialog expects the log entries to be sorted by date
\r
1777 SortByColumn(3, false);
\r
1778 CPtrArray shownlist;
\r
1779 m_LogList.RecalculateShownList(&shownlist);
\r
1780 // create arrays which are aware of the current filter
\r
1781 CStringArray m_arAuthorsFiltered;
\r
1782 CDWordArray m_arDatesFiltered;
\r
1783 CDWordArray m_arFileChangesFiltered;
\r
1784 for (INT_PTR i=0; i<shownlist.GetCount(); ++i)
\r
1786 GitRev* pLogEntry = reinterpret_cast<GitRev*>(shownlist.GetAt(i));
\r
1787 CString strAuthor = pLogEntry->m_AuthorName;
\r
1788 if ( strAuthor.IsEmpty() )
\r
1790 strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);
\r
1792 m_arAuthorsFiltered.Add(strAuthor);
\r
1793 m_arDatesFiltered.Add(pLogEntry->m_AuthorDate.GetTime());
\r
1794 m_arFileChangesFiltered.Add(pLogEntry->m_Files.GetCount());
\r
1796 CStatGraphDlg dlg;
\r
1797 dlg.m_parAuthors = &m_arAuthorsFiltered;
\r
1798 dlg.m_parDates = &m_arDatesFiltered;
\r
1799 dlg.m_parFileChanges = &m_arFileChangesFiltered;
\r
1800 dlg.m_path = m_path;
\r
1802 // restore the previous sorting
\r
1803 SortByColumn(m_nSortColumn, m_bAscending);
\r
1804 OnTimer(LOGFILTER_TIMER);
\r
1808 void CLogDlg::DoSizeV1(int delta)
\r
1811 RemoveAnchor(IDC_LOGLIST);
\r
1812 RemoveAnchor(IDC_SPLITTERTOP);
\r
1813 RemoveAnchor(IDC_MSGVIEW);
\r
1814 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
1815 RemoveAnchor(IDC_LOGMSG);
\r
1816 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
\r
1817 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
\r
1818 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
1819 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
1820 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
1821 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1822 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1825 SetSplitterRange();
\r
1826 m_LogList.Invalidate();
\r
1827 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
1831 void CLogDlg::DoSizeV2(int delta)
\r
1834 RemoveAnchor(IDC_LOGLIST);
\r
1835 RemoveAnchor(IDC_SPLITTERTOP);
\r
1836 RemoveAnchor(IDC_MSGVIEW);
\r
1837 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
1838 RemoveAnchor(IDC_LOGMSG);
\r
1839 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
\r
1840 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
\r
1841 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
1842 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
1843 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
1844 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1845 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1848 SetSplitterRange();
\r
1849 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
1850 m_ChangedFileListCtrl.Invalidate();
\r
1854 void CLogDlg::AdjustMinSize()
\r
1856 // adjust the minimum size of the dialog to prevent the resizing from
\r
1857 // moving the list control too far down.
\r
1858 CRect rcChgListView;
\r
1859 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
\r
1861 m_LogList.GetClientRect(rcLogList);
\r
1863 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
\r
1864 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
\r
1865 +rcChgListView.Height()+rcLogList.Height()+60));
\r
1868 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
1870 switch (message) {
\r
1872 if (wParam == IDC_SPLITTERTOP)
\r
1874 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
1875 DoSizeV1(pHdr->delta);
\r
1877 else if (wParam == IDC_SPLITTERBOTTOM)
\r
1879 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
1880 DoSizeV2(pHdr->delta);
\r
1885 return CResizableDialog::DefWindowProc(message, wParam, lParam);
\r
1888 void CLogDlg::SetSplitterRange()
\r
1890 if ((m_LogList)&&(m_ChangedFileListCtrl))
\r
1893 m_LogList.GetWindowRect(rcTop);
\r
1894 ScreenToClient(rcTop);
\r
1896 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
\r
1897 ScreenToClient(rcMiddle);
\r
1898 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
\r
1900 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
\r
1901 ScreenToClient(rcBottom);
\r
1902 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
\r
1906 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
\r
1908 // FIXME: x64 version would get this function called with unexpected parameters.
\r
1912 RECT * rect = (LPRECT)lParam;
\r
1915 point = CPoint(rect->left, rect->bottom);
\r
1916 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
\r
1918 if (popup.CreatePopupMenu())
\r
1920 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
1921 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);
\r
1923 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1925 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
1926 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
\r
1927 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
1928 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
\r
1929 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
1930 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
\r
1931 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
1932 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
\r
1933 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
\r
1934 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
\r
1936 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1938 temp.LoadString(IDS_LOG_FILTER_REGEX);
\r
1939 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
\r
1942 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1943 if (selection != 0)
\r
1946 if (selection == LOGFILTER_REGEX)
\r
1948 m_bFilterWithRegex = !m_bFilterWithRegex;
\r
1949 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
1950 b = m_bFilterWithRegex;
\r
1951 CheckRegexpTooltip();
\r
1955 m_LogList.m_nSelectedFilter = selection;
\r
1956 SetFilterCueText();
\r
1958 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
1964 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
1967 KillTimer(LOGFILTER_TIMER);
\r
1969 m_LogList.m_sFilterText.Empty();
\r
1970 UpdateData(FALSE);
\r
1971 theApp.DoWaitCursor(1);
\r
1972 CStoreSelection storeselection(this);
\r
1973 FillLogMessageCtrl(false);
\r
1975 m_LogList.RemoveFilter();
\r
1978 m_LogList.GetTimeRange(begin,end);
\r
1979 m_DateFrom.SetTime(&begin);
\r
1980 m_DateTo.SetTime(&end);
\r
1982 theApp.DoWaitCursor(-1);
\r
1983 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
1984 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
1985 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
1986 UpdateLogInfoLabel();
\r
1992 void CLogDlg::SetFilterCueText()
\r
1995 switch (m_LogList.m_nSelectedFilter)
\r
1997 case LOGFILTER_ALL:
\r
1998 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2000 case LOGFILTER_MESSAGES:
\r
2001 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2003 case LOGFILTER_PATHS:
\r
2004 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2006 case LOGFILTER_AUTHORS:
\r
2007 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2009 case LOGFILTER_REVS:
\r
2010 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2013 // to make the cue banner text appear more to the right of the edit control
\r
2014 temp = _T(" ")+temp;
\r
2015 m_cFilter.SetCueBanner(temp);
\r
2018 bool CLogDlg::Validate(LPCTSTR string)
\r
2020 if (!m_bFilterWithRegex)
\r
2023 return m_LogList.ValidateRegexp(string, pat, false);
\r
2027 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
\r
2029 if (nIDEvent == LOGFILTER_TIMER)
\r
2031 if (this->IsThreadRunning())
\r
2033 // thread still running! So just restart the timer.
\r
2034 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2037 CWnd * focusWnd = GetFocus();
\r
2038 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
\r
2039 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
\r
2040 if (m_LogList.m_sFilterText.IsEmpty())
\r
2042 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2043 // do not return here!
\r
2044 // we also need to run the filter if the filter text is empty:
\r
2045 // 1. to clear an existing filter
\r
2046 // 2. to rebuild the m_arShownList after sorting
\r
2048 theApp.DoWaitCursor(1);
\r
2049 CStoreSelection storeselection(this);
\r
2050 KillTimer(LOGFILTER_TIMER);
\r
2051 FillLogMessageCtrl(false);
\r
2053 // now start filter the log list
\r
2054 m_LogList.StartFilter();
\r
2056 if ( m_LogList.GetItemCount()==1 )
\r
2058 m_LogList.SetSelectionMark(0);
\r
2059 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
2061 theApp.DoWaitCursor(-1);
\r
2062 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2063 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2064 if (bSetFocusToFilterControl)
\r
2065 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2066 UpdateLogInfoLabel();
\r
2067 } // if (nIDEvent == LOGFILTER_TIMER)
\r
2068 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2069 __super::OnTimer(nIDEvent);
\r
2072 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2075 m_DateTo.GetTime(_time);
\r
2078 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
\r
2079 if (time.GetTime() != m_LogList.m_To.GetTime())
\r
2081 m_LogList.m_To = (DWORD)time.GetTime();
\r
2082 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2085 catch (CAtlException)
\r
2092 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2095 m_DateFrom.GetTime(_time);
\r
2098 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
\r
2099 if (time.GetTime() != m_LogList.m_From.GetTime())
\r
2101 m_LogList.m_From = (DWORD)time.GetTime();
\r
2102 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2105 catch (CAtlException)
\r
2114 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
\r
2116 CTGitPathList pathList;
\r
2119 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2121 m_sRepositoryRoot = GetRepositoryRoot(m_path);
\r
2123 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2126 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2131 int nextpos = m_LogList.GetNextSelectedItem(pos);
\r
2132 if (nextpos >= m_arShownList.GetCount())
\r
2134 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));
\r
2135 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
2136 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
2138 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2139 if (cpath == NULL)
\r
2142 if (!bRelativePaths)
\r
2143 path.SetFromGit(m_sRepositoryRoot);
\r
2144 path.AppendPathString(cpath->sPath);
\r
2145 if ((!bUseFilter)||
\r
2146 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
\r
2147 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
\r
2148 pathList.AddPath(path);
\r
2153 pathList.RemoveDuplicates();
\r
2158 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
\r
2161 switch(nSortColumn)
\r
2163 case 0: // Revision
\r
2166 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
\r
2168 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
\r
2174 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
\r
2176 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
\r
2182 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
\r
2184 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
\r
2190 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
\r
2192 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
\r
2195 case 4: // Message or bug id
\r
2196 if (m_bShowBugtraqColumn)
\r
2199 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
\r
2201 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
\r
2204 // fall through here
\r
2205 case 5: // Message
\r
2208 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
\r
2210 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
\r
2220 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
\r
2222 if (this->IsThreadRunning())
\r
2223 return; //no sorting while the arrays are filled
\r
2224 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2225 const int nColumn = pNMLV->iSubItem;
\r
2226 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
\r
2227 m_nSortColumn = nColumn;
\r
2228 SortByColumn(m_nSortColumn, m_bAscending);
\r
2229 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
\r
2230 SortShownListArray();
\r
2231 m_LogList.Invalidate();
\r
2232 UpdateLogInfoLabel();
\r
2237 void CLogDlg::SortShownListArray()
\r
2239 // make sure the shown list still matches the filter after sorting.
\r
2240 OnTimer(LOGFILTER_TIMER);
\r
2241 // clear the selection states
\r
2242 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2245 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
\r
2247 m_LogList.SetSelectionMark(-1);
\r
2250 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
\r
2252 if (control == NULL)
\r
2254 // set the sort arrow
\r
2255 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
\r
2256 HDITEM HeaderItem = {0};
\r
2257 HeaderItem.mask = HDI_FORMAT;
\r
2258 for (int i=0; i<pHeader->GetItemCount(); ++i)
\r
2260 pHeader->GetItem(i, &HeaderItem);
\r
2261 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
\r
2262 pHeader->SetItem(i, &HeaderItem);
\r
2266 pHeader->GetItem(nColumn, &HeaderItem);
\r
2267 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
\r
2268 pHeader->SetItem(nColumn, &HeaderItem);
\r
2271 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
\r
2274 if (this->IsThreadRunning())
\r
2275 return; //no sorting while the arrays are filled
\r
2276 if (m_currentChangedArray == NULL)
\r
2278 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2279 const int nColumn = pNMLV->iSubItem;
\r
2280 m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;
\r
2281 m_nSortColumnPathList = nColumn;
\r
2282 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
\r
2284 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
2285 m_ChangedFileListCtrl.Invalidate();
\r
2290 int CLogDlg::m_nSortColumnPathList = 0;
\r
2291 bool CLogDlg::m_bAscendingPathList = false;
\r
2293 int CLogDlg::SortCompare(const void * /*pElem1*/, const void * /*pElem2*/)
\r
2296 LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);
\r
2297 LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);
\r
2299 if (m_bAscendingPathList)
\r
2300 std::swap (cpath1, cpath2);
\r
2303 switch (m_nSortColumnPathList)
\r
2306 cmp = cpath2->GetAction().Compare(cpath1->GetAction());
\r
2311 cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);
\r
2315 case 2: // copy from path
\r
2316 cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);
\r
2320 case 3: // copy from revision
\r
2321 return cpath2->lCopyFromRev > cpath1->lCopyFromRev;
\r
2327 void CLogDlg::OnBnClickedHidepaths()
\r
2329 FillLogMessageCtrl();
\r
2330 m_ChangedFileListCtrl.Invalidate();
\r
2335 void CLogDlg::OnBnClickedCheckStoponcopy()
\r
2338 if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
2341 // ignore old fetch limits when switching
\r
2342 // between copy-following and stop-on-copy
\r
2343 // (otherwise stop-on-copy will limit what
\r
2344 // we see immediately after switching to
\r
2345 // copy-following)
\r
2349 // now, restart the query
\r
2355 void CLogDlg::UpdateLogInfoLabel()
\r
2358 git_revnum_t rev1 ;
\r
2359 git_revnum_t rev2 ;
\r
2360 long selectedrevs = 0;
\r
2361 int count =m_LogList.m_arShownList.GetCount();
\r
2364 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(0)))->m_CommitHash;
\r
2365 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
\r
2366 rev2 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;
\r
2367 selectedrevs = m_LogList.GetSelectedCount();
\r
2370 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
2371 m_sLogInfo = sTemp;
\r
2373 UpdateData(FALSE);
\r
2377 void CLogDlg::ShowContextMenuForChangedpaths(CWnd* /*pWnd*/, CPoint point)
\r
2380 int selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
2381 if ((point.x == -1) && (point.y == -1))
\r
2384 m_ChangedFileListCtrl.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
2385 m_ChangedFileListCtrl.ClientToScreen(&rect);
\r
2386 point = rect.CenterPoint();
\r
2390 int s = m_LogList.GetSelectionMark();
\r
2393 std::vector<CString> changedpaths;
\r
2394 std::vector<LogChangedPath*> changedlogpaths;
\r
2395 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2397 return; // nothing is selected, get out of here
\r
2399 bool bOneRev = true;
\r
2400 int sel=m_LogList.GetNextSelectedItem(pos);
\r
2401 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel));
\r
2402 GitRev * rev1 = pLogEntry;
\r
2403 GitRev * rev2 = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel+1));
\r
2405 bool bOneRev = true;
\r
2410 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
2413 rev1 = max(rev1,(git_revnum_t)pLogEntry->Rev);
\r
2414 rev2 = min(rev2,(git_revnum_t)pLogEntry->Rev);
\r
2420 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2423 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2424 changedpaths.push_back(m_currentChangedPathList[nItem].GetGitPathString());
\r
2429 // only one revision is selected in the log dialog top pane
\r
2430 // but multiple items could be selected in the changed items list
\r
2433 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2436 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2437 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
2439 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2441 if ((changedlogpath)&&(!changedlogpath->sCopyFromPath.IsEmpty()))
\r
2442 rev2 = changedlogpath->lCopyFromRev;
\r
2445 // if the path was modified but the parent path was 'added with history'
\r
2446 // then we have to use the copy from revision of the parent path
\r
2447 CTGitPath cpath = CTGitPath(changedlogpath->sPath);
\r
2448 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
2450 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
2451 if (p.IsAncestorOf(cpath))
\r
2453 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
2454 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
2459 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
2461 // some items are hidden! So find out which item the user really clicked on
\r
2462 INT_PTR selRealIndex = -1;
\r
2463 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
2465 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
2467 if (selRealIndex == nItem)
\r
2469 selIndex = hiddenindex;
\r
2470 changedlogpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
2475 if (changedlogpath)
\r
2477 changedpaths.push_back(changedlogpath->sPath);
\r
2478 changedlogpaths.push_back(changedlogpath);
\r
2483 //entry is selected, now show the popup menu
\r
2485 if (popup.CreatePopupMenu())
\r
2487 bool bEntryAdded = false;
\r
2488 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2490 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
\r
2492 popup.AppendMenuIcon(CGitLogList::ID_DIFF, IDS_LOG_POPUP_DIFF, IDI_DIFF);
\r
2493 popup.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF, IDS_LOG_POPUP_BLAMEDIFF, IDI_BLAME);
\r
2494 popup.SetDefaultItem(CGitLogList::ID_DIFF, FALSE);
\r
2495 popup.AppendMenuIcon(CGitLogList::ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
2496 bEntryAdded = true;
\r
2498 // if (rev2 == rev1-1)
\r
2501 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2502 popup.AppendMenuIcon(CGitLogList::ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
2503 popup.AppendMenuIcon(CGitLogList::ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
2504 popup.AppendMenuIcon(CGitLogList::ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
2505 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2507 popup.AppendMenuIcon(CGitLogList::ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
2508 popup.AppendMenuIcon(CGitLogList::ID_POPPROPS, IDS_REPOBROWSE_SHOWPROP, IDI_PROPERTIES); // "Show Properties"
\r
2509 popup.AppendMenuIcon(CGitLogList::ID_LOG, IDS_MENULOG, IDI_LOG); // "Show Log"
\r
2510 popup.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS, IDS_LOG_POPUP_GETMERGELOGS, IDI_LOG); // "Show merge log"
\r
2511 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
2512 bEntryAdded = true;
\r
2513 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
2515 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2516 popup.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
2518 if (popup.GetDefaultItem(0,FALSE)==-1)
\r
2519 popup.SetDefaultItem(CGitLogList::ID_OPEN, FALSE);
\r
2522 else if (changedlogpaths.size())
\r
2524 // more than one entry is selected
\r
2525 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE);
\r
2526 bEntryAdded = true;
\r
2531 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2532 bool bOpenWith = false;
\r
2533 bool bMergeLog = false;
\r
2534 m_bCancelled = false;
\r
2538 case CGitLogList::ID_DIFF:
\r
2540 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
2544 case ID_BLAMEDIFF:
\r
2546 DoDiffFromLog(selIndex, rev1, rev2, true, false);
\r
2551 DoDiffFromLog(selIndex, rev1, rev2, false, true);
\r
2554 case ID_REVERTREV:
\r
2556 SetPromptApp(&theApp);
\r
2557 theApp.DoWaitCursor(1);
\r
2559 if (Git::PathIsURL(m_path))
\r
2561 sUrl = m_path.GetGitPathString();
\r
2565 sUrl = GetURLFromPath(m_path);
\r
2566 if (sUrl.IsEmpty())
\r
2568 theApp.DoWaitCursor(-1);
\r
2570 temp.Format(IDS_ERR_NOURLOFFILE, m_path.GetWinPath());
\r
2571 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2573 theApp.DoWaitCursor(-1);
\r
2577 // find the working copy path of the selected item from the URL
\r
2578 m_bCancelled = false;
\r
2579 CString sUrlRoot = GetRepositoryRoot(CTGitPath(sUrl));
\r
2581 CString fileURL = changedpaths[0];
\r
2582 fileURL = sUrlRoot + fileURL.Trim();
\r
2583 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
\r
2584 // sUrl = http://mydomain.com/repos/trunk/folder
\r
2585 CString sUnescapedUrl = CPathUtils::PathUnescape(sUrl);
\r
2586 // find out until which char the urls are identical
\r
2588 while ((i<fileURL.GetLength())&&(i<sUnescapedUrl.GetLength())&&(fileURL[i]==sUnescapedUrl[i]))
\r
2590 int leftcount = m_path.GetWinPathString().GetLength()-(sUnescapedUrl.GetLength()-i);
\r
2591 CString wcPath = m_path.GetWinPathString().Left(leftcount);
\r
2592 wcPath += fileURL.Mid(i);
\r
2593 wcPath.Replace('/', '\\');
\r
2594 CGitProgressDlg dlg;
\r
2595 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
2597 // a deleted path! Since the path isn't there anymore, merge
\r
2598 // won't work. So just do a copy url->wc
\r
2599 dlg.SetCommand(CGitProgressDlg::GitProgress_Copy);
\r
2600 dlg.SetPathList(CTGitPathList(CTGitPath(fileURL)));
\r
2601 dlg.SetUrl(wcPath);
\r
2602 dlg.SetRevision(rev2);
\r
2606 if (!PathFileExists(wcPath))
\r
2608 // seems the path got renamed
\r
2609 // tell the user how to work around this.
\r
2610 CMessageBox::Show(this->m_hWnd, IDS_LOG_REVERTREV_ERROR, IDS_APPNAME, MB_ICONERROR);
\r
2612 theApp.DoWaitCursor(-1);
\r
2615 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
2616 dlg.SetPathList(CTGitPathList(CTGitPath(wcPath)));
\r
2617 dlg.SetUrl(fileURL);
\r
2618 dlg.SetSecondUrl(fileURL);
\r
2619 GitRevRangeArray revarray;
\r
2620 revarray.AddRevRange(rev1, rev2);
\r
2621 dlg.SetRevisionRanges(revarray);
\r
2624 msg.Format(IDS_LOG_REVERT_CONFIRM, (LPCTSTR)wcPath);
\r
2625 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
2629 theApp.DoWaitCursor(-1);
\r
2634 DialogEnableWindow(IDOK, FALSE);
\r
2635 SetPromptApp(&theApp);
\r
2636 theApp.DoWaitCursor(1);
\r
2638 if (Git::PathIsURL(m_path))
\r
2640 filepath = m_path.GetGitPathString();
\r
2644 filepath = GetURLFromPath(m_path);
\r
2645 if (filepath.IsEmpty())
\r
2647 theApp.DoWaitCursor(-1);
\r
2649 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2650 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2651 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2656 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2657 filepath += changedpaths[0];
\r
2660 dlg.m_Path = CTGitPath(filepath);
\r
2663 theApp.DoWaitCursor(-1);
\r
2668 DialogEnableWindow(IDOK, FALSE);
\r
2669 SetPromptApp(&theApp);
\r
2670 theApp.DoWaitCursor(1);
\r
2672 if (Git::PathIsURL(m_path))
\r
2674 filepath = m_path.GetGitPathString();
\r
2678 filepath = GetURLFromPath(m_path);
\r
2679 if (filepath.IsEmpty())
\r
2681 theApp.DoWaitCursor(-1);
\r
2683 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2684 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2685 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2690 m_bCancelled = false;
\r
2691 CString sRoot = GetRepositoryRoot(CTGitPath(filepath));
\r
2692 // if more than one entry is selected, we save them
\r
2693 // one by one into a folder the user has selected
\r
2694 bool bTargetSelected = false;
\r
2695 CTGitPath TargetPath;
\r
2696 if (m_ChangedFileListCtrl.GetSelectedCount() > 1)
\r
2698 CBrowseFolder browseFolder;
\r
2699 browseFolder.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT)));
\r
2700 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
\r
2701 CString strSaveAsDirectory;
\r
2702 if (browseFolder.Show(GetSafeHwnd(), strSaveAsDirectory) == CBrowseFolder::OK)
\r
2704 TargetPath = CTGitPath(strSaveAsDirectory);
\r
2705 bTargetSelected = true;
\r
2710 // Display the Open dialog box.
\r
2711 CString revFilename;
\r
2713 temp = CPathUtils::GetFileNameFromPath(changedpaths[0]);
\r
2714 int rfind = temp.ReverseFind('.');
\r
2716 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)temp.Left(rfind), rev1, (LPCTSTR)temp.Mid(rfind));
\r
2718 revFilename.Format(_T("%s-%ld"), (LPCTSTR)temp, rev1);
\r
2719 bTargetSelected = CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd);
\r
2720 TargetPath.SetFromWin(revFilename);
\r
2722 if (bTargetSelected)
\r
2724 CProgressDlg progDlg;
\r
2725 progDlg.SetTitle(IDS_APPNAME);
\r
2726 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
2727 for (std::vector<LogChangedPath*>::iterator it = changedlogpaths.begin(); it!= changedlogpaths.end(); ++it)
\r
2729 GitRev getrev = ((*it)->action == LOGACTIONS_DELETED) ? rev2 : rev1;
\r
2731 CString sInfoLine;
\r
2732 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)getrev.ToString());
\r
2733 progDlg.SetLine(1, sInfoLine, true);
\r
2734 SetAndClearProgressInfo(&progDlg);
\r
2735 progDlg.ShowModeless(m_hWnd);
\r
2737 CTGitPath tempfile = TargetPath;
\r
2738 if (changedpaths.size() > 1)
\r
2740 // if multiple items are selected, then the TargetPath
\r
2741 // points to a folder and we have to append the filename
\r
2742 // to save to to that folder.
\r
2743 CString sName = (*it)->sPath;
\r
2744 int slashpos = sName.ReverseFind('/');
\r
2745 if (slashpos >= 0)
\r
2746 sName = sName.Mid(slashpos);
\r
2747 tempfile.AppendPathString(sName);
\r
2748 // one problem here:
\r
2749 // a user could have selected multiple items which
\r
2750 // have the same filename but reside in different
\r
2751 // directories, e.g.
\r
2754 // in that case, the second 'file1' will overwrite
\r
2755 // the already saved 'file1'.
\r
2757 // we could maybe find the common root of all selected
\r
2758 // items and then create sub folders to save those files
\r
2760 // But I think we should just leave it that way: to check
\r
2761 // out multiple items at once, the better way is still to
\r
2762 // use the export command from the top pane of the log dialog.
\r
2764 filepath = sRoot + (*it)->sPath;
\r
2765 if (!Cat(CTGitPath(filepath), getrev, getrev, tempfile))
\r
2768 SetAndClearProgressInfo((HWND)NULL);
\r
2769 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2771 theApp.DoWaitCursor(-1);
\r
2776 SetAndClearProgressInfo((HWND)NULL);
\r
2779 theApp.DoWaitCursor(-1);
\r
2786 GitRev getrev = pLogEntry->pArChangedPaths->GetAt(selIndex)->action == LOGACTIONS_DELETED ? rev2 : rev1;
\r
2787 Open(bOpenWith,changedpaths[0],getrev);
\r
2793 if (Git::PathIsURL(m_path))
\r
2795 filepath = m_path.GetGitPathString();
\r
2799 filepath = GetURLFromPath(m_path);
\r
2800 if (filepath.IsEmpty())
\r
2802 theApp.DoWaitCursor(-1);
\r
2804 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2805 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2806 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2811 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2812 filepath += changedpaths[0];
\r
2814 dlg.EndRev = rev1;
\r
2815 if (dlg.DoModal() == IDOK)
\r
2820 tempfile = blame.BlameToTempFile(CTGitPath(filepath), dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
2821 if (!tempfile.IsEmpty())
\r
2823 if (dlg.m_bTextView)
\r
2825 //open the default text editor for the result file
\r
2826 CAppUtils::StartTextViewer(tempfile);
\r
2830 CString sParams = _T("/path:\"") + filepath + _T("\" ");
\r
2831 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(filepath),sParams))
\r
2839 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2844 case ID_GETMERGELOGS:
\r
2849 DialogEnableWindow(IDOK, FALSE);
\r
2850 SetPromptApp(&theApp);
\r
2851 theApp.DoWaitCursor(1);
\r
2853 if (Git::PathIsURL(m_path))
\r
2855 filepath = m_path.GetGitPathString();
\r
2859 filepath = GetURLFromPath(m_path);
\r
2860 if (filepath.IsEmpty())
\r
2862 theApp.DoWaitCursor(-1);
\r
2864 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2865 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2866 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2871 m_bCancelled = false;
\r
2872 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2873 filepath += changedpaths[0];
\r
2874 git_revnum_t logrev = rev1;
\r
2875 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
2877 // if the item got deleted in this revision,
\r
2878 // fetch the log from the previous revision where it
\r
2883 sCmd.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR)filepath, logrev);
\r
2885 sCmd += _T(" /merge");
\r
2886 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
2888 theApp.DoWaitCursor(-1);
\r
2891 case ID_VIEWPATHREV:
\r
2893 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetSelectionMark()));
\r
2894 GitRev rev = pLogEntry->Rev;
\r
2895 CString relurl = changedpaths[0];
\r
2896 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
2897 url.Replace(_T("%REVISION%"), rev.ToString());
\r
2898 url.Replace(_T("%PATH%"), relurl);
\r
2899 relurl = relurl.Mid(relurl.Find('/'));
\r
2900 url.Replace(_T("%PATH1%"), relurl);
\r
2901 if (!url.IsEmpty())
\r
2902 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
2910 } // if (popup.CreatePopupMenu())
\r
2914 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2916 // the date control should not show the "today" button
\r
2917 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
\r
2919 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
2923 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2925 // the date control should not show the "today" button
\r
2926 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
\r
2928 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
2932 void CLogDlg::OnSize(UINT nType, int cx, int cy)
\r
2934 __super::OnSize(nType, cx, cy);
\r
2936 SetSplitterRange();
\r
2939 void CLogDlg::OnRefresh()
\r
2941 //if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
2945 this->m_LogProgress.SetPos(0);
\r
2951 void CLogDlg::OnFind()
\r
2953 if (!m_pFindDialog)
\r
2955 m_pFindDialog = new CFindReplaceDialog();
\r
2956 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
2960 void CLogDlg::OnFocusFilter()
\r
2962 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2965 void CLogDlg::OnEditCopy()
\r
2967 if (GetFocus() == &m_ChangedFileListCtrl)
\r
2968 CopyChangedSelectionToClipBoard();
\r
2970 m_LogList.CopySelectionToClipBoard();
\r
2973 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
\r
2975 // is the URL a relative one?
\r
2976 if (url.Left(2).Compare(_T("^/")) == 0)
\r
2978 // URL is relative to the repository root
\r
2979 CString url1 = m_sRepositoryRoot + url.Mid(1);
\r
2980 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
2981 DWORD len = url.GetLength();
\r
2982 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
\r
2983 return CString(buf, len);
\r
2986 else if (url[0] == '/')
\r
2988 // URL is relative to the server's hostname
\r
2990 // find the server's hostname
\r
2991 int schemepos = m_sRepositoryRoot.Find(_T("//"));
\r
2992 if (schemepos >= 0)
\r
2994 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
\r
2995 CString url1 = sHost + url;
\r
2996 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
2997 DWORD len = url.GetLength();
\r
2998 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
\r
2999 return CString(buf, len);
\r
3007 void CLogDlg::OnEnChangeSearchedit()
\r
3010 if (m_LogList.m_sFilterText.IsEmpty())
\r
3012 CStoreSelection storeselection(this);
\r
3013 // clear the filter, i.e. make all entries appear
\r
3014 theApp.DoWaitCursor(1);
\r
3015 KillTimer(LOGFILTER_TIMER);
\r
3016 FillLogMessageCtrl(false);
\r
3017 m_LogList.StartFilter();
\r
3019 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3020 m_arShownList.RemoveAll();
\r
3021 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3023 if (IsEntryInDateRange(i))
\r
3024 m_arShownList.Add(m_logEntries[i]);
\r
3026 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3027 m_LogList.DeleteAllItems();
\r
3028 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3029 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3030 m_LogList.SetRedraw(false);
\r
3031 ResizeAllListCtrlCols();
\r
3032 m_LogList.SetRedraw(true);
\r
3034 theApp.DoWaitCursor(-1);
\r
3035 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3036 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3037 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3038 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
3041 if (Validate(m_LogList.m_sFilterText))
\r
3042 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3044 KillTimer(LOGFILTER_TIMER);
\r
3048 void CLogDlg::OnBnClickedAllBranch()
\r
3050 this->UpdateData();
\r
3052 if(this->m_bAllBranch)
\r
3053 m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH;
\r
3055 m_LogList.m_ShowMask&=~CGit::LOG_INFO_ALL_BRANCH;
\r
3059 FillLogMessageCtrl(false);
\r
3062 void CLogDlg::OnBnClickedBrowseRef()
\r
3064 CString newRef = CBrowseRefsDlg::PickRef(false,m_LogList.GetStartRef());
\r
3065 if(newRef.IsEmpty())
\r
3068 SetStartRef(newRef);
\r
3069 ((CButton*)GetDlgItem(IDC_LOG_ALLBRANCH))->SetCheck(0);
\r
3071 OnBnClickedAllBranch();
\r
3074 void CLogDlg::ShowStartRef()
\r
3076 //Show ref name on top
\r
3077 if(!::IsWindow(m_hWnd))
\r
3081 m_staticRef.SetWindowText(L"<All Branches>");
\r
3082 m_staticRef.Invalidate(TRUE);
\r
3086 CString showStartRef = m_LogList.GetStartRef();
\r
3087 if(showStartRef.IsEmpty())
\r
3089 //Ref name is HEAD
\r
3090 g_Git.Run(L"git symbolic-ref HEAD",&showStartRef,CP_UTF8);
\r
3091 showStartRef.Trim(L"\r\n\t ");
\r
3095 if(wcsncmp(showStartRef,L"refs/",5) == 0)
\r
3096 showStartRef = showStartRef.Mid(5);
\r
3097 if(wcsncmp(showStartRef,L"heads/",6) == 0)
\r
3098 showStartRef = showStartRef.Mid(6);
\r
3100 m_staticRef.SetWindowText(showStartRef);
\r
3101 m_staticRef.Invalidate(TRUE);
\r
3104 void CLogDlg::SetStartRef(const CString& StartRef)
\r
3106 m_LogList.SetStartRef(StartRef);
\r
3113 void CLogDlg::OnBnClickedFirstParent()
\r
3115 this->UpdateData();
\r
3117 if(this->m_bFirstParent)
\r
3118 m_LogList.m_ShowMask|=CGit::LOG_INFO_FIRST_PARENT;
\r
3120 m_LogList.m_ShowMask&=~CGit::LOG_INFO_FIRST_PARENT;
\r
3124 FillLogMessageCtrl(false);
\r
3128 void CLogDlg::OnBnClickShowWholeProject()
\r
3130 this->UpdateData();
\r
3132 if(this->m_bWholeProject)
\r
3134 m_LogList.m_Path.Reset();
\r
3135 SetWindowText(m_sTitle + _T(" - ") + CString(_T("Whole Project")));
\r
3139 m_LogList.m_Path=m_path;
\r
3140 if(!m_path.IsEmpty())
\r
3141 SetWindowText(m_sTitle + _T(" - ") + m_path.GetGitPathString());
\r
3146 FillLogMessageCtrl(false);
\r