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
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
125 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)
\r
126 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)
\r
128 ON_MESSAGE(MSG_LOAD_PERCENTAGE,OnLogListLoading)
\r
130 ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)
\r
132 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)
\r
133 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)
\r
134 ON_BN_CLICKED(IDC_SHOWWHOLEPROJECT, OnBnClickShowWholeProject)
\r
135 //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
\r
136 //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
\r
137 ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST , OnLvnColumnclick)
\r
138 //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
\r
139 ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)
\r
140 ON_BN_CLICKED(IDC_LOG_ALLBRANCH,OnBnClickedAllBranch)
\r
142 ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)
\r
143 ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)
\r
145 ON_BN_CLICKED(IDC_LOG_FIRSTPARENT, &CLogDlg::OnBnClickedFirstParent)
\r
146 ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)
\r
147 ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CLogDlg::OnBnClickedBrowseRef)
\r
148 ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)
\r
149 ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)
\r
150 ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)
\r
151 ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)
\r
154 void CLogDlg::SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit /* = FALSE */)
\r
158 m_startrev = startrev;
\r
159 m_LogRevision = startrev;
\r
161 m_hasWC = !path.IsUrl();
\r
163 if (::IsWindow(m_hWnd))
\r
167 BOOL CLogDlg::OnInitDialog()
\r
170 CResizableStandAloneDialog::OnInitDialog();
\r
172 m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));
\r
175 // use the state of the "stop on copy/rename" option from the last time
\r
178 // set the font to use in the log message view, configured in the settings dialog
\r
179 CAppUtils::CreateFontForLogs(m_logFont);
\r
180 GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);
\r
181 // automatically detect URLs in the log message and turn them into links
\r
182 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);
\r
183 // make the log message rich edit control send a message when the mouse pointer is over a link
\r
184 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);
\r
185 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
187 // the "hide unrelated paths" checkbox should be indeterminate
\r
188 m_cHidePaths.SetCheck(BST_INDETERMINATE);
\r
191 // if there is a working copy, load the project properties
\r
192 // to get information about the bugtraq: integration
\r
194 m_ProjectProperties.ReadProps(m_path);
\r
196 // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set
\r
197 if ((!m_ProjectProperties.sUrl.IsEmpty())||(!m_ProjectProperties.sCheckRe.IsEmpty()))
\r
198 m_bShowBugtraqColumn = true;
\r
200 //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
\r
201 //theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
\r
203 // set up the columns
\r
204 m_LogList.DeleteAllItems();
\r
205 m_LogList.InsertGitColumn();
\r
207 m_ChangedFileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("LogDlg"),(SVNSLC_POPALL ^ (SVNSLC_POPCOMMIT|SVNSLC_POPREVERT)),false);
\r
209 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
212 m_sMessageBuf.Preallocate(100000);
\r
214 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
\r
215 SetDlgTitle(false);
\r
217 m_tooltips.Create(this);
\r
218 CheckRegexpTooltip();
\r
220 SetSplitterRange();
\r
222 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
\r
223 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
\r
224 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
\r
225 m_cFilter.SetValidator(this);
\r
227 AdjustControlSize(IDC_HIDEPATHS);
\r
228 AdjustControlSize(IDC_LOG_FIRSTPARENT);
\r
229 AdjustControlSize(IDC_LOG_ALLBRANCH);
\r
231 GetClientRect(m_DlgOrigRect);
\r
232 m_LogList.GetClientRect(m_LogListOrigRect);
\r
233 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
\r
234 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
\r
236 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
237 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
240 AddAnchor(IDC_STATIC_REF, TOP_LEFT);
\r
241 AddAnchor(IDC_BUTTON_BROWSE_REF, TOP_LEFT);
\r
242 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
\r
243 AddAnchor(IDC_DATEFROM, TOP_LEFT);
\r
244 AddAnchor(IDC_TOLABEL, TOP_LEFT);
\r
245 AddAnchor(IDC_DATETO, TOP_LEFT);
\r
247 SetFilterCueText();
\r
248 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
\r
250 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
251 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
252 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
253 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
254 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
256 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
257 AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);
\r
258 AddAnchor(IDC_LOG_ALLBRANCH,BOTTOM_LEFT);
\r
259 AddAnchor(IDC_LOG_FIRSTPARENT, BOTTOM_LEFT);
\r
260 //AddAnchor(IDC_GETALL, BOTTOM_LEFT);
\r
261 AddAnchor(IDC_SHOWWHOLEPROJECT, BOTTOM_LEFT);
\r
262 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
\r
263 AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);
\r
264 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
265 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
266 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
267 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
269 // SetPromptParentWindow(m_hWnd);
\r
272 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
273 EnableSaveRestore(_T("LogDlg"));
\r
275 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
276 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
277 RECT rcDlg, rcLogList, rcChgMsg;
\r
278 GetClientRect(&rcDlg);
\r
279 m_LogList.GetWindowRect(&rcLogList);
\r
280 ScreenToClient(&rcLogList);
\r
281 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
\r
282 ScreenToClient(&rcChgMsg);
\r
286 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
287 ScreenToClient(&rectSplitter);
\r
288 int delta = yPos1 - rectSplitter.top;
\r
290 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
\r
292 m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);
\r
299 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
300 ScreenToClient(&rectSplitter);
\r
301 int delta = yPos2 - rectSplitter.top;
\r
303 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
\r
305 m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);
\r
313 // the dialog is used to select revisions
\r
314 // enable the OK button if appropriate
\r
319 // the dialog is used to just view log messages
\r
320 // hide the OK button and set text on Cancel button to OK
\r
321 GetDlgItemText(IDOK, temp);
\r
322 SetDlgItemText(IDCANCEL, temp);
\r
323 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
\r
326 m_mergedRevs.clear();
\r
328 // first start a thread to obtain the log messages without
\r
329 // blocking the dialog
\r
331 //m_tFrom = (DWORD)-1;
\r
333 m_LogList.m_Path=m_path;
\r
334 m_LogList.FetchLogAsync(this);
\r
336 GetDlgItem(IDC_LOGLIST)->SetFocus();
\r
342 LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM /*lParam*/)
\r
344 int cur=(int)wParam;
\r
346 if( cur == GITLOG_START )
\r
349 temp.LoadString(IDS_PROGRESSWAIT);
\r
351 this->m_LogList.ShowText(temp, true);
\r
353 // We use a progress bar while getting the logs
\r
354 m_LogProgress.SetRange32(0, 100);
\r
355 m_LogProgress.SetPos(0);
\r
357 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
\r
359 //DialogEnableWindow(IDC_GETALL, FALSE);
\r
360 //DialogEnableWindow(IDC_SHOWWHOLEPROJECT, FALSE);
\r
361 //DialogEnableWindow(IDC_LOG_FIRSTPARENT, FALSE);
\r
362 DialogEnableWindow(IDC_STATBUTTON, FALSE);
\r
363 DialogEnableWindow(IDC_REFRESH, FALSE);
\r
364 DialogEnableWindow(IDC_HIDEPATHS,FALSE);
\r
366 }else if( cur == GITLOG_END)
\r
369 //if (!m_bShowedAll)
\r
370 DialogEnableWindow(IDC_SHOWWHOLEPROJECT, TRUE);
\r
372 //DialogEnableWindow(IDC_GETALL, TRUE);
\r
373 DialogEnableWindow(IDC_LOG_FIRSTPARENT, TRUE);
\r
374 DialogEnableWindow(IDC_STATBUTTON, TRUE);
\r
375 DialogEnableWindow(IDC_REFRESH, TRUE);
\r
376 DialogEnableWindow(IDC_HIDEPATHS,TRUE);
\r
378 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
\r
379 GetDlgItem(IDC_PROGRESS)->ShowWindow(FALSE);
\r
380 //CTime time=m_LogList.GetOldestTime();
\r
382 m_LogList.GetTimeRange(begin,end);
\r
383 m_DateFrom.SetTime(&begin);
\r
384 m_DateTo.SetTime(&end);
\r
390 if(this->m_LogList.HasText())
\r
392 this->m_LogList.ClearText();
\r
393 UpdateLogInfoLabel();
\r
395 m_LogProgress.SetPos(cur);
\r
399 void CLogDlg::SetDlgTitle(bool bOffline)
\r
401 if (m_sTitle.IsEmpty())
\r
402 GetWindowText(m_sTitle);
\r
407 if (m_path.IsUrl())
\r
408 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());
\r
409 else if (m_path.IsDirectory())
\r
410 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());
\r
412 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());
\r
413 SetWindowText(sTemp);
\r
417 if (m_path.IsUrl())
\r
418 SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());
\r
419 else if (m_path.IsEmpty())
\r
420 SetWindowText(m_sTitle + _T(" - ") + CString(_T("Whole Project")));
\r
421 else if (m_path.IsDirectory())
\r
422 SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());
\r
424 SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());
\r
428 void CLogDlg::CheckRegexpTooltip()
\r
430 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
\r
431 // Since tooltip describes regexp features, show it only if regexps are enabled.
\r
432 if (m_bFilterWithRegex)
\r
434 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
\r
437 m_tooltips.DelTool(pWnd);
\r
440 void CLogDlg::EnableOKButton()
\r
444 // the dialog is used to select revisions
\r
445 if (m_bSelectionMustBeSingle)
\r
447 // enable OK button if only a single revision is selected
\r
448 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()==1));
\r
450 else if (m_bSelectionMustBeContinuous)
\r
451 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
\r
453 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
456 DialogEnableWindow(IDOK, TRUE);
\r
459 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
\r
461 // we fill here the log message rich edit control,
\r
462 // and also populate the changed files list control
\r
463 // according to the selected revision(s).
\r
465 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
466 // empty the log message view
\r
467 pMsgView->SetWindowText(_T(" "));
\r
468 // empty the changed files list
\r
469 m_ChangedFileListCtrl.SetRedraw(FALSE);
\r
470 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
471 m_currentChangedArray = NULL;
\r
472 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
473 m_ChangedFileListCtrl.DeleteAllItems();
\r
475 // if we're not here to really show a selected revision, just
\r
476 // get out of here after clearing the views, which is what is intended
\r
477 // if that flag is not set.
\r
481 m_ChangedFileListCtrl.Invalidate();
\r
482 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
483 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
487 // depending on how many revisions are selected, we have to do different
\r
489 int selCount = m_LogList.GetSelectedCount();
\r
492 // if nothing is selected, we have nothing more to do
\r
493 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
494 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
497 else if (selCount == 1)
\r
499 // if one revision is selected, we have to fill the log message view
\r
500 // with the corresponding log message, and also fill the changed files
\r
502 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
503 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
504 if (selIndex >= m_LogList.m_arShownList.GetCount())
\r
506 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
507 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
510 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));
\r
512 if(!pLogEntry->m_IsFull)
\r
514 pMsgView->SetWindowText(_T("load ..."));
\r
517 // set the log message text
\r
518 pMsgView->SetWindowText(_T("Commit:")+pLogEntry->m_CommitHash+_T("\r\n\r\n*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);
\r
519 // turn bug ID's into links if the bugtraq: properties have been set
\r
520 // and we can find a match of those in the log message
\r
521 m_ProjectProperties.FindBugID(pLogEntry->m_Body, pMsgView);
\r
522 CAppUtils::FormatTextInRichEditControl(pMsgView);
\r
524 int HidePaths=m_cHidePaths.GetState() & 0x0003;
\r
525 CString matchpath=this->m_path.GetGitPathString();
\r
527 for(int i=0;i<pLogEntry->m_Files.GetCount() && (!matchpath.IsEmpty());i++)
\r
529 if( m_bWholeProject )
\r
532 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action &= ~(CTGitPath::LOGACTIONS_HIDE|CTGitPath::LOGACTIONS_GRAY);
\r
534 if(pLogEntry->m_Files[i].GetGitPathString().Left(matchpath.GetLength()) != matchpath)
\r
536 if(HidePaths==BST_CHECKED)
\r
537 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action |= CTGitPath::LOGACTIONS_HIDE;
\r
538 if(HidePaths==BST_INDETERMINATE)
\r
539 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action |= CTGitPath::LOGACTIONS_GRAY;
\r
542 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->m_Files);
\r
543 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;
\r
544 m_ChangedFileListCtrl.Show(SVNSLC_SHOWVERSIONED);
\r
546 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
553 // more than one revision is selected:
\r
554 // the log message view must be emptied
\r
555 // the changed files list contains all the changed paths from all
\r
556 // selected revisions, with 'doubles' removed
\r
557 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
\r
560 // redraw the views
\r
561 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
563 if (m_currentChangedArray)
\r
565 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
\r
566 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
\r
568 else if (m_currentChangedPathList.GetCount())
\r
570 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
\r
571 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
\r
575 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
576 m_ChangedFileListCtrl.Invalidate();
\r
579 // sort according to the settings
\r
580 if (m_nSortColumnPathList > 0)
\r
581 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
583 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
\r
584 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
588 void CLogDlg::OnBnClickedRefresh()
\r
594 void CLogDlg::Refresh (bool /*autoGoOnline*/)
\r
596 m_LogList.Refresh();
\r
601 BOOL CLogDlg::Cancel()
\r
603 return m_bCancelled;
\r
606 void CLogDlg::SaveSplitterPos()
\r
610 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
611 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
613 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
614 ScreenToClient(&rectSplitter);
\r
615 regPos1 = rectSplitter.top;
\r
616 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
617 ScreenToClient(&rectSplitter);
\r
618 regPos2 = rectSplitter.top;
\r
622 void CLogDlg::OnCancel()
\r
624 // canceling means stopping the working thread if it's still running.
\r
625 if (this->IsThreadRunning())
\r
627 m_LogList.TerminateThread();
\r
632 __super::OnCancel();
\r
635 CString CLogDlg::MakeShortMessage(const CString& message)
\r
637 bool bFoundShort = true;
\r
638 CString sShortMessage = m_ProjectProperties.GetLogSummary(message);
\r
639 if (sShortMessage.IsEmpty())
\r
641 bFoundShort = false;
\r
642 sShortMessage = message;
\r
644 // Remove newlines and tabs 'cause those are not shown nicely in the list control
\r
645 sShortMessage.Replace(_T("\r"), _T(""));
\r
646 sShortMessage.Replace(_T("\t"), _T(" "));
\r
648 // Suppose the first empty line separates 'summary' from the rest of the message.
\r
649 int found = sShortMessage.Find(_T("\n\n"));
\r
650 // To avoid too short 'short' messages
\r
651 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
\r
652 // only use the empty newline as a separator if it comes after at least 15 chars.
\r
653 if ((!bFoundShort)&&(found >= 15))
\r
655 sShortMessage = sShortMessage.Left(found);
\r
657 sShortMessage.Replace('\n', ' ');
\r
658 return sShortMessage;
\r
661 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
664 if (rev == SVN_INVALID_REVNUM)
\r
670 // this is the callback function which receives the data for every revision we ask the log for
\r
671 // we store this information here one by one.
\r
673 if (m_startrev == -1)
\r
678 m_LogProgress.SetPos(m_limit - m_limitcounter);
\r
680 else if (m_startrev.IsNumber() && m_startrev.IsNumber())
\r
681 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);
\r
682 __time64_t ttime = time/1000000L;
\r
683 if (m_tTo < (DWORD)ttime)
\r
684 m_tTo = (DWORD)ttime;
\r
685 if (m_tFrom > (DWORD)ttime)
\r
686 m_tFrom = (DWORD)ttime;
\r
687 if ((m_lowestRev > rev)||(m_lowestRev < 0))
\r
689 // Add as many characters from the log message to the list control
\r
690 PLOGENTRYDATA pLogItem = new LOGENTRYDATA;
\r
691 pLogItem->bCopies = !!copies;
\r
693 // find out if this item was copied in the revision
\r
694 BOOL copiedself = FALSE;
\r
697 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)
\r
699 LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);
\r
700 if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))
\r
702 // note: this only works if the log is fetched top-to-bottom
\r
703 // but since we do that, it shouldn't be a problem
\r
704 m_sSelfRelativeURL = cpath->sCopyFromPath;
\r
710 pLogItem->bCopiedSelf = copiedself;
\r
711 pLogItem->tmDate = ttime;
\r
712 pLogItem->sAuthor = author;
\r
713 pLogItem->sDate = date;
\r
714 pLogItem->sShortMessage = MakeShortMessage(message);
\r
715 pLogItem->dwFileChanges = filechanges;
\r
716 pLogItem->actions = actions;
\r
717 pLogItem->haschildren = haschildren;
\r
718 pLogItem->childStackDepth = m_childCounter;
\r
719 m_maxChild = max(m_childCounter, m_maxChild);
\r
722 pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();
\r
724 // split multi line log entries and concatenate them
\r
725 // again but this time with \r\n as line separators
\r
726 // so that the edit control recognizes them
\r
729 if (message.GetLength()>0)
\r
731 m_sMessageBuf = message;
\r
732 m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));
\r
733 m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));
\r
734 if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)
\r
735 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);
\r
738 m_sMessageBuf.Empty();
\r
739 pLogItem->sMessage = m_sMessageBuf;
\r
740 pLogItem->Rev = rev;
\r
742 // move-construct path array
\r
744 pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);
\r
745 cpaths->RemoveAll();
\r
747 catch (CException * e)
\r
749 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);
\r
751 m_bCancelled = TRUE;
\r
753 m_logEntries.push_back(pLogItem);
\r
754 m_arShownList.Add(pLogItem);
\r
760 //this is the thread function which calls the subversion function
\r
765 void CLogDlg::CopyChangedSelectionToClipBoard()
\r
768 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
770 return; // nothing is selected, get out of here
\r
774 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
777 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
780 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
781 CTGitPath *path = (CTGitPath*)m_ChangedFileListCtrl.GetItemData(nItem);
\r
783 sPaths += path->GetGitPathString();
\r
784 sPaths += _T("\r\n");
\r
790 // only one revision is selected in the log dialog top pane
\r
791 // but multiple items could be selected in the changed items list
\r
792 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
795 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
796 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
798 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
800 // some items are hidden! So find out which item the user really selected
\r
801 INT_PTR selRealIndex = -1;
\r
802 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
804 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
806 if (selRealIndex == nItem)
\r
808 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);
\r
813 if (changedlogpath)
\r
815 sPaths += changedlogpath->sPath;
\r
816 sPaths += _T("\r\n");
\r
822 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
\r
826 BOOL CLogDlg::IsDiffPossible(LogChangedPath * /*changedpath*/, git_revnum_t rev)
\r
829 CString added, deleted;
\r
830 if (changedpath == NULL)
\r
833 if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))
\r
835 if (changedpath->action == LOGACTIONS_ADDED) // file is added
\r
837 if (changedpath->lCopyFromRev == 0)
\r
838 return FALSE; // but file was not added with history
\r
846 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
848 // we have two separate context menus:
\r
849 // one shown on the log message list control,
\r
850 // the other shown in the changed-files list control
\r
851 int selCount = m_LogList.GetSelectedCount();
\r
852 if (pWnd == &m_LogList)
\r
854 //ShowContextMenuForRevisions(pWnd, point);
\r
856 else if (pWnd == &m_ChangedFileListCtrl)
\r
858 //ShowContextMenuForChangedpaths(pWnd, point);
\r
860 else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
862 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
865 selIndex = m_LogList.GetNextSelectedItem(pos);
\r
866 if ((point.x == -1) && (point.y == -1))
\r
869 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
\r
870 ClientToScreen(&rect);
\r
871 point = rect.CenterPoint();
\r
873 CString sMenuItemText;
\r
875 if (popup.CreatePopupMenu())
\r
877 // add the 'default' entries
\r
878 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
\r
879 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
\r
880 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
\r
881 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
\r
883 //if (selIndex >= 0)
\r
885 // popup.AppendMenu(MF_SEPARATOR);
\r
886 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
\r
887 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
\r
890 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
894 break; // no command selected
\r
897 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
\r
899 case CGitLogList::ID_EDITAUTHOR:
\r
900 EditLogMessage(selIndex);
\r
908 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
911 ASSERT(m_pFindDialog != NULL);
\r
913 if (m_pFindDialog->IsTerminating())
\r
915 // invalidate the handle identifying the dialog box.
\r
916 m_pFindDialog = NULL;
\r
920 if(m_pFindDialog->FindNext())
\r
922 //read data from dialog
\r
923 CString FindText = m_pFindDialog->GetFindString();
\r
924 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
\r
925 bool bFound = false;
\r
927 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
\r
929 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
\r
932 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
\r
936 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
938 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))
\r
943 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
944 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
946 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
947 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))
\r
953 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))
\r
965 if (m_logEntries[i]->sMessage.Find(FindText) >= 0)
\r
970 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
971 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
972 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
974 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
975 if (cpath->sCopyFromPath.Find(FindText)>=0)
\r
981 if (cpath->sPath.Find(FindText)>=0)
\r
991 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
992 CString msg = pLogEntry->sMessage;
\r
993 msg = msg.MakeLower();
\r
994 CString find = FindText.MakeLower();
\r
995 if (msg.Find(find) >= 0)
\r
1000 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1001 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1003 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1004 CString lowerpath = cpath->sCopyFromPath;
\r
1005 lowerpath.MakeLower();
\r
1006 if (lowerpath.Find(find)>=0)
\r
1012 lowerpath = cpath->sPath;
\r
1013 lowerpath.MakeLower();
\r
1014 if (lowerpath.Find(find)>=0)
\r
1023 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
\r
1026 this->m_nSearchIndex = (i+1);
\r
1027 m_LogList.EnsureVisible(i, FALSE);
\r
1028 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);
\r
1029 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1030 m_LogList.SetSelectionMark(i);
\r
1031 FillLogMessageCtrl();
\r
1032 UpdateData(FALSE);
\r
1034 if (m_nSearchIndex >= m_arShownList.GetCount())
\r
1035 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
\r
1037 } // if(m_pFindDialog->FindNext())
\r
1038 UpdateLogInfoLabel();
\r
1043 void CLogDlg::OnOK()
\r
1045 // since the log dialog is also used to select revisions for other
\r
1046 // dialogs, we have to do some work before closing this dialog
\r
1047 if (GetFocus() != GetDlgItem(IDOK))
\r
1048 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
\r
1051 if (this->IsThreadRunning())
\r
1053 m_LogList.TerminateThread();
\r
1056 // check that one and only one row is selected
\r
1057 if (m_LogList.GetSelectedCount() == 1)
\r
1059 // get the selected row
\r
1060 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1061 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
1062 if (selIndex < m_LogList.m_arShownList.GetCount())
\r
1064 // all ok, pick up the revision
\r
1065 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));
\r
1066 // extract the hash
\r
1067 m_sSelectedHash = pLogEntry->m_CommitHash;
\r
1070 UpdateData(FALSE);
\r
1071 SaveSplitterPos();
\r
1075 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
\r
1076 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
\r
1079 CString buttontext;
\r
1080 GetDlgItemText(IDOK, buttontext);
\r
1081 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1082 if (temp.Compare(buttontext) != 0)
\r
1083 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
\r
1084 m_bCancelled = TRUE;
\r
1085 m_selectedRevs.Clear();
\r
1086 m_selectedRevsOneRange.Clear();
\r
1087 if (m_pNotifyWindow)
\r
1089 int selIndex = m_LogList.GetSelectionMark();
\r
1090 if (selIndex >= 0)
\r
1092 PLOGENTRYDATA pLogEntry = NULL;
\r
1093 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1094 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1095 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1096 git_revnum_t lowerRev = pLogEntry->Rev;
\r
1097 git_revnum_t higherRev = lowerRev;
\r
1100 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1101 git_revnum_t rev = pLogEntry->Rev;
\r
1102 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1103 if (lowerRev > rev)
\r
1105 if (higherRev < rev)
\r
1108 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
\r
1110 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
\r
1112 BOOL bSentMessage = FALSE;
\r
1113 if (m_LogList.GetSelectedCount() == 1)
\r
1115 // if only one revision is selected, check if the path/url with which the dialog was started
\r
1116 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
\r
1117 // if it was copied, use the copy from revision as lowerRev
\r
1118 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
\r
1120 CString sUrl = m_path.GetGitPathString();
\r
1121 if (!m_path.IsUrl())
\r
1123 sUrl = GetURLFromPath(m_path);
\r
1125 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
\r
1126 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
\r
1128 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);
\r
1131 if (sUrl.Compare(pData->sPath) == 0)
\r
1133 if (!pData->sCopyFromPath.IsEmpty())
\r
1135 lowerRev = pData->lCopyFromRev;
\r
1136 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
\r
1137 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
\r
1138 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1139 bSentMessage = TRUE;
\r
1146 if ( !bSentMessage )
\r
1148 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
\r
1149 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
\r
1150 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1151 if (m_selectedRevsOneRange.GetCount())
\r
1152 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
\r
1157 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
1158 reg = m_btnShow.GetCurrentEntry();
\r
1159 SaveSplitterPos();
\r
1163 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1165 // a double click on an entry in the changed-files list has happened
\r
1168 DiffSelectedFile();
\r
1171 void CLogDlg::DiffSelectedFile()
\r
1174 if (m_bThreadRunning)
\r
1176 UpdateLogInfoLabel();
\r
1177 INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
1180 if (m_ChangedFileListCtrl.GetSelectedCount() == 0)
\r
1182 // find out if there's an entry selected in the log list
\r
1183 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1184 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1185 git_revnum_t rev1 = pLogEntry->Rev;
\r
1186 git_revnum_t rev2 = rev1;
\r
1191 // there's at least a second entry selected in the log list: several revisions selected!
\r
1192 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1195 rev1 = max(rev1,(long)pLogEntry->Rev);
\r
1196 rev2 = min(rev2,(long)pLogEntry->Rev);
\r
1200 // now we have both revisions selected in the log list, so we can do a diff of the selected
\r
1201 // entry in the changed files list with these two revisions.
\r
1202 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1207 // nothing or only one revision selected in the log list
\r
1208 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1210 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1212 // some items are hidden! So find out which item the user really clicked on
\r
1213 INT_PTR selRealIndex = -1;
\r
1214 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1216 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1218 if (selRealIndex == selIndex)
\r
1220 selIndex = hiddenindex;
\r
1221 changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1227 if (IsDiffPossible(changedpath, rev1))
\r
1229 // diffs with renamed files are possible
\r
1230 if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))
\r
1231 rev2 = changedpath->lCopyFromRev;
\r
1234 // if the path was modified but the parent path was 'added with history'
\r
1235 // then we have to use the copy from revision of the parent path
\r
1236 CTGitPath cpath = CTGitPath(changedpath->sPath);
\r
1237 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
1239 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
1240 if (p.IsAncestorOf(cpath))
\r
1242 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
1243 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
1247 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1251 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1252 CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1254 // deleted files must be opened from the revision before the deletion
\r
1255 if (changedpath->action == LOGACTIONS_DELETED)
\r
1257 m_bCancelled = false;
\r
1259 CProgressDlg progDlg;
\r
1260 progDlg.SetTitle(IDS_APPNAME);
\r
1261 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1262 CString sInfoLine;
\r
1263 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());
\r
1264 progDlg.SetLine(1, sInfoLine, true);
\r
1265 SetAndClearProgressInfo(&progDlg);
\r
1266 progDlg.ShowModeless(m_hWnd);
\r
1268 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))
\r
1270 m_bCancelled = false;
\r
1271 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))
\r
1274 SetAndClearProgressInfo((HWND)NULL);
\r
1275 CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1280 SetAndClearProgressInfo((HWND)NULL);
\r
1282 CString sName1, sName2;
\r
1283 sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);
\r
1284 sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);
\r
1285 CAppUtils::DiffFlags flags;
\r
1286 flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1287 if (changedpath->action == LOGACTIONS_DELETED)
\r
1288 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);
\r
1290 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);
\r
1297 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)
\r
1299 DialogEnableWindow(IDOK, FALSE);
\r
1300 // SetPromptApp(&theApp);
\r
1301 theApp.DoWaitCursor(1);
\r
1304 GetTempPath(temppath);
\r
1307 file1.Format(_T("%s%s_%s%s"),
\r
1309 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1310 rev1->m_CommitHash.Left(6),
\r
1311 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1314 file2.Format(_T("%s\\%s_%s%s"),
\r
1316 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1317 rev2->m_CommitHash.Left(6),
\r
1318 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1322 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1323 g_Git.RunLogFile(cmd,file1);
\r
1324 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1325 g_Git.RunLogFile(cmd,file2);
\r
1327 CAppUtils::DiffFlags flags;
\r
1328 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);
\r
1331 //get the filename
\r
1333 if (Git::PathIsURL(m_path))
\r
1335 filepath = m_path.GetGitPathString();
\r
1339 filepath = GetURLFromPath(m_path);
\r
1340 if (filepath.IsEmpty())
\r
1342 theApp.DoWaitCursor(-1);
\r
1344 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1345 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1346 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1348 theApp.DoWaitCursor(-11);
\r
1352 m_bCancelled = FALSE;
\r
1353 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1355 CString firstfile, secondfile;
\r
1356 if (m_LogList.GetSelectedCount()==1)
\r
1358 int s = m_LogList.GetSelectionMark();
\r
1359 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));
\r
1360 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1361 firstfile = changedpath->sPath;
\r
1362 secondfile = firstfile;
\r
1363 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?
\r
1365 secondfile = changedpath->sCopyFromPath;
\r
1366 rev2 = changedpath->lCopyFromRev;
\r
1371 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();
\r
1372 secondfile = firstfile;
\r
1375 firstfile = filepath + firstfile.Trim();
\r
1376 secondfile = filepath + secondfile.Trim();
\r
1378 GitDiff diff(this, this->m_hWnd, true);
\r
1379 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1380 diff.SetHEADPeg(m_LogRevision);
\r
1383 if (PromptShown())
\r
1384 diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);
\r
1386 CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);
\r
1390 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))
\r
1392 if (firstfile.Compare(secondfile)==0)
\r
1394 git_revnum_t baseRev = 0;
\r
1395 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);
\r
1402 theApp.DoWaitCursor(-1);
\r
1406 BOOL CLogDlg::Open(bool /*bOpenWith*/,CString changedpath, git_revnum_t rev)
\r
1409 DialogEnableWindow(IDOK, FALSE);
\r
1410 SetPromptApp(&theApp);
\r
1411 theApp.DoWaitCursor(1);
\r
1413 if (Git::PathIsURL(m_path))
\r
1415 filepath = m_path.GetGitPathString();
\r
1419 filepath = GetURLFromPath(m_path);
\r
1420 if (filepath.IsEmpty())
\r
1422 theApp.DoWaitCursor(-1);
\r
1424 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1425 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1426 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1431 m_bCancelled = false;
\r
1432 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1433 filepath += changedpath;
\r
1435 CProgressDlg progDlg;
\r
1436 progDlg.SetTitle(IDS_APPNAME);
\r
1437 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1438 CString sInfoLine;
\r
1439 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());
\r
1440 progDlg.SetLine(1, sInfoLine, true);
\r
1441 SetAndClearProgressInfo(&progDlg);
\r
1442 progDlg.ShowModeless(m_hWnd);
\r
1444 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);
\r
1445 m_bCancelled = false;
\r
1446 if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))
\r
1449 SetAndClearProgressInfo((HWND)NULL);
\r
1450 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1452 theApp.DoWaitCursor(-1);
\r
1456 SetAndClearProgressInfo((HWND)NULL);
\r
1457 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1460 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1461 if (ret <= HINSTANCE_ERROR)
\r
1466 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1467 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1468 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1471 theApp.DoWaitCursor(-1);
\r
1476 void CLogDlg::EditAuthor(const CLogDataVector& /*logs*/)
\r
1481 if (logs.size() == 0)
\r
1483 DialogEnableWindow(IDOK, FALSE);
\r
1484 SetPromptApp(&theApp);
\r
1485 theApp.DoWaitCursor(1);
\r
1486 if (Git::PathIsURL(m_path))
\r
1487 url = m_path.GetGitPathString();
\r
1490 url = GetURLFromPath(m_path);
\r
1492 name = Git_PROP_REVISION_AUTHOR;
\r
1494 CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);
\r
1495 CString sOldValue = value;
\r
1496 value.Replace(_T("\n"), _T("\r\n"));
\r
1497 CInputDlg dlg(this);
\r
1498 dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);
\r
1499 dlg.m_sInputText = value;
\r
1500 dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);
\r
1501 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1502 dlg.m_bUseLogWidth = false;
\r
1503 if (dlg.DoModal() == IDOK)
\r
1505 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1507 LogCache::CCachedLogInfo* toUpdate
\r
1508 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1510 CProgressDlg progDlg;
\r
1511 progDlg.SetTitle(IDS_APPNAME);
\r
1512 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
\r
1513 progDlg.SetTime(true);
\r
1514 progDlg.SetShowProgressBar(true);
\r
1515 progDlg.ShowModeless(m_hWnd);
\r
1516 for (DWORD i=0; i<logs.size(); ++i)
\r
1518 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))
\r
1521 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1527 logs[i]->sAuthor = dlg.m_sInputText;
\r
1528 m_LogList.Invalidate();
\r
1530 // update the log cache
\r
1532 if (toUpdate != NULL)
\r
1534 // log caching is active
\r
1536 LogCache::CCachedLogInfo newInfo;
\r
1537 newInfo.Insert ( logs[i]->Rev
\r
1538 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)
\r
1541 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);
\r
1543 toUpdate->Update (newInfo);
\r
1546 progDlg.SetProgress64(i, logs.size());
\r
1550 theApp.DoWaitCursor(-1);
\r
1555 void CLogDlg::EditLogMessage(int /*index*/)
\r
1560 DialogEnableWindow(IDOK, FALSE);
\r
1561 SetPromptApp(&theApp);
\r
1562 theApp.DoWaitCursor(1);
\r
1563 if (Git::PathIsURL(m_path))
\r
1564 url = m_path.GetGitPathString();
\r
1567 url = GetURLFromPath(m_path);
\r
1569 name = Git_PROP_REVISION_LOG;
\r
1571 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
1572 m_bCancelled = FALSE;
\r
1573 CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);
\r
1574 CString sOldValue = value;
\r
1575 value.Replace(_T("\n"), _T("\r\n"));
\r
1576 CInputDlg dlg(this);
\r
1577 dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);
\r
1578 dlg.m_sInputText = value;
\r
1579 dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);
\r
1580 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1581 dlg.m_bUseLogWidth = true;
\r
1582 if (dlg.DoModal() == IDOK)
\r
1584 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1585 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))
\r
1587 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1591 pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);
\r
1592 // split multi line log entries and concatenate them
\r
1593 // again but this time with \r\n as line separators
\r
1594 // so that the edit control recognizes them
\r
1595 if (dlg.m_sInputText.GetLength()>0)
\r
1597 m_sMessageBuf = dlg.m_sInputText;
\r
1598 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));
\r
1599 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));
\r
1600 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)
\r
1601 dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);
\r
1604 dlg.m_sInputText.Empty();
\r
1605 pLogEntry->sMessage = dlg.m_sInputText;
\r
1606 pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);
\r
1607 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
1608 pMsgView->SetWindowText(_T(" "));
\r
1609 pMsgView->SetWindowText(dlg.m_sInputText);
\r
1610 m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);
\r
1611 m_LogList.Invalidate();
\r
1613 // update the log cache
\r
1615 LogCache::CCachedLogInfo* toUpdate
\r
1616 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1617 if (toUpdate != NULL)
\r
1619 // log caching is active
\r
1621 LogCache::CCachedLogInfo newInfo;
\r
1622 newInfo.Insert ( pLogEntry->Rev
\r
1624 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)
\r
1626 , LogCache::CRevisionInfoContainer::HAS_COMMENT);
\r
1628 toUpdate->Update (newInfo);
\r
1632 theApp.DoWaitCursor(-1);
\r
1637 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
\r
1639 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1640 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1641 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1643 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1645 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1647 m_LogList.DiffSelectedRevWithPrevious();
\r
1651 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1653 DiffSelectedFile();
\r
1657 if (m_hAccel && !bSkipAccelerator)
\r
1659 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1664 if(::IsWindow(m_tooltips.m_hWnd))
\r
1665 m_tooltips.RelayEvent(pMsg);
\r
1666 return __super::PreTranslateMessage(pMsg);
\r
1670 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
1672 //if (this->IsThreadRunning())
\r
1673 if(m_LogList.m_bNoDispUpdates)
\r
1675 // only show the wait cursor over the list control
\r
1677 ((pWnd == GetDlgItem(IDC_LOGLIST))||
\r
1678 (pWnd == GetDlgItem(IDC_MSGVIEW))||
\r
1679 (pWnd == GetDlgItem(IDC_LOGMSG))))
\r
1681 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
1686 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1687 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1689 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
1691 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1694 void CLogDlg::OnBnClickedHelp()
\r
1699 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1701 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
1703 //if (this->IsThreadRunning())
\r
1704 if(m_LogList.m_bNoDispUpdates)
\r
1706 if (pNMLV->iItem >= 0)
\r
1708 m_nSearchIndex = pNMLV->iItem;
\r
1709 if (pNMLV->iSubItem != 0)
\r
1711 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount()))
\r
1713 // remove the selected state
\r
1714 if (pNMLV->uChanged & LVIF_STATE)
\r
1716 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
\r
1717 FillLogMessageCtrl();
\r
1718 UpdateData(FALSE);
\r
1719 UpdateLogInfoLabel();
\r
1723 if (pNMLV->uChanged & LVIF_STATE)
\r
1725 FillLogMessageCtrl();
\r
1726 UpdateData(FALSE);
\r
1731 FillLogMessageCtrl();
\r
1732 UpdateData(FALSE);
\r
1735 UpdateLogInfoLabel();
\r
1738 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
\r
1740 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
\r
1741 if (pEnLink->msg == WM_LBUTTONUP)
\r
1744 GetDlgItemText(IDC_MSGVIEW, msg);
\r
1745 msg.Replace(_T("\r\n"), _T("\n"));
\r
1746 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
\r
1747 if (!::PathIsURL(url))
\r
1749 url = m_ProjectProperties.GetBugIDUrl(url);
\r
1750 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1752 if (!url.IsEmpty())
\r
1753 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1758 void CLogDlg::OnBnClickedStatbutton()
\r
1761 if (this->IsThreadRunning())
\r
1763 if (m_LogList.m_arShownList.IsEmpty())
\r
1764 return; // nothing is shown, so no statistics.
\r
1765 // the statistics dialog expects the log entries to be sorted by date
\r
1766 SortByColumn(3, false);
\r
1767 CPtrArray shownlist;
\r
1768 m_LogList.RecalculateShownList(&shownlist);
\r
1769 // create arrays which are aware of the current filter
\r
1770 CStringArray m_arAuthorsFiltered;
\r
1771 CDWordArray m_arDatesFiltered;
\r
1772 CDWordArray m_arFileChangesFiltered;
\r
1773 for (INT_PTR i=0; i<shownlist.GetCount(); ++i)
\r
1775 GitRev* pLogEntry = reinterpret_cast<GitRev*>(shownlist.GetAt(i));
\r
1776 CString strAuthor = pLogEntry->m_AuthorName;
\r
1777 if ( strAuthor.IsEmpty() )
\r
1779 strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);
\r
1781 m_arAuthorsFiltered.Add(strAuthor);
\r
1782 m_arDatesFiltered.Add(pLogEntry->m_AuthorDate.GetTime());
\r
1783 m_arFileChangesFiltered.Add(pLogEntry->m_Files.GetCount());
\r
1785 CStatGraphDlg dlg;
\r
1786 dlg.m_parAuthors = &m_arAuthorsFiltered;
\r
1787 dlg.m_parDates = &m_arDatesFiltered;
\r
1788 dlg.m_parFileChanges = &m_arFileChangesFiltered;
\r
1789 dlg.m_path = m_path;
\r
1791 // restore the previous sorting
\r
1792 SortByColumn(m_nSortColumn, m_bAscending);
\r
1793 OnTimer(LOGFILTER_TIMER);
\r
1797 void CLogDlg::DoSizeV1(int delta)
\r
1800 RemoveAnchor(IDC_LOGLIST);
\r
1801 RemoveAnchor(IDC_SPLITTERTOP);
\r
1802 RemoveAnchor(IDC_MSGVIEW);
\r
1803 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
1804 RemoveAnchor(IDC_LOGMSG);
\r
1805 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
\r
1806 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
\r
1807 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
1808 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
1809 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
1810 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1811 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1814 SetSplitterRange();
\r
1815 m_LogList.Invalidate();
\r
1816 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
1820 void CLogDlg::DoSizeV2(int delta)
\r
1823 RemoveAnchor(IDC_LOGLIST);
\r
1824 RemoveAnchor(IDC_SPLITTERTOP);
\r
1825 RemoveAnchor(IDC_MSGVIEW);
\r
1826 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
1827 RemoveAnchor(IDC_LOGMSG);
\r
1828 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
\r
1829 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
\r
1830 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
1831 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
1832 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
1833 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1834 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1837 SetSplitterRange();
\r
1838 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
1839 m_ChangedFileListCtrl.Invalidate();
\r
1843 void CLogDlg::AdjustMinSize()
\r
1845 // adjust the minimum size of the dialog to prevent the resizing from
\r
1846 // moving the list control too far down.
\r
1847 CRect rcChgListView;
\r
1848 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
\r
1850 m_LogList.GetClientRect(rcLogList);
\r
1852 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
\r
1853 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
\r
1854 +rcChgListView.Height()+rcLogList.Height()+60));
\r
1857 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
1859 switch (message) {
\r
1861 if (wParam == IDC_SPLITTERTOP)
\r
1863 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
1864 DoSizeV1(pHdr->delta);
\r
1866 else if (wParam == IDC_SPLITTERBOTTOM)
\r
1868 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
1869 DoSizeV2(pHdr->delta);
\r
1874 return CResizableDialog::DefWindowProc(message, wParam, lParam);
\r
1877 void CLogDlg::SetSplitterRange()
\r
1879 if ((m_LogList)&&(m_ChangedFileListCtrl))
\r
1882 m_LogList.GetWindowRect(rcTop);
\r
1883 ScreenToClient(rcTop);
\r
1885 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
\r
1886 ScreenToClient(rcMiddle);
\r
1887 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
\r
1889 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
\r
1890 ScreenToClient(rcBottom);
\r
1891 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
\r
1895 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
\r
1897 // FIXME: x64 version would get this function called with unexpected parameters.
\r
1901 RECT * rect = (LPRECT)lParam;
\r
1904 point = CPoint(rect->left, rect->bottom);
\r
1905 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
\r
1907 if (popup.CreatePopupMenu())
\r
1909 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
1910 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);
\r
1912 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1914 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
1915 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
\r
1916 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
1917 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
\r
1918 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
1919 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
\r
1920 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
1921 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
\r
1922 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
\r
1923 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
\r
1925 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1927 temp.LoadString(IDS_LOG_FILTER_REGEX);
\r
1928 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
\r
1931 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1932 if (selection != 0)
\r
1935 if (selection == LOGFILTER_REGEX)
\r
1937 m_bFilterWithRegex = !m_bFilterWithRegex;
\r
1938 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
1939 b = m_bFilterWithRegex;
\r
1940 CheckRegexpTooltip();
\r
1944 m_LogList.m_nSelectedFilter = selection;
\r
1945 SetFilterCueText();
\r
1947 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
1953 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
1956 KillTimer(LOGFILTER_TIMER);
\r
1958 m_LogList.m_sFilterText.Empty();
\r
1959 UpdateData(FALSE);
\r
1960 theApp.DoWaitCursor(1);
\r
1961 CStoreSelection storeselection(this);
\r
1962 FillLogMessageCtrl(false);
\r
1964 m_LogList.RemoveFilter();
\r
1967 m_LogList.GetTimeRange(begin,end);
\r
1968 m_DateFrom.SetTime(&begin);
\r
1969 m_DateTo.SetTime(&end);
\r
1971 theApp.DoWaitCursor(-1);
\r
1972 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
1973 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
1974 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
1975 UpdateLogInfoLabel();
\r
1981 void CLogDlg::SetFilterCueText()
\r
1984 switch (m_LogList.m_nSelectedFilter)
\r
1986 case LOGFILTER_ALL:
\r
1987 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
1989 case LOGFILTER_MESSAGES:
\r
1990 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
1992 case LOGFILTER_PATHS:
\r
1993 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
1995 case LOGFILTER_AUTHORS:
\r
1996 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
1998 case LOGFILTER_REVS:
\r
1999 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2002 // to make the cue banner text appear more to the right of the edit control
\r
2003 temp = _T(" ")+temp;
\r
2004 m_cFilter.SetCueBanner(temp);
\r
2007 bool CLogDlg::Validate(LPCTSTR string)
\r
2009 if (!m_bFilterWithRegex)
\r
2012 return m_LogList.ValidateRegexp(string, pat, false);
\r
2016 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
\r
2018 if (nIDEvent == LOGFILTER_TIMER)
\r
2020 if (this->IsThreadRunning())
\r
2022 // thread still running! So just restart the timer.
\r
2023 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2026 CWnd * focusWnd = GetFocus();
\r
2027 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
\r
2028 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
\r
2029 if (m_LogList.m_sFilterText.IsEmpty())
\r
2031 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2032 // do not return here!
\r
2033 // we also need to run the filter if the filter text is empty:
\r
2034 // 1. to clear an existing filter
\r
2035 // 2. to rebuild the m_arShownList after sorting
\r
2037 theApp.DoWaitCursor(1);
\r
2038 CStoreSelection storeselection(this);
\r
2039 KillTimer(LOGFILTER_TIMER);
\r
2040 FillLogMessageCtrl(false);
\r
2042 // now start filter the log list
\r
2043 m_LogList.StartFilter();
\r
2045 if ( m_LogList.GetItemCount()==1 )
\r
2047 m_LogList.SetSelectionMark(0);
\r
2048 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
2050 theApp.DoWaitCursor(-1);
\r
2051 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2052 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2053 if (bSetFocusToFilterControl)
\r
2054 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2055 UpdateLogInfoLabel();
\r
2056 } // if (nIDEvent == LOGFILTER_TIMER)
\r
2057 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2058 __super::OnTimer(nIDEvent);
\r
2061 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2064 m_DateTo.GetTime(_time);
\r
2067 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
\r
2068 if (time.GetTime() != m_LogList.m_To.GetTime())
\r
2070 m_LogList.m_To = (DWORD)time.GetTime();
\r
2071 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2074 catch (CAtlException)
\r
2081 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2084 m_DateFrom.GetTime(_time);
\r
2087 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
\r
2088 if (time.GetTime() != m_LogList.m_From.GetTime())
\r
2090 m_LogList.m_From = (DWORD)time.GetTime();
\r
2091 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2094 catch (CAtlException)
\r
2103 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
\r
2105 CTGitPathList pathList;
\r
2108 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2110 m_sRepositoryRoot = GetRepositoryRoot(m_path);
\r
2112 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2115 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2120 int nextpos = m_LogList.GetNextSelectedItem(pos);
\r
2121 if (nextpos >= m_arShownList.GetCount())
\r
2123 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));
\r
2124 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
2125 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
2127 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2128 if (cpath == NULL)
\r
2131 if (!bRelativePaths)
\r
2132 path.SetFromGit(m_sRepositoryRoot);
\r
2133 path.AppendPathString(cpath->sPath);
\r
2134 if ((!bUseFilter)||
\r
2135 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
\r
2136 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
\r
2137 pathList.AddPath(path);
\r
2142 pathList.RemoveDuplicates();
\r
2147 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
\r
2150 switch(nSortColumn)
\r
2152 case 0: // Revision
\r
2155 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
\r
2157 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
\r
2163 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
\r
2165 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
\r
2171 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
\r
2173 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
\r
2179 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
\r
2181 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
\r
2184 case 4: // Message or bug id
\r
2185 if (m_bShowBugtraqColumn)
\r
2188 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
\r
2190 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
\r
2193 // fall through here
\r
2194 case 5: // Message
\r
2197 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
\r
2199 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
\r
2209 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
\r
2211 if (this->IsThreadRunning())
\r
2212 return; //no sorting while the arrays are filled
\r
2213 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2214 const int nColumn = pNMLV->iSubItem;
\r
2215 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
\r
2216 m_nSortColumn = nColumn;
\r
2217 SortByColumn(m_nSortColumn, m_bAscending);
\r
2218 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
\r
2219 SortShownListArray();
\r
2220 m_LogList.Invalidate();
\r
2221 UpdateLogInfoLabel();
\r
2226 void CLogDlg::SortShownListArray()
\r
2228 // make sure the shown list still matches the filter after sorting.
\r
2229 OnTimer(LOGFILTER_TIMER);
\r
2230 // clear the selection states
\r
2231 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2234 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
\r
2236 m_LogList.SetSelectionMark(-1);
\r
2239 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
\r
2241 if (control == NULL)
\r
2243 // set the sort arrow
\r
2244 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
\r
2245 HDITEM HeaderItem = {0};
\r
2246 HeaderItem.mask = HDI_FORMAT;
\r
2247 for (int i=0; i<pHeader->GetItemCount(); ++i)
\r
2249 pHeader->GetItem(i, &HeaderItem);
\r
2250 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
\r
2251 pHeader->SetItem(i, &HeaderItem);
\r
2255 pHeader->GetItem(nColumn, &HeaderItem);
\r
2256 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
\r
2257 pHeader->SetItem(nColumn, &HeaderItem);
\r
2260 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
\r
2263 if (this->IsThreadRunning())
\r
2264 return; //no sorting while the arrays are filled
\r
2265 if (m_currentChangedArray == NULL)
\r
2267 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2268 const int nColumn = pNMLV->iSubItem;
\r
2269 m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;
\r
2270 m_nSortColumnPathList = nColumn;
\r
2271 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
\r
2273 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
2274 m_ChangedFileListCtrl.Invalidate();
\r
2279 int CLogDlg::m_nSortColumnPathList = 0;
\r
2280 bool CLogDlg::m_bAscendingPathList = false;
\r
2282 int CLogDlg::SortCompare(const void * /*pElem1*/, const void * /*pElem2*/)
\r
2285 LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);
\r
2286 LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);
\r
2288 if (m_bAscendingPathList)
\r
2289 std::swap (cpath1, cpath2);
\r
2292 switch (m_nSortColumnPathList)
\r
2295 cmp = cpath2->GetAction().Compare(cpath1->GetAction());
\r
2300 cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);
\r
2304 case 2: // copy from path
\r
2305 cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);
\r
2309 case 3: // copy from revision
\r
2310 return cpath2->lCopyFromRev > cpath1->lCopyFromRev;
\r
2316 void CLogDlg::OnBnClickedHidepaths()
\r
2318 FillLogMessageCtrl();
\r
2319 m_ChangedFileListCtrl.Invalidate();
\r
2324 void CLogDlg::OnBnClickedCheckStoponcopy()
\r
2327 if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
2330 // ignore old fetch limits when switching
\r
2331 // between copy-following and stop-on-copy
\r
2332 // (otherwise stop-on-copy will limit what
\r
2333 // we see immediately after switching to
\r
2334 // copy-following)
\r
2338 // now, restart the query
\r
2344 void CLogDlg::UpdateLogInfoLabel()
\r
2347 git_revnum_t rev1 ;
\r
2348 git_revnum_t rev2 ;
\r
2349 long selectedrevs = 0;
\r
2350 int count =m_LogList.m_arShownList.GetCount();
\r
2353 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(0)))->m_CommitHash;
\r
2354 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
\r
2355 rev2 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;
\r
2356 selectedrevs = m_LogList.GetSelectedCount();
\r
2359 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
2360 m_sLogInfo = sTemp;
\r
2362 UpdateData(FALSE);
\r
2366 void CLogDlg::ShowContextMenuForChangedpaths(CWnd* /*pWnd*/, CPoint point)
\r
2369 int selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
2370 if ((point.x == -1) && (point.y == -1))
\r
2373 m_ChangedFileListCtrl.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
2374 m_ChangedFileListCtrl.ClientToScreen(&rect);
\r
2375 point = rect.CenterPoint();
\r
2379 int s = m_LogList.GetSelectionMark();
\r
2382 std::vector<CString> changedpaths;
\r
2383 std::vector<LogChangedPath*> changedlogpaths;
\r
2384 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2386 return; // nothing is selected, get out of here
\r
2388 bool bOneRev = true;
\r
2389 int sel=m_LogList.GetNextSelectedItem(pos);
\r
2390 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel));
\r
2391 GitRev * rev1 = pLogEntry;
\r
2392 GitRev * rev2 = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel+1));
\r
2394 bool bOneRev = true;
\r
2399 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
2402 rev1 = max(rev1,(git_revnum_t)pLogEntry->Rev);
\r
2403 rev2 = min(rev2,(git_revnum_t)pLogEntry->Rev);
\r
2409 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2412 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2413 changedpaths.push_back(m_currentChangedPathList[nItem].GetGitPathString());
\r
2418 // only one revision is selected in the log dialog top pane
\r
2419 // but multiple items could be selected in the changed items list
\r
2422 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2425 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2426 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
2428 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2430 if ((changedlogpath)&&(!changedlogpath->sCopyFromPath.IsEmpty()))
\r
2431 rev2 = changedlogpath->lCopyFromRev;
\r
2434 // if the path was modified but the parent path was 'added with history'
\r
2435 // then we have to use the copy from revision of the parent path
\r
2436 CTGitPath cpath = CTGitPath(changedlogpath->sPath);
\r
2437 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
2439 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
2440 if (p.IsAncestorOf(cpath))
\r
2442 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
2443 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
2448 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
2450 // some items are hidden! So find out which item the user really clicked on
\r
2451 INT_PTR selRealIndex = -1;
\r
2452 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
2454 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
2456 if (selRealIndex == nItem)
\r
2458 selIndex = hiddenindex;
\r
2459 changedlogpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
2464 if (changedlogpath)
\r
2466 changedpaths.push_back(changedlogpath->sPath);
\r
2467 changedlogpaths.push_back(changedlogpath);
\r
2472 //entry is selected, now show the popup menu
\r
2474 if (popup.CreatePopupMenu())
\r
2476 bool bEntryAdded = false;
\r
2477 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2479 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
\r
2481 popup.AppendMenuIcon(CGitLogList::ID_DIFF, IDS_LOG_POPUP_DIFF, IDI_DIFF);
\r
2482 popup.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF, IDS_LOG_POPUP_BLAMEDIFF, IDI_BLAME);
\r
2483 popup.SetDefaultItem(CGitLogList::ID_DIFF, FALSE);
\r
2484 popup.AppendMenuIcon(CGitLogList::ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
2485 bEntryAdded = true;
\r
2487 // if (rev2 == rev1-1)
\r
2490 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2491 popup.AppendMenuIcon(CGitLogList::ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
2492 popup.AppendMenuIcon(CGitLogList::ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
2493 popup.AppendMenuIcon(CGitLogList::ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
2494 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2496 popup.AppendMenuIcon(CGitLogList::ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
2497 popup.AppendMenuIcon(CGitLogList::ID_POPPROPS, IDS_REPOBROWSE_SHOWPROP, IDI_PROPERTIES); // "Show Properties"
\r
2498 popup.AppendMenuIcon(CGitLogList::ID_LOG, IDS_MENULOG, IDI_LOG); // "Show Log"
\r
2499 popup.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS, IDS_LOG_POPUP_GETMERGELOGS, IDI_LOG); // "Show merge log"
\r
2500 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
2501 bEntryAdded = true;
\r
2502 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
2504 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2505 popup.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
2507 if (popup.GetDefaultItem(0,FALSE)==-1)
\r
2508 popup.SetDefaultItem(CGitLogList::ID_OPEN, FALSE);
\r
2511 else if (changedlogpaths.size())
\r
2513 // more than one entry is selected
\r
2514 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE);
\r
2515 bEntryAdded = true;
\r
2520 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2521 bool bOpenWith = false;
\r
2522 bool bMergeLog = false;
\r
2523 m_bCancelled = false;
\r
2527 case CGitLogList::ID_DIFF:
\r
2529 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
2533 case ID_BLAMEDIFF:
\r
2535 DoDiffFromLog(selIndex, rev1, rev2, true, false);
\r
2540 DoDiffFromLog(selIndex, rev1, rev2, false, true);
\r
2543 case ID_REVERTREV:
\r
2545 SetPromptApp(&theApp);
\r
2546 theApp.DoWaitCursor(1);
\r
2548 if (Git::PathIsURL(m_path))
\r
2550 sUrl = m_path.GetGitPathString();
\r
2554 sUrl = GetURLFromPath(m_path);
\r
2555 if (sUrl.IsEmpty())
\r
2557 theApp.DoWaitCursor(-1);
\r
2559 temp.Format(IDS_ERR_NOURLOFFILE, m_path.GetWinPath());
\r
2560 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2562 theApp.DoWaitCursor(-1);
\r
2566 // find the working copy path of the selected item from the URL
\r
2567 m_bCancelled = false;
\r
2568 CString sUrlRoot = GetRepositoryRoot(CTGitPath(sUrl));
\r
2570 CString fileURL = changedpaths[0];
\r
2571 fileURL = sUrlRoot + fileURL.Trim();
\r
2572 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
\r
2573 // sUrl = http://mydomain.com/repos/trunk/folder
\r
2574 CString sUnescapedUrl = CPathUtils::PathUnescape(sUrl);
\r
2575 // find out until which char the urls are identical
\r
2577 while ((i<fileURL.GetLength())&&(i<sUnescapedUrl.GetLength())&&(fileURL[i]==sUnescapedUrl[i]))
\r
2579 int leftcount = m_path.GetWinPathString().GetLength()-(sUnescapedUrl.GetLength()-i);
\r
2580 CString wcPath = m_path.GetWinPathString().Left(leftcount);
\r
2581 wcPath += fileURL.Mid(i);
\r
2582 wcPath.Replace('/', '\\');
\r
2583 CGitProgressDlg dlg;
\r
2584 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
2586 // a deleted path! Since the path isn't there anymore, merge
\r
2587 // won't work. So just do a copy url->wc
\r
2588 dlg.SetCommand(CGitProgressDlg::GitProgress_Copy);
\r
2589 dlg.SetPathList(CTGitPathList(CTGitPath(fileURL)));
\r
2590 dlg.SetUrl(wcPath);
\r
2591 dlg.SetRevision(rev2);
\r
2595 if (!PathFileExists(wcPath))
\r
2597 // seems the path got renamed
\r
2598 // tell the user how to work around this.
\r
2599 CMessageBox::Show(this->m_hWnd, IDS_LOG_REVERTREV_ERROR, IDS_APPNAME, MB_ICONERROR);
\r
2601 theApp.DoWaitCursor(-1);
\r
2604 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
2605 dlg.SetPathList(CTGitPathList(CTGitPath(wcPath)));
\r
2606 dlg.SetUrl(fileURL);
\r
2607 dlg.SetSecondUrl(fileURL);
\r
2608 GitRevRangeArray revarray;
\r
2609 revarray.AddRevRange(rev1, rev2);
\r
2610 dlg.SetRevisionRanges(revarray);
\r
2613 msg.Format(IDS_LOG_REVERT_CONFIRM, (LPCTSTR)wcPath);
\r
2614 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
2618 theApp.DoWaitCursor(-1);
\r
2623 DialogEnableWindow(IDOK, FALSE);
\r
2624 SetPromptApp(&theApp);
\r
2625 theApp.DoWaitCursor(1);
\r
2627 if (Git::PathIsURL(m_path))
\r
2629 filepath = m_path.GetGitPathString();
\r
2633 filepath = GetURLFromPath(m_path);
\r
2634 if (filepath.IsEmpty())
\r
2636 theApp.DoWaitCursor(-1);
\r
2638 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2639 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2640 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2645 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2646 filepath += changedpaths[0];
\r
2649 dlg.m_Path = CTGitPath(filepath);
\r
2652 theApp.DoWaitCursor(-1);
\r
2657 DialogEnableWindow(IDOK, FALSE);
\r
2658 SetPromptApp(&theApp);
\r
2659 theApp.DoWaitCursor(1);
\r
2661 if (Git::PathIsURL(m_path))
\r
2663 filepath = m_path.GetGitPathString();
\r
2667 filepath = GetURLFromPath(m_path);
\r
2668 if (filepath.IsEmpty())
\r
2670 theApp.DoWaitCursor(-1);
\r
2672 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2673 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2674 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2679 m_bCancelled = false;
\r
2680 CString sRoot = GetRepositoryRoot(CTGitPath(filepath));
\r
2681 // if more than one entry is selected, we save them
\r
2682 // one by one into a folder the user has selected
\r
2683 bool bTargetSelected = false;
\r
2684 CTGitPath TargetPath;
\r
2685 if (m_ChangedFileListCtrl.GetSelectedCount() > 1)
\r
2687 CBrowseFolder browseFolder;
\r
2688 browseFolder.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT)));
\r
2689 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
\r
2690 CString strSaveAsDirectory;
\r
2691 if (browseFolder.Show(GetSafeHwnd(), strSaveAsDirectory) == CBrowseFolder::OK)
\r
2693 TargetPath = CTGitPath(strSaveAsDirectory);
\r
2694 bTargetSelected = true;
\r
2699 // Display the Open dialog box.
\r
2700 CString revFilename;
\r
2702 temp = CPathUtils::GetFileNameFromPath(changedpaths[0]);
\r
2703 int rfind = temp.ReverseFind('.');
\r
2705 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)temp.Left(rfind), rev1, (LPCTSTR)temp.Mid(rfind));
\r
2707 revFilename.Format(_T("%s-%ld"), (LPCTSTR)temp, rev1);
\r
2708 bTargetSelected = CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd);
\r
2709 TargetPath.SetFromWin(revFilename);
\r
2711 if (bTargetSelected)
\r
2713 CProgressDlg progDlg;
\r
2714 progDlg.SetTitle(IDS_APPNAME);
\r
2715 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
2716 for (std::vector<LogChangedPath*>::iterator it = changedlogpaths.begin(); it!= changedlogpaths.end(); ++it)
\r
2718 GitRev getrev = ((*it)->action == LOGACTIONS_DELETED) ? rev2 : rev1;
\r
2720 CString sInfoLine;
\r
2721 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)getrev.ToString());
\r
2722 progDlg.SetLine(1, sInfoLine, true);
\r
2723 SetAndClearProgressInfo(&progDlg);
\r
2724 progDlg.ShowModeless(m_hWnd);
\r
2726 CTGitPath tempfile = TargetPath;
\r
2727 if (changedpaths.size() > 1)
\r
2729 // if multiple items are selected, then the TargetPath
\r
2730 // points to a folder and we have to append the filename
\r
2731 // to save to to that folder.
\r
2732 CString sName = (*it)->sPath;
\r
2733 int slashpos = sName.ReverseFind('/');
\r
2734 if (slashpos >= 0)
\r
2735 sName = sName.Mid(slashpos);
\r
2736 tempfile.AppendPathString(sName);
\r
2737 // one problem here:
\r
2738 // a user could have selected multiple items which
\r
2739 // have the same filename but reside in different
\r
2740 // directories, e.g.
\r
2743 // in that case, the second 'file1' will overwrite
\r
2744 // the already saved 'file1'.
\r
2746 // we could maybe find the common root of all selected
\r
2747 // items and then create sub folders to save those files
\r
2749 // But I think we should just leave it that way: to check
\r
2750 // out multiple items at once, the better way is still to
\r
2751 // use the export command from the top pane of the log dialog.
\r
2753 filepath = sRoot + (*it)->sPath;
\r
2754 if (!Cat(CTGitPath(filepath), getrev, getrev, tempfile))
\r
2757 SetAndClearProgressInfo((HWND)NULL);
\r
2758 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2760 theApp.DoWaitCursor(-1);
\r
2765 SetAndClearProgressInfo((HWND)NULL);
\r
2768 theApp.DoWaitCursor(-1);
\r
2775 GitRev getrev = pLogEntry->pArChangedPaths->GetAt(selIndex)->action == LOGACTIONS_DELETED ? rev2 : rev1;
\r
2776 Open(bOpenWith,changedpaths[0],getrev);
\r
2782 if (Git::PathIsURL(m_path))
\r
2784 filepath = m_path.GetGitPathString();
\r
2788 filepath = GetURLFromPath(m_path);
\r
2789 if (filepath.IsEmpty())
\r
2791 theApp.DoWaitCursor(-1);
\r
2793 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2794 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2795 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2800 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2801 filepath += changedpaths[0];
\r
2803 dlg.EndRev = rev1;
\r
2804 if (dlg.DoModal() == IDOK)
\r
2809 tempfile = blame.BlameToTempFile(CTGitPath(filepath), dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
2810 if (!tempfile.IsEmpty())
\r
2812 if (dlg.m_bTextView)
\r
2814 //open the default text editor for the result file
\r
2815 CAppUtils::StartTextViewer(tempfile);
\r
2819 CString sParams = _T("/path:\"") + filepath + _T("\" ");
\r
2820 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(filepath),sParams))
\r
2828 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2833 case ID_GETMERGELOGS:
\r
2838 DialogEnableWindow(IDOK, FALSE);
\r
2839 SetPromptApp(&theApp);
\r
2840 theApp.DoWaitCursor(1);
\r
2842 if (Git::PathIsURL(m_path))
\r
2844 filepath = m_path.GetGitPathString();
\r
2848 filepath = GetURLFromPath(m_path);
\r
2849 if (filepath.IsEmpty())
\r
2851 theApp.DoWaitCursor(-1);
\r
2853 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2854 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2855 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2860 m_bCancelled = false;
\r
2861 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2862 filepath += changedpaths[0];
\r
2863 git_revnum_t logrev = rev1;
\r
2864 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
2866 // if the item got deleted in this revision,
\r
2867 // fetch the log from the previous revision where it
\r
2872 sCmd.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR)filepath, logrev);
\r
2874 sCmd += _T(" /merge");
\r
2875 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
2877 theApp.DoWaitCursor(-1);
\r
2880 case ID_VIEWPATHREV:
\r
2882 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetSelectionMark()));
\r
2883 GitRev rev = pLogEntry->Rev;
\r
2884 CString relurl = changedpaths[0];
\r
2885 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
2886 url.Replace(_T("%REVISION%"), rev.ToString());
\r
2887 url.Replace(_T("%PATH%"), relurl);
\r
2888 relurl = relurl.Mid(relurl.Find('/'));
\r
2889 url.Replace(_T("%PATH1%"), relurl);
\r
2890 if (!url.IsEmpty())
\r
2891 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
2899 } // if (popup.CreatePopupMenu())
\r
2903 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2905 // the date control should not show the "today" button
\r
2906 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
\r
2908 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
2912 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2914 // the date control should not show the "today" button
\r
2915 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
\r
2917 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
2921 void CLogDlg::OnSize(UINT nType, int cx, int cy)
\r
2923 __super::OnSize(nType, cx, cy);
\r
2925 SetSplitterRange();
\r
2928 void CLogDlg::OnRefresh()
\r
2930 //if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
2934 this->m_LogProgress.SetPos(0);
\r
2940 void CLogDlg::OnFind()
\r
2942 if (!m_pFindDialog)
\r
2944 m_pFindDialog = new CFindReplaceDialog();
\r
2945 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
2949 void CLogDlg::OnFocusFilter()
\r
2951 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2954 void CLogDlg::OnEditCopy()
\r
2956 if (GetFocus() == &m_ChangedFileListCtrl)
\r
2957 CopyChangedSelectionToClipBoard();
\r
2959 m_LogList.CopySelectionToClipBoard();
\r
2962 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
\r
2964 // is the URL a relative one?
\r
2965 if (url.Left(2).Compare(_T("^/")) == 0)
\r
2967 // URL is relative to the repository root
\r
2968 CString url1 = m_sRepositoryRoot + url.Mid(1);
\r
2969 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
2970 DWORD len = url.GetLength();
\r
2971 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
\r
2972 return CString(buf, len);
\r
2975 else if (url[0] == '/')
\r
2977 // URL is relative to the server's hostname
\r
2979 // find the server's hostname
\r
2980 int schemepos = m_sRepositoryRoot.Find(_T("//"));
\r
2981 if (schemepos >= 0)
\r
2983 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
\r
2984 CString url1 = sHost + url;
\r
2985 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
2986 DWORD len = url.GetLength();
\r
2987 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
\r
2988 return CString(buf, len);
\r
2996 void CLogDlg::OnEnChangeSearchedit()
\r
2999 if (m_LogList.m_sFilterText.IsEmpty())
\r
3001 CStoreSelection storeselection(this);
\r
3002 // clear the filter, i.e. make all entries appear
\r
3003 theApp.DoWaitCursor(1);
\r
3004 KillTimer(LOGFILTER_TIMER);
\r
3005 FillLogMessageCtrl(false);
\r
3006 m_LogList.StartFilter();
\r
3008 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3009 m_arShownList.RemoveAll();
\r
3010 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3012 if (IsEntryInDateRange(i))
\r
3013 m_arShownList.Add(m_logEntries[i]);
\r
3015 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3016 m_LogList.DeleteAllItems();
\r
3017 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3018 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3019 m_LogList.SetRedraw(false);
\r
3020 ResizeAllListCtrlCols();
\r
3021 m_LogList.SetRedraw(true);
\r
3023 theApp.DoWaitCursor(-1);
\r
3024 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3025 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3026 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3027 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
3030 if (Validate(m_LogList.m_sFilterText))
\r
3031 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3033 KillTimer(LOGFILTER_TIMER);
\r
3037 void CLogDlg::OnBnClickedAllBranch()
\r
3039 this->UpdateData();
\r
3041 if(this->m_bAllBranch)
\r
3042 m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH;
\r
3044 m_LogList.m_ShowMask&=~CGit::LOG_INFO_ALL_BRANCH;
\r
3048 FillLogMessageCtrl(false);
\r
3051 void CLogDlg::OnBnClickedBrowseRef()
\r
3053 CString newRef = CBrowseRefsDlg::PickRef(false,m_LogList.GetStartRef());
\r
3054 if(newRef.IsEmpty())
\r
3057 SetStartRef(newRef);
\r
3058 ((CButton*)GetDlgItem(IDC_LOG_ALLBRANCH))->SetCheck(0);
\r
3060 OnBnClickedAllBranch();
\r
3063 void CLogDlg::ShowStartRef()
\r
3065 //Show ref name on top
\r
3066 if(!::IsWindow(m_hWnd))
\r
3070 GetDlgItem(IDC_STATIC_REF)->SetWindowText(L"<All Branches>");
\r
3074 CString showStartRef = m_LogList.GetStartRef();
\r
3075 if(showStartRef.IsEmpty())
\r
3077 //Ref name is HEAD
\r
3078 g_Git.Run(L"git symbolic-ref HEAD",&showStartRef,CP_UTF8);
\r
3079 showStartRef.Trim(L"\r\n\t ");
\r
3083 if(wcsncmp(showStartRef,L"refs/",5) == 0)
\r
3084 showStartRef = showStartRef.Mid(5);
\r
3085 if(wcsncmp(showStartRef,L"heads/",6) == 0)
\r
3086 showStartRef = showStartRef.Mid(6);
\r
3088 GetDlgItem(IDC_STATIC_REF)->SetWindowText(showStartRef);
\r
3091 void CLogDlg::SetStartRef(const CString& StartRef)
\r
3093 m_LogList.SetStartRef(StartRef);
\r
3100 void CLogDlg::OnBnClickedFirstParent()
\r
3102 this->UpdateData();
\r
3104 if(this->m_bFirstParent)
\r
3105 m_LogList.m_ShowMask|=CGit::LOG_INFO_FIRST_PARENT;
\r
3107 m_LogList.m_ShowMask&=~CGit::LOG_INFO_FIRST_PARENT;
\r
3111 FillLogMessageCtrl(false);
\r
3115 void CLogDlg::OnBnClickShowWholeProject()
\r
3117 this->UpdateData();
\r
3119 if(this->m_bWholeProject)
\r
3121 m_LogList.m_Path.Reset();
\r
3122 SetWindowText(m_sTitle + _T(" - ") + CString(_T("Whole Project")));
\r
3126 m_LogList.m_Path=m_path;
\r
3127 if(!m_path.IsEmpty())
\r
3128 SetWindowText(m_sTitle + _T(" - ") + m_path.GetGitPathString());
\r
3133 FillLogMessageCtrl(false);
\r