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.m_bShowWC = true;
\r
339 m_LogList.FetchLogAsync(this);
\r
341 GetDlgItem(IDC_LOGLIST)->SetFocus();
\r
347 LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM /*lParam*/)
\r
349 int cur=(int)wParam;
\r
351 if( cur == GITLOG_START )
\r
354 temp.LoadString(IDS_PROGRESSWAIT);
\r
356 this->m_LogList.ShowText(temp, true);
\r
358 // We use a progress bar while getting the logs
\r
359 m_LogProgress.SetRange32(0, 100);
\r
360 m_LogProgress.SetPos(0);
\r
362 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
\r
364 //DialogEnableWindow(IDC_GETALL, FALSE);
\r
365 //DialogEnableWindow(IDC_SHOWWHOLEPROJECT, FALSE);
\r
366 //DialogEnableWindow(IDC_LOG_FIRSTPARENT, FALSE);
\r
367 DialogEnableWindow(IDC_STATBUTTON, FALSE);
\r
368 DialogEnableWindow(IDC_REFRESH, FALSE);
\r
369 DialogEnableWindow(IDC_HIDEPATHS,FALSE);
\r
372 }else if( cur == GITLOG_END)
\r
375 //if (!m_bShowedAll)
\r
376 DialogEnableWindow(IDC_SHOWWHOLEPROJECT, TRUE);
\r
378 //DialogEnableWindow(IDC_GETALL, TRUE);
\r
379 DialogEnableWindow(IDC_LOG_FIRSTPARENT, TRUE);
\r
380 DialogEnableWindow(IDC_STATBUTTON, TRUE);
\r
381 DialogEnableWindow(IDC_REFRESH, TRUE);
\r
382 DialogEnableWindow(IDC_HIDEPATHS,TRUE);
\r
384 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
\r
385 GetDlgItem(IDC_PROGRESS)->ShowWindow(FALSE);
\r
386 //CTime time=m_LogList.GetOldestTime();
\r
388 m_LogList.GetTimeRange(begin,end);
\r
389 m_DateFrom.SetTime(&begin);
\r
390 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 CRichEditCtrl * pMsgView = (CRichEditCtrl*)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"));
\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
526 pMsgView->SetSel(-1,-1);
\r
527 CHARFORMAT2 format;
\r
528 SecureZeroMemory(&format, sizeof(CHARFORMAT2));
\r
529 format.cbSize = sizeof(CHARFORMAT2);
\r
530 format.dwMask = CFM_BOLD;
\r
531 format.dwEffects = CFE_BOLD;
\r
532 pMsgView->SendMessage(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format);
\r
534 CString msg=_T("* ");
\r
535 msg+=pLogEntry->m_Subject;
\r
536 pMsgView->ReplaceSel(msg);
\r
538 pMsgView->SetSel(-1,-1);
\r
539 format.dwEffects = 0;
\r
540 pMsgView->SendMessage(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format);
\r
543 msg+=pLogEntry->m_Body;
\r
544 pMsgView->ReplaceSel(msg);
\r
547 pMsgView->GetWindowText(text);
\r
548 // the rich edit control doesn't count the CR char!
\r
549 // to be exact: CRLF is treated as one char.
\r
550 text.Replace(_T("\r"), _T(""));
\r
552 m_ProjectProperties.FindBugID(text, pMsgView);
\r
553 CAppUtils::FormatTextInRichEditControl(pMsgView);
\r
555 int HidePaths=m_cHidePaths.GetState() & 0x0003;
\r
556 CString matchpath=this->m_path.GetGitPathString();
\r
558 for(int i=0;i<pLogEntry->m_Files.GetCount() && (!matchpath.IsEmpty());i++)
\r
560 if( m_bWholeProject )
\r
563 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action &= ~(CTGitPath::LOGACTIONS_HIDE|CTGitPath::LOGACTIONS_GRAY);
\r
565 if(pLogEntry->m_Files[i].GetGitPathString().Left(matchpath.GetLength()) != matchpath)
\r
567 if(HidePaths==BST_CHECKED)
\r
568 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action |= CTGitPath::LOGACTIONS_HIDE;
\r
569 if(HidePaths==BST_INDETERMINATE)
\r
570 ((CTGitPath&)pLogEntry->m_Files[i]).m_Action |= CTGitPath::LOGACTIONS_GRAY;
\r
573 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->m_Files);
\r
574 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;
\r
575 m_ChangedFileListCtrl.Show(SVNSLC_SHOWVERSIONED);
\r
577 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
584 // more than one revision is selected:
\r
585 // the log message view must be emptied
\r
586 // the changed files list contains all the changed paths from all
\r
587 // selected revisions, with 'doubles' removed
\r
588 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
\r
591 // redraw the views
\r
592 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
594 if (m_currentChangedArray)
\r
596 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
\r
597 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
\r
599 else if (m_currentChangedPathList.GetCount())
\r
601 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
\r
602 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
\r
606 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
607 m_ChangedFileListCtrl.Invalidate();
\r
610 // sort according to the settings
\r
611 if (m_nSortColumnPathList > 0)
\r
612 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
614 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
\r
615 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
619 void CLogDlg::OnBnClickedRefresh()
\r
625 void CLogDlg::Refresh (bool /*autoGoOnline*/)
\r
627 m_LogList.Refresh();
\r
628 FillLogMessageCtrl(false);
\r
633 BOOL CLogDlg::Cancel()
\r
635 return m_bCancelled;
\r
638 void CLogDlg::SaveSplitterPos()
\r
642 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
643 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
645 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
646 ScreenToClient(&rectSplitter);
\r
647 regPos1 = rectSplitter.top;
\r
648 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
649 ScreenToClient(&rectSplitter);
\r
650 regPos2 = rectSplitter.top;
\r
654 void CLogDlg::OnCancel()
\r
656 // canceling means stopping the working thread if it's still running.
\r
657 if (this->IsThreadRunning())
\r
659 m_LogList.TerminateThread();
\r
664 __super::OnCancel();
\r
667 CString CLogDlg::MakeShortMessage(const CString& message)
\r
669 bool bFoundShort = true;
\r
670 CString sShortMessage = m_ProjectProperties.GetLogSummary(message);
\r
671 if (sShortMessage.IsEmpty())
\r
673 bFoundShort = false;
\r
674 sShortMessage = message;
\r
676 // Remove newlines and tabs 'cause those are not shown nicely in the list control
\r
677 sShortMessage.Replace(_T("\r"), _T(""));
\r
678 sShortMessage.Replace(_T("\t"), _T(" "));
\r
680 // Suppose the first empty line separates 'summary' from the rest of the message.
\r
681 int found = sShortMessage.Find(_T("\n\n"));
\r
682 // To avoid too short 'short' messages
\r
683 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
\r
684 // only use the empty newline as a separator if it comes after at least 15 chars.
\r
685 if ((!bFoundShort)&&(found >= 15))
\r
687 sShortMessage = sShortMessage.Left(found);
\r
689 sShortMessage.Replace('\n', ' ');
\r
690 return sShortMessage;
\r
693 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
696 if (rev == SVN_INVALID_REVNUM)
\r
702 // this is the callback function which receives the data for every revision we ask the log for
\r
703 // we store this information here one by one.
\r
705 if (m_startrev == -1)
\r
710 m_LogProgress.SetPos(m_limit - m_limitcounter);
\r
712 else if (m_startrev.IsNumber() && m_startrev.IsNumber())
\r
713 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);
\r
714 __time64_t ttime = time/1000000L;
\r
715 if (m_tTo < (DWORD)ttime)
\r
716 m_tTo = (DWORD)ttime;
\r
717 if (m_tFrom > (DWORD)ttime)
\r
718 m_tFrom = (DWORD)ttime;
\r
719 if ((m_lowestRev > rev)||(m_lowestRev < 0))
\r
721 // Add as many characters from the log message to the list control
\r
722 PLOGENTRYDATA pLogItem = new LOGENTRYDATA;
\r
723 pLogItem->bCopies = !!copies;
\r
725 // find out if this item was copied in the revision
\r
726 BOOL copiedself = FALSE;
\r
729 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)
\r
731 LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);
\r
732 if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))
\r
734 // note: this only works if the log is fetched top-to-bottom
\r
735 // but since we do that, it shouldn't be a problem
\r
736 m_sSelfRelativeURL = cpath->sCopyFromPath;
\r
742 pLogItem->bCopiedSelf = copiedself;
\r
743 pLogItem->tmDate = ttime;
\r
744 pLogItem->sAuthor = author;
\r
745 pLogItem->sDate = date;
\r
746 pLogItem->sShortMessage = MakeShortMessage(message);
\r
747 pLogItem->dwFileChanges = filechanges;
\r
748 pLogItem->actions = actions;
\r
749 pLogItem->haschildren = haschildren;
\r
750 pLogItem->childStackDepth = m_childCounter;
\r
751 m_maxChild = max(m_childCounter, m_maxChild);
\r
754 pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();
\r
756 // split multi line log entries and concatenate them
\r
757 // again but this time with \r\n as line separators
\r
758 // so that the edit control recognizes them
\r
761 if (message.GetLength()>0)
\r
763 m_sMessageBuf = message;
\r
764 m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));
\r
765 m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));
\r
766 if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)
\r
767 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);
\r
770 m_sMessageBuf.Empty();
\r
771 pLogItem->sMessage = m_sMessageBuf;
\r
772 pLogItem->Rev = rev;
\r
774 // move-construct path array
\r
776 pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);
\r
777 cpaths->RemoveAll();
\r
779 catch (CException * e)
\r
781 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);
\r
783 m_bCancelled = TRUE;
\r
785 m_logEntries.push_back(pLogItem);
\r
786 m_arShownList.Add(pLogItem);
\r
792 //this is the thread function which calls the subversion function
\r
797 void CLogDlg::CopyChangedSelectionToClipBoard()
\r
800 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
802 return; // nothing is selected, get out of here
\r
806 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
809 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
812 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
813 CTGitPath *path = (CTGitPath*)m_ChangedFileListCtrl.GetItemData(nItem);
\r
815 sPaths += path->GetGitPathString();
\r
816 sPaths += _T("\r\n");
\r
822 // only one revision is selected in the log dialog top pane
\r
823 // but multiple items could be selected in the changed items list
\r
824 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
827 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
828 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
830 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
832 // some items are hidden! So find out which item the user really selected
\r
833 INT_PTR selRealIndex = -1;
\r
834 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
836 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
838 if (selRealIndex == nItem)
\r
840 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);
\r
845 if (changedlogpath)
\r
847 sPaths += changedlogpath->sPath;
\r
848 sPaths += _T("\r\n");
\r
854 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
\r
858 BOOL CLogDlg::IsDiffPossible(LogChangedPath * /*changedpath*/, git_revnum_t rev)
\r
861 CString added, deleted;
\r
862 if (changedpath == NULL)
\r
865 if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))
\r
867 if (changedpath->action == LOGACTIONS_ADDED) // file is added
\r
869 if (changedpath->lCopyFromRev == 0)
\r
870 return FALSE; // but file was not added with history
\r
878 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
880 // we have two separate context menus:
\r
881 // one shown on the log message list control,
\r
882 // the other shown in the changed-files list control
\r
883 int selCount = m_LogList.GetSelectedCount();
\r
884 if (pWnd == &m_LogList)
\r
886 //ShowContextMenuForRevisions(pWnd, point);
\r
888 else if (pWnd == &m_ChangedFileListCtrl)
\r
890 //ShowContextMenuForChangedpaths(pWnd, point);
\r
892 else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
894 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
897 selIndex = m_LogList.GetNextSelectedItem(pos);
\r
898 if ((point.x == -1) && (point.y == -1))
\r
901 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
\r
902 ClientToScreen(&rect);
\r
903 point = rect.CenterPoint();
\r
905 CString sMenuItemText;
\r
907 if (popup.CreatePopupMenu())
\r
909 // add the 'default' entries
\r
910 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
\r
911 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
\r
912 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
\r
913 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
\r
915 //if (selIndex >= 0)
\r
917 // popup.AppendMenu(MF_SEPARATOR);
\r
918 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
\r
919 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
\r
922 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
926 break; // no command selected
\r
929 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
\r
931 case CGitLogList::ID_EDITAUTHOR:
\r
932 EditLogMessage(selIndex);
\r
940 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
943 ASSERT(m_pFindDialog != NULL);
\r
945 if (m_pFindDialog->IsTerminating())
\r
947 // invalidate the handle identifying the dialog box.
\r
948 m_pFindDialog = NULL;
\r
952 if(m_pFindDialog->FindNext())
\r
954 //read data from dialog
\r
955 CString FindText = m_pFindDialog->GetFindString();
\r
956 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
\r
957 bool bFound = false;
\r
959 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
\r
961 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
\r
964 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
\r
968 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
970 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))
\r
975 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
976 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
978 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
979 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))
\r
985 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))
\r
997 if (m_logEntries[i]->sMessage.Find(FindText) >= 0)
\r
1002 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1003 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1004 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1006 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1007 if (cpath->sCopyFromPath.Find(FindText)>=0)
\r
1013 if (cpath->sPath.Find(FindText)>=0)
\r
1023 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1024 CString msg = pLogEntry->sMessage;
\r
1025 msg = msg.MakeLower();
\r
1026 CString find = FindText.MakeLower();
\r
1027 if (msg.Find(find) >= 0)
\r
1032 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1033 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1035 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1036 CString lowerpath = cpath->sCopyFromPath;
\r
1037 lowerpath.MakeLower();
\r
1038 if (lowerpath.Find(find)>=0)
\r
1044 lowerpath = cpath->sPath;
\r
1045 lowerpath.MakeLower();
\r
1046 if (lowerpath.Find(find)>=0)
\r
1055 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
\r
1058 this->m_nSearchIndex = (i+1);
\r
1059 m_LogList.EnsureVisible(i, FALSE);
\r
1060 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);
\r
1061 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1062 m_LogList.SetSelectionMark(i);
\r
1063 FillLogMessageCtrl();
\r
1064 UpdateData(FALSE);
\r
1066 if (m_nSearchIndex >= m_arShownList.GetCount())
\r
1067 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
\r
1069 } // if(m_pFindDialog->FindNext())
\r
1070 UpdateLogInfoLabel();
\r
1075 void CLogDlg::OnOK()
\r
1077 // since the log dialog is also used to select revisions for other
\r
1078 // dialogs, we have to do some work before closing this dialog
\r
1079 if (GetFocus() != GetDlgItem(IDOK))
\r
1080 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
\r
1083 if (this->IsThreadRunning())
\r
1085 m_LogList.TerminateThread();
\r
1088 // check that one and only one row is selected
\r
1089 if (m_LogList.GetSelectedCount() == 1)
\r
1091 // get the selected row
\r
1092 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1093 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
1094 if (selIndex < m_LogList.m_arShownList.GetCount())
\r
1096 // all ok, pick up the revision
\r
1097 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));
\r
1098 // extract the hash
\r
1099 m_sSelectedHash = pLogEntry->m_CommitHash;
\r
1102 UpdateData(FALSE);
\r
1103 SaveSplitterPos();
\r
1107 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
\r
1108 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
\r
1111 CString buttontext;
\r
1112 GetDlgItemText(IDOK, buttontext);
\r
1113 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1114 if (temp.Compare(buttontext) != 0)
\r
1115 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
\r
1116 m_bCancelled = TRUE;
\r
1117 m_selectedRevs.Clear();
\r
1118 m_selectedRevsOneRange.Clear();
\r
1119 if (m_pNotifyWindow)
\r
1121 int selIndex = m_LogList.GetSelectionMark();
\r
1122 if (selIndex >= 0)
\r
1124 PLOGENTRYDATA pLogEntry = NULL;
\r
1125 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1126 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1127 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1128 git_revnum_t lowerRev = pLogEntry->Rev;
\r
1129 git_revnum_t higherRev = lowerRev;
\r
1132 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1133 git_revnum_t rev = pLogEntry->Rev;
\r
1134 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1135 if (lowerRev > rev)
\r
1137 if (higherRev < rev)
\r
1140 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
\r
1142 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
\r
1144 BOOL bSentMessage = FALSE;
\r
1145 if (m_LogList.GetSelectedCount() == 1)
\r
1147 // if only one revision is selected, check if the path/url with which the dialog was started
\r
1148 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
\r
1149 // if it was copied, use the copy from revision as lowerRev
\r
1150 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
\r
1152 CString sUrl = m_path.GetGitPathString();
\r
1153 if (!m_path.IsUrl())
\r
1155 sUrl = GetURLFromPath(m_path);
\r
1157 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
\r
1158 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
\r
1160 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);
\r
1163 if (sUrl.Compare(pData->sPath) == 0)
\r
1165 if (!pData->sCopyFromPath.IsEmpty())
\r
1167 lowerRev = pData->lCopyFromRev;
\r
1168 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
\r
1169 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
\r
1170 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1171 bSentMessage = TRUE;
\r
1178 if ( !bSentMessage )
\r
1180 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
\r
1181 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
\r
1182 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1183 if (m_selectedRevsOneRange.GetCount())
\r
1184 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
\r
1189 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
1190 reg = m_btnShow.GetCurrentEntry();
\r
1191 SaveSplitterPos();
\r
1195 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1197 // a double click on an entry in the changed-files list has happened
\r
1200 DiffSelectedFile();
\r
1203 void CLogDlg::DiffSelectedFile()
\r
1206 if (m_bThreadRunning)
\r
1208 UpdateLogInfoLabel();
\r
1209 INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
1212 if (m_ChangedFileListCtrl.GetSelectedCount() == 0)
\r
1214 // find out if there's an entry selected in the log list
\r
1215 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1216 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1217 git_revnum_t rev1 = pLogEntry->Rev;
\r
1218 git_revnum_t rev2 = rev1;
\r
1223 // there's at least a second entry selected in the log list: several revisions selected!
\r
1224 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1227 rev1 = max(rev1,(long)pLogEntry->Rev);
\r
1228 rev2 = min(rev2,(long)pLogEntry->Rev);
\r
1232 // now we have both revisions selected in the log list, so we can do a diff of the selected
\r
1233 // entry in the changed files list with these two revisions.
\r
1234 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1239 // nothing or only one revision selected in the log list
\r
1240 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1242 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1244 // some items are hidden! So find out which item the user really clicked on
\r
1245 INT_PTR selRealIndex = -1;
\r
1246 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1248 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1250 if (selRealIndex == selIndex)
\r
1252 selIndex = hiddenindex;
\r
1253 changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1259 if (IsDiffPossible(changedpath, rev1))
\r
1261 // diffs with renamed files are possible
\r
1262 if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))
\r
1263 rev2 = changedpath->lCopyFromRev;
\r
1266 // if the path was modified but the parent path was 'added with history'
\r
1267 // then we have to use the copy from revision of the parent path
\r
1268 CTGitPath cpath = CTGitPath(changedpath->sPath);
\r
1269 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
1271 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
1272 if (p.IsAncestorOf(cpath))
\r
1274 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
1275 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
1279 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1283 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1284 CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1286 // deleted files must be opened from the revision before the deletion
\r
1287 if (changedpath->action == LOGACTIONS_DELETED)
\r
1289 m_bCancelled = false;
\r
1291 CProgressDlg progDlg;
\r
1292 progDlg.SetTitle(IDS_APPNAME);
\r
1293 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1294 CString sInfoLine;
\r
1295 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());
\r
1296 progDlg.SetLine(1, sInfoLine, true);
\r
1297 SetAndClearProgressInfo(&progDlg);
\r
1298 progDlg.ShowModeless(m_hWnd);
\r
1300 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))
\r
1302 m_bCancelled = false;
\r
1303 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))
\r
1306 SetAndClearProgressInfo((HWND)NULL);
\r
1307 CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1312 SetAndClearProgressInfo((HWND)NULL);
\r
1314 CString sName1, sName2;
\r
1315 sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);
\r
1316 sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);
\r
1317 CAppUtils::DiffFlags flags;
\r
1318 flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1319 if (changedpath->action == LOGACTIONS_DELETED)
\r
1320 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);
\r
1322 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);
\r
1329 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)
\r
1331 DialogEnableWindow(IDOK, FALSE);
\r
1332 // SetPromptApp(&theApp);
\r
1333 theApp.DoWaitCursor(1);
\r
1336 GetTempPath(temppath);
\r
1339 file1.Format(_T("%s%s_%s%s"),
\r
1341 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1342 rev1->m_CommitHash.Left(6),
\r
1343 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1346 file2.Format(_T("%s\\%s_%s%s"),
\r
1348 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1349 rev2->m_CommitHash.Left(6),
\r
1350 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1354 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1355 g_Git.RunLogFile(cmd,file1);
\r
1356 cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1357 g_Git.RunLogFile(cmd,file2);
\r
1359 CAppUtils::DiffFlags flags;
\r
1360 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);
\r
1363 //get the filename
\r
1365 if (Git::PathIsURL(m_path))
\r
1367 filepath = m_path.GetGitPathString();
\r
1371 filepath = GetURLFromPath(m_path);
\r
1372 if (filepath.IsEmpty())
\r
1374 theApp.DoWaitCursor(-1);
\r
1376 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1377 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1378 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1380 theApp.DoWaitCursor(-11);
\r
1384 m_bCancelled = FALSE;
\r
1385 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1387 CString firstfile, secondfile;
\r
1388 if (m_LogList.GetSelectedCount()==1)
\r
1390 int s = m_LogList.GetSelectionMark();
\r
1391 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));
\r
1392 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1393 firstfile = changedpath->sPath;
\r
1394 secondfile = firstfile;
\r
1395 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?
\r
1397 secondfile = changedpath->sCopyFromPath;
\r
1398 rev2 = changedpath->lCopyFromRev;
\r
1403 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();
\r
1404 secondfile = firstfile;
\r
1407 firstfile = filepath + firstfile.Trim();
\r
1408 secondfile = filepath + secondfile.Trim();
\r
1410 GitDiff diff(this, this->m_hWnd, true);
\r
1411 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1412 diff.SetHEADPeg(m_LogRevision);
\r
1415 if (PromptShown())
\r
1416 diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);
\r
1418 CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);
\r
1422 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))
\r
1424 if (firstfile.Compare(secondfile)==0)
\r
1426 git_revnum_t baseRev = 0;
\r
1427 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);
\r
1434 theApp.DoWaitCursor(-1);
\r
1438 BOOL CLogDlg::Open(bool /*bOpenWith*/,CString changedpath, git_revnum_t rev)
\r
1441 DialogEnableWindow(IDOK, FALSE);
\r
1442 SetPromptApp(&theApp);
\r
1443 theApp.DoWaitCursor(1);
\r
1445 if (Git::PathIsURL(m_path))
\r
1447 filepath = m_path.GetGitPathString();
\r
1451 filepath = GetURLFromPath(m_path);
\r
1452 if (filepath.IsEmpty())
\r
1454 theApp.DoWaitCursor(-1);
\r
1456 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1457 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1458 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1463 m_bCancelled = false;
\r
1464 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1465 filepath += changedpath;
\r
1467 CProgressDlg progDlg;
\r
1468 progDlg.SetTitle(IDS_APPNAME);
\r
1469 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1470 CString sInfoLine;
\r
1471 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());
\r
1472 progDlg.SetLine(1, sInfoLine, true);
\r
1473 SetAndClearProgressInfo(&progDlg);
\r
1474 progDlg.ShowModeless(m_hWnd);
\r
1476 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);
\r
1477 m_bCancelled = false;
\r
1478 if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))
\r
1481 SetAndClearProgressInfo((HWND)NULL);
\r
1482 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1484 theApp.DoWaitCursor(-1);
\r
1488 SetAndClearProgressInfo((HWND)NULL);
\r
1489 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1492 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1493 if (ret <= HINSTANCE_ERROR)
\r
1498 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1499 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1500 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1503 theApp.DoWaitCursor(-1);
\r
1508 void CLogDlg::EditAuthor(const CLogDataVector& /*logs*/)
\r
1513 if (logs.size() == 0)
\r
1515 DialogEnableWindow(IDOK, FALSE);
\r
1516 SetPromptApp(&theApp);
\r
1517 theApp.DoWaitCursor(1);
\r
1518 if (Git::PathIsURL(m_path))
\r
1519 url = m_path.GetGitPathString();
\r
1522 url = GetURLFromPath(m_path);
\r
1524 name = Git_PROP_REVISION_AUTHOR;
\r
1526 CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);
\r
1527 CString sOldValue = value;
\r
1528 value.Replace(_T("\n"), _T("\r\n"));
\r
1529 CInputDlg dlg(this);
\r
1530 dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);
\r
1531 dlg.m_sInputText = value;
\r
1532 dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);
\r
1533 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1534 dlg.m_bUseLogWidth = false;
\r
1535 if (dlg.DoModal() == IDOK)
\r
1537 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1539 LogCache::CCachedLogInfo* toUpdate
\r
1540 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1542 CProgressDlg progDlg;
\r
1543 progDlg.SetTitle(IDS_APPNAME);
\r
1544 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
\r
1545 progDlg.SetTime(true);
\r
1546 progDlg.SetShowProgressBar(true);
\r
1547 progDlg.ShowModeless(m_hWnd);
\r
1548 for (DWORD i=0; i<logs.size(); ++i)
\r
1550 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))
\r
1553 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1559 logs[i]->sAuthor = dlg.m_sInputText;
\r
1560 m_LogList.Invalidate();
\r
1562 // update the log cache
\r
1564 if (toUpdate != NULL)
\r
1566 // log caching is active
\r
1568 LogCache::CCachedLogInfo newInfo;
\r
1569 newInfo.Insert ( logs[i]->Rev
\r
1570 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)
\r
1573 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);
\r
1575 toUpdate->Update (newInfo);
\r
1578 progDlg.SetProgress64(i, logs.size());
\r
1582 theApp.DoWaitCursor(-1);
\r
1587 void CLogDlg::EditLogMessage(int /*index*/)
\r
1592 DialogEnableWindow(IDOK, FALSE);
\r
1593 SetPromptApp(&theApp);
\r
1594 theApp.DoWaitCursor(1);
\r
1595 if (Git::PathIsURL(m_path))
\r
1596 url = m_path.GetGitPathString();
\r
1599 url = GetURLFromPath(m_path);
\r
1601 name = Git_PROP_REVISION_LOG;
\r
1603 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
1604 m_bCancelled = FALSE;
\r
1605 CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);
\r
1606 CString sOldValue = value;
\r
1607 value.Replace(_T("\n"), _T("\r\n"));
\r
1608 CInputDlg dlg(this);
\r
1609 dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);
\r
1610 dlg.m_sInputText = value;
\r
1611 dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);
\r
1612 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
1613 dlg.m_bUseLogWidth = true;
\r
1614 if (dlg.DoModal() == IDOK)
\r
1616 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
1617 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))
\r
1619 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1623 pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);
\r
1624 // split multi line log entries and concatenate them
\r
1625 // again but this time with \r\n as line separators
\r
1626 // so that the edit control recognizes them
\r
1627 if (dlg.m_sInputText.GetLength()>0)
\r
1629 m_sMessageBuf = dlg.m_sInputText;
\r
1630 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));
\r
1631 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));
\r
1632 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)
\r
1633 dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);
\r
1636 dlg.m_sInputText.Empty();
\r
1637 pLogEntry->sMessage = dlg.m_sInputText;
\r
1638 pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);
\r
1639 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
1640 pMsgView->SetWindowText(_T(" "));
\r
1641 pMsgView->SetWindowText(dlg.m_sInputText);
\r
1642 m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);
\r
1643 m_LogList.Invalidate();
\r
1645 // update the log cache
\r
1647 LogCache::CCachedLogInfo* toUpdate
\r
1648 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
1649 if (toUpdate != NULL)
\r
1651 // log caching is active
\r
1653 LogCache::CCachedLogInfo newInfo;
\r
1654 newInfo.Insert ( pLogEntry->Rev
\r
1656 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)
\r
1658 , LogCache::CRevisionInfoContainer::HAS_COMMENT);
\r
1660 toUpdate->Update (newInfo);
\r
1664 theApp.DoWaitCursor(-1);
\r
1669 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
\r
1671 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1672 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1673 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1675 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1677 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1679 m_LogList.DiffSelectedRevWithPrevious();
\r
1683 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1685 DiffSelectedFile();
\r
1689 if (m_hAccel && !bSkipAccelerator)
\r
1691 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1696 if(::IsWindow(m_tooltips.m_hWnd))
\r
1697 m_tooltips.RelayEvent(pMsg);
\r
1698 return __super::PreTranslateMessage(pMsg);
\r
1702 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
1704 //if (this->IsThreadRunning())
\r
1705 if(m_LogList.m_bNoDispUpdates)
\r
1707 // only show the wait cursor over the list control
\r
1709 ((pWnd == GetDlgItem(IDC_LOGLIST))||
\r
1710 (pWnd == GetDlgItem(IDC_MSGVIEW))||
\r
1711 (pWnd == GetDlgItem(IDC_LOGMSG))))
\r
1713 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
1718 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1719 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1721 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
1723 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1726 void CLogDlg::OnBnClickedHelp()
\r
1731 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1733 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
1735 //if (this->IsThreadRunning())
\r
1736 if(m_LogList.m_bNoDispUpdates)
\r
1738 if (pNMLV->iItem >= 0)
\r
1740 m_nSearchIndex = pNMLV->iItem;
\r
1741 if (pNMLV->iSubItem != 0)
\r
1743 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount()))
\r
1745 // remove the selected state
\r
1746 if (pNMLV->uChanged & LVIF_STATE)
\r
1748 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
\r
1749 FillLogMessageCtrl();
\r
1750 UpdateData(FALSE);
\r
1751 UpdateLogInfoLabel();
\r
1755 if (pNMLV->uChanged & LVIF_STATE)
\r
1757 FillLogMessageCtrl();
\r
1758 UpdateData(FALSE);
\r
1763 FillLogMessageCtrl();
\r
1764 UpdateData(FALSE);
\r
1767 UpdateLogInfoLabel();
\r
1770 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
\r
1772 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
\r
1773 if (pEnLink->msg == WM_LBUTTONUP)
\r
1776 GetDlgItemText(IDC_MSGVIEW, msg);
\r
1777 msg.Replace(_T("\r\n"), _T("\n"));
\r
1778 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
\r
1779 if (!::PathIsURL(url))
\r
1781 url = m_ProjectProperties.GetBugIDUrl(url);
\r
1782 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1784 if (!url.IsEmpty())
\r
1785 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1793 class CCommitPointer
\r
1796 CCommitPointer():m_cont(NULL){}
\r
1797 CCommitPointer(const CCommitPointer& P_Right)
\r
1803 CCommitPointer& operator = (const CCommitPointer& P_Right)
\r
1807 (*m_cont->m_parDates)[m_place] = P_Right.GetDate();
\r
1808 (*m_cont->m_parFileChanges)[m_place] = P_Right.GetChanges();
\r
1809 (*m_cont->m_parAuthors)[m_place] = P_Right.GetAuthor();
\r
1813 m_Date = P_Right.GetDate();
\r
1814 m_Changes = P_Right.GetChanges();
\r
1815 m_csAuthor = P_Right.GetAuthor();
\r
1820 void Clone(const CCommitPointer& P_Right)
\r
1822 m_cont = P_Right.m_cont;
\r
1823 m_place = P_Right.m_place;
\r
1824 m_Date = P_Right.m_Date;
\r
1825 m_Changes = P_Right.m_Changes;
\r
1826 m_csAuthor = P_Right.m_csAuthor;
\r
1829 DWORD GetDate() const {return IsPointer() ? (*m_cont->m_parDates)[m_place] : m_Date;}
\r
1830 DWORD GetChanges() const {return IsPointer() ? (*m_cont->m_parFileChanges)[m_place] : m_Changes;}
\r
1831 CString GetAuthor() const {return IsPointer() ? (*m_cont->m_parAuthors)[m_place] : m_csAuthor;}
\r
1833 bool IsPointer() const {return m_cont != NULL;}
\r
1835 CDateSorter* m_cont;
\r
1841 CString m_csAuthor;
\r
1844 class iterator : public std::iterator<std::random_access_iterator_tag, CCommitPointer>
\r
1847 CCommitPointer m_ptr;
\r
1850 iterator(const iterator& P_Right){*this = P_Right;}
\r
1851 iterator& operator=(const iterator& P_Right)
\r
1853 m_ptr.Clone(P_Right.m_ptr);
\r
1857 CCommitPointer& operator*(){return m_ptr;}
\r
1858 CCommitPointer* operator->(){return &m_ptr;}
\r
1859 const CCommitPointer& operator*()const{return m_ptr;}
\r
1860 const CCommitPointer* operator->()const{return &m_ptr;}
\r
1862 iterator& operator+=(size_t P_iOffset){m_ptr.m_place += P_iOffset;return *this;}
\r
1863 iterator& operator-=(size_t P_iOffset){m_ptr.m_place -= P_iOffset;return *this;}
\r
1864 iterator operator+(size_t P_iOffset)const{iterator it(*this); it += P_iOffset;return it;}
\r
1865 iterator operator-(size_t P_iOffset)const{iterator it(*this); it -= P_iOffset;return it;}
\r
1867 iterator& operator++(){++m_ptr.m_place;return *this;}
\r
1868 iterator& operator--(){--m_ptr.m_place;return *this;}
\r
1869 iterator operator++(int){iterator it(*this);++*this;return it;}
\r
1870 iterator operator--(int){iterator it(*this);--*this;return it;}
\r
1872 size_t operator-(const iterator& P_itRight)const{return m_ptr.m_place - P_itRight->m_place;}
\r
1874 bool operator<(const iterator& P_itRight)const{return m_ptr.m_place < P_itRight->m_place;}
\r
1875 bool operator!=(const iterator& P_itRight)const{return m_ptr.m_place != P_itRight->m_place;}
\r
1876 bool operator==(const iterator& P_itRight)const{return m_ptr.m_place == P_itRight->m_place;}
\r
1877 bool operator>(const iterator& P_itRight)const{return m_ptr.m_place > P_itRight->m_place;}
\r
1883 it->m_cont = this;
\r
1889 it->m_place = m_parDates->GetCount();
\r
1890 it->m_cont = this;
\r
1894 CDWordArray * m_parDates;
\r
1895 CDWordArray * m_parFileChanges;
\r
1896 CStringArray * m_parAuthors;
\r
1899 class CDateSorterLess
\r
1902 bool operator () (const CDateSorter::CCommitPointer& P_Left, const CDateSorter::CCommitPointer& P_Right) const
\r
1904 return P_Left.GetDate() > P_Right.GetDate(); //Last date first
\r
1911 void CLogDlg::OnBnClickedStatbutton()
\r
1914 if (this->IsThreadRunning())
\r
1916 if (m_LogList.m_arShownList.IsEmpty())
\r
1917 return; // nothing is shown, so no statistics.
\r
1918 // the statistics dialog expects the log entries to be sorted by date
\r
1919 SortByColumn(3, false);
\r
1920 CPtrArray shownlist;
\r
1921 m_LogList.RecalculateShownList(&shownlist);
\r
1922 // create arrays which are aware of the current filter
\r
1923 CStringArray m_arAuthorsFiltered;
\r
1924 CDWordArray m_arDatesFiltered;
\r
1925 CDWordArray m_arFileChangesFiltered;
\r
1926 for (INT_PTR i=0; i<shownlist.GetCount(); ++i)
\r
1928 GitRev* pLogEntry = reinterpret_cast<GitRev*>(shownlist.GetAt(i));
\r
1929 CString strAuthor = pLogEntry->m_AuthorName;
\r
1930 if ( strAuthor.IsEmpty() )
\r
1932 strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);
\r
1934 m_arAuthorsFiltered.Add(strAuthor);
\r
1935 m_arDatesFiltered.Add(pLogEntry->m_AuthorDate.GetTime());
\r
1936 m_arFileChangesFiltered.Add(pLogEntry->m_Files.GetCount());
\r
1939 CDateSorter W_Sorter;
\r
1940 W_Sorter.m_parAuthors = &m_arAuthorsFiltered;
\r
1941 W_Sorter.m_parDates = &m_arDatesFiltered;
\r
1942 W_Sorter.m_parFileChanges = &m_arFileChangesFiltered;
\r
1943 std::sort(W_Sorter.begin(), W_Sorter.end(), CDateSorterLess());
\r
1945 CStatGraphDlg dlg;
\r
1946 dlg.m_parAuthors = &m_arAuthorsFiltered;
\r
1947 dlg.m_parDates = &m_arDatesFiltered;
\r
1948 dlg.m_parFileChanges = &m_arFileChangesFiltered;
\r
1949 dlg.m_path = m_path;
\r
1951 // restore the previous sorting
\r
1952 SortByColumn(m_nSortColumn, m_bAscending);
\r
1953 OnTimer(LOGFILTER_TIMER);
\r
1957 void CLogDlg::DoSizeV1(int delta)
\r
1960 RemoveAnchor(IDC_LOGLIST);
\r
1961 RemoveAnchor(IDC_SPLITTERTOP);
\r
1962 RemoveAnchor(IDC_MSGVIEW);
\r
1963 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
1964 RemoveAnchor(IDC_LOGMSG);
\r
1965 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
\r
1966 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
\r
1967 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
1968 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
1969 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
1970 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1971 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1974 SetSplitterRange();
\r
1975 m_LogList.Invalidate();
\r
1976 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
1980 void CLogDlg::DoSizeV2(int delta)
\r
1983 RemoveAnchor(IDC_LOGLIST);
\r
1984 RemoveAnchor(IDC_SPLITTERTOP);
\r
1985 RemoveAnchor(IDC_MSGVIEW);
\r
1986 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
1987 RemoveAnchor(IDC_LOGMSG);
\r
1988 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
\r
1989 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
\r
1990 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
1991 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
1992 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
1993 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1994 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
1997 SetSplitterRange();
\r
1998 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
1999 m_ChangedFileListCtrl.Invalidate();
\r
2003 void CLogDlg::AdjustMinSize()
\r
2005 // adjust the minimum size of the dialog to prevent the resizing from
\r
2006 // moving the list control too far down.
\r
2007 CRect rcChgListView;
\r
2008 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
\r
2010 m_LogList.GetClientRect(rcLogList);
\r
2012 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
\r
2013 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
\r
2014 +rcChgListView.Height()+rcLogList.Height()+60));
\r
2017 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
2019 switch (message) {
\r
2021 if (wParam == IDC_SPLITTERTOP)
\r
2023 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2024 DoSizeV1(pHdr->delta);
\r
2026 else if (wParam == IDC_SPLITTERBOTTOM)
\r
2028 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2029 DoSizeV2(pHdr->delta);
\r
2034 return CResizableDialog::DefWindowProc(message, wParam, lParam);
\r
2037 void CLogDlg::SetSplitterRange()
\r
2039 if ((m_LogList)&&(m_ChangedFileListCtrl))
\r
2042 m_LogList.GetWindowRect(rcTop);
\r
2043 ScreenToClient(rcTop);
\r
2045 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
\r
2046 ScreenToClient(rcMiddle);
\r
2047 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
\r
2049 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
\r
2050 ScreenToClient(rcBottom);
\r
2051 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
\r
2055 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
\r
2057 // FIXME: x64 version would get this function called with unexpected parameters.
\r
2061 RECT * rect = (LPRECT)lParam;
\r
2064 point = CPoint(rect->left, rect->bottom);
\r
2065 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
\r
2067 if (popup.CreatePopupMenu())
\r
2069 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2070 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);
\r
2072 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2074 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2075 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
\r
2076 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2077 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
\r
2078 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2079 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
\r
2080 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2081 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
\r
2082 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
\r
2083 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
\r
2085 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2087 temp.LoadString(IDS_LOG_FILTER_REGEX);
\r
2088 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
\r
2091 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2092 if (selection != 0)
\r
2095 if (selection == LOGFILTER_REGEX)
\r
2097 m_bFilterWithRegex = !m_bFilterWithRegex;
\r
2098 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
2099 b = m_bFilterWithRegex;
\r
2100 CheckRegexpTooltip();
\r
2104 m_LogList.m_nSelectedFilter = selection;
\r
2105 SetFilterCueText();
\r
2107 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2113 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
2116 KillTimer(LOGFILTER_TIMER);
\r
2118 m_LogList.m_sFilterText.Empty();
\r
2119 UpdateData(FALSE);
\r
2120 theApp.DoWaitCursor(1);
\r
2121 CStoreSelection storeselection(this);
\r
2122 FillLogMessageCtrl(false);
\r
2124 m_LogList.RemoveFilter();
\r
2127 m_LogList.GetTimeRange(begin,end);
\r
2128 m_DateFrom.SetTime(&begin);
\r
2129 m_DateTo.SetTime(&end);
\r
2131 theApp.DoWaitCursor(-1);
\r
2132 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2133 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2134 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2135 UpdateLogInfoLabel();
\r
2141 void CLogDlg::SetFilterCueText()
\r
2144 switch (m_LogList.m_nSelectedFilter)
\r
2146 case LOGFILTER_ALL:
\r
2147 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2149 case LOGFILTER_MESSAGES:
\r
2150 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2152 case LOGFILTER_PATHS:
\r
2153 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2155 case LOGFILTER_AUTHORS:
\r
2156 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2158 case LOGFILTER_REVS:
\r
2159 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2162 // to make the cue banner text appear more to the right of the edit control
\r
2163 temp = _T(" ")+temp;
\r
2164 m_cFilter.SetCueBanner(temp);
\r
2167 bool CLogDlg::Validate(LPCTSTR string)
\r
2169 if (!m_bFilterWithRegex)
\r
2172 return m_LogList.ValidateRegexp(string, pat, false);
\r
2176 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
\r
2178 if (nIDEvent == LOGFILTER_TIMER)
\r
2180 if (this->IsThreadRunning())
\r
2182 // thread still running! So just restart the timer.
\r
2183 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2186 CWnd * focusWnd = GetFocus();
\r
2187 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
\r
2188 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
\r
2189 if (m_LogList.m_sFilterText.IsEmpty())
\r
2191 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2192 // do not return here!
\r
2193 // we also need to run the filter if the filter text is empty:
\r
2194 // 1. to clear an existing filter
\r
2195 // 2. to rebuild the m_arShownList after sorting
\r
2197 theApp.DoWaitCursor(1);
\r
2198 CStoreSelection storeselection(this);
\r
2199 KillTimer(LOGFILTER_TIMER);
\r
2200 FillLogMessageCtrl(false);
\r
2202 // now start filter the log list
\r
2203 m_LogList.StartFilter();
\r
2205 if ( m_LogList.GetItemCount()==1 )
\r
2207 m_LogList.SetSelectionMark(0);
\r
2208 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
2210 theApp.DoWaitCursor(-1);
\r
2211 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2212 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2213 if (bSetFocusToFilterControl)
\r
2214 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2215 UpdateLogInfoLabel();
\r
2216 } // if (nIDEvent == LOGFILTER_TIMER)
\r
2217 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
2218 __super::OnTimer(nIDEvent);
\r
2221 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2224 m_DateTo.GetTime(_time);
\r
2227 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
\r
2228 if (time.GetTime() != m_LogList.m_To.GetTime())
\r
2230 m_LogList.m_To = (DWORD)time.GetTime();
\r
2231 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2234 catch (CAtlException)
\r
2241 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
2244 m_DateFrom.GetTime(_time);
\r
2247 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
\r
2248 if (time.GetTime() != m_LogList.m_From.GetTime())
\r
2250 m_LogList.m_From = (DWORD)time.GetTime();
\r
2251 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
2254 catch (CAtlException)
\r
2263 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
\r
2265 CTGitPathList pathList;
\r
2268 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2270 m_sRepositoryRoot = GetRepositoryRoot(m_path);
\r
2272 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
2275 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2280 int nextpos = m_LogList.GetNextSelectedItem(pos);
\r
2281 if (nextpos >= m_arShownList.GetCount())
\r
2283 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));
\r
2284 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
2285 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
2287 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2288 if (cpath == NULL)
\r
2291 if (!bRelativePaths)
\r
2292 path.SetFromGit(m_sRepositoryRoot);
\r
2293 path.AppendPathString(cpath->sPath);
\r
2294 if ((!bUseFilter)||
\r
2295 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
\r
2296 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
\r
2297 pathList.AddPath(path);
\r
2302 pathList.RemoveDuplicates();
\r
2307 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
\r
2310 switch(nSortColumn)
\r
2312 case 0: // Revision
\r
2315 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
\r
2317 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
\r
2323 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
\r
2325 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
\r
2331 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
\r
2333 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
\r
2339 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
\r
2341 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
\r
2344 case 4: // Message or bug id
\r
2345 if (m_bShowBugtraqColumn)
\r
2348 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
\r
2350 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
\r
2353 // fall through here
\r
2354 case 5: // Message
\r
2357 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
\r
2359 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
\r
2369 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
\r
2371 if (this->IsThreadRunning())
\r
2372 return; //no sorting while the arrays are filled
\r
2374 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2375 const int nColumn = pNMLV->iSubItem;
\r
2376 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
\r
2377 m_nSortColumn = nColumn;
\r
2378 SortByColumn(m_nSortColumn, m_bAscending);
\r
2379 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
\r
2380 SortShownListArray();
\r
2381 m_LogList.Invalidate();
\r
2382 UpdateLogInfoLabel();
\r
2387 void CLogDlg::SortShownListArray()
\r
2389 // make sure the shown list still matches the filter after sorting.
\r
2390 OnTimer(LOGFILTER_TIMER);
\r
2391 // clear the selection states
\r
2392 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2395 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
\r
2397 m_LogList.SetSelectionMark(-1);
\r
2400 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
\r
2402 if (control == NULL)
\r
2404 // set the sort arrow
\r
2405 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
\r
2406 HDITEM HeaderItem = {0};
\r
2407 HeaderItem.mask = HDI_FORMAT;
\r
2408 for (int i=0; i<pHeader->GetItemCount(); ++i)
\r
2410 pHeader->GetItem(i, &HeaderItem);
\r
2411 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
\r
2412 pHeader->SetItem(i, &HeaderItem);
\r
2416 pHeader->GetItem(nColumn, &HeaderItem);
\r
2417 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
\r
2418 pHeader->SetItem(nColumn, &HeaderItem);
\r
2421 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
\r
2424 if (this->IsThreadRunning())
\r
2425 return; //no sorting while the arrays are filled
\r
2426 if (m_currentChangedArray == NULL)
\r
2428 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2429 const int nColumn = pNMLV->iSubItem;
\r
2430 m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;
\r
2431 m_nSortColumnPathList = nColumn;
\r
2432 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
\r
2434 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
2435 m_ChangedFileListCtrl.Invalidate();
\r
2440 int CLogDlg::m_nSortColumnPathList = 0;
\r
2441 bool CLogDlg::m_bAscendingPathList = false;
\r
2443 int CLogDlg::SortCompare(const void * /*pElem1*/, const void * /*pElem2*/)
\r
2446 LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);
\r
2447 LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);
\r
2449 if (m_bAscendingPathList)
\r
2450 std::swap (cpath1, cpath2);
\r
2453 switch (m_nSortColumnPathList)
\r
2456 cmp = cpath2->GetAction().Compare(cpath1->GetAction());
\r
2461 cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);
\r
2465 case 2: // copy from path
\r
2466 cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);
\r
2470 case 3: // copy from revision
\r
2471 return cpath2->lCopyFromRev > cpath1->lCopyFromRev;
\r
2477 void CLogDlg::OnBnClickedHidepaths()
\r
2479 FillLogMessageCtrl();
\r
2480 m_ChangedFileListCtrl.Invalidate();
\r
2485 void CLogDlg::OnBnClickedCheckStoponcopy()
\r
2488 if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
2491 // ignore old fetch limits when switching
\r
2492 // between copy-following and stop-on-copy
\r
2493 // (otherwise stop-on-copy will limit what
\r
2494 // we see immediately after switching to
\r
2495 // copy-following)
\r
2499 // now, restart the query
\r
2505 void CLogDlg::UpdateLogInfoLabel()
\r
2508 git_revnum_t rev1 ;
\r
2509 git_revnum_t rev2 ;
\r
2510 long selectedrevs = 0;
\r
2511 int count =m_LogList.m_arShownList.GetCount();
\r
2514 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(0)))->m_CommitHash;
\r
2515 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
\r
2516 rev2 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;
\r
2517 selectedrevs = m_LogList.GetSelectedCount();
\r
2520 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
2521 m_sLogInfo = sTemp;
\r
2523 UpdateData(FALSE);
\r
2527 void CLogDlg::ShowContextMenuForChangedpaths(CWnd* /*pWnd*/, CPoint point)
\r
2530 int selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
2531 if ((point.x == -1) && (point.y == -1))
\r
2534 m_ChangedFileListCtrl.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
2535 m_ChangedFileListCtrl.ClientToScreen(&rect);
\r
2536 point = rect.CenterPoint();
\r
2540 int s = m_LogList.GetSelectionMark();
\r
2543 std::vector<CString> changedpaths;
\r
2544 std::vector<LogChangedPath*> changedlogpaths;
\r
2545 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
2547 return; // nothing is selected, get out of here
\r
2549 bool bOneRev = true;
\r
2550 int sel=m_LogList.GetNextSelectedItem(pos);
\r
2551 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel));
\r
2552 GitRev * rev1 = pLogEntry;
\r
2553 GitRev * rev2 = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(sel+1));
\r
2555 bool bOneRev = true;
\r
2560 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
2563 rev1 = max(rev1,(git_revnum_t)pLogEntry->Rev);
\r
2564 rev2 = min(rev2,(git_revnum_t)pLogEntry->Rev);
\r
2570 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2573 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2574 changedpaths.push_back(m_currentChangedPathList[nItem].GetGitPathString());
\r
2579 // only one revision is selected in the log dialog top pane
\r
2580 // but multiple items could be selected in the changed items list
\r
2583 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
2586 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
2587 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
2589 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2591 if ((changedlogpath)&&(!changedlogpath->sCopyFromPath.IsEmpty()))
\r
2592 rev2 = changedlogpath->lCopyFromRev;
\r
2595 // if the path was modified but the parent path was 'added with history'
\r
2596 // then we have to use the copy from revision of the parent path
\r
2597 CTGitPath cpath = CTGitPath(changedlogpath->sPath);
\r
2598 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
2600 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
2601 if (p.IsAncestorOf(cpath))
\r
2603 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
2604 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
2609 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
2611 // some items are hidden! So find out which item the user really clicked on
\r
2612 INT_PTR selRealIndex = -1;
\r
2613 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
2615 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
2617 if (selRealIndex == nItem)
\r
2619 selIndex = hiddenindex;
\r
2620 changedlogpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
2625 if (changedlogpath)
\r
2627 changedpaths.push_back(changedlogpath->sPath);
\r
2628 changedlogpaths.push_back(changedlogpath);
\r
2633 //entry is selected, now show the popup menu
\r
2635 if (popup.CreatePopupMenu())
\r
2637 bool bEntryAdded = false;
\r
2638 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
2640 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
\r
2642 popup.AppendMenuIcon(CGitLogList::ID_DIFF, IDS_LOG_POPUP_DIFF, IDI_DIFF);
\r
2643 popup.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF, IDS_LOG_POPUP_BLAMEDIFF, IDI_BLAME);
\r
2644 popup.SetDefaultItem(CGitLogList::ID_DIFF, FALSE);
\r
2645 popup.AppendMenuIcon(CGitLogList::ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
2646 bEntryAdded = true;
\r
2648 // if (rev2 == rev1-1)
\r
2651 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2652 popup.AppendMenuIcon(CGitLogList::ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
2653 popup.AppendMenuIcon(CGitLogList::ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
2654 popup.AppendMenuIcon(CGitLogList::ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
2655 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2657 popup.AppendMenuIcon(CGitLogList::ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
2658 popup.AppendMenuIcon(CGitLogList::ID_POPPROPS, IDS_REPOBROWSE_SHOWPROP, IDI_PROPERTIES); // "Show Properties"
\r
2659 popup.AppendMenuIcon(CGitLogList::ID_LOG, IDS_MENULOG, IDI_LOG); // "Show Log"
\r
2660 popup.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS, IDS_LOG_POPUP_GETMERGELOGS, IDI_LOG); // "Show merge log"
\r
2661 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
2662 bEntryAdded = true;
\r
2663 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
2665 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2666 popup.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
2668 if (popup.GetDefaultItem(0,FALSE)==-1)
\r
2669 popup.SetDefaultItem(CGitLogList::ID_OPEN, FALSE);
\r
2672 else if (changedlogpaths.size())
\r
2674 // more than one entry is selected
\r
2675 popup.AppendMenuIcon(CGitLogList::ID_SAVEAS, IDS_LOG_POPUP_SAVE);
\r
2676 bEntryAdded = true;
\r
2681 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2682 bool bOpenWith = false;
\r
2683 bool bMergeLog = false;
\r
2684 m_bCancelled = false;
\r
2688 case CGitLogList::ID_DIFF:
\r
2690 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
2694 case ID_BLAMEDIFF:
\r
2696 DoDiffFromLog(selIndex, rev1, rev2, true, false);
\r
2701 DoDiffFromLog(selIndex, rev1, rev2, false, true);
\r
2704 case ID_REVERTREV:
\r
2706 SetPromptApp(&theApp);
\r
2707 theApp.DoWaitCursor(1);
\r
2709 if (Git::PathIsURL(m_path))
\r
2711 sUrl = m_path.GetGitPathString();
\r
2715 sUrl = GetURLFromPath(m_path);
\r
2716 if (sUrl.IsEmpty())
\r
2718 theApp.DoWaitCursor(-1);
\r
2720 temp.Format(IDS_ERR_NOURLOFFILE, m_path.GetWinPath());
\r
2721 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2723 theApp.DoWaitCursor(-1);
\r
2727 // find the working copy path of the selected item from the URL
\r
2728 m_bCancelled = false;
\r
2729 CString sUrlRoot = GetRepositoryRoot(CTGitPath(sUrl));
\r
2731 CString fileURL = changedpaths[0];
\r
2732 fileURL = sUrlRoot + fileURL.Trim();
\r
2733 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
\r
2734 // sUrl = http://mydomain.com/repos/trunk/folder
\r
2735 CString sUnescapedUrl = CPathUtils::PathUnescape(sUrl);
\r
2736 // find out until which char the urls are identical
\r
2738 while ((i<fileURL.GetLength())&&(i<sUnescapedUrl.GetLength())&&(fileURL[i]==sUnescapedUrl[i]))
\r
2740 int leftcount = m_path.GetWinPathString().GetLength()-(sUnescapedUrl.GetLength()-i);
\r
2741 CString wcPath = m_path.GetWinPathString().Left(leftcount);
\r
2742 wcPath += fileURL.Mid(i);
\r
2743 wcPath.Replace('/', '\\');
\r
2744 CGitProgressDlg dlg;
\r
2745 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
2747 // a deleted path! Since the path isn't there anymore, merge
\r
2748 // won't work. So just do a copy url->wc
\r
2749 dlg.SetCommand(CGitProgressDlg::GitProgress_Copy);
\r
2750 dlg.SetPathList(CTGitPathList(CTGitPath(fileURL)));
\r
2751 dlg.SetUrl(wcPath);
\r
2752 dlg.SetRevision(rev2);
\r
2756 if (!PathFileExists(wcPath))
\r
2758 // seems the path got renamed
\r
2759 // tell the user how to work around this.
\r
2760 CMessageBox::Show(this->m_hWnd, IDS_LOG_REVERTREV_ERROR, IDS_APPNAME, MB_ICONERROR);
\r
2762 theApp.DoWaitCursor(-1);
\r
2765 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
2766 dlg.SetPathList(CTGitPathList(CTGitPath(wcPath)));
\r
2767 dlg.SetUrl(fileURL);
\r
2768 dlg.SetSecondUrl(fileURL);
\r
2769 GitRevRangeArray revarray;
\r
2770 revarray.AddRevRange(rev1, rev2);
\r
2771 dlg.SetRevisionRanges(revarray);
\r
2774 msg.Format(IDS_LOG_REVERT_CONFIRM, (LPCTSTR)wcPath);
\r
2775 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
2779 theApp.DoWaitCursor(-1);
\r
2784 DialogEnableWindow(IDOK, FALSE);
\r
2785 SetPromptApp(&theApp);
\r
2786 theApp.DoWaitCursor(1);
\r
2788 if (Git::PathIsURL(m_path))
\r
2790 filepath = m_path.GetGitPathString();
\r
2794 filepath = GetURLFromPath(m_path);
\r
2795 if (filepath.IsEmpty())
\r
2797 theApp.DoWaitCursor(-1);
\r
2799 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2800 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2801 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2806 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2807 filepath += changedpaths[0];
\r
2810 dlg.m_Path = CTGitPath(filepath);
\r
2813 theApp.DoWaitCursor(-1);
\r
2818 DialogEnableWindow(IDOK, FALSE);
\r
2819 SetPromptApp(&theApp);
\r
2820 theApp.DoWaitCursor(1);
\r
2822 if (Git::PathIsURL(m_path))
\r
2824 filepath = m_path.GetGitPathString();
\r
2828 filepath = GetURLFromPath(m_path);
\r
2829 if (filepath.IsEmpty())
\r
2831 theApp.DoWaitCursor(-1);
\r
2833 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2834 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2835 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2840 m_bCancelled = false;
\r
2841 CString sRoot = GetRepositoryRoot(CTGitPath(filepath));
\r
2842 // if more than one entry is selected, we save them
\r
2843 // one by one into a folder the user has selected
\r
2844 bool bTargetSelected = false;
\r
2845 CTGitPath TargetPath;
\r
2846 if (m_ChangedFileListCtrl.GetSelectedCount() > 1)
\r
2848 CBrowseFolder browseFolder;
\r
2849 browseFolder.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT)));
\r
2850 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
\r
2851 CString strSaveAsDirectory;
\r
2852 if (browseFolder.Show(GetSafeHwnd(), strSaveAsDirectory) == CBrowseFolder::OK)
\r
2854 TargetPath = CTGitPath(strSaveAsDirectory);
\r
2855 bTargetSelected = true;
\r
2860 // Display the Open dialog box.
\r
2861 CString revFilename;
\r
2863 temp = CPathUtils::GetFileNameFromPath(changedpaths[0]);
\r
2864 int rfind = temp.ReverseFind('.');
\r
2866 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)temp.Left(rfind), rev1, (LPCTSTR)temp.Mid(rfind));
\r
2868 revFilename.Format(_T("%s-%ld"), (LPCTSTR)temp, rev1);
\r
2869 bTargetSelected = CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd);
\r
2870 TargetPath.SetFromWin(revFilename);
\r
2872 if (bTargetSelected)
\r
2874 CProgressDlg progDlg;
\r
2875 progDlg.SetTitle(IDS_APPNAME);
\r
2876 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
2877 for (std::vector<LogChangedPath*>::iterator it = changedlogpaths.begin(); it!= changedlogpaths.end(); ++it)
\r
2879 GitRev getrev = ((*it)->action == LOGACTIONS_DELETED) ? rev2 : rev1;
\r
2881 CString sInfoLine;
\r
2882 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)getrev.ToString());
\r
2883 progDlg.SetLine(1, sInfoLine, true);
\r
2884 SetAndClearProgressInfo(&progDlg);
\r
2885 progDlg.ShowModeless(m_hWnd);
\r
2887 CTGitPath tempfile = TargetPath;
\r
2888 if (changedpaths.size() > 1)
\r
2890 // if multiple items are selected, then the TargetPath
\r
2891 // points to a folder and we have to append the filename
\r
2892 // to save to to that folder.
\r
2893 CString sName = (*it)->sPath;
\r
2894 int slashpos = sName.ReverseFind('/');
\r
2895 if (slashpos >= 0)
\r
2896 sName = sName.Mid(slashpos);
\r
2897 tempfile.AppendPathString(sName);
\r
2898 // one problem here:
\r
2899 // a user could have selected multiple items which
\r
2900 // have the same filename but reside in different
\r
2901 // directories, e.g.
\r
2904 // in that case, the second 'file1' will overwrite
\r
2905 // the already saved 'file1'.
\r
2907 // we could maybe find the common root of all selected
\r
2908 // items and then create sub folders to save those files
\r
2910 // But I think we should just leave it that way: to check
\r
2911 // out multiple items at once, the better way is still to
\r
2912 // use the export command from the top pane of the log dialog.
\r
2914 filepath = sRoot + (*it)->sPath;
\r
2915 if (!Cat(CTGitPath(filepath), getrev, getrev, tempfile))
\r
2918 SetAndClearProgressInfo((HWND)NULL);
\r
2919 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2921 theApp.DoWaitCursor(-1);
\r
2926 SetAndClearProgressInfo((HWND)NULL);
\r
2929 theApp.DoWaitCursor(-1);
\r
2936 GitRev getrev = pLogEntry->pArChangedPaths->GetAt(selIndex)->action == LOGACTIONS_DELETED ? rev2 : rev1;
\r
2937 Open(bOpenWith,changedpaths[0],getrev);
\r
2943 if (Git::PathIsURL(m_path))
\r
2945 filepath = m_path.GetGitPathString();
\r
2949 filepath = GetURLFromPath(m_path);
\r
2950 if (filepath.IsEmpty())
\r
2952 theApp.DoWaitCursor(-1);
\r
2954 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2955 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2956 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2961 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2962 filepath += changedpaths[0];
\r
2964 dlg.EndRev = rev1;
\r
2965 if (dlg.DoModal() == IDOK)
\r
2970 tempfile = blame.BlameToTempFile(CTGitPath(filepath), dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
2971 if (!tempfile.IsEmpty())
\r
2973 if (dlg.m_bTextView)
\r
2975 //open the default text editor for the result file
\r
2976 CAppUtils::StartTextViewer(tempfile);
\r
2980 CString sParams = _T("/path:\"") + filepath + _T("\" ");
\r
2981 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(filepath),sParams))
\r
2989 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2994 case ID_GETMERGELOGS:
\r
2999 DialogEnableWindow(IDOK, FALSE);
\r
3000 SetPromptApp(&theApp);
\r
3001 theApp.DoWaitCursor(1);
\r
3003 if (Git::PathIsURL(m_path))
\r
3005 filepath = m_path.GetGitPathString();
\r
3009 filepath = GetURLFromPath(m_path);
\r
3010 if (filepath.IsEmpty())
\r
3012 theApp.DoWaitCursor(-1);
\r
3014 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
3015 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
3016 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
3021 m_bCancelled = false;
\r
3022 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
3023 filepath += changedpaths[0];
\r
3024 git_revnum_t logrev = rev1;
\r
3025 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
3027 // if the item got deleted in this revision,
\r
3028 // fetch the log from the previous revision where it
\r
3033 sCmd.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR)filepath, logrev);
\r
3035 sCmd += _T(" /merge");
\r
3036 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
3038 theApp.DoWaitCursor(-1);
\r
3041 case ID_VIEWPATHREV:
\r
3043 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetSelectionMark()));
\r
3044 GitRev rev = pLogEntry->Rev;
\r
3045 CString relurl = changedpaths[0];
\r
3046 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
3047 url.Replace(_T("%REVISION%"), rev.ToString());
\r
3048 url.Replace(_T("%PATH%"), relurl);
\r
3049 relurl = relurl.Mid(relurl.Find('/'));
\r
3050 url.Replace(_T("%PATH1%"), relurl);
\r
3051 if (!url.IsEmpty())
\r
3052 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
3060 } // if (popup.CreatePopupMenu())
\r
3064 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3066 // the date control should not show the "today" button
\r
3067 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
\r
3069 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
3073 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3075 // the date control should not show the "today" button
\r
3076 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
\r
3078 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
3082 void CLogDlg::OnSize(UINT nType, int cx, int cy)
\r
3084 __super::OnSize(nType, cx, cy);
\r
3086 SetSplitterRange();
\r
3089 void CLogDlg::OnRefresh()
\r
3091 //if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
3095 this->m_LogProgress.SetPos(0);
\r
3101 void CLogDlg::OnFind()
\r
3103 if (!m_pFindDialog)
\r
3105 m_pFindDialog = new CFindReplaceDialog();
\r
3106 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
3110 void CLogDlg::OnFocusFilter()
\r
3112 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3115 void CLogDlg::OnEditCopy()
\r
3117 if (GetFocus() == &m_ChangedFileListCtrl)
\r
3118 CopyChangedSelectionToClipBoard();
\r
3120 m_LogList.CopySelectionToClipBoard();
\r
3123 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
\r
3125 // is the URL a relative one?
\r
3126 if (url.Left(2).Compare(_T("^/")) == 0)
\r
3128 // URL is relative to the repository root
\r
3129 CString url1 = m_sRepositoryRoot + url.Mid(1);
\r
3130 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
3131 DWORD len = url.GetLength();
\r
3132 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
\r
3133 return CString(buf, len);
\r
3136 else if (url[0] == '/')
\r
3138 // URL is relative to the server's hostname
\r
3140 // find the server's hostname
\r
3141 int schemepos = m_sRepositoryRoot.Find(_T("//"));
\r
3142 if (schemepos >= 0)
\r
3144 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
\r
3145 CString url1 = sHost + url;
\r
3146 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
3147 DWORD len = url.GetLength();
\r
3148 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
\r
3149 return CString(buf, len);
\r
3157 void CLogDlg::OnEnChangeSearchedit()
\r
3160 if (m_LogList.m_sFilterText.IsEmpty())
\r
3162 CStoreSelection storeselection(this);
\r
3163 // clear the filter, i.e. make all entries appear
\r
3164 theApp.DoWaitCursor(1);
\r
3165 KillTimer(LOGFILTER_TIMER);
\r
3166 FillLogMessageCtrl(false);
\r
3167 m_LogList.StartFilter();
\r
3169 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3170 m_arShownList.RemoveAll();
\r
3171 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3173 if (IsEntryInDateRange(i))
\r
3174 m_arShownList.Add(m_logEntries[i]);
\r
3176 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3177 m_LogList.DeleteAllItems();
\r
3178 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3179 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3180 m_LogList.SetRedraw(false);
\r
3181 ResizeAllListCtrlCols();
\r
3182 m_LogList.SetRedraw(true);
\r
3184 theApp.DoWaitCursor(-1);
\r
3185 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3186 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3187 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3188 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
\r
3191 if (Validate(m_LogList.m_sFilterText))
\r
3192 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3194 KillTimer(LOGFILTER_TIMER);
\r
3198 void CLogDlg::OnBnClickedAllBranch()
\r
3200 this->UpdateData();
\r
3202 if(this->m_bAllBranch)
\r
3203 m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH;
\r
3205 m_LogList.m_ShowMask&=~CGit::LOG_INFO_ALL_BRANCH;
\r
3209 FillLogMessageCtrl(false);
\r
3212 void CLogDlg::OnBnClickedBrowseRef()
\r
3214 CString newRef = CBrowseRefsDlg::PickRef(false,m_LogList.GetStartRef());
\r
3215 if(newRef.IsEmpty())
\r
3218 SetStartRef(newRef);
\r
3219 ((CButton*)GetDlgItem(IDC_LOG_ALLBRANCH))->SetCheck(0);
\r
3221 OnBnClickedAllBranch();
\r
3224 void CLogDlg::ShowStartRef()
\r
3226 //Show ref name on top
\r
3227 if(!::IsWindow(m_hWnd))
\r
3231 m_staticRef.SetWindowText(L"<All Branches>");
\r
3232 m_staticRef.Invalidate(TRUE);
\r
3236 CString showStartRef = m_LogList.GetStartRef();
\r
3237 if(showStartRef.IsEmpty())
\r
3239 //Ref name is HEAD
\r
3240 if( g_Git.Run(L"git symbolic-ref HEAD",&showStartRef,CP_UTF8) )
\r
3241 showStartRef = _T("<No branch>");
\r
3242 showStartRef.Trim(L"\r\n\t ");
\r
3246 if(wcsncmp(showStartRef,L"refs/",5) == 0)
\r
3247 showStartRef = showStartRef.Mid(5);
\r
3248 if(wcsncmp(showStartRef,L"heads/",6) == 0)
\r
3249 showStartRef = showStartRef.Mid(6);
\r
3251 m_staticRef.SetWindowText(showStartRef);
\r
3252 m_staticRef.Invalidate(TRUE);
\r
3255 void CLogDlg::SetStartRef(const CString& StartRef)
\r
3257 m_LogList.SetStartRef(StartRef);
\r
3264 void CLogDlg::OnBnClickedFirstParent()
\r
3266 this->UpdateData();
\r
3268 if(this->m_bFirstParent)
\r
3269 m_LogList.m_ShowMask|=CGit::LOG_INFO_FIRST_PARENT;
\r
3271 m_LogList.m_ShowMask&=~CGit::LOG_INFO_FIRST_PARENT;
\r
3275 FillLogMessageCtrl(false);
\r
3279 void CLogDlg::OnBnClickShowWholeProject()
\r
3281 this->UpdateData();
\r
3283 if(this->m_bWholeProject)
\r
3285 m_LogList.m_Path.Reset();
\r
3286 SetWindowText(m_sTitle + _T(" - ") + CString(_T("Whole Project")));
\r
3290 m_LogList.m_Path=m_path;
\r
3291 if(!m_path.IsEmpty())
\r
3292 SetWindowText(m_sTitle + _T(" - ") + m_path.GetGitPathString());
\r
3297 FillLogMessageCtrl(false);
\r