1 // TortoiseGit - a Windows shell extension for easy version control
2 // Copyright (C) 2003-2008 - TortoiseGit
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License for more details.
12 // You should have received a copy of the GNU General Public License
13 // along with this program; if not, write to the Free Software Foundation,
14 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #include "TortoiseProc.h"
21 #include "SVNProgressDlg.h"
22 #include "ProgressDlg.h"
23 //#include "RepositoryBrowser.h"
24 //#include "CopyDlg.h"
25 #include "StatGraphDlg.h"
27 #include "MessageBox.h"
30 #include "PathUtils.h"
31 #include "StringUtils.h"
32 #include "UnicodeUtils.h"
34 //#include "GitInfo.h"
35 //#include "GitDiff.h"
37 //#include "RevisionRangeDlg.h"
38 //#include "BrowseFolder.h"
39 //#include "BlameDlg.h"
41 //#include "GitHelpers.h"
42 #include "GitStatus.h"
43 //#include "LogDlgHelper.h"
44 //#include "CachedLogInfo.h"
45 //#include "RepositoryInfo.h"
46 //#include "EditPropertiesDlg.h"
47 #include "FileDiffDlg.h"
48 #include "BrowseRefsDlg.h"
51 IMPLEMENT_DYNAMIC(CLogDlg
, CResizableStandAloneDialog
)
52 CLogDlg::CLogDlg(CWnd
* pParent
/*=NULL*/)
53 : CResizableStandAloneDialog(CLogDlg::IDD
, pParent
)
56 , m_currentChangedArray(NULL
)
61 , m_bSelectionMustBeContinuous(false)
62 , m_bShowBugtraqColumn(false)
68 , m_pNotifyWindow(NULL
)
75 , m_bIncludeMerges(FALSE
)
78 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
81 str
=g_Git
.m_CurrentDir
;
82 str
.Replace(_T(":"),_T("_"));
83 str
=CString(_T("Software\\TortoiseGit\\LogDialog\\AllBranch\\"))+str
;
85 m_regbAllBranch
=CRegDWORD(str
,FALSE
);
87 m_bAllBranch
=m_regbAllBranch
;
90 m_bWholeProject
=FALSE
;
96 m_regbAllBranch
=m_bAllBranch
;
98 m_CurrentFilteredChangedArray
.RemoveAll();
102 void CLogDlg::DoDataExchange(CDataExchange
* pDX
)
104 CResizableStandAloneDialog::DoDataExchange(pDX
);
105 DDX_Control(pDX
, IDC_LOGLIST
, m_LogList
);
106 DDX_Control(pDX
, IDC_LOGMSG
, m_ChangedFileListCtrl
);
107 DDX_Control(pDX
, IDC_PROGRESS
, m_LogProgress
);
108 DDX_Control(pDX
, IDC_SPLITTERTOP
, m_wndSplitter1
);
109 DDX_Control(pDX
, IDC_SPLITTERBOTTOM
, m_wndSplitter2
);
110 DDX_Text(pDX
, IDC_SEARCHEDIT
, m_LogList
.m_sFilterText
);
111 DDX_Control(pDX
, IDC_DATEFROM
, m_DateFrom
);
112 DDX_Control(pDX
, IDC_DATETO
, m_DateTo
);
113 DDX_Control(pDX
, IDC_HIDEPATHS
, m_cHidePaths
);
114 DDX_Text(pDX
, IDC_LOGINFO
, m_sLogInfo
);
115 DDX_Check(pDX
, IDC_LOG_FIRSTPARENT
, m_bFirstParent
);
116 DDX_Check(pDX
, IDC_LOG_ALLBRANCH
,m_bAllBranch
);
117 DDX_Check(pDX
, IDC_SHOWWHOLEPROJECT
,m_bWholeProject
);
118 DDX_Control(pDX
, IDC_SEARCHEDIT
, m_cFilter
);
119 DDX_Control(pDX
, IDC_STATIC_REF
, m_staticRef
);
122 BEGIN_MESSAGE_MAP(CLogDlg
, CResizableStandAloneDialog
)
123 //ON_BN_CLICKED(IDC_GETALL, OnBnClickedGetall)
124 //ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)
127 ON_BN_CLICKED(IDHELP
, OnBnClickedHelp
)
128 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_LOGLIST
, OnLvnItemchangedLoglist
)
129 ON_NOTIFY(EN_LINK
, IDC_MSGVIEW
, OnEnLinkMsgview
)
130 ON_BN_CLICKED(IDC_STATBUTTON
, OnBnClickedStatbutton
)
133 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED
, OnClickedInfoIcon
)
134 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED
, OnClickedCancelFilter
)
136 ON_MESSAGE(MSG_LOAD_PERCENTAGE
,OnLogListLoading
)
138 ON_EN_CHANGE(IDC_SEARCHEDIT
, OnEnChangeSearchedit
)
140 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATETO
, OnDtnDatetimechangeDateto
)
141 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATEFROM
, OnDtnDatetimechangeDatefrom
)
142 ON_BN_CLICKED(IDC_SHOWWHOLEPROJECT
, OnBnClickShowWholeProject
)
143 //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
144 //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
145 ON_NOTIFY(LVN_COLUMNCLICK
,IDC_LOGLIST
, OnLvnColumnclick
)
146 //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
147 ON_BN_CLICKED(IDC_HIDEPATHS
, OnBnClickedHidepaths
)
148 ON_BN_CLICKED(IDC_LOG_ALLBRANCH
,OnBnClickedAllBranch
)
150 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATEFROM
, &CLogDlg::OnDtnDropdownDatefrom
)
151 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATETO
, &CLogDlg::OnDtnDropdownDateto
)
153 ON_BN_CLICKED(IDC_LOG_FIRSTPARENT
, &CLogDlg::OnBnClickedFirstParent
)
154 ON_BN_CLICKED(IDC_REFRESH
, &CLogDlg::OnBnClickedRefresh
)
155 // ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CLogDlg::OnBnClickedBrowseRef)
156 ON_STN_CLICKED(IDC_STATIC_REF
, &CLogDlg::OnBnClickedBrowseRef
)
157 ON_COMMAND(ID_LOGDLG_REFRESH
,&CLogDlg::OnRefresh
)
158 ON_COMMAND(ID_LOGDLG_FIND
,&CLogDlg::OnFind
)
159 ON_COMMAND(ID_LOGDLG_FOCUSFILTER
,&CLogDlg::OnFocusFilter
)
160 ON_COMMAND(ID_EDIT_COPY
, &CLogDlg::OnEditCopy
)
163 void CLogDlg::SetParams(const CTGitPath
& path
, CString pegrev
, CString startrev
, CString endrev
, int limit
/* = FALSE */)
167 this->m_LogList
.m_startrev
= startrev
;
168 m_LogRevision
= startrev
;
169 this->m_LogList
.m_endrev
= endrev
;
170 m_hasWC
= !path
.IsUrl();
172 if (::IsWindow(m_hWnd
))
176 BOOL
CLogDlg::OnInitDialog()
179 CResizableStandAloneDialog::OnInitDialog();
181 m_hAccel
= LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG
));
184 // use the state of the "stop on copy/rename" option from the last time
187 // set the font to use in the log message view, configured in the settings dialog
188 CAppUtils::CreateFontForLogs(m_logFont
);
189 GetDlgItem(IDC_MSGVIEW
)->SetFont(&m_logFont
);
190 // automatically detect URLs in the log message and turn them into links
191 GetDlgItem(IDC_MSGVIEW
)->SendMessage(EM_AUTOURLDETECT
, TRUE
, NULL
);
192 // make the log message rich edit control send a message when the mouse pointer is over a link
193 GetDlgItem(IDC_MSGVIEW
)->SendMessage(EM_SETEVENTMASK
, NULL
, ENM_LINK
);
194 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
196 // the "hide unrelated paths" checkbox should be indeterminate
197 m_cHidePaths
.SetCheck(BST_INDETERMINATE
);
200 // if there is a working copy, load the project properties
201 // to get information about the bugtraq: integration
203 m_ProjectProperties
.ReadProps(m_path
);
205 // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set
206 if ((!m_ProjectProperties
.sUrl
.IsEmpty())||(!m_ProjectProperties
.sCheckRe
.IsEmpty()))
207 m_bShowBugtraqColumn
= true;
209 //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
210 //theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
212 // set up the columns
213 m_LogList
.DeleteAllItems();
214 m_LogList
.InsertGitColumn();
216 m_ChangedFileListCtrl
.Init(SVNSLC_COLEXT
| SVNSLC_COLSTATUS
|SVNSLC_COLADD
|SVNSLC_COLDEL
, _T("LogDlg"),(SVNSLC_POPALL
^ (SVNSLC_POPCOMMIT
)),false);
218 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
221 m_sMessageBuf
.Preallocate(100000);
223 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
226 m_tooltips
.Create(this);
227 CheckRegexpTooltip();
231 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
232 m_cFilter
.SetCancelBitmaps(IDI_CANCELNORMAL
, IDI_CANCELPRESSED
);
233 m_cFilter
.SetInfoIcon(IDI_LOGFILTER
);
234 m_cFilter
.SetValidator(this);
236 AdjustControlSize(IDC_HIDEPATHS
);
237 AdjustControlSize(IDC_LOG_FIRSTPARENT
);
238 AdjustControlSize(IDC_LOG_ALLBRANCH
);
240 GetClientRect(m_DlgOrigRect
);
241 m_LogList
.GetClientRect(m_LogListOrigRect
);
242 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(m_MsgViewOrigRect
);
243 m_ChangedFileListCtrl
.GetClientRect(m_ChgOrigRect
);
245 m_DateFrom
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
246 m_DateTo
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
248 m_staticRef
.SetURL(CString());
251 AddAnchor(IDC_STATIC_REF
, TOP_LEFT
);
252 //AddAnchor(IDC_BUTTON_BROWSE_REF, TOP_LEFT);
253 AddAnchor(IDC_FROMLABEL
, TOP_LEFT
);
254 AddAnchor(IDC_DATEFROM
, TOP_LEFT
);
255 AddAnchor(IDC_TOLABEL
, TOP_LEFT
);
256 AddAnchor(IDC_DATETO
, TOP_LEFT
);
259 AddAnchor(IDC_SEARCHEDIT
, TOP_LEFT
, TOP_RIGHT
);
261 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
262 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
263 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
264 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
265 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
267 AddAnchor(IDC_LOGINFO
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
268 AddAnchor(IDC_HIDEPATHS
, BOTTOM_LEFT
);
269 AddAnchor(IDC_LOG_ALLBRANCH
,BOTTOM_LEFT
);
270 AddAnchor(IDC_LOG_FIRSTPARENT
, BOTTOM_LEFT
);
271 //AddAnchor(IDC_GETALL, BOTTOM_LEFT);
272 AddAnchor(IDC_SHOWWHOLEPROJECT
, BOTTOM_LEFT
);
273 AddAnchor(IDC_REFRESH
, BOTTOM_LEFT
);
274 AddAnchor(IDC_STATBUTTON
, BOTTOM_RIGHT
);
275 AddAnchor(IDC_PROGRESS
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
276 AddAnchor(IDOK
, BOTTOM_RIGHT
);
277 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
278 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
280 if(this->m_bAllBranch
)
281 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_ALL_BRANCH
;
283 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_ALL_BRANCH
;
285 // SetPromptParentWindow(m_hWnd);
288 CenterWindow(CWnd::FromHandle(hWndExplorer
));
289 EnableSaveRestore(_T("LogDlg"));
291 DWORD yPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
292 DWORD yPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
293 RECT rcDlg
, rcLogList
, rcChgMsg
;
294 GetClientRect(&rcDlg
);
295 m_LogList
.GetWindowRect(&rcLogList
);
296 ScreenToClient(&rcLogList
);
297 m_ChangedFileListCtrl
.GetWindowRect(&rcChgMsg
);
298 ScreenToClient(&rcChgMsg
);
302 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
303 ScreenToClient(&rectSplitter
);
304 int delta
= yPos1
- rectSplitter
.top
;
306 if ((rcLogList
.bottom
+ delta
> rcLogList
.top
)&&(rcLogList
.bottom
+ delta
< rcChgMsg
.bottom
- 30))
308 m_wndSplitter1
.SetWindowPos(NULL
, 0, yPos1
, 0, 0, SWP_NOSIZE
);
315 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
316 ScreenToClient(&rectSplitter
);
317 int delta
= yPos2
- rectSplitter
.top
;
319 if ((rcChgMsg
.top
+ delta
< rcChgMsg
.bottom
)&&(rcChgMsg
.top
+ delta
> rcLogList
.top
+ 30))
321 m_wndSplitter2
.SetWindowPos(NULL
, 0, yPos2
, 0, 0, SWP_NOSIZE
);
329 // the dialog is used to select revisions
330 // enable the OK button if appropriate
335 // the dialog is used to just view log messages
336 // hide the OK button and set text on Cancel button to OK
337 GetDlgItemText(IDOK
, temp
);
338 SetDlgItemText(IDCANCEL
, temp
);
339 GetDlgItem(IDOK
)->ShowWindow(SW_HIDE
);
342 m_mergedRevs
.clear();
344 // first start a thread to obtain the log messages without
345 // blocking the dialog
347 //m_tFrom = (DWORD)-1;
349 m_LogList
.m_Path
=m_path
;
350 m_LogList
.m_bShowWC
= true;
351 m_LogList
.FetchLogAsync(this);
353 GetDlgItem(IDC_LOGLIST
)->SetFocus();
359 LRESULT
CLogDlg::OnLogListLoading(WPARAM wParam
, LPARAM
/*lParam*/)
363 if( cur
== GITLOG_START
)
366 temp
.LoadString(IDS_PROGRESSWAIT
);
368 this->m_LogList
.ShowText(temp
, true);
370 // We use a progress bar while getting the logs
371 m_LogProgress
.SetRange32(0, 100);
372 m_LogProgress
.SetPos(0);
374 GetDlgItem(IDC_PROGRESS
)->ShowWindow(TRUE
);
376 //DialogEnableWindow(IDC_GETALL, FALSE);
377 //DialogEnableWindow(IDC_SHOWWHOLEPROJECT, FALSE);
378 //DialogEnableWindow(IDC_LOG_FIRSTPARENT, FALSE);
379 DialogEnableWindow(IDC_STATBUTTON
, FALSE
);
380 //DialogEnableWindow(IDC_REFRESH, FALSE);
381 DialogEnableWindow(IDC_HIDEPATHS
,FALSE
);
383 DialogEnableWindow(IDC_DATEFROM
,FALSE
);
384 DialogEnableWindow(IDC_DATETO
,FALSE
);
386 DialogEnableWindow(IDC_SEARCHEDIT
,FALSE
);
388 }else if( cur
== GITLOG_END
)
391 if(this->m_LogList
.HasText())
393 this->m_LogList
.ClearText();
396 UpdateLogInfoLabel();
400 DialogEnableWindow(IDC_SHOWWHOLEPROJECT
, TRUE
);
402 //DialogEnableWindow(IDC_GETALL, TRUE);
403 DialogEnableWindow(IDC_LOG_FIRSTPARENT
, TRUE
);
404 DialogEnableWindow(IDC_STATBUTTON
, TRUE
);
405 DialogEnableWindow(IDC_REFRESH
, TRUE
);
406 DialogEnableWindow(IDC_HIDEPATHS
,TRUE
);
408 DialogEnableWindow(IDC_DATEFROM
,TRUE
);
409 DialogEnableWindow(IDC_DATETO
,TRUE
);
411 DialogEnableWindow(IDC_SEARCHEDIT
,TRUE
);
413 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
414 GetDlgItem(IDC_PROGRESS
)->ShowWindow(FALSE
);
415 //CTime time=m_LogList.GetOldestTime();
417 m_LogList
.GetTimeRange(begin
,end
);
418 m_DateFrom
.SetTime(&begin
);
419 m_DateTo
.SetTime(&end
);
424 if(this->m_LogList
.HasText())
426 this->m_LogList
.ClearText();
427 this->m_LogList
.Invalidate();
429 UpdateLogInfoLabel();
430 m_LogProgress
.SetPos(cur
);
434 void CLogDlg::SetDlgTitle(bool bOffline
)
436 if (m_sTitle
.IsEmpty())
437 GetWindowText(m_sTitle
);
443 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetUIPathString());
444 else if (m_path
.IsDirectory())
445 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetWinPathString());
447 sTemp
.Format(IDS_LOG_DLGTITLEOFFLINE
, (LPCTSTR
)m_sTitle
, (LPCTSTR
)m_path
.GetFilename());
448 SetWindowText(sTemp
);
453 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetUIPathString());
454 else if (m_path
.IsEmpty())
455 SetWindowText(m_sTitle
+ _T(" - ") + CString(_T("Whole Project")));
456 else if (m_path
.IsDirectory())
457 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetWinPathString());
459 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetFilename());
463 void CLogDlg::CheckRegexpTooltip()
465 CWnd
*pWnd
= GetDlgItem(IDC_SEARCHEDIT
);
466 // Since tooltip describes regexp features, show it only if regexps are enabled.
467 if (m_bFilterWithRegex
)
469 m_tooltips
.AddTool(pWnd
, IDS_LOG_FILTER_REGEX_TT
);
472 m_tooltips
.DelTool(pWnd
);
475 void CLogDlg::EnableOKButton()
479 // the dialog is used to select revisions
480 if (m_bSelectionMustBeSingle
)
482 // enable OK button if only a single revision is selected
483 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()==1));
485 else if (m_bSelectionMustBeContinuous
)
486 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()!=0)&&(m_LogList
.IsSelectionContinuous()));
488 DialogEnableWindow(IDOK
, m_LogList
.GetSelectedCount()!=0);
491 DialogEnableWindow(IDOK
, TRUE
);
494 CString
CLogDlg::GetTagInfo(GitRev
* pLogEntry
)
499 if(m_LogList
.m_HashMap
.find(pLogEntry
->m_CommitHash
) != m_LogList
.m_HashMap
.end())
501 STRING_VECTOR
&vector
= m_LogList
.m_HashMap
[pLogEntry
->m_CommitHash
];
502 for(int i
=0;i
<vector
.size();i
++)
504 if(vector
[i
].Find(_T("refs/tags/")) == 0 )
506 CString tag
= vector
[i
];
507 int start
= vector
[i
].Find(_T("^{}"));
513 cmd
.Format(_T("git.exe cat-file tag %s"), tag
);
515 if(g_Git
.Run(cmd
, &output
, CP_UTF8
) == 0 )
521 if(!output
.IsEmpty())
523 output
= _T("\n*Tag Info*\n\n") + output
;
529 void CLogDlg::FillLogMessageCtrl(bool bShow
/* = true*/)
531 // we fill here the log message rich edit control,
532 // and also populate the changed files list control
533 // according to the selected revision(s).
535 CRichEditCtrl
* pMsgView
= (CRichEditCtrl
*)GetDlgItem(IDC_MSGVIEW
);
536 // empty the log message view
537 pMsgView
->SetWindowText(_T(" "));
538 // empty the changed files list
539 m_ChangedFileListCtrl
.SetRedraw(FALSE
);
540 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
541 m_currentChangedArray
= NULL
;
542 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
543 m_ChangedFileListCtrl
.DeleteAllItems();
545 // if we're not here to really show a selected revision, just
546 // get out of here after clearing the views, which is what is intended
547 // if that flag is not set.
551 m_ChangedFileListCtrl
.Invalidate();
552 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
553 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
557 // depending on how many revisions are selected, we have to do different
559 int selCount
= m_LogList
.GetSelectedCount();
562 // if nothing is selected, we have nothing more to do
563 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
564 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
567 else if (selCount
== 1)
569 // if one revision is selected, we have to fill the log message view
570 // with the corresponding log message, and also fill the changed files
572 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
573 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
574 if (selIndex
>= m_LogList
.m_arShownList
.GetCount())
576 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
577 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
580 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(selIndex
));
582 if(!pLogEntry
->m_IsFull
)
584 pMsgView
->SetWindowText(_T("load ..."));
587 // set the log message text
588 pMsgView
->SetWindowText(_T("Commit:")+pLogEntry
->m_CommitHash
.ToString()+_T("\r\n\r\n"));
589 // turn bug ID's into links if the bugtraq: properties have been set
590 // and we can find a match of those in the log message
592 pMsgView
->SetSel(-1,-1);
594 SecureZeroMemory(&format
, sizeof(CHARFORMAT2
));
595 format
.cbSize
= sizeof(CHARFORMAT2
);
596 format
.dwMask
= CFM_BOLD
;
597 format
.dwEffects
= CFE_BOLD
;
598 pMsgView
->SendMessage(EM_SETCHARFORMAT
, SCF_SELECTION
, (LPARAM
)&format
);
600 CString msg
=_T("* ");
601 msg
+=pLogEntry
->m_Subject
;
602 pMsgView
->ReplaceSel(msg
);
604 pMsgView
->SetSel(-1,-1);
605 format
.dwEffects
= 0;
606 pMsgView
->SendMessage(EM_SETCHARFORMAT
, SCF_SELECTION
, (LPARAM
)&format
);
609 msg
+=pLogEntry
->m_Body
;
611 if(!pLogEntry
->m_Notes
.IsEmpty())
613 msg
+= _T("\n*Notes* ");
614 msg
+= pLogEntry
->m_Notes
;
618 msg
+=GetTagInfo(pLogEntry
);
620 pMsgView
->ReplaceSel(msg
);
623 pMsgView
->GetWindowText(text
);
624 // the rich edit control doesn't count the CR char!
625 // to be exact: CRLF is treated as one char.
626 text
.Replace(_T("\r"), _T(""));
628 m_ProjectProperties
.FindBugID(text
, pMsgView
);
629 CAppUtils::FormatTextInRichEditControl(pMsgView
);
631 int HidePaths
=m_cHidePaths
.GetState() & 0x0003;
632 CString matchpath
=this->m_path
.GetGitPathString();
634 for(int i
=0;i
<pLogEntry
->m_Files
.GetCount() && (!matchpath
.IsEmpty());i
++)
636 if( m_bWholeProject
)
639 ((CTGitPath
&)pLogEntry
->m_Files
[i
]).m_Action
&= ~(CTGitPath::LOGACTIONS_HIDE
|CTGitPath::LOGACTIONS_GRAY
);
641 if(pLogEntry
->m_Files
[i
].GetGitPathString().Left(matchpath
.GetLength()) != matchpath
)
643 if(HidePaths
==BST_CHECKED
)
644 ((CTGitPath
&)pLogEntry
->m_Files
[i
]).m_Action
|= CTGitPath::LOGACTIONS_HIDE
;
645 if(HidePaths
==BST_INDETERMINATE
)
646 ((CTGitPath
&)pLogEntry
->m_Files
[i
]).m_Action
|= CTGitPath::LOGACTIONS_GRAY
;
650 m_ChangedFileListCtrl
.UpdateWithGitPathList(pLogEntry
->m_Files
);
651 m_ChangedFileListCtrl
.m_CurrentVersion
=pLogEntry
->m_CommitHash
;
652 m_ChangedFileListCtrl
.Show(SVNSLC_SHOWVERSIONED
);
654 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
661 // more than one revision is selected:
662 // the log message view must be emptied
663 // the changed files list contains all the changed paths from all
664 // selected revisions, with 'doubles' removed
665 m_currentChangedPathList
= GetChangedPathsFromSelectedRevisions(true);
669 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
671 if (m_currentChangedArray
)
673 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedArray
->GetCount());
674 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedArray
->GetCount());
676 else if (m_currentChangedPathList
.GetCount())
678 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedPathList
.GetCount());
679 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedPathList
.GetCount());
683 m_ChangedFileListCtrl
.SetItemCountEx(0);
684 m_ChangedFileListCtrl
.Invalidate();
687 // sort according to the settings
688 if (m_nSortColumnPathList
> 0)
689 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
691 SetSortArrow(&m_ChangedFileListCtrl
, -1, false);
692 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
696 void CLogDlg::OnBnClickedRefresh()
702 void CLogDlg::Refresh (bool /*autoGoOnline*/)
706 FillLogMessageCtrl(false);
711 BOOL
CLogDlg::Cancel()
716 void CLogDlg::SaveSplitterPos()
720 CRegDWORD regPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
721 CRegDWORD regPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
723 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
724 ScreenToClient(&rectSplitter
);
725 regPos1
= rectSplitter
.top
;
726 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
727 ScreenToClient(&rectSplitter
);
728 regPos2
= rectSplitter
.top
;
732 void CLogDlg::OnCancel()
734 // canceling means stopping the working thread if it's still running.
735 if (this->IsThreadRunning())
737 m_LogList
.SafeTerminateThread();
745 CString
CLogDlg::MakeShortMessage(const CString
& message
)
747 bool bFoundShort
= true;
748 CString sShortMessage
= m_ProjectProperties
.GetLogSummary(message
);
749 if (sShortMessage
.IsEmpty())
752 sShortMessage
= message
;
754 // Remove newlines and tabs 'cause those are not shown nicely in the list control
755 sShortMessage
.Replace(_T("\r"), _T(""));
756 sShortMessage
.Replace(_T("\t"), _T(" "));
758 // Suppose the first empty line separates 'summary' from the rest of the message.
759 int found
= sShortMessage
.Find(_T("\n\n"));
760 // To avoid too short 'short' messages
761 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
762 // only use the empty newline as a separator if it comes after at least 15 chars.
763 if ((!bFoundShort
)&&(found
>= 15))
765 sShortMessage
= sShortMessage
.Left(found
);
767 sShortMessage
.Replace('\n', ' ');
768 return sShortMessage
;
771 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*/)
774 if (rev
== SVN_INVALID_REVNUM
)
780 // this is the callback function which receives the data for every revision we ask the log for
781 // we store this information here one by one.
783 if (m_startrev
== -1)
788 m_LogProgress
.SetPos(m_limit
- m_limitcounter
);
790 else if (m_startrev
.IsNumber() && m_startrev
.IsNumber())
791 m_LogProgress
.SetPos((git_revnum_t
)m_startrev
-rev
+(git_revnum_t
)m_endrev
);
792 __time64_t ttime
= time
/1000000L;
793 if (m_tTo
< (DWORD
)ttime
)
794 m_tTo
= (DWORD
)ttime
;
795 if (m_tFrom
> (DWORD
)ttime
)
796 m_tFrom
= (DWORD
)ttime
;
797 if ((m_lowestRev
> rev
)||(m_lowestRev
< 0))
799 // Add as many characters from the log message to the list control
800 PLOGENTRYDATA pLogItem
= new LOGENTRYDATA
;
801 pLogItem
->bCopies
= !!copies
;
803 // find out if this item was copied in the revision
804 BOOL copiedself
= FALSE
;
807 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< cpaths
->GetCount(); ++cpPathIndex
)
809 LogChangedPath
* cpath
= cpaths
->GetAt(cpPathIndex
);
810 if (!cpath
->sCopyFromPath
.IsEmpty() && (cpath
->sPath
.Compare(m_sSelfRelativeURL
) == 0))
812 // note: this only works if the log is fetched top-to-bottom
813 // but since we do that, it shouldn't be a problem
814 m_sSelfRelativeURL
= cpath
->sCopyFromPath
;
820 pLogItem
->bCopiedSelf
= copiedself
;
821 pLogItem
->tmDate
= ttime
;
822 pLogItem
->sAuthor
= author
;
823 pLogItem
->sDate
= date
;
824 pLogItem
->sShortMessage
= MakeShortMessage(message
);
825 pLogItem
->dwFileChanges
= filechanges
;
826 pLogItem
->actions
= actions
;
827 pLogItem
->haschildren
= haschildren
;
828 pLogItem
->childStackDepth
= m_childCounter
;
829 m_maxChild
= max(m_childCounter
, m_maxChild
);
832 pLogItem
->sBugIDs
= m_ProjectProperties
.FindBugID(message
).Trim();
834 // split multi line log entries and concatenate them
835 // again but this time with \r\n as line separators
836 // so that the edit control recognizes them
839 if (message
.GetLength()>0)
841 m_sMessageBuf
= message
;
842 m_sMessageBuf
.Replace(_T("\n\r"), _T("\n"));
843 m_sMessageBuf
.Replace(_T("\r\n"), _T("\n"));
844 if (m_sMessageBuf
.Right(1).Compare(_T("\n"))==0)
845 m_sMessageBuf
= m_sMessageBuf
.Left(m_sMessageBuf
.GetLength()-1);
848 m_sMessageBuf
.Empty();
849 pLogItem
->sMessage
= m_sMessageBuf
;
852 // move-construct path array
854 pLogItem
->pArChangedPaths
= new LogChangedPathArray (*cpaths
);
857 catch (CException
* e
)
859 ::MessageBox(NULL
, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR
);
863 m_logEntries
.push_back(pLogItem
);
864 m_arShownList
.Add(pLogItem
);
870 //this is the thread function which calls the subversion function
875 void CLogDlg::CopyChangedSelectionToClipBoard()
878 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
880 return; // nothing is selected, get out of here
884 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
887 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
890 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
891 CTGitPath
*path
= (CTGitPath
*)m_ChangedFileListCtrl
.GetItemData(nItem
);
893 sPaths
+= path
->GetGitPathString();
894 sPaths
+= _T("\r\n");
900 // only one revision is selected in the log dialog top pane
901 // but multiple items could be selected in the changed items list
902 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
905 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
906 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(nItem
);
908 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
910 // some items are hidden! So find out which item the user really selected
911 INT_PTR selRealIndex
= -1;
912 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
914 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
916 if (selRealIndex
== nItem
)
918 changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
);
925 sPaths
+= changedlogpath
->sPath
;
926 sPaths
+= _T("\r\n");
932 CStringUtils::WriteAsciiStringToClipboard(sPaths
, GetSafeHwnd());
936 BOOL
CLogDlg::IsDiffPossible(LogChangedPath
* /*changedpath*/, git_revnum_t rev
)
939 CString added
, deleted
;
940 if (changedpath
== NULL
)
943 if ((rev
> 1)&&(changedpath
->action
!= LOGACTIONS_DELETED
))
945 if (changedpath
->action
== LOGACTIONS_ADDED
) // file is added
947 if (changedpath
->lCopyFromRev
== 0)
948 return FALSE
; // but file was not added with history
956 void CLogDlg::OnContextMenu(CWnd
* pWnd
, CPoint point
)
958 // we have two separate context menus:
959 // one shown on the log message list control,
960 // the other shown in the changed-files list control
961 int selCount
= m_LogList
.GetSelectedCount();
962 if (pWnd
== &m_LogList
)
964 //ShowContextMenuForRevisions(pWnd, point);
966 else if (pWnd
== &m_ChangedFileListCtrl
)
968 //ShowContextMenuForChangedpaths(pWnd, point);
970 else if ((selCount
== 1)&&(pWnd
== GetDlgItem(IDC_MSGVIEW
)))
972 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
975 selIndex
= m_LogList
.GetNextSelectedItem(pos
);
977 GitRev
*pRev
= ((GitRev
*)m_LogList
.m_arShownList
[selIndex
]);
979 if ((point
.x
== -1) && (point
.y
== -1))
982 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(&rect
);
983 ClientToScreen(&rect
);
984 point
= rect
.CenterPoint();
986 CString sMenuItemText
;
988 if (popup
.CreatePopupMenu())
990 // add the 'default' entries
991 sMenuItemText
.LoadString(IDS_SCIEDIT_COPY
);
992 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, WM_COPY
, sMenuItemText
);
993 sMenuItemText
.LoadString(IDS_SCIEDIT_SELECTALL
);
994 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, EM_SETSEL
, sMenuItemText
);
995 sMenuItemText
.LoadString(IDS_EDIT_NOTES
);
996 popup
.AppendMenuIcon( CGitLogList::ID_EDITNOTE
, sMenuItemText
, IDI_EDIT
);
1000 // popup.AppendMenu(MF_SEPARATOR);
1001 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
1002 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
1005 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1009 break; // no command selected
1012 ::SendMessage(GetDlgItem(IDC_MSGVIEW
)->GetSafeHwnd(), cmd
, 0, -1);
1014 case CGitLogList::ID_EDITNOTE
:
1015 CAppUtils::EditNote(pRev
);
1016 this->FillLogMessageCtrl(true);
1026 void CLogDlg::OnOK()
1028 // since the log dialog is also used to select revisions for other
1029 // dialogs, we have to do some work before closing this dialog
1030 if (GetFocus() != GetDlgItem(IDOK
))
1031 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
1034 if (this->IsThreadRunning())
1036 m_LogList
.SafeTerminateThread();
1039 // check that one and only one row is selected
1040 if (m_LogList
.GetSelectedCount() == 1)
1042 // get the selected row
1043 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1044 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
1045 if (selIndex
< m_LogList
.m_arShownList
.GetCount())
1047 // all ok, pick up the revision
1048 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(selIndex
));
1050 m_sSelectedHash
= pLogEntry
->m_CommitHash
;
1058 if (!GetDlgItem(IDOK
)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL
))
1059 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
1063 GetDlgItemText(IDOK
, buttontext
);
1064 temp
.LoadString(IDS_MSGBOX_CANCEL
);
1065 if (temp
.Compare(buttontext
) != 0)
1066 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
1067 m_bCancelled
= TRUE
;
1068 m_selectedRevs
.Clear();
1069 m_selectedRevsOneRange
.Clear();
1070 if (m_pNotifyWindow
)
1072 int selIndex
= m_LogList
.GetSelectionMark();
1075 PLOGENTRYDATA pLogEntry
= NULL
;
1076 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1077 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1078 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1079 git_revnum_t lowerRev
= pLogEntry
->Rev
;
1080 git_revnum_t higherRev
= lowerRev
;
1083 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1084 git_revnum_t rev
= pLogEntry
->Rev
;
1085 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1088 if (higherRev
< rev
)
1091 if (m_sFilterText
.IsEmpty() && m_nSortColumn
== 0 && IsSelectionContinuous())
1093 m_selectedRevsOneRange
.AddRevRange(lowerRev
, higherRev
);
1095 BOOL bSentMessage
= FALSE
;
1096 if (m_LogList
.GetSelectedCount() == 1)
1098 // if only one revision is selected, check if the path/url with which the dialog was started
1099 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
1100 // if it was copied, use the copy from revision as lowerRev
1101 if ((pLogEntry
)&&(pLogEntry
->pArChangedPaths
)&&(lowerRev
== higherRev
))
1103 CString sUrl
= m_path
.GetGitPathString();
1104 if (!m_path
.IsUrl())
1106 sUrl
= GetURLFromPath(m_path
);
1108 sUrl
= sUrl
.Mid(m_sRepositoryRoot
.GetLength());
1109 for (int cp
= 0; cp
< pLogEntry
->pArChangedPaths
->GetCount(); ++cp
)
1111 LogChangedPath
* pData
= pLogEntry
->pArChangedPaths
->GetAt(cp
);
1114 if (sUrl
.Compare(pData
->sPath
) == 0)
1116 if (!pData
->sCopyFromPath
.IsEmpty())
1118 lowerRev
= pData
->lCopyFromRev
;
1119 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
), lowerRev
);
1120 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
), higherRev
);
1121 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1122 bSentMessage
= TRUE
;
1129 if ( !bSentMessage
)
1131 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
| MERGE_REVSELECTMINUSONE
), lowerRev
);
1132 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
| MERGE_REVSELECTMINUSONE
), higherRev
);
1133 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1134 if (m_selectedRevsOneRange
.GetCount())
1135 m_pNotifyWindow
->SendMessage(WM_REVLISTONERANGE
, 0, (LPARAM
)&m_selectedRevsOneRange
);
1140 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
1141 reg
= m_btnShow
.GetCurrentEntry();
1146 void CLogDlg::OnNMDblclkChangedFileList(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
1148 // a double click on an entry in the changed-files list has happened
1154 void CLogDlg::DiffSelectedFile()
1157 if (m_bThreadRunning
)
1159 UpdateLogInfoLabel();
1160 INT_PTR selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
1163 if (m_ChangedFileListCtrl
.GetSelectedCount() == 0)
1165 // find out if there's an entry selected in the log list
1166 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1167 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1168 git_revnum_t rev1
= pLogEntry
->Rev
;
1169 git_revnum_t rev2
= rev1
;
1174 // there's at least a second entry selected in the log list: several revisions selected!
1175 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1178 rev1
= max(rev1
,(long)pLogEntry
->Rev
);
1179 rev2
= min(rev2
,(long)pLogEntry
->Rev
);
1183 // now we have both revisions selected in the log list, so we can do a diff of the selected
1184 // entry in the changed files list with these two revisions.
1185 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1190 // nothing or only one revision selected in the log list
1191 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1193 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
1195 // some items are hidden! So find out which item the user really clicked on
1196 INT_PTR selRealIndex
= -1;
1197 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
1199 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
1201 if (selRealIndex
== selIndex
)
1203 selIndex
= hiddenindex
;
1204 changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1210 if (IsDiffPossible(changedpath
, rev1
))
1212 // diffs with renamed files are possible
1213 if ((changedpath
)&&(!changedpath
->sCopyFromPath
.IsEmpty()))
1214 rev2
= changedpath
->lCopyFromRev
;
1217 // if the path was modified but the parent path was 'added with history'
1218 // then we have to use the copy from revision of the parent path
1219 CTGitPath cpath
= CTGitPath(changedpath
->sPath
);
1220 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
1222 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->GetAt(flist
)->sPath
);
1223 if (p
.IsAncestorOf(cpath
))
1225 if (!pLogEntry
->pArChangedPaths
->GetAt(flist
)->sCopyFromPath
.IsEmpty())
1226 rev2
= pLogEntry
->pArChangedPaths
->GetAt(flist
)->lCopyFromRev
;
1230 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1234 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1235 CTGitPath tempfile2
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1237 // deleted files must be opened from the revision before the deletion
1238 if (changedpath
->action
== LOGACTIONS_DELETED
)
1240 m_bCancelled
= false;
1242 CProgressDlg progDlg
;
1243 progDlg
.SetTitle(IDS_APPNAME
);
1244 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1246 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)(m_sRepositoryRoot
+ changedpath
->sPath
), (LPCTSTR
)r
.ToString());
1247 progDlg
.SetLine(1, sInfoLine
, true);
1248 SetAndClearProgressInfo(&progDlg
);
1249 progDlg
.ShowModeless(m_hWnd
);
1251 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), r
, r
, tempfile
))
1253 m_bCancelled
= false;
1254 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), GitRev::REV_HEAD
, r
, tempfile
))
1257 SetAndClearProgressInfo((HWND
)NULL
);
1258 CMessageBox::Show(m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1263 SetAndClearProgressInfo((HWND
)NULL
);
1265 CString sName1
, sName2
;
1266 sName1
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
);
1267 sName2
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
-1);
1268 CAppUtils::DiffFlags flags
;
1269 flags
.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1270 if (changedpath
->action
== LOGACTIONS_DELETED
)
1271 CAppUtils::StartExtDiff(tempfile
, tempfile2
, sName2
, sName1
, flags
);
1273 CAppUtils::StartExtDiff(tempfile2
, tempfile
, sName2
, sName1
, flags
);
1280 void CLogDlg::DoDiffFromLog(INT_PTR selIndex
, GitRev
* rev1
, GitRev
* rev2
, bool blame
, bool unified
)
1282 DialogEnableWindow(IDOK
, FALSE
);
1283 // SetPromptApp(&theApp);
1284 theApp
.DoWaitCursor(1);
1287 GetTempPath(temppath
);
1290 file1
.Format(_T("%s%s_%s%s"),
1292 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1293 rev1
->m_CommitHash
.ToString().Left(6),
1294 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1297 file2
.Format(_T("%s\\%s_%s%s"),
1299 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1300 rev2
->m_CommitHash
.ToString().Left(6),
1301 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1305 cmd
.Format(_T("git.exe cat-file -p %s:%s"),rev1
->m_CommitHash
.ToString(),(*m_currentChangedArray
)[selIndex
].GetGitPathString());
1306 g_Git
.RunLogFile(cmd
,file1
);
1307 cmd
.Format(_T("git.exe cat-file -p %s:%s"),rev2
->m_CommitHash
.ToString(),(*m_currentChangedArray
)[selIndex
].GetGitPathString());
1308 g_Git
.RunLogFile(cmd
,file2
);
1310 CAppUtils::DiffFlags flags
;
1311 CAppUtils::StartExtDiff(file1
,file2
,_T("A"),_T("B"),flags
);
1316 if (Git::PathIsURL(m_path
))
1318 filepath
= m_path
.GetGitPathString();
1322 filepath
= GetURLFromPath(m_path
);
1323 if (filepath
.IsEmpty())
1325 theApp
.DoWaitCursor(-1);
1327 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1328 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1329 TRACE(_T("could not retrieve the URL of the file!\n"));
1331 theApp
.DoWaitCursor(-11);
1335 m_bCancelled
= FALSE
;
1336 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1338 CString firstfile
, secondfile
;
1339 if (m_LogList
.GetSelectedCount()==1)
1341 int s
= m_LogList
.GetSelectionMark();
1342 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(s
));
1343 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
1344 firstfile
= changedpath
->sPath
;
1345 secondfile
= firstfile
;
1346 if ((rev2
== rev1
-1)&&(changedpath
->lCopyFromRev
> 0)) // is it an added file with history?
1348 secondfile
= changedpath
->sCopyFromPath
;
1349 rev2
= changedpath
->lCopyFromRev
;
1354 firstfile
= m_currentChangedPathList
[selIndex
].GetGitPathString();
1355 secondfile
= firstfile
;
1358 firstfile
= filepath
+ firstfile
.Trim();
1359 secondfile
= filepath
+ secondfile
.Trim();
1361 GitDiff
diff(this, this->m_hWnd
, true);
1362 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1363 diff
.SetHEADPeg(m_LogRevision
);
1367 diff
.ShowUnifiedDiff(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
);
1369 CAppUtils::StartShowUnifiedDiff(m_hWnd
, CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), m_LogRevision
);
1373 if (diff
.ShowCompare(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), false, blame
))
1375 if (firstfile
.Compare(secondfile
)==0)
1377 git_revnum_t baseRev
= 0;
1378 diff
.DiffProps(CTGitPath(firstfile
), rev2
, rev1
, baseRev
);
1385 theApp
.DoWaitCursor(-1);
1389 BOOL
CLogDlg::Open(bool /*bOpenWith*/,CString changedpath
, git_revnum_t rev
)
1392 DialogEnableWindow(IDOK
, FALSE
);
1393 SetPromptApp(&theApp
);
1394 theApp
.DoWaitCursor(1);
1396 if (Git::PathIsURL(m_path
))
1398 filepath
= m_path
.GetGitPathString();
1402 filepath
= GetURLFromPath(m_path
);
1403 if (filepath
.IsEmpty())
1405 theApp
.DoWaitCursor(-1);
1407 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1408 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1409 TRACE(_T("could not retrieve the URL of the file!\n"));
1414 m_bCancelled
= false;
1415 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1416 filepath
+= changedpath
;
1418 CProgressDlg progDlg
;
1419 progDlg
.SetTitle(IDS_APPNAME
);
1420 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1422 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)GitRev(rev
).ToString());
1423 progDlg
.SetLine(1, sInfoLine
, true);
1424 SetAndClearProgressInfo(&progDlg
);
1425 progDlg
.ShowModeless(m_hWnd
);
1427 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath
), rev
);
1428 m_bCancelled
= false;
1429 if (!Cat(CTGitPath(filepath
), GitRev(rev
), rev
, tempfile
))
1432 SetAndClearProgressInfo((HWND
)NULL
);
1433 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1435 theApp
.DoWaitCursor(-1);
1439 SetAndClearProgressInfo((HWND
)NULL
);
1440 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1443 int ret
= (int)ShellExecute(this->m_hWnd
, NULL
, tempfile
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1444 if (ret
<= HINSTANCE_ERROR
)
1449 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1450 cmd
+= tempfile
.GetWinPathString() + _T(" ");
1451 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1454 theApp
.DoWaitCursor(-1);
1459 void CLogDlg::EditAuthor(const CLogDataVector
& /*logs*/)
1464 if (logs
.size() == 0)
1466 DialogEnableWindow(IDOK
, FALSE
);
1467 SetPromptApp(&theApp
);
1468 theApp
.DoWaitCursor(1);
1469 if (Git::PathIsURL(m_path
))
1470 url
= m_path
.GetGitPathString();
1473 url
= GetURLFromPath(m_path
);
1475 name
= Git_PROP_REVISION_AUTHOR
;
1477 CString value
= RevPropertyGet(name
, CTGitPath(url
), logs
[0]->Rev
);
1478 CString sOldValue
= value
;
1479 value
.Replace(_T("\n"), _T("\r\n"));
1480 CInputDlg
dlg(this);
1481 dlg
.m_sHintText
.LoadString(IDS_LOG_AUTHOR
);
1482 dlg
.m_sInputText
= value
;
1483 dlg
.m_sTitle
.LoadString(IDS_LOG_AUTHOREDITTITLE
);
1484 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1485 dlg
.m_bUseLogWidth
= false;
1486 if (dlg
.DoModal() == IDOK
)
1488 dlg
.m_sInputText
.Replace(_T("\r"), _T(""));
1490 LogCache::CCachedLogInfo
* toUpdate
1491 = GetLogCache (CTGitPath (m_sRepositoryRoot
));
1493 CProgressDlg progDlg
;
1494 progDlg
.SetTitle(IDS_APPNAME
);
1495 progDlg
.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT
)));
1496 progDlg
.SetTime(true);
1497 progDlg
.SetShowProgressBar(true);
1498 progDlg
.ShowModeless(m_hWnd
);
1499 for (DWORD i
=0; i
<logs
.size(); ++i
)
1501 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), logs
[i
]->Rev
))
1504 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1510 logs
[i
]->sAuthor
= dlg
.m_sInputText
;
1511 m_LogList
.Invalidate();
1513 // update the log cache
1515 if (toUpdate
!= NULL
)
1517 // log caching is active
1519 LogCache::CCachedLogInfo newInfo
;
1520 newInfo
.Insert ( logs
[i
]->Rev
1521 , (const char*) CUnicodeUtils::GetUTF8 (logs
[i
]->sAuthor
)
1524 , LogCache::CRevisionInfoContainer::HAS_AUTHOR
);
1526 toUpdate
->Update (newInfo
);
1529 progDlg
.SetProgress64(i
, logs
.size());
1533 theApp
.DoWaitCursor(-1);
1538 void CLogDlg::EditLogMessage(int /*index*/)
1544 DialogEnableWindow(IDOK
, FALSE
);
1545 SetPromptApp(&theApp
);
1546 theApp
.DoWaitCursor(1);
1547 if (Git::PathIsURL(m_path
))
1548 url
= m_path
.GetGitPathString();
1551 url
= GetURLFromPath(m_path
);
1553 name
= Git_PROP_REVISION_LOG
;
1555 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(index
));
1556 m_bCancelled
= FALSE
;
1557 CString value
= RevPropertyGet(name
, CTGitPath(url
), pLogEntry
->Rev
);
1558 CString sOldValue
= value
;
1559 value
.Replace(_T("\n"), _T("\r\n"));
1560 CInputDlg
dlg(this);
1561 dlg
.m_sHintText
.LoadString(IDS_LOG_MESSAGE
);
1562 dlg
.m_sInputText
= value
;
1563 dlg
.m_sTitle
.LoadString(IDS_LOG_MESSAGEEDITTITLE
);
1564 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1565 dlg
.m_bUseLogWidth
= true;
1566 if (dlg
.DoModal() == IDOK
)
1568 dlg
.m_sInputText
.Replace(_T("\r"), _T(""));
1569 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), pLogEntry
->Rev
))
1571 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1575 pLogEntry
->sShortMessage
= MakeShortMessage(dlg
.m_sInputText
);
1576 // split multi line log entries and concatenate them
1577 // again but this time with \r\n as line separators
1578 // so that the edit control recognizes them
1579 if (dlg
.m_sInputText
.GetLength()>0)
1581 m_sMessageBuf
= dlg
.m_sInputText
;
1582 dlg
.m_sInputText
.Replace(_T("\n\r"), _T("\n"));
1583 dlg
.m_sInputText
.Replace(_T("\r\n"), _T("\n"));
1584 if (dlg
.m_sInputText
.Right(1).Compare(_T("\n"))==0)
1585 dlg
.m_sInputText
= dlg
.m_sInputText
.Left(dlg
.m_sInputText
.GetLength()-1);
1588 dlg
.m_sInputText
.Empty();
1589 pLogEntry
->sMessage
= dlg
.m_sInputText
;
1590 pLogEntry
->sBugIDs
= m_ProjectProperties
.FindBugID(dlg
.m_sInputText
);
1591 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
1592 pMsgView
->SetWindowText(_T(" "));
1593 pMsgView
->SetWindowText(dlg
.m_sInputText
);
1594 m_ProjectProperties
.FindBugID(dlg
.m_sInputText
, pMsgView
);
1595 m_LogList
.Invalidate();
1597 // update the log cache
1599 LogCache::CCachedLogInfo
* toUpdate
1600 = GetLogCache (CTGitPath (m_sRepositoryRoot
));
1601 if (toUpdate
!= NULL
)
1603 // log caching is active
1605 LogCache::CCachedLogInfo newInfo
;
1606 newInfo
.Insert ( pLogEntry
->Rev
1608 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry
->sMessage
)
1610 , LogCache::CRevisionInfoContainer::HAS_COMMENT
);
1612 toUpdate
->Update (newInfo
);
1616 theApp
.DoWaitCursor(-1);
1621 BOOL
CLogDlg::PreTranslateMessage(MSG
* pMsg
)
1623 // Skip Ctrl-C when copying text out of the log message or search filter
1624 BOOL bSkipAccelerator
= ( pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW
) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT
) ) && GetKeyState(VK_CONTROL
)&0x8000 );
1625 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
1627 if (GetFocus()==GetDlgItem(IDC_LOGLIST
))
1629 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1631 m_LogList
.DiffSelectedRevWithPrevious();
1636 if (m_hAccel
&& !bSkipAccelerator
)
1638 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
1643 if(::IsWindow(m_tooltips
.m_hWnd
))
1644 m_tooltips
.RelayEvent(pMsg
);
1645 return __super::PreTranslateMessage(pMsg
);
1649 BOOL
CLogDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1651 //if (this->IsThreadRunning())
1652 if(m_LogList
.m_bNoDispUpdates
)
1654 // only show the wait cursor over the list control
1656 ((pWnd
== GetDlgItem(IDC_LOGLIST
))||
1657 (pWnd
== GetDlgItem(IDC_MSGVIEW
))||
1658 (pWnd
== GetDlgItem(IDC_LOGMSG
))))
1660 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1665 if ((pWnd
) && (pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1666 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1668 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1670 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1673 void CLogDlg::OnBnClickedHelp()
1678 void CLogDlg::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1680 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1682 //if (this->IsThreadRunning())
1683 if(m_LogList
.m_bNoDispUpdates
)
1685 if (pNMLV
->iItem
>= 0)
1687 this->m_LogList
.m_nSearchIndex
= pNMLV
->iItem
;
1688 if (pNMLV
->iSubItem
!= 0)
1690 if ((pNMLV
->iItem
== m_LogList
.m_arShownList
.GetCount()))
1692 // remove the selected state
1693 if (pNMLV
->uChanged
& LVIF_STATE
)
1695 m_LogList
.SetItemState(pNMLV
->iItem
, 0, LVIS_SELECTED
);
1696 FillLogMessageCtrl();
1698 UpdateLogInfoLabel();
1702 if (pNMLV
->uChanged
& LVIF_STATE
)
1704 FillLogMessageCtrl();
1710 FillLogMessageCtrl();
1714 UpdateLogInfoLabel();
1717 void CLogDlg::OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1719 ENLINK
*pEnLink
= reinterpret_cast<ENLINK
*>(pNMHDR
);
1720 if (pEnLink
->msg
== WM_LBUTTONUP
)
1723 GetDlgItemText(IDC_MSGVIEW
, msg
);
1724 msg
.Replace(_T("\r\n"), _T("\n"));
1725 url
= msg
.Mid(pEnLink
->chrg
.cpMin
, pEnLink
->chrg
.cpMax
-pEnLink
->chrg
.cpMin
);
1726 if (!::PathIsURL(url
))
1728 url
= m_ProjectProperties
.GetBugIDUrl(url
);
1729 url
= GetAbsoluteUrlFromRelativeUrl(url
);
1732 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
1740 class CCommitPointer
1743 CCommitPointer():m_cont(NULL
){}
1744 CCommitPointer(const CCommitPointer
& P_Right
)
1750 CCommitPointer
& operator = (const CCommitPointer
& P_Right
)
1754 (*m_cont
->m_parDates
)[m_place
] = P_Right
.GetDate();
1755 (*m_cont
->m_parFileChanges
)[m_place
] = P_Right
.GetChanges();
1756 (*m_cont
->m_parAuthors
)[m_place
] = P_Right
.GetAuthor();
1760 m_Date
= P_Right
.GetDate();
1761 m_Changes
= P_Right
.GetChanges();
1762 m_csAuthor
= P_Right
.GetAuthor();
1767 void Clone(const CCommitPointer
& P_Right
)
1769 m_cont
= P_Right
.m_cont
;
1770 m_place
= P_Right
.m_place
;
1771 m_Date
= P_Right
.m_Date
;
1772 m_Changes
= P_Right
.m_Changes
;
1773 m_csAuthor
= P_Right
.m_csAuthor
;
1776 DWORD
GetDate() const {return IsPointer() ? (*m_cont
->m_parDates
)[m_place
] : m_Date
;}
1777 DWORD
GetChanges() const {return IsPointer() ? (*m_cont
->m_parFileChanges
)[m_place
] : m_Changes
;}
1778 CString
GetAuthor() const {return IsPointer() ? (*m_cont
->m_parAuthors
)[m_place
] : m_csAuthor
;}
1780 bool IsPointer() const {return m_cont
!= NULL
;}
1782 CDateSorter
* m_cont
;
1791 class iterator
: public std::iterator
<std::random_access_iterator_tag
, CCommitPointer
>
1794 CCommitPointer m_ptr
;
1797 iterator(const iterator
& P_Right
){*this = P_Right
;}
1798 iterator
& operator=(const iterator
& P_Right
)
1800 m_ptr
.Clone(P_Right
.m_ptr
);
1804 CCommitPointer
& operator*(){return m_ptr
;}
1805 CCommitPointer
* operator->(){return &m_ptr
;}
1806 const CCommitPointer
& operator*()const{return m_ptr
;}
1807 const CCommitPointer
* operator->()const{return &m_ptr
;}
1809 iterator
& operator+=(size_t P_iOffset
){m_ptr
.m_place
+= P_iOffset
;return *this;}
1810 iterator
& operator-=(size_t P_iOffset
){m_ptr
.m_place
-= P_iOffset
;return *this;}
1811 iterator
operator+(size_t P_iOffset
)const{iterator
it(*this); it
+= P_iOffset
;return it
;}
1812 iterator
operator-(size_t P_iOffset
)const{iterator
it(*this); it
-= P_iOffset
;return it
;}
1814 iterator
& operator++(){++m_ptr
.m_place
;return *this;}
1815 iterator
& operator--(){--m_ptr
.m_place
;return *this;}
1816 iterator
operator++(int){iterator
it(*this);++*this;return it
;}
1817 iterator
operator--(int){iterator
it(*this);--*this;return it
;}
1819 size_t operator-(const iterator
& P_itRight
)const{return m_ptr
.m_place
- P_itRight
->m_place
;}
1821 bool operator<(const iterator
& P_itRight
)const{return m_ptr
.m_place
< P_itRight
->m_place
;}
1822 bool operator!=(const iterator
& P_itRight
)const{return m_ptr
.m_place
!= P_itRight
->m_place
;}
1823 bool operator==(const iterator
& P_itRight
)const{return m_ptr
.m_place
== P_itRight
->m_place
;}
1824 bool operator>(const iterator
& P_itRight
)const{return m_ptr
.m_place
> P_itRight
->m_place
;}
1836 it
->m_place
= m_parDates
->GetCount();
1841 CDWordArray
* m_parDates
;
1842 CDWordArray
* m_parFileChanges
;
1843 CStringArray
* m_parAuthors
;
1846 class CDateSorterLess
1849 bool operator () (const CDateSorter::CCommitPointer
& P_Left
, const CDateSorter::CCommitPointer
& P_Right
) const
1851 return P_Left
.GetDate() > P_Right
.GetDate(); //Last date first
1858 void CLogDlg::OnBnClickedStatbutton()
1861 if (this->IsThreadRunning())
1863 if (m_LogList
.m_arShownList
.IsEmpty())
1864 return; // nothing is shown, so no statistics.
1865 // the statistics dialog expects the log entries to be sorted by date
1866 SortByColumn(3, false);
1867 CPtrArray shownlist
;
1868 m_LogList
.RecalculateShownList(&shownlist
);
1869 // create arrays which are aware of the current filter
1870 CStringArray m_arAuthorsFiltered
;
1871 CDWordArray m_arDatesFiltered
;
1872 CDWordArray m_arFileChangesFiltered
;
1873 for (INT_PTR i
=0; i
<shownlist
.GetCount(); ++i
)
1875 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(shownlist
.GetAt(i
));
1876 CString strAuthor
= pLogEntry
->m_AuthorName
;
1877 if ( strAuthor
.IsEmpty() )
1879 strAuthor
.LoadString(IDS_STATGRAPH_EMPTYAUTHOR
);
1881 m_arAuthorsFiltered
.Add(strAuthor
);
1882 m_arDatesFiltered
.Add(pLogEntry
->m_AuthorDate
.GetTime());
1883 m_arFileChangesFiltered
.Add(pLogEntry
->m_Files
.GetCount());
1886 CDateSorter W_Sorter
;
1887 W_Sorter
.m_parAuthors
= &m_arAuthorsFiltered
;
1888 W_Sorter
.m_parDates
= &m_arDatesFiltered
;
1889 W_Sorter
.m_parFileChanges
= &m_arFileChangesFiltered
;
1890 std::sort(W_Sorter
.begin(), W_Sorter
.end(), CDateSorterLess());
1893 dlg
.m_parAuthors
= &m_arAuthorsFiltered
;
1894 dlg
.m_parDates
= &m_arDatesFiltered
;
1895 dlg
.m_parFileChanges
= &m_arFileChangesFiltered
;
1896 dlg
.m_path
= m_path
;
1898 // restore the previous sorting
1899 SortByColumn(m_nSortColumn
, m_bAscending
);
1900 OnTimer(LOGFILTER_TIMER
);
1904 void CLogDlg::DoSizeV1(int delta
)
1907 RemoveAnchor(IDC_LOGLIST
);
1908 RemoveAnchor(IDC_SPLITTERTOP
);
1909 RemoveAnchor(IDC_MSGVIEW
);
1910 RemoveAnchor(IDC_SPLITTERBOTTOM
);
1911 RemoveAnchor(IDC_LOGMSG
);
1912 CSplitterControl::ChangeHeight(&m_LogList
, delta
, CW_TOPALIGN
);
1913 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), -delta
, CW_BOTTOMALIGN
);
1914 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
1915 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
1916 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
1917 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1918 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1922 m_LogList
.Invalidate();
1923 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
1927 void CLogDlg::DoSizeV2(int delta
)
1930 RemoveAnchor(IDC_LOGLIST
);
1931 RemoveAnchor(IDC_SPLITTERTOP
);
1932 RemoveAnchor(IDC_MSGVIEW
);
1933 RemoveAnchor(IDC_SPLITTERBOTTOM
);
1934 RemoveAnchor(IDC_LOGMSG
);
1935 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), delta
, CW_TOPALIGN
);
1936 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl
, -delta
, CW_BOTTOMALIGN
);
1937 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
1938 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
1939 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
1940 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1941 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1945 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
1946 m_ChangedFileListCtrl
.Invalidate();
1950 void CLogDlg::AdjustMinSize()
1952 // adjust the minimum size of the dialog to prevent the resizing from
1953 // moving the list control too far down.
1954 CRect rcChgListView
;
1955 m_ChangedFileListCtrl
.GetClientRect(rcChgListView
);
1957 m_LogList
.GetClientRect(rcLogList
);
1959 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(),
1960 m_DlgOrigRect
.Height()-m_ChgOrigRect
.Height()-m_LogListOrigRect
.Height()-m_MsgViewOrigRect
.Height()
1961 +rcChgListView
.Height()+rcLogList
.Height()+60));
1964 LRESULT
CLogDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
1968 if (wParam
== IDC_SPLITTERTOP
)
1970 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
1971 DoSizeV1(pHdr
->delta
);
1973 else if (wParam
== IDC_SPLITTERBOTTOM
)
1975 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
1976 DoSizeV2(pHdr
->delta
);
1981 return CResizableDialog::DefWindowProc(message
, wParam
, lParam
);
1984 void CLogDlg::SetSplitterRange()
1986 if ((m_LogList
)&&(m_ChangedFileListCtrl
))
1989 m_LogList
.GetWindowRect(rcTop
);
1990 ScreenToClient(rcTop
);
1992 GetDlgItem(IDC_MSGVIEW
)->GetWindowRect(rcMiddle
);
1993 ScreenToClient(rcMiddle
);
1994 m_wndSplitter1
.SetRange(rcTop
.top
+30, rcMiddle
.bottom
-20);
1996 m_ChangedFileListCtrl
.GetWindowRect(rcBottom
);
1997 ScreenToClient(rcBottom
);
1998 m_wndSplitter2
.SetRange(rcMiddle
.top
+30, rcBottom
.bottom
-20);
2002 LRESULT
CLogDlg::OnClickedInfoIcon(WPARAM
/*wParam*/, LPARAM lParam
)
2004 // FIXME: x64 version would get this function called with unexpected parameters.
2008 RECT
* rect
= (LPRECT
)lParam
;
2011 point
= CPoint(rect
->left
, rect
->bottom
);
2012 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
2014 if (popup
.CreatePopupMenu())
2016 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2017 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL
), LOGFILTER_ALL
, temp
);
2019 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2021 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2022 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES
), LOGFILTER_MESSAGES
, temp
);
2023 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2024 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS
), LOGFILTER_PATHS
, temp
);
2025 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2026 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS
), LOGFILTER_AUTHORS
, temp
);
2027 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2028 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS
), LOGFILTER_REVS
, temp
);
2029 temp
.LoadString(IDS_LOG_FILTER_BUGIDS
);
2030 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID
), LOGFILTER_BUGID
, temp
);
2032 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2034 temp
.LoadString(IDS_LOG_FILTER_REGEX
);
2035 popup
.AppendMenu(MF_STRING
| MF_ENABLED
| (m_bFilterWithRegex
? MF_CHECKED
: MF_UNCHECKED
), LOGFILTER_REGEX
, temp
);
2038 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2042 if (selection
== LOGFILTER_REGEX
)
2044 m_bFilterWithRegex
= !m_bFilterWithRegex
;
2045 CRegDWORD b
= CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
2046 b
= m_bFilterWithRegex
;
2047 CheckRegexpTooltip();
2051 m_LogList
.m_nSelectedFilter
= selection
;
2054 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2060 LRESULT
CLogDlg::OnClickedCancelFilter(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2063 KillTimer(LOGFILTER_TIMER
);
2065 m_LogList
.m_sFilterText
.Empty();
2067 theApp
.DoWaitCursor(1);
2068 CStoreSelection
storeselection(this);
2069 FillLogMessageCtrl(false);
2071 m_LogList
.RemoveFilter();
2074 m_LogList
.GetTimeRange(begin
,end
);
2075 m_DateFrom
.SetTime(&begin
);
2076 m_DateTo
.SetTime(&end
);
2078 theApp
.DoWaitCursor(-1);
2079 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2080 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2081 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2082 UpdateLogInfoLabel();
2088 void CLogDlg::SetFilterCueText()
2091 switch (m_LogList
.m_nSelectedFilter
)
2094 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2096 case LOGFILTER_MESSAGES
:
2097 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2099 case LOGFILTER_PATHS
:
2100 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2102 case LOGFILTER_AUTHORS
:
2103 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2105 case LOGFILTER_REVS
:
2106 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2109 // to make the cue banner text appear more to the right of the edit control
2110 temp
= _T(" ")+temp
;
2111 m_cFilter
.SetCueBanner(temp
);
2114 bool CLogDlg::Validate(LPCTSTR string
)
2116 if (!m_bFilterWithRegex
)
2119 return m_LogList
.ValidateRegexp(string
, pat
, false);
2123 void CLogDlg::OnTimer(UINT_PTR nIDEvent
)
2125 if (nIDEvent
== LOGFILTER_TIMER
)
2127 if (this->IsThreadRunning())
2129 // thread still running! So just restart the timer.
2130 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2133 CWnd
* focusWnd
= GetFocus();
2134 bool bSetFocusToFilterControl
= ((focusWnd
!= GetDlgItem(IDC_DATEFROM
))&&(focusWnd
!= GetDlgItem(IDC_DATETO
))
2135 && (focusWnd
!= GetDlgItem(IDC_LOGLIST
)));
2136 if (m_LogList
.m_sFilterText
.IsEmpty())
2138 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2139 // do not return here!
2140 // we also need to run the filter if the filter text is empty:
2141 // 1. to clear an existing filter
2142 // 2. to rebuild the m_arShownList after sorting
2144 theApp
.DoWaitCursor(1);
2145 CStoreSelection
storeselection(this);
2146 KillTimer(LOGFILTER_TIMER
);
2147 FillLogMessageCtrl(false);
2149 // now start filter the log list
2150 m_LogList
.StartFilter();
2152 if ( m_LogList
.GetItemCount()==1 )
2154 m_LogList
.SetSelectionMark(0);
2155 m_LogList
.SetItemState(0, LVIS_SELECTED
, LVIS_SELECTED
);
2157 theApp
.DoWaitCursor(-1);
2158 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2159 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2160 if (bSetFocusToFilterControl
)
2161 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2162 UpdateLogInfoLabel();
2163 } // if (nIDEvent == LOGFILTER_TIMER)
2164 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2165 __super::OnTimer(nIDEvent
);
2168 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2173 m_DateTo
.GetTime(_time
);
2175 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 23, 59, 59);
2176 if (time
.GetTime() != m_LogList
.m_To
.GetTime())
2178 m_LogList
.m_To
= (DWORD
)time
.GetTime();
2179 SetTimer(LOGFILTER_TIMER
, 10, NULL
);
2184 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2190 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2196 m_DateFrom
.GetTime(_time
);
2198 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 0, 0, 0);
2199 if (time
.GetTime() != m_LogList
.m_From
.GetTime())
2201 m_LogList
.m_From
= (DWORD
)time
.GetTime();
2202 SetTimer(LOGFILTER_TIMER
, 10, NULL
);
2207 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2215 CTGitPathList
CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
2217 CTGitPathList pathList
;
2220 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2222 m_sRepositoryRoot
= GetRepositoryRoot(m_path
);
2224 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2227 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2232 int nextpos
= m_LogList
.GetNextSelectedItem(pos
);
2233 if (nextpos
>= m_arShownList
.GetCount())
2235 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(nextpos
));
2236 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
2237 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
2239 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
2243 if (!bRelativePaths
)
2244 path
.SetFromGit(m_sRepositoryRoot
);
2245 path
.AppendPathString(cpath
->sPath
);
2247 ((m_cHidePaths
.GetState() & 0x0003)!=BST_CHECKED
)||
2248 (cpath
->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0))
2249 pathList
.AddPath(path
);
2254 pathList
.RemoveDuplicates();
2259 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
2267 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscRevSort());
2269 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescRevSort());
2275 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscActionSort());
2277 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescActionSort());
2283 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscAuthorSort());
2285 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescAuthorSort());
2291 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscDateSort());
2293 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescDateSort());
2296 case 4: // Message or bug id
2297 if (m_bShowBugtraqColumn
)
2300 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscBugIDSort());
2302 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescBugIDSort());
2305 // fall through here
2309 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscMessageSort());
2311 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescMessageSort());
2321 void CLogDlg::OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2323 if (this->IsThreadRunning())
2324 return; //no sorting while the arrays are filled
2326 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2327 const int nColumn
= pNMLV
->iSubItem
;
2328 m_bAscending
= nColumn
== m_nSortColumn
? !m_bAscending
: TRUE
;
2329 m_nSortColumn
= nColumn
;
2330 SortByColumn(m_nSortColumn
, m_bAscending
);
2331 SetSortArrow(&m_LogList
, m_nSortColumn
, !!m_bAscending
);
2332 SortShownListArray();
2333 m_LogList
.Invalidate();
2334 UpdateLogInfoLabel();
2339 void CLogDlg::SortShownListArray()
2341 // make sure the shown list still matches the filter after sorting.
2342 OnTimer(LOGFILTER_TIMER
);
2343 // clear the selection states
2344 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2347 m_LogList
.SetItemState(m_LogList
.GetNextSelectedItem(pos
), 0, LVIS_SELECTED
);
2349 m_LogList
.SetSelectionMark(-1);
2352 void CLogDlg::SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
)
2354 if (control
== NULL
)
2356 // set the sort arrow
2357 CHeaderCtrl
* pHeader
= control
->GetHeaderCtrl();
2358 HDITEM HeaderItem
= {0};
2359 HeaderItem
.mask
= HDI_FORMAT
;
2360 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
2362 pHeader
->GetItem(i
, &HeaderItem
);
2363 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
2364 pHeader
->SetItem(i
, &HeaderItem
);
2368 pHeader
->GetItem(nColumn
, &HeaderItem
);
2369 HeaderItem
.fmt
|= (bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
2370 pHeader
->SetItem(nColumn
, &HeaderItem
);
2373 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
2376 if (this->IsThreadRunning())
2377 return; //no sorting while the arrays are filled
2378 if (m_currentChangedArray
== NULL
)
2380 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2381 const int nColumn
= pNMLV
->iSubItem
;
2382 m_bAscendingPathList
= nColumn
== m_nSortColumnPathList
? !m_bAscendingPathList
: TRUE
;
2383 m_nSortColumnPathList
= nColumn
;
2384 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
2386 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
2387 m_ChangedFileListCtrl
.Invalidate();
2392 int CLogDlg::m_nSortColumnPathList
= 0;
2393 bool CLogDlg::m_bAscendingPathList
= false;
2395 int CLogDlg::SortCompare(const void * /*pElem1*/, const void * /*pElem2*/)
2398 LogChangedPath
* cpath1
= *((LogChangedPath
**)pElem1
);
2399 LogChangedPath
* cpath2
= *((LogChangedPath
**)pElem2
);
2401 if (m_bAscendingPathList
)
2402 std::swap (cpath1
, cpath2
);
2405 switch (m_nSortColumnPathList
)
2408 cmp
= cpath2
->GetAction().Compare(cpath1
->GetAction());
2413 cmp
= cpath2
->sPath
.CompareNoCase(cpath1
->sPath
);
2417 case 2: // copy from path
2418 cmp
= cpath2
->sCopyFromPath
.Compare(cpath1
->sCopyFromPath
);
2422 case 3: // copy from revision
2423 return cpath2
->lCopyFromRev
> cpath1
->lCopyFromRev
;
2429 void CLogDlg::OnBnClickedHidepaths()
2431 FillLogMessageCtrl();
2432 m_ChangedFileListCtrl
.Invalidate();
2437 void CLogDlg::OnBnClickedCheckStoponcopy()
2440 if (!GetDlgItem(IDC_GETALL
)->IsWindowEnabled())
2443 // ignore old fetch limits when switching
2444 // between copy-following and stop-on-copy
2445 // (otherwise stop-on-copy will limit what
2446 // we see immediately after switching to
2451 // now, restart the query
2457 void CLogDlg::UpdateLogInfoLabel()
2462 long selectedrevs
= 0;
2463 int count
=m_LogList
.m_arShownList
.GetCount();
2467 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(0)))->m_CommitHash
;
2468 if(this->m_LogList
.m_bShowWC
&& rev1
.IsEmpty()&&(count
>1))
2470 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(start
)))->m_CommitHash
;
2471 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
2472 rev2
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(count
-1)))->m_CommitHash
;
2473 selectedrevs
= m_LogList
.GetSelectedCount();
2476 sTemp
.Format(_T("Showing %ld revision(s), from revision %s to revision %s - %ld revision(s) selected\n"),
2478 rev2
.ToString().Left(6), rev1
.ToString().Left(6), selectedrevs
);
2480 if(selectedrevs
== 1)
2482 CString str
=m_ChangedFileListCtrl
.GetStatisticsString(true);
2483 str
.Replace(_T('\n'), _T(' '));
2492 void CLogDlg::ShowContextMenuForChangedpaths(CWnd
* /*pWnd*/, CPoint point
)
2495 int selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
2496 if ((point
.x
== -1) && (point
.y
== -1))
2499 m_ChangedFileListCtrl
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
2500 m_ChangedFileListCtrl
.ClientToScreen(&rect
);
2501 point
= rect
.CenterPoint();
2505 int s
= m_LogList
.GetSelectionMark();
2508 std::vector
<CString
> changedpaths
;
2509 std::vector
<LogChangedPath
*> changedlogpaths
;
2510 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2512 return; // nothing is selected, get out of here
2514 bool bOneRev
= true;
2515 int sel
=m_LogList
.GetNextSelectedItem(pos
);
2516 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(sel
));
2517 GitRev
* rev1
= pLogEntry
;
2518 GitRev
* rev2
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.GetAt(sel
+1));
2520 bool bOneRev
= true;
2525 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
2528 rev1
= max(rev1
,(git_revnum_t
)pLogEntry
->Rev
);
2529 rev2
= min(rev2
,(git_revnum_t
)pLogEntry
->Rev
);
2535 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2538 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2539 changedpaths
.push_back(m_currentChangedPathList
[nItem
].GetGitPathString());
2544 // only one revision is selected in the log dialog top pane
2545 // but multiple items could be selected in the changed items list
2548 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2551 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2552 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(nItem
);
2554 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2556 if ((changedlogpath
)&&(!changedlogpath
->sCopyFromPath
.IsEmpty()))
2557 rev2
= changedlogpath
->lCopyFromRev
;
2560 // if the path was modified but the parent path was 'added with history'
2561 // then we have to use the copy from revision of the parent path
2562 CTGitPath cpath
= CTGitPath(changedlogpath
->sPath
);
2563 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
2565 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->GetAt(flist
)->sPath
);
2566 if (p
.IsAncestorOf(cpath
))
2568 if (!pLogEntry
->pArChangedPaths
->GetAt(flist
)->sCopyFromPath
.IsEmpty())
2569 rev2
= pLogEntry
->pArChangedPaths
->GetAt(flist
)->lCopyFromRev
;
2574 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
2576 // some items are hidden! So find out which item the user really clicked on
2577 INT_PTR selRealIndex
= -1;
2578 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
2580 if (pLogEntry
->pArChangedPaths
->GetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
2582 if (selRealIndex
== nItem
)
2584 selIndex
= hiddenindex
;
2585 changedlogpath
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
);
2592 changedpaths
.push_back(changedlogpath
->sPath
);
2593 changedlogpaths
.push_back(changedlogpath
);
2598 //entry is selected, now show the popup menu
2600 if (popup
.CreatePopupMenu())
2602 bool bEntryAdded
= false;
2603 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2605 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
2607 popup
.AppendMenuIcon(CGitLogList::ID_DIFF
, IDS_LOG_POPUP_DIFF
, IDI_DIFF
);
2608 popup
.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF
, IDS_LOG_POPUP_BLAMEDIFF
, IDI_BLAME
);
2609 popup
.SetDefaultItem(CGitLogList::ID_DIFF
, FALSE
);
2610 popup
.AppendMenuIcon(CGitLogList::ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
2613 // if (rev2 == rev1-1)
2616 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2617 popup
.AppendMenuIcon(CGitLogList::ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
2618 popup
.AppendMenuIcon(CGitLogList::ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
2619 popup
.AppendMenuIcon(CGitLogList::ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
2620 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2622 popup
.AppendMenuIcon(CGitLogList::ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
2623 popup
.AppendMenuIcon(CGitLogList::ID_POPPROPS
, IDS_REPOBROWSE_SHOWPROP
, IDI_PROPERTIES
); // "Show Properties"
2624 popup
.AppendMenuIcon(CGitLogList::ID_LOG
, IDS_MENULOG
, IDI_LOG
); // "Show Log"
2625 popup
.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS
, IDS_LOG_POPUP_GETMERGELOGS
, IDI_LOG
); // "Show merge log"
2626 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
, IDI_SAVEAS
);
2628 if (!m_ProjectProperties
.sWebViewerPathRev
.IsEmpty())
2630 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2631 popup
.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV
, IDS_LOG_POPUP_VIEWPATHREV
);
2633 if (popup
.GetDefaultItem(0,FALSE
)==-1)
2634 popup
.SetDefaultItem(CGitLogList::ID_OPEN
, FALSE
);
2637 else if (changedlogpaths
.size())
2639 // more than one entry is selected
2640 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
);
2646 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2647 bool bOpenWith
= false;
2648 bool bMergeLog
= false;
2649 m_bCancelled
= false;
2653 case CGitLogList::ID_DIFF
:
2655 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
2661 DoDiffFromLog(selIndex
, rev1
, rev2
, true, false);
2666 DoDiffFromLog(selIndex
, rev1
, rev2
, false, true);
2671 SetPromptApp(&theApp
);
2672 theApp
.DoWaitCursor(1);
2674 if (Git::PathIsURL(m_path
))
2676 sUrl
= m_path
.GetGitPathString();
2680 sUrl
= GetURLFromPath(m_path
);
2683 theApp
.DoWaitCursor(-1);
2685 temp
.Format(IDS_ERR_NOURLOFFILE
, m_path
.GetWinPath());
2686 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2688 theApp
.DoWaitCursor(-1);
2692 // find the working copy path of the selected item from the URL
2693 m_bCancelled
= false;
2694 CString sUrlRoot
= GetRepositoryRoot(CTGitPath(sUrl
));
2696 CString fileURL
= changedpaths
[0];
2697 fileURL
= sUrlRoot
+ fileURL
.Trim();
2698 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
2699 // sUrl = http://mydomain.com/repos/trunk/folder
2700 CString sUnescapedUrl
= CPathUtils::PathUnescape(sUrl
);
2701 // find out until which char the urls are identical
2703 while ((i
<fileURL
.GetLength())&&(i
<sUnescapedUrl
.GetLength())&&(fileURL
[i
]==sUnescapedUrl
[i
]))
2705 int leftcount
= m_path
.GetWinPathString().GetLength()-(sUnescapedUrl
.GetLength()-i
);
2706 CString wcPath
= m_path
.GetWinPathString().Left(leftcount
);
2707 wcPath
+= fileURL
.Mid(i
);
2708 wcPath
.Replace('/', '\\');
2709 CGitProgressDlg dlg
;
2710 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
2712 // a deleted path! Since the path isn't there anymore, merge
2713 // won't work. So just do a copy url->wc
2714 dlg
.SetCommand(CGitProgressDlg::GitProgress_Copy
);
2715 dlg
.SetPathList(CTGitPathList(CTGitPath(fileURL
)));
2717 dlg
.SetRevision(rev2
);
2721 if (!PathFileExists(wcPath
))
2723 // seems the path got renamed
2724 // tell the user how to work around this.
2725 CMessageBox::Show(this->m_hWnd
, IDS_LOG_REVERTREV_ERROR
, IDS_APPNAME
, MB_ICONERROR
);
2727 theApp
.DoWaitCursor(-1);
2730 dlg
.SetCommand(CGitProgressDlg::GitProgress_Merge
);
2731 dlg
.SetPathList(CTGitPathList(CTGitPath(wcPath
)));
2732 dlg
.SetUrl(fileURL
);
2733 dlg
.SetSecondUrl(fileURL
);
2734 GitRevRangeArray revarray
;
2735 revarray
.AddRevRange(rev1
, rev2
);
2736 dlg
.SetRevisionRanges(revarray
);
2739 msg
.Format(IDS_LOG_REVERT_CONFIRM
, (LPCTSTR
)wcPath
);
2740 if (CMessageBox::Show(this->m_hWnd
, msg
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
2744 theApp
.DoWaitCursor(-1);
2749 DialogEnableWindow(IDOK
, FALSE
);
2750 SetPromptApp(&theApp
);
2751 theApp
.DoWaitCursor(1);
2753 if (Git::PathIsURL(m_path
))
2755 filepath
= m_path
.GetGitPathString();
2759 filepath
= GetURLFromPath(m_path
);
2760 if (filepath
.IsEmpty())
2762 theApp
.DoWaitCursor(-1);
2764 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
2765 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2766 TRACE(_T("could not retrieve the URL of the file!\n"));
2771 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
2772 filepath
+= changedpaths
[0];
2775 dlg
.m_Path
= CTGitPath(filepath
);
2778 theApp
.DoWaitCursor(-1);
2783 DialogEnableWindow(IDOK
, FALSE
);
2784 SetPromptApp(&theApp
);
2785 theApp
.DoWaitCursor(1);
2787 if (Git::PathIsURL(m_path
))
2789 filepath
= m_path
.GetGitPathString();
2793 filepath
= GetURLFromPath(m_path
);
2794 if (filepath
.IsEmpty())
2796 theApp
.DoWaitCursor(-1);
2798 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
2799 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2800 TRACE(_T("could not retrieve the URL of the file!\n"));
2805 m_bCancelled
= false;
2806 CString sRoot
= GetRepositoryRoot(CTGitPath(filepath
));
2807 // if more than one entry is selected, we save them
2808 // one by one into a folder the user has selected
2809 bool bTargetSelected
= false;
2810 CTGitPath TargetPath
;
2811 if (m_ChangedFileListCtrl
.GetSelectedCount() > 1)
2813 CBrowseFolder browseFolder
;
2814 browseFolder
.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT
)));
2815 browseFolder
.m_style
= BIF_EDITBOX
| BIF_NEWDIALOGSTYLE
| BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
;
2816 CString strSaveAsDirectory
;
2817 if (browseFolder
.Show(GetSafeHwnd(), strSaveAsDirectory
) == CBrowseFolder::OK
)
2819 TargetPath
= CTGitPath(strSaveAsDirectory
);
2820 bTargetSelected
= true;
2825 // Display the Open dialog box.
2826 CString revFilename
;
2828 temp
= CPathUtils::GetFileNameFromPath(changedpaths
[0]);
2829 int rfind
= temp
.ReverseFind('.');
2831 revFilename
.Format(_T("%s-%ld%s"), (LPCTSTR
)temp
.Left(rfind
), rev1
, (LPCTSTR
)temp
.Mid(rfind
));
2833 revFilename
.Format(_T("%s-%ld"), (LPCTSTR
)temp
, rev1
);
2834 bTargetSelected
= CAppUtils::FileOpenSave(revFilename
, NULL
, IDS_LOG_POPUP_SAVE
, IDS_COMMONFILEFILTER
, false, m_hWnd
);
2835 TargetPath
.SetFromWin(revFilename
);
2837 if (bTargetSelected
)
2839 CProgressDlg progDlg
;
2840 progDlg
.SetTitle(IDS_APPNAME
);
2841 progDlg
.SetAnimation(IDR_DOWNLOAD
);
2842 for (std::vector
<LogChangedPath
*>::iterator it
= changedlogpaths
.begin(); it
!= changedlogpaths
.end(); ++it
)
2844 GitRev getrev
= ((*it
)->action
== LOGACTIONS_DELETED
) ? rev2
: rev1
;
2847 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)getrev
.ToString());
2848 progDlg
.SetLine(1, sInfoLine
, true);
2849 SetAndClearProgressInfo(&progDlg
);
2850 progDlg
.ShowModeless(m_hWnd
);
2852 CTGitPath tempfile
= TargetPath
;
2853 if (changedpaths
.size() > 1)
2855 // if multiple items are selected, then the TargetPath
2856 // points to a folder and we have to append the filename
2857 // to save to to that folder.
2858 CString sName
= (*it
)->sPath
;
2859 int slashpos
= sName
.ReverseFind('/');
2861 sName
= sName
.Mid(slashpos
);
2862 tempfile
.AppendPathString(sName
);
2863 // one problem here:
2864 // a user could have selected multiple items which
2865 // have the same filename but reside in different
2866 // directories, e.g.
2869 // in that case, the second 'file1' will overwrite
2870 // the already saved 'file1'.
2872 // we could maybe find the common root of all selected
2873 // items and then create sub folders to save those files
2875 // But I think we should just leave it that way: to check
2876 // out multiple items at once, the better way is still to
2877 // use the export command from the top pane of the log dialog.
2879 filepath
= sRoot
+ (*it
)->sPath
;
2880 if (!Cat(CTGitPath(filepath
), getrev
, getrev
, tempfile
))
2883 SetAndClearProgressInfo((HWND
)NULL
);
2884 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
2886 theApp
.DoWaitCursor(-1);
2891 SetAndClearProgressInfo((HWND
)NULL
);
2894 theApp
.DoWaitCursor(-1);
2901 GitRev getrev
= pLogEntry
->pArChangedPaths
->GetAt(selIndex
)->action
== LOGACTIONS_DELETED
? rev2
: rev1
;
2902 Open(bOpenWith
,changedpaths
[0],getrev
);
2908 if (Git::PathIsURL(m_path
))
2910 filepath
= m_path
.GetGitPathString();
2914 filepath
= GetURLFromPath(m_path
);
2915 if (filepath
.IsEmpty())
2917 theApp
.DoWaitCursor(-1);
2919 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
2920 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2921 TRACE(_T("could not retrieve the URL of the file!\n"));
2926 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
2927 filepath
+= changedpaths
[0];
2930 if (dlg
.DoModal() == IDOK
)
2935 tempfile
= blame
.BlameToTempFile(CTGitPath(filepath
), dlg
.StartRev
, dlg
.EndRev
, dlg
.EndRev
, logfile
, _T(""), dlg
.m_bIncludeMerge
, TRUE
, TRUE
);
2936 if (!tempfile
.IsEmpty())
2938 if (dlg
.m_bTextView
)
2940 //open the default text editor for the result file
2941 CAppUtils::StartTextViewer(tempfile
);
2945 CString sParams
= _T("/path:\"") + filepath
+ _T("\" ");
2946 if(!CAppUtils::LaunchTortoiseBlame(tempfile
, logfile
, CPathUtils::GetFileNameFromPath(filepath
),sParams
))
2954 CMessageBox::Show(this->m_hWnd
, blame
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
2959 case ID_GETMERGELOGS
:
2964 DialogEnableWindow(IDOK
, FALSE
);
2965 SetPromptApp(&theApp
);
2966 theApp
.DoWaitCursor(1);
2968 if (Git::PathIsURL(m_path
))
2970 filepath
= m_path
.GetGitPathString();
2974 filepath
= GetURLFromPath(m_path
);
2975 if (filepath
.IsEmpty())
2977 theApp
.DoWaitCursor(-1);
2979 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
2980 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2981 TRACE(_T("could not retrieve the URL of the file!\n"));
2986 m_bCancelled
= false;
2987 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
2988 filepath
+= changedpaths
[0];
2989 git_revnum_t logrev
= rev1
;
2990 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
2992 // if the item got deleted in this revision,
2993 // fetch the log from the previous revision where it
2998 sCmd
.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR
)filepath
, logrev
);
3000 sCmd
+= _T(" /merge");
3001 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
3003 theApp
.DoWaitCursor(-1);
3006 case ID_VIEWPATHREV
:
3008 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetSelectionMark()));
3009 GitRev rev
= pLogEntry
->Rev
;
3010 CString relurl
= changedpaths
[0];
3011 CString url
= m_ProjectProperties
.sWebViewerPathRev
;
3012 url
.Replace(_T("%REVISION%"), rev
.ToString());
3013 url
.Replace(_T("%PATH%"), relurl
);
3014 relurl
= relurl
.Mid(relurl
.Find('/'));
3015 url
.Replace(_T("%PATH1%"), relurl
);
3017 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
3025 } // if (popup.CreatePopupMenu())
3029 void CLogDlg::OnDtnDropdownDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3031 // the date control should not show the "today" button
3032 CMonthCalCtrl
* pCtrl
= m_DateFrom
.GetMonthCalCtrl();
3034 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3038 void CLogDlg::OnDtnDropdownDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3040 // the date control should not show the "today" button
3041 CMonthCalCtrl
* pCtrl
= m_DateTo
.GetMonthCalCtrl();
3043 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3047 void CLogDlg::OnSize(UINT nType
, int cx
, int cy
)
3049 __super::OnSize(nType
, cx
, cy
);
3054 void CLogDlg::OnRefresh()
3056 //if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
3060 this->m_LogProgress
.SetPos(0);
3068 void CLogDlg::OnFocusFilter()
3070 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3073 void CLogDlg::OnEditCopy()
3075 if (GetFocus() == &m_ChangedFileListCtrl
)
3076 CopyChangedSelectionToClipBoard();
3078 m_LogList
.CopySelectionToClipBoard();
3081 CString
CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString
& url
)
3083 // is the URL a relative one?
3084 if (url
.Left(2).Compare(_T("^/")) == 0)
3086 // URL is relative to the repository root
3087 CString url1
= m_sRepositoryRoot
+ url
.Mid(1);
3088 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3089 DWORD len
= url
.GetLength();
3090 if (UrlCanonicalize((LPCTSTR
)url1
, buf
, &len
, 0) == S_OK
)
3091 return CString(buf
, len
);
3094 else if (url
[0] == '/')
3096 // URL is relative to the server's hostname
3098 // find the server's hostname
3099 int schemepos
= m_sRepositoryRoot
.Find(_T("//"));
3102 sHost
= m_sRepositoryRoot
.Left(m_sRepositoryRoot
.Find('/', schemepos
+3));
3103 CString url1
= sHost
+ url
;
3104 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3105 DWORD len
= url
.GetLength();
3106 if (UrlCanonicalize((LPCTSTR
)url
, buf
, &len
, 0) == S_OK
)
3107 return CString(buf
, len
);
3115 void CLogDlg::OnEnChangeSearchedit()
3118 if (m_LogList
.m_sFilterText
.IsEmpty())
3120 CStoreSelection
storeselection(this);
3121 // clear the filter, i.e. make all entries appear
3122 theApp
.DoWaitCursor(1);
3123 KillTimer(LOGFILTER_TIMER
);
3124 FillLogMessageCtrl(false);
3125 m_LogList
.StartFilter();
3127 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3128 m_arShownList
.RemoveAll();
3129 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3131 if (IsEntryInDateRange(i
))
3132 m_arShownList
.Add(m_logEntries
[i
]);
3134 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3135 m_LogList
.DeleteAllItems();
3136 m_LogList
.SetItemCountEx(ShownCountWithStopped());
3137 m_LogList
.RedrawItems(0, ShownCountWithStopped());
3138 m_LogList
.SetRedraw(false);
3139 ResizeAllListCtrlCols();
3140 m_LogList
.SetRedraw(true);
3142 theApp
.DoWaitCursor(-1);
3143 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
3144 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
3145 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3146 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
3149 if (Validate(m_LogList
.m_sFilterText
))
3150 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
3152 KillTimer(LOGFILTER_TIMER
);
3156 void CLogDlg::OnBnClickedAllBranch()
3160 if(this->m_bAllBranch
)
3161 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_ALL_BRANCH
;
3163 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_ALL_BRANCH
;
3167 FillLogMessageCtrl(false);
3170 void CLogDlg::OnBnClickedBrowseRef()
3172 CString newRef
= CBrowseRefsDlg::PickRef(false,m_LogList
.GetStartRef());
3173 if(newRef
.IsEmpty())
3176 SetStartRef(newRef
);
3177 ((CButton
*)GetDlgItem(IDC_LOG_ALLBRANCH
))->SetCheck(0);
3179 OnBnClickedAllBranch();
3182 void CLogDlg::ShowStartRef()
3184 //Show ref name on top
3185 if(!::IsWindow(m_hWnd
))
3189 m_staticRef
.SetWindowText(L
"<All Branches>");
3190 m_staticRef
.Invalidate(TRUE
);
3194 CString showStartRef
= m_LogList
.GetStartRef();
3195 if(showStartRef
.IsEmpty())
3198 if( g_Git
.Run(L
"git symbolic-ref HEAD",&showStartRef
,CP_UTF8
) )
3199 showStartRef
= _T("<No branch>");
3200 showStartRef
.Trim(L
"\r\n\t ");
3204 if(wcsncmp(showStartRef
,L
"refs/",5) == 0)
3205 showStartRef
= showStartRef
.Mid(5);
3206 if(wcsncmp(showStartRef
,L
"heads/",6) == 0)
3207 showStartRef
= showStartRef
.Mid(6);
3209 m_staticRef
.SetWindowText(showStartRef
);
3210 m_staticRef
.Invalidate(TRUE
);
3213 void CLogDlg::SetStartRef(const CString
& StartRef
)
3215 m_LogList
.SetStartRef(StartRef
);
3222 void CLogDlg::OnBnClickedFirstParent()
3226 if(this->m_bFirstParent
)
3227 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_FIRST_PARENT
;
3229 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_FIRST_PARENT
;
3233 FillLogMessageCtrl(false);
3237 void CLogDlg::OnBnClickShowWholeProject()
3241 if(this->m_bWholeProject
)
3243 m_LogList
.m_Path
.Reset();
3244 SetWindowText(m_sTitle
+ _T(" - ") + CString(_T("Whole Project")));
3248 m_LogList
.m_Path
=m_path
;
3249 if(!m_path
.IsEmpty())
3250 SetWindowText(m_sTitle
+ _T(" - ") + m_path
.GetGitPathString());
3255 FillLogMessageCtrl(false);