1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2011 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "TortoiseProc.h"
24 #include "GITProgressDlg.h"
25 #include "ProgressDlg.h"
26 //#include "RepositoryBrowser.h"
27 //#include "CopyDlg.h"
28 #include "StatGraphDlg.h"
30 #include "MessageBox.h"
33 #include "PathUtils.h"
34 #include "StringUtils.h"
35 #include "UnicodeUtils.h"
37 //#include "GitInfo.h"
38 //#include "GitDiff.h"
40 //#include "RevisionRangeDlg.h"
41 //#include "BrowseFolder.h"
42 //#include "BlameDlg.h"
44 //#include "GitHelpers.h"
45 #include "GitStatus.h"
46 //#include "LogDlgHelper.h"
47 //#include "CachedLogInfo.h"
48 //#include "RepositoryInfo.h"
49 //#include "EditPropertiesDlg.h"
50 #include "FileDiffDlg.h"
51 #include "BrowseRefsDlg.h"
54 IMPLEMENT_DYNAMIC(CLogDlg
, CResizableStandAloneDialog
)
55 CLogDlg::CLogDlg(CWnd
* pParent
/*=NULL*/)
56 : CResizableStandAloneDialog(CLogDlg::IDD
, pParent
)
59 , m_currentChangedArray(NULL
)
64 , m_bSelectionMustBeContinuous(false)
70 , m_pNotifyWindow(NULL
)
77 , m_bIncludeMerges(FALSE
)
80 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
83 str
=g_Git
.m_CurrentDir
;
84 str
.Replace(_T(":"),_T("_"));
85 str
=CString(_T("Software\\TortoiseGit\\LogDialog\\AllBranch\\"))+str
;
87 m_regbAllBranch
=CRegDWORD(str
,FALSE
);
89 m_bAllBranch
=m_regbAllBranch
;
92 m_bWholeProject
=FALSE
;
98 m_regbAllBranch
=m_bAllBranch
;
100 m_CurrentFilteredChangedArray
.RemoveAll();
104 void CLogDlg::DoDataExchange(CDataExchange
* pDX
)
106 CResizableStandAloneDialog::DoDataExchange(pDX
);
107 DDX_Control(pDX
, IDC_LOGLIST
, m_LogList
);
108 DDX_Control(pDX
, IDC_LOGMSG
, m_ChangedFileListCtrl
);
109 DDX_Control(pDX
, IDC_PROGRESS
, m_LogProgress
);
110 DDX_Control(pDX
, IDC_SPLITTERTOP
, m_wndSplitter1
);
111 DDX_Control(pDX
, IDC_SPLITTERBOTTOM
, m_wndSplitter2
);
112 DDX_Text(pDX
, IDC_SEARCHEDIT
, m_LogList
.m_sFilterText
);
113 DDX_Control(pDX
, IDC_DATEFROM
, m_DateFrom
);
114 DDX_Control(pDX
, IDC_DATETO
, m_DateTo
);
115 DDX_Control(pDX
, IDC_HIDEPATHS
, m_cHidePaths
);
116 DDX_Text(pDX
, IDC_LOGINFO
, m_sLogInfo
);
117 DDX_Check(pDX
, IDC_LOG_FIRSTPARENT
, m_bFirstParent
);
118 DDX_Check(pDX
, IDC_LOG_ALLBRANCH
,m_bAllBranch
);
119 DDX_Check(pDX
, IDC_SHOWWHOLEPROJECT
,m_bWholeProject
);
120 DDX_Control(pDX
, IDC_SEARCHEDIT
, m_cFilter
);
121 DDX_Control(pDX
, IDC_STATIC_REF
, m_staticRef
);
124 BEGIN_MESSAGE_MAP(CLogDlg
, CResizableStandAloneDialog
)
125 //ON_BN_CLICKED(IDC_GETALL, OnBnClickedGetall)
126 //ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)
129 ON_BN_CLICKED(IDHELP
, OnBnClickedHelp
)
130 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_LOGLIST
, OnLvnItemchangedLoglist
)
131 ON_NOTIFY(EN_LINK
, IDC_MSGVIEW
, OnEnLinkMsgview
)
132 ON_BN_CLICKED(IDC_STATBUTTON
, OnBnClickedStatbutton
)
135 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED
, OnClickedInfoIcon
)
136 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED
, OnClickedCancelFilter
)
138 ON_MESSAGE(MSG_LOAD_PERCENTAGE
,OnLogListLoading
)
140 ON_EN_CHANGE(IDC_SEARCHEDIT
, OnEnChangeSearchedit
)
142 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATETO
, OnDtnDatetimechangeDateto
)
143 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATEFROM
, OnDtnDatetimechangeDatefrom
)
144 ON_BN_CLICKED(IDC_SHOWWHOLEPROJECT
, OnBnClickShowWholeProject
)
145 //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
146 //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
147 ON_NOTIFY(LVN_COLUMNCLICK
,IDC_LOGLIST
, OnLvnColumnclick
)
148 //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
149 ON_BN_CLICKED(IDC_HIDEPATHS
, OnBnClickedHidepaths
)
150 ON_COMMAND(MSG_FETCHED_DIFF
, OnBnClickedHidepaths
)
151 ON_BN_CLICKED(IDC_LOG_ALLBRANCH
, OnBnClickedAllBranch
)
153 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATEFROM
, &CLogDlg::OnDtnDropdownDatefrom
)
154 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATETO
, &CLogDlg::OnDtnDropdownDateto
)
156 ON_BN_CLICKED(IDC_LOG_FIRSTPARENT
, &CLogDlg::OnBnClickedFirstParent
)
157 ON_BN_CLICKED(IDC_REFRESH
, &CLogDlg::OnBnClickedRefresh
)
158 // ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CLogDlg::OnBnClickedBrowseRef)
159 ON_STN_CLICKED(IDC_STATIC_REF
, &CLogDlg::OnBnClickedBrowseRef
)
160 ON_COMMAND(ID_LOGDLG_REFRESH
, &CLogDlg::OnBnClickedRefresh
)
161 ON_COMMAND(ID_LOGDLG_FIND
, &CLogDlg::OnFind
)
162 ON_COMMAND(ID_LOGDLG_FOCUSFILTER
, &CLogDlg::OnFocusFilter
)
163 ON_COMMAND(ID_EDIT_COPY
, &CLogDlg::OnEditCopy
)
164 ON_MESSAGE(MSG_REFLOG_CHANGED
, OnRefLogChanged
)
165 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED
, OnTaskbarBtnCreated
)
168 void CLogDlg::SetParams(const CTGitPath
& orgPath
, const CTGitPath
& path
, CString hightlightRevision
, CString startrev
, CString endrev
, int limit
/* = FALSE */)
172 m_hightlightRevision
= hightlightRevision
;
173 this->m_LogList
.m_startrev
= startrev
;
174 m_LogRevision
= startrev
;
175 this->m_LogList
.m_endrev
= endrev
;
177 if(!endrev
.IsEmpty())
178 this->SetStartRef(endrev
);
180 m_hasWC
= !path
.IsUrl();
182 if (::IsWindow(m_hWnd
))
186 BOOL
CLogDlg::OnInitDialog()
189 CResizableStandAloneDialog::OnInitDialog();
190 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
192 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
193 // do this, Explorer would be unable to send that message to our window if we
194 // were running elevated. It's OK to make the call all the time, since if we're
195 // not elevated, this is a no-op.
196 CHANGEFILTERSTRUCT cfs
= { sizeof(CHANGEFILTERSTRUCT
) };
197 typedef BOOL STDAPICALLTYPE
ChangeWindowMessageFilterExDFN(HWND hWnd
, UINT message
, DWORD action
, PCHANGEFILTERSTRUCT pChangeFilterStruct
);
198 HMODULE hUser
= ::LoadLibrary(_T("user32.dll"));
201 ChangeWindowMessageFilterExDFN
*pfnChangeWindowMessageFilterEx
= (ChangeWindowMessageFilterExDFN
*)GetProcAddress(hUser
, "ChangeWindowMessageFilterEx");
202 if (pfnChangeWindowMessageFilterEx
)
204 pfnChangeWindowMessageFilterEx(m_hWnd
, WM_TASKBARBTNCREATED
, MSGFLT_ALLOW
, &cfs
);
208 m_pTaskbarList
.Release();
209 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);
211 m_hAccel
= LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG
));
213 // use the state of the "stop on copy/rename" option from the last time
216 // set the font to use in the log message view, configured in the settings dialog
217 CAppUtils::CreateFontForLogs(m_logFont
);
218 GetDlgItem(IDC_MSGVIEW
)->SetFont(&m_logFont
);
219 // automatically detect URLs in the log message and turn them into links
220 GetDlgItem(IDC_MSGVIEW
)->SendMessage(EM_AUTOURLDETECT
, TRUE
, NULL
);
221 // make the log message rich edit control send a message when the mouse pointer is over a link
222 GetDlgItem(IDC_MSGVIEW
)->SendMessage(EM_SETEVENTMASK
, NULL
, ENM_LINK
);
223 //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
225 // the "hide unrelated paths" checkbox should be indeterminate
226 m_cHidePaths
.SetCheck(BST_INDETERMINATE
);
229 //SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
230 //SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
232 // set up the columns
233 m_LogList
.DeleteAllItems();
235 m_LogList
.m_Path
=m_path
;
236 m_LogList
.m_bShowWC
= true;
237 m_LogList
.InsertGitColumn();
239 m_ChangedFileListCtrl
.Init(GITSLC_COLEXT
| GITSLC_COLSTATUS
|GITSLC_COLADD
|GITSLC_COLDEL
, _T("LogDlg"),(GITSLC_POPALL
^ (GITSLC_POPCOMMIT
|GITSLC_POPIGNORE
)),false);
241 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
244 m_sMessageBuf
.Preallocate(100000);
248 m_tooltips
.Create(this);
249 CheckRegexpTooltip();
253 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
254 m_cFilter
.SetCancelBitmaps(IDI_CANCELNORMAL
, IDI_CANCELPRESSED
);
255 m_cFilter
.SetInfoIcon(IDI_LOGFILTER
);
256 m_cFilter
.SetValidator(this);
258 AdjustControlSize(IDC_HIDEPATHS
);
259 AdjustControlSize(IDC_LOG_FIRSTPARENT
);
260 AdjustControlSize(IDC_LOG_ALLBRANCH
);
262 GetClientRect(m_DlgOrigRect
);
263 m_LogList
.GetClientRect(m_LogListOrigRect
);
264 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(m_MsgViewOrigRect
);
265 m_ChangedFileListCtrl
.GetClientRect(m_ChgOrigRect
);
267 m_DateFrom
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
268 m_DateTo
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
270 m_staticRef
.SetURL(CString());
273 AddAnchor(IDC_STATIC_REF
, TOP_LEFT
);
274 //AddAnchor(IDC_BUTTON_BROWSE_REF, TOP_LEFT);
275 AddAnchor(IDC_FROMLABEL
, TOP_LEFT
);
276 AddAnchor(IDC_DATEFROM
, TOP_LEFT
);
277 AddAnchor(IDC_TOLABEL
, TOP_LEFT
);
278 AddAnchor(IDC_DATETO
, TOP_LEFT
);
281 AddAnchor(IDC_SEARCHEDIT
, TOP_LEFT
, TOP_RIGHT
);
283 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
284 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
285 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
286 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
287 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
289 AddAnchor(IDC_LOGINFO
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
290 AddAnchor(IDC_HIDEPATHS
, BOTTOM_LEFT
);
291 AddAnchor(IDC_LOG_ALLBRANCH
,BOTTOM_LEFT
);
292 AddAnchor(IDC_LOG_FIRSTPARENT
, BOTTOM_LEFT
);
293 //AddAnchor(IDC_GETALL, BOTTOM_LEFT);
294 AddAnchor(IDC_SHOWWHOLEPROJECT
, BOTTOM_LEFT
);
295 AddAnchor(IDC_REFRESH
, BOTTOM_LEFT
);
296 AddAnchor(IDC_STATBUTTON
, BOTTOM_RIGHT
);
297 AddAnchor(IDC_PROGRESS
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
298 AddAnchor(IDOK
, BOTTOM_RIGHT
);
299 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
300 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
302 if(this->m_bAllBranch
)
303 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_ALL_BRANCH
;
305 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_ALL_BRANCH
;
307 // SetPromptParentWindow(m_hWnd);
310 CenterWindow(CWnd::FromHandle(hWndExplorer
));
311 EnableSaveRestore(_T("LogDlg"));
313 DWORD yPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
314 DWORD yPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
315 RECT rcDlg
, rcLogList
, rcChgMsg
;
316 GetClientRect(&rcDlg
);
317 m_LogList
.GetWindowRect(&rcLogList
);
318 ScreenToClient(&rcLogList
);
319 m_ChangedFileListCtrl
.GetWindowRect(&rcChgMsg
);
320 ScreenToClient(&rcChgMsg
);
324 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
325 ScreenToClient(&rectSplitter
);
326 int delta
= yPos1
- rectSplitter
.top
;
328 if ((rcLogList
.bottom
+ delta
> rcLogList
.top
)&&(rcLogList
.bottom
+ delta
< rcChgMsg
.bottom
- 30))
330 m_wndSplitter1
.SetWindowPos(NULL
, 0, yPos1
, 0, 0, SWP_NOSIZE
);
337 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
338 ScreenToClient(&rectSplitter
);
339 int delta
= yPos2
- rectSplitter
.top
;
341 if ((rcChgMsg
.top
+ delta
< rcChgMsg
.bottom
)&&(rcChgMsg
.top
+ delta
> rcLogList
.top
+ 30))
343 m_wndSplitter2
.SetWindowPos(NULL
, 0, yPos2
, 0, 0, SWP_NOSIZE
);
351 // the dialog is used to select revisions
352 // enable the OK button if appropriate
357 // the dialog is used to just view log messages
358 // hide the OK button and set text on Cancel button to OK
359 GetDlgItemText(IDOK
, temp
);
360 SetDlgItemText(IDCANCEL
, temp
);
361 GetDlgItem(IDOK
)->ShowWindow(SW_HIDE
);
364 m_mergedRevs
.clear();
366 // first start a thread to obtain the log messages without
367 // blocking the dialog
369 //m_tFrom = (DWORD)-1;
371 // scroll to user selected or current revision
372 if (!m_hightlightRevision
.IsEmpty() && m_hightlightRevision
.GetLength() >= GIT_HASH_SIZE
)
373 m_LogList
.m_lastSelectedHash
= m_hightlightRevision
;
374 else if (!m_LogList
.m_endrev
.IsEmpty() && m_LogList
.m_endrev
.GetLength() >= GIT_HASH_SIZE
)
375 m_LogList
.m_lastSelectedHash
= m_hightlightRevision
;
377 m_LogList
.m_lastSelectedHash
= g_Git
.GetHash(_T("HEAD"));
379 m_LogList
.FetchLogAsync(this);
381 GetDlgItem(IDC_LOGLIST
)->SetFocus();
387 LRESULT
CLogDlg::OnLogListLoading(WPARAM wParam
, LPARAM
/*lParam*/)
391 if( cur
== GITLOG_START
)
394 temp
.LoadString(IDS_PROGRESSWAIT
);
396 this->m_LogList
.ShowText(temp
, true);
398 // We use a progress bar while getting the logs
399 m_LogProgress
.SetRange32(0, 100);
400 m_LogProgress
.SetPos(0);
403 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
404 m_pTaskbarList
->SetProgressValue(m_hWnd
, 0, 100);
407 GetDlgItem(IDC_PROGRESS
)->ShowWindow(TRUE
);
409 //DialogEnableWindow(IDC_GETALL, FALSE);
410 //DialogEnableWindow(IDC_SHOWWHOLEPROJECT, FALSE);
411 //DialogEnableWindow(IDC_LOG_FIRSTPARENT, FALSE);
412 DialogEnableWindow(IDC_STATBUTTON
, FALSE
);
413 //DialogEnableWindow(IDC_REFRESH, FALSE);
414 DialogEnableWindow(IDC_HIDEPATHS
,FALSE
);
417 else if( cur
== GITLOG_END
)
419 if(this->m_LogList
.HasText())
421 this->m_LogList
.ClearText();
423 UpdateLogInfoLabel();
426 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NOPROGRESS
);
429 DialogEnableWindow(IDC_SHOWWHOLEPROJECT
, TRUE
);
431 //DialogEnableWindow(IDC_GETALL, TRUE);
432 DialogEnableWindow(IDC_STATBUTTON
, !(m_LogList
.m_arShownList
.IsEmpty() || m_LogList
.m_arShownList
.GetCount() == 1 && m_LogList
.m_bShowWC
));
433 DialogEnableWindow(IDC_REFRESH
, TRUE
);
434 DialogEnableWindow(IDC_HIDEPATHS
,TRUE
);
436 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
437 GetDlgItem(IDC_PROGRESS
)->ShowWindow(FALSE
);
438 //CTime time=m_LogList.GetOldestTime();
440 m_LogList
.GetTimeRange(begin
,end
);
442 if(m_LogList
.m_From
== -1)
443 m_DateFrom
.SetTime(&begin
);
445 if(m_LogList
.m_To
== -1)
446 m_DateTo
.SetTime(&end
);
452 if(this->m_LogList
.HasText())
454 this->m_LogList
.ClearText();
455 this->m_LogList
.Invalidate();
457 UpdateLogInfoLabel();
458 m_LogProgress
.SetPos(cur
);
461 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
462 m_pTaskbarList
->SetProgressValue(m_hWnd
, cur
, 100);
467 void CLogDlg::SetDlgTitle()
469 if (m_sTitle
.IsEmpty())
470 GetWindowText(m_sTitle
);
472 if (m_LogList
.m_Path
.IsEmpty() || m_orgPath
.GetWinPathString().IsEmpty())
474 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, m_sTitle
);
477 CAppUtils::SetWindowTitle(m_hWnd
, m_orgPath
.GetWinPathString(), m_sTitle
);
480 void CLogDlg::CheckRegexpTooltip()
482 CWnd
*pWnd
= GetDlgItem(IDC_SEARCHEDIT
);
483 // Since tooltip describes regexp features, show it only if regexps are enabled.
484 if (m_bFilterWithRegex
)
486 m_tooltips
.AddTool(pWnd
, IDS_LOG_FILTER_REGEX_TT
);
489 m_tooltips
.DelTool(pWnd
);
492 void CLogDlg::EnableOKButton()
496 // the dialog is used to select revisions
497 if (m_bSelectionMustBeSingle
)
499 // enable OK button if only a single revision is selected
500 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()==1));
502 else if (m_bSelectionMustBeContinuous
)
503 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()!=0)&&(m_LogList
.IsSelectionContinuous()));
505 DialogEnableWindow(IDOK
, m_LogList
.GetSelectedCount()!=0);
508 DialogEnableWindow(IDOK
, TRUE
);
511 CString
CLogDlg::GetTagInfo(GitRev
* pLogEntry
)
516 if(m_LogList
.m_HashMap
.find(pLogEntry
->m_CommitHash
) != m_LogList
.m_HashMap
.end())
518 STRING_VECTOR
&vector
= m_LogList
.m_HashMap
[pLogEntry
->m_CommitHash
];
519 for(int i
=0;i
<vector
.size();i
++)
521 if(vector
[i
].Find(_T("refs/tags/")) == 0 )
523 CString tag
= vector
[i
];
524 int start
= vector
[i
].Find(_T("^{}"));
530 cmd
.Format(_T("git.exe cat-file tag %s"), tag
);
532 if(g_Git
.Run(cmd
, &output
, NULL
, CP_UTF8
) == 0 )
538 if(!output
.IsEmpty())
540 output
= _T("\n*Tag Info*\n\n") + output
;
546 void CLogDlg::FillLogMessageCtrl(bool bShow
/* = true*/)
548 // we fill here the log message rich edit control,
549 // and also populate the changed files list control
550 // according to the selected revision(s).
552 CRichEditCtrl
* pMsgView
= (CRichEditCtrl
*)GetDlgItem(IDC_MSGVIEW
);
553 // empty the log message view
554 pMsgView
->SetWindowText(_T(" "));
555 // empty the changed files list
556 m_ChangedFileListCtrl
.SetRedraw(FALSE
);
557 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
558 m_currentChangedArray
= NULL
;
559 //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
560 m_ChangedFileListCtrl
.DeleteAllItems();
562 // if we're not here to really show a selected revision, just
563 // get out of here after clearing the views, which is what is intended
564 // if that flag is not set.
568 m_ChangedFileListCtrl
.Invalidate();
569 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
570 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
574 // depending on how many revisions are selected, we have to do different
576 int selCount
= m_LogList
.GetSelectedCount();
579 // if nothing is selected, we have nothing more to do
580 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
581 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
584 else if (selCount
== 1)
586 // if one revision is selected, we have to fill the log message view
587 // with the corresponding log message, and also fill the changed files
589 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
590 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
591 if (selIndex
>= m_LogList
.m_arShownList
.GetCount())
593 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
594 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
597 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(selIndex
));
600 // set the log message text
601 pMsgView
->SetWindowText(_T("Commit:")+pLogEntry
->m_CommitHash
.ToString()+_T("\r\n\r\n"));
602 // turn bug ID's into links if the bugtraq: properties have been set
603 // and we can find a match of those in the log message
605 pMsgView
->SetSel(-1,-1);
607 SecureZeroMemory(&format
, sizeof(CHARFORMAT2
));
608 format
.cbSize
= sizeof(CHARFORMAT2
);
609 format
.dwMask
= CFM_BOLD
;
610 format
.dwEffects
= CFE_BOLD
;
611 pMsgView
->SendMessage(EM_SETCHARFORMAT
, SCF_SELECTION
, (LPARAM
)&format
);
613 CString msg
=_T("* ");
614 msg
+=pLogEntry
->GetSubject();
615 pMsgView
->ReplaceSel(msg
);
617 pMsgView
->SetSel(-1,-1);
618 format
.dwEffects
= 0;
619 pMsgView
->SendMessage(EM_SETCHARFORMAT
, SCF_SELECTION
, (LPARAM
)&format
);
622 msg
+=pLogEntry
->GetBody();
624 if(!pLogEntry
->m_Notes
.IsEmpty())
626 msg
+= _T("\n*Notes* ");
627 msg
+= pLogEntry
->m_Notes
;
631 msg
+=GetTagInfo(pLogEntry
);
633 pMsgView
->ReplaceSel(msg
);
636 pMsgView
->GetWindowText(text
);
637 // the rich edit control doesn't count the CR char!
638 // to be exact: CRLF is treated as one char.
641 m_LogList
.m_ProjectProperties
.FindBugID(text
, pMsgView
);
642 CAppUtils::FormatTextInRichEditControl(pMsgView
);
644 int HidePaths
=m_cHidePaths
.GetState() & 0x0003;
645 CString matchpath
=this->m_path
.GetGitPathString();
647 int count
= pLogEntry
->GetFiles(&m_LogList
).GetCount();
648 for(int i
=0;i
<count
&& (!matchpath
.IsEmpty());i
++)
650 if( m_bWholeProject
)
653 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
&= ~(CTGitPath::LOGACTIONS_HIDE
|CTGitPath::LOGACTIONS_GRAY
);
655 if(pLogEntry
->GetFiles(&m_LogList
)[i
].GetGitPathString().Left(matchpath
.GetLength()) != matchpath
)
657 if(HidePaths
==BST_CHECKED
)
658 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
|= CTGitPath::LOGACTIONS_HIDE
;
659 if(HidePaths
==BST_INDETERMINATE
)
660 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
|= CTGitPath::LOGACTIONS_GRAY
;
664 m_ChangedFileListCtrl
.UpdateWithGitPathList(pLogEntry
->GetFiles(&m_LogList
));
665 m_ChangedFileListCtrl
.m_CurrentVersion
=pLogEntry
->m_CommitHash
;
666 m_ChangedFileListCtrl
.Show(GITSLC_SHOWVERSIONED
);
668 m_ChangedFileListCtrl
.SetBusyString(_T("Fetch Changed File..."));
670 if(!pLogEntry
->m_IsDiffFiles
)
671 m_ChangedFileListCtrl
.SetBusy(TRUE
);
673 m_ChangedFileListCtrl
.SetBusy(FALSE
);
675 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
682 // more than one revision is selected:
683 // the log message view must be emptied
684 // the changed files list contains all the changed paths from all
685 // selected revisions, with 'doubles' removed
686 m_currentChangedPathList
= GetChangedPathsFromSelectedRevisions(true);
690 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
692 if (m_currentChangedArray
)
694 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedArray
->GetCount());
695 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedArray
->GetCount());
697 else if (m_currentChangedPathList
.GetCount())
699 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedPathList
.GetCount());
700 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedPathList
.GetCount());
704 m_ChangedFileListCtrl
.SetItemCountEx(0);
705 m_ChangedFileListCtrl
.Invalidate();
708 // sort according to the settings
709 if (m_nSortColumnPathList
> 0)
710 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
712 SetSortArrow(&m_ChangedFileListCtrl
, -1, false);
713 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
717 void CLogDlg::OnBnClickedRefresh()
722 void CLogDlg::Refresh (bool clearfilter
/*autoGoOnline*/)
725 m_LogList
.Refresh(clearfilter
);
726 FillLogMessageCtrl(false);
731 BOOL
CLogDlg::Cancel()
736 void CLogDlg::SaveSplitterPos()
740 CRegDWORD regPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
741 CRegDWORD regPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
743 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
744 ScreenToClient(&rectSplitter
);
745 regPos1
= rectSplitter
.top
;
746 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
747 ScreenToClient(&rectSplitter
);
748 regPos2
= rectSplitter
.top
;
752 void CLogDlg::OnCancel()
754 this->ShowWindow(SW_HIDE
);
756 // canceling means stopping the working thread if it's still running.
757 m_LogList
.SafeTerminateAsyncDiffThread();
758 if (this->IsThreadRunning())
760 m_LogList
.SafeTerminateThread();
768 CString
CLogDlg::MakeShortMessage(const CString
& message
)
770 bool bFoundShort
= true;
771 CString sShortMessage
= m_LogList
.m_ProjectProperties
.GetLogSummary(message
);
772 if (sShortMessage
.IsEmpty())
775 sShortMessage
= message
;
777 // Remove newlines and tabs 'cause those are not shown nicely in the list control
778 sShortMessage
.Remove('\r');
779 sShortMessage
.Replace(_T('\t'), _T(' '));
781 // Suppose the first empty line separates 'summary' from the rest of the message.
782 int found
= sShortMessage
.Find(_T("\n\n"));
783 // To avoid too short 'short' messages
784 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
785 // only use the empty newline as a separator if it comes after at least 15 chars.
786 if ((!bFoundShort
)&&(found
>= 15))
788 sShortMessage
= sShortMessage
.Left(found
);
790 sShortMessage
.Replace('\n', ' ');
791 return sShortMessage
;
794 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*/)
797 if (rev
== SVN_INVALID_REVNUM
)
803 // this is the callback function which receives the data for every revision we ask the log for
804 // we store this information here one by one.
806 if (m_startrev
== -1)
811 m_LogProgress
.SetPos(m_limit
- m_limitcounter
);
813 else if (m_startrev
.IsNumber() && m_startrev
.IsNumber())
814 m_LogProgress
.SetPos((git_revnum_t
)m_startrev
-rev
+(git_revnum_t
)m_endrev
);
815 __time64_t ttime
= time
/1000000L;
816 if (m_tTo
< (DWORD
)ttime
)
817 m_tTo
= (DWORD
)ttime
;
818 if (m_tFrom
> (DWORD
)ttime
)
819 m_tFrom
= (DWORD
)ttime
;
820 if ((m_lowestRev
> rev
)||(m_lowestRev
< 0))
822 // Add as many characters from the log message to the list control
823 PLOGENTRYDATA pLogItem
= new LOGENTRYDATA
;
824 pLogItem
->bCopies
= !!copies
;
826 // find out if this item was copied in the revision
827 BOOL copiedself
= FALSE
;
830 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< cpaths
->GetCount(); ++cpPathIndex
)
832 LogChangedPath
* cpath
= cpaths
->SafeGetAt(cpPathIndex
);
833 if (!cpath
->sCopyFromPath
.IsEmpty() && (cpath
->sPath
.Compare(m_sSelfRelativeURL
) == 0))
835 // note: this only works if the log is fetched top-to-bottom
836 // but since we do that, it shouldn't be a problem
837 m_sSelfRelativeURL
= cpath
->sCopyFromPath
;
843 pLogItem
->bCopiedSelf
= copiedself
;
844 pLogItem
->tmDate
= ttime
;
845 pLogItem
->sAuthor
= author
;
846 pLogItem
->sDate
= date
;
847 pLogItem
->sShortMessage
= MakeShortMessage(message
);
848 pLogItem
->dwFileChanges
= filechanges
;
849 pLogItem
->actions
= actions
;
850 pLogItem
->haschildren
= haschildren
;
851 pLogItem
->childStackDepth
= m_childCounter
;
852 m_maxChild
= max(m_childCounter
, m_maxChild
);
855 pLogItem
->sBugIDs
= m_ProjectProperties
.FindBugID(message
).Trim();
857 // split multi line log entries and concatenate them
858 // again but this time with \r\n as line separators
859 // so that the edit control recognizes them
862 if (message
.GetLength()>0)
864 m_sMessageBuf
= message
;
865 m_sMessageBuf
.Replace(_T("\n\r"), _T("\n"));
866 m_sMessageBuf
.Replace(_T("\r\n"), _T("\n"));
867 if (m_sMessageBuf
.Right(1).Compare(_T("\n"))==0)
868 m_sMessageBuf
= m_sMessageBuf
.Left(m_sMessageBuf
.GetLength()-1);
871 m_sMessageBuf
.Empty();
872 pLogItem
->sMessage
= m_sMessageBuf
;
875 // move-construct path array
877 pLogItem
->pArChangedPaths
= new LogChangedPathArray (*cpaths
);
880 catch (CException
* e
)
882 ::MessageBox(NULL
, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR
);
886 m_logEntries
.push_back(pLogItem
);
887 m_arShownList
.Add(pLogItem
);
893 //this is the thread function which calls the subversion function
898 void CLogDlg::CopyChangedSelectionToClipBoard()
901 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
903 return; // nothing is selected, get out of here
907 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
910 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
913 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
914 CTGitPath
*path
= (CTGitPath
*)m_ChangedFileListCtrl
.GetItemData(nItem
);
916 sPaths
+= path
->GetGitPathString();
917 sPaths
+= _T("\r\n");
923 // only one revision is selected in the log dialog top pane
924 // but multiple items could be selected in the changed items list
925 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
928 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
929 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(nItem
);
931 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
933 // some items are hidden! So find out which item the user really selected
934 INT_PTR selRealIndex
= -1;
935 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
937 if (pLogEntry
->pArChangedPaths
->SafeGetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
939 if (selRealIndex
== nItem
)
941 changedlogpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(hiddenindex
);
948 sPaths
+= changedlogpath
->sPath
;
949 sPaths
+= _T("\r\n");
955 CStringUtils::WriteAsciiStringToClipboard(sPaths
, GetSafeHwnd());
959 BOOL
CLogDlg::IsDiffPossible(LogChangedPath
* /*changedpath*/, git_revnum_t rev
)
962 CString added
, deleted
;
963 if (changedpath
== NULL
)
966 if ((rev
> 1)&&(changedpath
->action
!= LOGACTIONS_DELETED
))
968 if (changedpath
->action
== LOGACTIONS_ADDED
) // file is added
970 if (changedpath
->lCopyFromRev
== 0)
971 return FALSE
; // but file was not added with history
979 void CLogDlg::OnContextMenu(CWnd
* pWnd
, CPoint point
)
981 // we have two separate context menus:
982 // one shown on the log message list control,
983 // the other shown in the changed-files list control
984 int selCount
= m_LogList
.GetSelectedCount();
985 if (pWnd
== &m_LogList
)
987 //ShowContextMenuForRevisions(pWnd, point);
989 else if (pWnd
== &m_ChangedFileListCtrl
)
991 //ShowContextMenuForChangedpaths(pWnd, point);
993 else if ((selCount
== 1)&&(pWnd
== GetDlgItem(IDC_MSGVIEW
)))
995 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
998 selIndex
= m_LogList
.GetNextSelectedItem(pos
);
1000 GitRev
*pRev
= ((GitRev
*)m_LogList
.m_arShownList
[selIndex
]);
1002 if ((point
.x
== -1) && (point
.y
== -1))
1005 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(&rect
);
1006 ClientToScreen(&rect
);
1007 point
= rect
.CenterPoint();
1009 CString sMenuItemText
;
1011 if (popup
.CreatePopupMenu())
1013 // add the 'default' entries
1014 sMenuItemText
.LoadString(IDS_SCIEDIT_COPY
);
1015 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, WM_COPY
, sMenuItemText
);
1016 sMenuItemText
.LoadString(IDS_SCIEDIT_SELECTALL
);
1017 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, EM_SETSEL
, sMenuItemText
);
1018 sMenuItemText
.LoadString(IDS_EDIT_NOTES
);
1019 popup
.AppendMenuIcon( CGitLogList::ID_EDITNOTE
, sMenuItemText
, IDI_EDIT
);
1021 //if (selIndex >= 0)
1023 // popup.AppendMenu(MF_SEPARATOR);
1024 // sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
1025 // popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);
1028 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1032 break; // no command selected
1035 ::SendMessage(GetDlgItem(IDC_MSGVIEW
)->GetSafeHwnd(), cmd
, 0, -1);
1037 case CGitLogList::ID_EDITNOTE
:
1038 CAppUtils::EditNote(pRev
);
1039 this->FillLogMessageCtrl(true);
1046 void CLogDlg::OnOK()
1048 // since the log dialog is also used to select revisions for other
1049 // dialogs, we have to do some work before closing this dialog
1050 if (GetFocus() != GetDlgItem(IDOK
))
1051 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
1053 m_LogList
.SafeTerminateAsyncDiffThread();
1054 if (this->IsThreadRunning())
1056 m_LogList
.SafeTerminateThread();
1059 // check that one and only one row is selected
1060 if (m_LogList
.GetSelectedCount() == 1)
1062 // get the selected row
1063 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1064 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
1065 if (selIndex
< m_LogList
.m_arShownList
.GetCount())
1067 // all ok, pick up the revision
1068 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(selIndex
));
1070 m_sSelectedHash
= pLogEntry
->m_CommitHash
;
1078 if (!GetDlgItem(IDOK
)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL
))
1079 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
1083 GetDlgItemText(IDOK
, buttontext
);
1084 temp
.LoadString(IDS_MSGBOX_CANCEL
);
1085 if (temp
.Compare(buttontext
) != 0)
1086 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
1087 m_bCancelled
= TRUE
;
1088 m_selectedRevs
.Clear();
1089 m_selectedRevsOneRange
.Clear();
1090 if (m_pNotifyWindow
)
1092 int selIndex
= m_LogList
.GetSelectionMark();
1095 PLOGENTRYDATA pLogEntry
= NULL
;
1096 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1097 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
1098 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1099 git_revnum_t lowerRev
= pLogEntry
->Rev
;
1100 git_revnum_t higherRev
= lowerRev
;
1103 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
1104 git_revnum_t rev
= pLogEntry
->Rev
;
1105 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1108 if (higherRev
< rev
)
1111 if (m_sFilterText
.IsEmpty() && m_nSortColumn
== 0 && IsSelectionContinuous())
1113 m_selectedRevsOneRange
.AddRevRange(lowerRev
, higherRev
);
1115 BOOL bSentMessage
= FALSE
;
1116 if (m_LogList
.GetSelectedCount() == 1)
1118 // if only one revision is selected, check if the path/url with which the dialog was started
1119 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
1120 // if it was copied, use the copy from revision as lowerRev
1121 if ((pLogEntry
)&&(pLogEntry
->pArChangedPaths
)&&(lowerRev
== higherRev
))
1123 CString sUrl
= m_path
.GetGitPathString();
1124 if (!m_path
.IsUrl())
1126 sUrl
= GetURLFromPath(m_path
);
1128 sUrl
= sUrl
.Mid(m_sRepositoryRoot
.GetLength());
1129 for (int cp
= 0; cp
< pLogEntry
->pArChangedPaths
->GetCount(); ++cp
)
1131 LogChangedPath
* pData
= pLogEntry
->pArChangedPaths
->SafeGetAt(cp
);
1134 if (sUrl
.Compare(pData
->sPath
) == 0)
1136 if (!pData
->sCopyFromPath
.IsEmpty())
1138 lowerRev
= pData
->lCopyFromRev
;
1139 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
), lowerRev
);
1140 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
), higherRev
);
1141 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1142 bSentMessage
= TRUE
;
1149 if ( !bSentMessage
)
1151 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
| MERGE_REVSELECTMINUSONE
), lowerRev
);
1152 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
| MERGE_REVSELECTMINUSONE
), higherRev
);
1153 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1154 if (m_selectedRevsOneRange
.GetCount())
1155 m_pNotifyWindow
->SendMessage(WM_REVLISTONERANGE
, 0, (LPARAM
)&m_selectedRevsOneRange
);
1160 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
1161 reg
= m_btnShow
.GetCurrentEntry();
1166 void CLogDlg::OnNMDblclkChangedFileList(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
1168 // a double click on an entry in the changed-files list has happened
1174 void CLogDlg::DiffSelectedFile()
1177 if (m_bThreadRunning
)
1179 UpdateLogInfoLabel();
1180 INT_PTR selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
1183 if (m_ChangedFileListCtrl
.GetSelectedCount() == 0)
1185 // find out if there's an entry selected in the log list
1186 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1187 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
1188 git_revnum_t rev1
= pLogEntry
->Rev
;
1189 git_revnum_t rev2
= rev1
;
1194 // there's at least a second entry selected in the log list: several revisions selected!
1195 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
1198 rev1
= max(rev1
,(long)pLogEntry
->Rev
);
1199 rev2
= min(rev2
,(long)pLogEntry
->Rev
);
1203 // now we have both revisions selected in the log list, so we can do a diff of the selected
1204 // entry in the changed files list with these two revisions.
1205 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1210 // nothing or only one revision selected in the log list
1211 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(selIndex
);
1213 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
1215 // some items are hidden! So find out which item the user really clicked on
1216 INT_PTR selRealIndex
= -1;
1217 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
1219 if (pLogEntry
->pArChangedPaths
->SafeGetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
1221 if (selRealIndex
== selIndex
)
1223 selIndex
= hiddenindex
;
1224 changedpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(selIndex
);
1230 if (IsDiffPossible(changedpath
, rev1
))
1232 // diffs with renamed files are possible
1233 if ((changedpath
)&&(!changedpath
->sCopyFromPath
.IsEmpty()))
1234 rev2
= changedpath
->lCopyFromRev
;
1237 // if the path was modified but the parent path was 'added with history'
1238 // then we have to use the copy from revision of the parent path
1239 CTGitPath cpath
= CTGitPath(changedpath
->sPath
);
1240 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
1242 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->SafeGetAt(flist
)->sPath
);
1243 if (p
.IsAncestorOf(cpath
))
1245 if (!pLogEntry
->pArChangedPaths
->SafeGetAt(flist
)->sCopyFromPath
.IsEmpty())
1246 rev2
= pLogEntry
->pArChangedPaths
->SafeGetAt(flist
)->lCopyFromRev
;
1250 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
1254 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1255 CTGitPath tempfile2
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath
->sPath
));
1257 // deleted files must be opened from the revision before the deletion
1258 if (changedpath
->action
== LOGACTIONS_DELETED
)
1260 m_bCancelled
= false;
1262 CProgressDlg progDlg
;
1263 progDlg
.SetTitle(IDS_APPNAME
);
1264 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1266 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)(m_sRepositoryRoot
+ changedpath
->sPath
), (LPCTSTR
)r
.ToString());
1267 progDlg
.SetLine(1, sInfoLine
, true);
1268 SetAndClearProgressInfo(&progDlg
);
1269 progDlg
.ShowModeless(m_hWnd
);
1271 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), r
, r
, tempfile
))
1273 m_bCancelled
= false;
1274 if (!Cat(CTGitPath(m_sRepositoryRoot
+ changedpath
->sPath
), GitRev::REV_HEAD
, r
, tempfile
))
1277 SetAndClearProgressInfo((HWND
)NULL
);
1278 CMessageBox::Show(m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1283 SetAndClearProgressInfo((HWND
)NULL
);
1285 CString sName1
, sName2
;
1286 sName1
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
);
1287 sName2
.Format(_T("%s - Revision %ld"), (LPCTSTR
)CPathUtils::GetFileNameFromPath(changedpath
->sPath
), (git_revnum_t
)rev1
-1);
1288 CAppUtils::DiffFlags flags
;
1289 flags
.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1290 if (changedpath
->action
== LOGACTIONS_DELETED
)
1291 CAppUtils::StartExtDiff(tempfile
, tempfile2
, sName2
, sName1
, flags
);
1293 CAppUtils::StartExtDiff(tempfile2
, tempfile
, sName2
, sName1
, flags
);
1300 void CLogDlg::DoDiffFromLog(INT_PTR selIndex
, GitRev
* rev1
, GitRev
* rev2
, bool /*blame*/, bool /*unified*/)
1302 DialogEnableWindow(IDOK
, FALSE
);
1303 // SetPromptApp(&theApp);
1304 theApp
.DoWaitCursor(1);
1307 GetTempPath(temppath
);
1310 file1
.Format(_T("%s%s_%s%s"),
1312 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1313 rev1
->m_CommitHash
.ToString().Left(6),
1314 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1317 file2
.Format(_T("%s\\%s_%s%s"),
1319 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1320 rev2
->m_CommitHash
.ToString().Left(6),
1321 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1325 g_Git
.GetOneFile(rev1
->m_CommitHash
.ToString(), (CTGitPath
&)(*m_currentChangedArray
)[selIndex
],file1
);
1327 g_Git
.GetOneFile(rev2
->m_CommitHash
.ToString(), (CTGitPath
&)(*m_currentChangedArray
)[selIndex
],file2
);
1329 CAppUtils::DiffFlags flags
;
1330 CAppUtils::StartExtDiff(file1
,file2
,_T("A"),_T("B"),flags
);
1335 if (Git::PathIsURL(m_path
))
1337 filepath
= m_path
.GetGitPathString();
1341 filepath
= GetURLFromPath(m_path
);
1342 if (filepath
.IsEmpty())
1344 theApp
.DoWaitCursor(-1);
1346 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1347 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1348 TRACE(_T("could not retrieve the URL of the file!\n"));
1350 theApp
.DoWaitCursor(-11);
1354 m_bCancelled
= FALSE
;
1355 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1357 CString firstfile
, secondfile
;
1358 if (m_LogList
.GetSelectedCount()==1)
1360 int s
= m_LogList
.GetSelectionMark();
1361 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(s
));
1362 LogChangedPath
* changedpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(selIndex
);
1363 firstfile
= changedpath
->sPath
;
1364 secondfile
= firstfile
;
1365 if ((rev2
== rev1
-1)&&(changedpath
->lCopyFromRev
> 0)) // is it an added file with history?
1367 secondfile
= changedpath
->sCopyFromPath
;
1368 rev2
= changedpath
->lCopyFromRev
;
1373 firstfile
= m_currentChangedPathList
[selIndex
].GetGitPathString();
1374 secondfile
= firstfile
;
1377 firstfile
= filepath
+ firstfile
.Trim();
1378 secondfile
= filepath
+ secondfile
.Trim();
1380 GitDiff
diff(this, this->m_hWnd
, true);
1381 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1382 diff
.SetHEADPeg(m_LogRevision
);
1386 diff
.ShowUnifiedDiff(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
);
1388 CAppUtils::StartShowUnifiedDiff(m_hWnd
, CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), m_LogRevision
);
1392 if (diff
.ShowCompare(CTGitPath(secondfile
), rev2
, CTGitPath(firstfile
), rev1
, GitRev(), false, blame
))
1394 if (firstfile
.Compare(secondfile
)==0)
1396 git_revnum_t baseRev
= 0;
1397 diff
.DiffProps(CTGitPath(firstfile
), rev2
, rev1
, baseRev
);
1404 theApp
.DoWaitCursor(-1);
1408 BOOL
CLogDlg::Open(bool /*bOpenWith*/,CString changedpath
, git_revnum_t rev
)
1411 DialogEnableWindow(IDOK
, FALSE
);
1412 SetPromptApp(&theApp
);
1413 theApp
.DoWaitCursor(1);
1415 if (Git::PathIsURL(m_path
))
1417 filepath
= m_path
.GetGitPathString();
1421 filepath
= GetURLFromPath(m_path
);
1422 if (filepath
.IsEmpty())
1424 theApp
.DoWaitCursor(-1);
1426 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
1427 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
1428 TRACE(_T("could not retrieve the URL of the file!\n"));
1433 m_bCancelled
= false;
1434 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
1435 filepath
+= changedpath
;
1437 CProgressDlg progDlg
;
1438 progDlg
.SetTitle(IDS_APPNAME
);
1439 progDlg
.SetAnimation(IDR_DOWNLOAD
);
1441 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)GitRev(rev
).ToString());
1442 progDlg
.SetLine(1, sInfoLine
, true);
1443 SetAndClearProgressInfo(&progDlg
);
1444 progDlg
.ShowModeless(m_hWnd
);
1446 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath
), rev
);
1447 m_bCancelled
= false;
1448 if (!Cat(CTGitPath(filepath
), GitRev(rev
), rev
, tempfile
))
1451 SetAndClearProgressInfo((HWND
)NULL
);
1452 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1454 theApp
.DoWaitCursor(-1);
1458 SetAndClearProgressInfo((HWND
)NULL
);
1459 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1462 int ret
= (int)ShellExecute(this->m_hWnd
, NULL
, tempfile
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1463 if (ret
<= HINSTANCE_ERROR
)
1468 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1469 cmd
+= tempfile
.GetWinPathString() + _T(" ");
1470 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1473 theApp
.DoWaitCursor(-1);
1478 void CLogDlg::EditAuthor(const CLogDataVector
& /*logs*/)
1483 if (logs
.size() == 0)
1485 DialogEnableWindow(IDOK
, FALSE
);
1486 SetPromptApp(&theApp
);
1487 theApp
.DoWaitCursor(1);
1488 if (Git::PathIsURL(m_path
))
1489 url
= m_path
.GetGitPathString();
1492 url
= GetURLFromPath(m_path
);
1494 name
= Git_PROP_REVISION_AUTHOR
;
1496 CString value
= RevPropertyGet(name
, CTGitPath(url
), logs
[0]->Rev
);
1497 CString sOldValue
= value
;
1498 value
.Replace(_T("\n"), _T("\r\n"));
1499 CInputDlg
dlg(this);
1500 dlg
.m_sHintText
.LoadString(IDS_LOG_AUTHOR
);
1501 dlg
.m_sInputText
= value
;
1502 dlg
.m_sTitle
.LoadString(IDS_LOG_AUTHOREDITTITLE
);
1503 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1504 dlg
.m_bUseLogWidth
= false;
1505 if (dlg
.DoModal() == IDOK
)
1507 dlg
.m_sInputText
.Remove('\r');
1509 LogCache::CCachedLogInfo
* toUpdate
= GetLogCache (CTGitPath (m_sRepositoryRoot
));
1511 CProgressDlg progDlg
;
1512 progDlg
.SetTitle(IDS_APPNAME
);
1513 progDlg
.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT
)));
1514 progDlg
.SetTime(true);
1515 progDlg
.SetShowProgressBar(true);
1516 progDlg
.ShowModeless(m_hWnd
);
1517 for (DWORD i
=0; i
<logs
.size(); ++i
)
1519 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), logs
[i
]->Rev
))
1522 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1528 logs
[i
]->sAuthor
= dlg
.m_sInputText
;
1529 m_LogList
.Invalidate();
1531 // update the log cache
1533 if (toUpdate
!= NULL
)
1535 // log caching is active
1537 LogCache::CCachedLogInfo newInfo
;
1538 newInfo
.Insert ( logs
[i
]->Rev
1539 , (const char*) CUnicodeUtils::GetUTF8 (logs
[i
]->sAuthor
)
1542 , LogCache::CRevisionInfoContainer::HAS_AUTHOR
);
1544 toUpdate
->Update (newInfo
);
1547 progDlg
.SetProgress64(i
, logs
.size());
1551 theApp
.DoWaitCursor(-1);
1556 void CLogDlg::EditLogMessage(int /*index*/)
1562 DialogEnableWindow(IDOK
, FALSE
);
1563 SetPromptApp(&theApp
);
1564 theApp
.DoWaitCursor(1);
1565 if (Git::PathIsURL(m_path
))
1566 url
= m_path
.GetGitPathString();
1569 url
= GetURLFromPath(m_path
);
1571 name
= Git_PROP_REVISION_LOG
;
1573 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(index
));
1574 m_bCancelled
= FALSE
;
1575 CString value
= RevPropertyGet(name
, CTGitPath(url
), pLogEntry
->Rev
);
1576 CString sOldValue
= value
;
1577 value
.Replace(_T("\n"), _T("\r\n"));
1578 CInputDlg
dlg(this);
1579 dlg
.m_sHintText
.LoadString(IDS_LOG_MESSAGE
);
1580 dlg
.m_sInputText
= value
;
1581 dlg
.m_sTitle
.LoadString(IDS_LOG_MESSAGEEDITTITLE
);
1582 dlg
.m_pProjectProperties
= &m_ProjectProperties
;
1583 dlg
.m_bUseLogWidth
= true;
1584 if (dlg
.DoModal() == IDOK
)
1586 dlg
.m_sInputText
.Remove('\r');
1587 if (!RevPropertySet(name
, dlg
.m_sInputText
, sOldValue
, CTGitPath(url
), pLogEntry
->Rev
))
1589 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1593 pLogEntry
->sShortMessage
= MakeShortMessage(dlg
.m_sInputText
);
1594 // split multi line log entries and concatenate them
1595 // again but this time with \r\n as line separators
1596 // so that the edit control recognizes them
1597 if (dlg
.m_sInputText
.GetLength()>0)
1599 m_sMessageBuf
= dlg
.m_sInputText
;
1600 dlg
.m_sInputText
.Replace(_T("\n\r"), _T("\n"));
1601 dlg
.m_sInputText
.Replace(_T("\r\n"), _T("\n"));
1602 if (dlg
.m_sInputText
.Right(1).Compare(_T("\n"))==0)
1603 dlg
.m_sInputText
= dlg
.m_sInputText
.Left(dlg
.m_sInputText
.GetLength()-1);
1606 dlg
.m_sInputText
.Empty();
1607 pLogEntry
->sMessage
= dlg
.m_sInputText
;
1608 pLogEntry
->sBugIDs
= m_ProjectProperties
.FindBugID(dlg
.m_sInputText
);
1609 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
1610 pMsgView
->SetWindowText(_T(" "));
1611 pMsgView
->SetWindowText(dlg
.m_sInputText
);
1612 m_ProjectProperties
.FindBugID(dlg
.m_sInputText
, pMsgView
);
1613 m_LogList
.Invalidate();
1615 // update the log cache
1616 LogCache::CCachedLogInfo
* toUpdate
= GetLogCache(CTGitPath (m_sRepositoryRoot
));
1617 if (toUpdate
!= NULL
)
1619 // log caching is active
1621 LogCache::CCachedLogInfo newInfo
;
1622 newInfo
.Insert( pLogEntry
->Rev
1624 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry
->sMessage
)
1626 , LogCache::CRevisionInfoContainer::HAS_COMMENT
);
1628 toUpdate
->Update(newInfo
);
1632 theApp
.DoWaitCursor(-1);
1637 BOOL
CLogDlg::PreTranslateMessage(MSG
* pMsg
)
1639 // Skip Ctrl-C when copying text out of the log message or search filter
1640 BOOL bSkipAccelerator
= ( pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW
) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT
) ) && GetKeyState(VK_CONTROL
)&0x8000 );
1641 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
1643 if (GetFocus()==GetDlgItem(IDC_LOGLIST
))
1645 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1647 m_LogList
.DiffSelectedRevWithPrevious();
1652 if (m_hAccel
&& !bSkipAccelerator
)
1654 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
1659 if(::IsWindow(m_tooltips
.m_hWnd
))
1660 m_tooltips
.RelayEvent(pMsg
);
1661 return __super::PreTranslateMessage(pMsg
);
1665 BOOL
CLogDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1667 //if (this->IsThreadRunning())
1668 if(m_LogList
.m_bNoDispUpdates
)
1670 // only show the wait cursor over the list control
1672 ((pWnd
== GetDlgItem(IDC_LOGLIST
))||
1673 (pWnd
== GetDlgItem(IDC_MSGVIEW
))||
1674 (pWnd
== GetDlgItem(IDC_LOGMSG
))))
1676 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1681 if ((pWnd
) && (pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1682 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1684 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1686 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1689 void CLogDlg::OnBnClickedHelp()
1694 void CLogDlg::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1696 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1698 //if (this->IsThreadRunning())
1699 if(m_LogList
.m_bNoDispUpdates
)
1701 if (pNMLV
->iItem
>= 0)
1703 this->m_LogList
.m_nSearchIndex
= pNMLV
->iItem
;
1704 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(pNMLV
->iItem
));
1705 m_LogList
.m_lastSelectedHash
= pLogEntry
->m_CommitHash
;
1706 if (pNMLV
->iSubItem
!= 0)
1708 if ((pNMLV
->iItem
== m_LogList
.m_arShownList
.GetCount()))
1710 // remove the selected state
1711 if (pNMLV
->uChanged
& LVIF_STATE
)
1713 m_LogList
.SetItemState(pNMLV
->iItem
, 0, LVIS_SELECTED
);
1714 FillLogMessageCtrl();
1716 UpdateLogInfoLabel();
1720 if (pNMLV
->uChanged
& LVIF_STATE
)
1722 FillLogMessageCtrl();
1728 m_LogList
.m_lastSelectedHash
.Empty();
1729 FillLogMessageCtrl();
1733 UpdateLogInfoLabel();
1736 void CLogDlg::OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1738 ENLINK
*pEnLink
= reinterpret_cast<ENLINK
*>(pNMHDR
);
1739 if (pEnLink
->msg
== WM_LBUTTONUP
)
1742 GetDlgItemText(IDC_MSGVIEW
, msg
);
1743 msg
.Replace(_T("\r\n"), _T("\n"));
1744 url
= msg
.Mid(pEnLink
->chrg
.cpMin
, pEnLink
->chrg
.cpMax
-pEnLink
->chrg
.cpMin
);
1745 if (!::PathIsURL(url
))
1747 url
= m_LogList
.m_ProjectProperties
.GetBugIDUrl(url
);
1748 url
= GetAbsoluteUrlFromRelativeUrl(url
);
1751 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
1759 class CCommitPointer
1762 CCommitPointer():m_cont(NULL
){}
1763 CCommitPointer(const CCommitPointer
& P_Right
)
1769 CCommitPointer
& operator = (const CCommitPointer
& P_Right
)
1773 (*m_cont
->m_parDates
)[m_place
] = P_Right
.GetDate();
1774 (*m_cont
->m_parFileChanges
)[m_place
] = P_Right
.GetChanges();
1775 (*m_cont
->m_parAuthors
)[m_place
] = P_Right
.GetAuthor();
1779 m_Date
= P_Right
.GetDate();
1780 m_Changes
= P_Right
.GetChanges();
1781 m_csAuthor
= P_Right
.GetAuthor();
1786 void Clone(const CCommitPointer
& P_Right
)
1788 m_cont
= P_Right
.m_cont
;
1789 m_place
= P_Right
.m_place
;
1790 m_Date
= P_Right
.m_Date
;
1791 m_Changes
= P_Right
.m_Changes
;
1792 m_csAuthor
= P_Right
.m_csAuthor
;
1795 DWORD
GetDate() const {return IsPointer() ? (*m_cont
->m_parDates
)[m_place
] : m_Date
;}
1796 DWORD
GetChanges() const {return IsPointer() ? (*m_cont
->m_parFileChanges
)[m_place
] : m_Changes
;}
1797 CString
GetAuthor() const {return IsPointer() ? (*m_cont
->m_parAuthors
)[m_place
] : m_csAuthor
;}
1799 bool IsPointer() const {return m_cont
!= NULL
;}
1801 CDateSorter
* m_cont
;
1810 class iterator
: public std::iterator
<std::random_access_iterator_tag
, CCommitPointer
>
1813 CCommitPointer m_ptr
;
1816 iterator(const iterator
& P_Right
){*this = P_Right
;}
1817 iterator
& operator=(const iterator
& P_Right
)
1819 m_ptr
.Clone(P_Right
.m_ptr
);
1823 CCommitPointer
& operator*(){return m_ptr
;}
1824 CCommitPointer
* operator->(){return &m_ptr
;}
1825 const CCommitPointer
& operator*()const{return m_ptr
;}
1826 const CCommitPointer
* operator->()const{return &m_ptr
;}
1828 iterator
& operator+=(size_t P_iOffset
){m_ptr
.m_place
+= P_iOffset
;return *this;}
1829 iterator
& operator-=(size_t P_iOffset
){m_ptr
.m_place
-= P_iOffset
;return *this;}
1830 iterator
operator+(size_t P_iOffset
)const{iterator
it(*this); it
+= P_iOffset
;return it
;}
1831 iterator
operator-(size_t P_iOffset
)const{iterator
it(*this); it
-= P_iOffset
;return it
;}
1833 iterator
& operator++(){++m_ptr
.m_place
;return *this;}
1834 iterator
& operator--(){--m_ptr
.m_place
;return *this;}
1835 iterator
operator++(int){iterator
it(*this);++*this;return it
;}
1836 iterator
operator--(int){iterator
it(*this);--*this;return it
;}
1838 size_t operator-(const iterator
& P_itRight
)const{return m_ptr
.m_place
- P_itRight
->m_place
;}
1840 bool operator<(const iterator
& P_itRight
)const{return m_ptr
.m_place
< P_itRight
->m_place
;}
1841 bool operator!=(const iterator
& P_itRight
)const{return m_ptr
.m_place
!= P_itRight
->m_place
;}
1842 bool operator==(const iterator
& P_itRight
)const{return m_ptr
.m_place
== P_itRight
->m_place
;}
1843 bool operator>(const iterator
& P_itRight
)const{return m_ptr
.m_place
> P_itRight
->m_place
;}
1855 it
->m_place
= m_parDates
->GetCount();
1860 CDWordArray
* m_parDates
;
1861 CDWordArray
* m_parFileChanges
;
1862 CStringArray
* m_parAuthors
;
1865 class CDateSorterLess
1868 bool operator () (const CDateSorter::CCommitPointer
& P_Left
, const CDateSorter::CCommitPointer
& P_Right
) const
1870 return P_Left
.GetDate() > P_Right
.GetDate(); //Last date first
1877 void CLogDlg::OnBnClickedStatbutton()
1879 if (this->IsThreadRunning())
1881 if (m_LogList
.m_arShownList
.IsEmpty() || m_LogList
.m_arShownList
.GetCount() == 1 && m_LogList
.m_bShowWC
)
1882 return; // nothing or just the working copy changes are shown, so no statistics.
1883 // the statistics dialog expects the log entries to be sorted by date
1884 SortByColumn(3, false);
1885 CThreadSafePtrArray
shownlist(NULL
);
1886 m_LogList
.RecalculateShownList(&shownlist
);
1887 // create arrays which are aware of the current filter
1888 CStringArray m_arAuthorsFiltered
;
1889 CDWordArray m_arDatesFiltered
;
1890 CDWordArray m_arFileChangesFiltered
;
1891 for (INT_PTR i
=0; i
<shownlist
.GetCount(); ++i
)
1893 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(shownlist
.SafeGetAt(i
));
1895 // do not take working dir changes into statistics
1896 if (pLogEntry
->m_CommitHash
.IsEmpty()) {
1900 CString strAuthor
= pLogEntry
->GetAuthorName();
1901 if ( strAuthor
.IsEmpty() )
1903 strAuthor
.LoadString(IDS_STATGRAPH_EMPTYAUTHOR
);
1905 m_arAuthorsFiltered
.Add(strAuthor
);
1906 m_arDatesFiltered
.Add(pLogEntry
->GetCommitterDate().GetTime());
1907 m_arFileChangesFiltered
.Add(pLogEntry
->GetFiles(&m_LogList
).GetCount());
1910 CDateSorter W_Sorter
;
1911 W_Sorter
.m_parAuthors
= &m_arAuthorsFiltered
;
1912 W_Sorter
.m_parDates
= &m_arDatesFiltered
;
1913 W_Sorter
.m_parFileChanges
= &m_arFileChangesFiltered
;
1914 std::sort(W_Sorter
.begin(), W_Sorter
.end(), CDateSorterLess());
1917 dlg
.m_parAuthors
= &m_arAuthorsFiltered
;
1918 dlg
.m_parDates
= &m_arDatesFiltered
;
1919 dlg
.m_parFileChanges
= &m_arFileChangesFiltered
;
1920 dlg
.m_path
= m_orgPath
;
1922 // restore the previous sorting
1923 SortByColumn(m_nSortColumn
, m_bAscending
);
1924 OnTimer(LOGFILTER_TIMER
);
1927 void CLogDlg::DoSizeV1(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(&m_LogList
, delta
, CW_TOPALIGN
);
1936 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), -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 m_LogList
.Invalidate();
1946 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
1950 void CLogDlg::DoSizeV2(int delta
)
1953 RemoveAnchor(IDC_LOGLIST
);
1954 RemoveAnchor(IDC_SPLITTERTOP
);
1955 RemoveAnchor(IDC_MSGVIEW
);
1956 RemoveAnchor(IDC_SPLITTERBOTTOM
);
1957 RemoveAnchor(IDC_LOGMSG
);
1958 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), delta
, CW_TOPALIGN
);
1959 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl
, -delta
, CW_BOTTOMALIGN
);
1960 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
1961 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
1962 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
1963 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1964 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1968 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
1969 m_ChangedFileListCtrl
.Invalidate();
1973 void CLogDlg::AdjustMinSize()
1975 // adjust the minimum size of the dialog to prevent the resizing from
1976 // moving the list control too far down.
1977 CRect rcChgListView
;
1978 m_ChangedFileListCtrl
.GetClientRect(rcChgListView
);
1980 m_LogList
.GetClientRect(rcLogList
);
1982 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(),
1983 m_DlgOrigRect
.Height()-m_ChgOrigRect
.Height()-m_LogListOrigRect
.Height()-m_MsgViewOrigRect
.Height()
1984 +rcChgListView
.Height()+rcLogList
.Height()+60));
1987 LRESULT
CLogDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
1991 if (wParam
== IDC_SPLITTERTOP
)
1993 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
1994 DoSizeV1(pHdr
->delta
);
1996 else if (wParam
== IDC_SPLITTERBOTTOM
)
1998 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
1999 DoSizeV2(pHdr
->delta
);
2004 return CResizableDialog::DefWindowProc(message
, wParam
, lParam
);
2007 void CLogDlg::SetSplitterRange()
2009 if ((m_LogList
)&&(m_ChangedFileListCtrl
))
2012 m_LogList
.GetWindowRect(rcTop
);
2013 ScreenToClient(rcTop
);
2015 GetDlgItem(IDC_MSGVIEW
)->GetWindowRect(rcMiddle
);
2016 ScreenToClient(rcMiddle
);
2017 m_wndSplitter1
.SetRange(rcTop
.top
+30, rcMiddle
.bottom
-20);
2019 m_ChangedFileListCtrl
.GetWindowRect(rcBottom
);
2020 ScreenToClient(rcBottom
);
2021 m_wndSplitter2
.SetRange(rcMiddle
.top
+30, rcBottom
.bottom
-20);
2025 LRESULT
CLogDlg::OnClickedInfoIcon(WPARAM
/*wParam*/, LPARAM lParam
)
2027 // FIXME: x64 version would get this function called with unexpected parameters.
2031 RECT
* rect
= (LPRECT
)lParam
;
2034 point
= CPoint(rect
->left
, rect
->bottom
);
2035 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
2037 if (popup
.CreatePopupMenu())
2039 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2040 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL
), LOGFILTER_ALL
, temp
);
2042 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2044 temp
.LoadString(IDS_LOG_FILTER_SUBJECT
);
2045 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_SUBJECT
), LOGFILTER_SUBJECT
, temp
);
2047 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2048 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES
), LOGFILTER_MESSAGES
, temp
);
2050 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2051 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS
), LOGFILTER_PATHS
, temp
);
2053 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2054 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS
), LOGFILTER_AUTHORS
, temp
);
2056 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2057 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS
), LOGFILTER_REVS
, temp
);
2059 if (m_LogList
.m_bShowBugtraqColumn
== true) {
2060 temp
.LoadString(IDS_LOG_FILTER_BUGIDS
);
2061 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID
), LOGFILTER_BUGID
, temp
);
2064 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2066 temp
.LoadString(IDS_LOG_FILTER_REGEX
);
2067 popup
.AppendMenu(MF_STRING
| MF_ENABLED
| (m_bFilterWithRegex
? MF_CHECKED
: MF_UNCHECKED
), LOGFILTER_REGEX
, temp
);
2070 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2074 if (selection
== LOGFILTER_REGEX
)
2076 m_bFilterWithRegex
= !m_bFilterWithRegex
;
2077 CRegDWORD b
= CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
2078 b
= m_bFilterWithRegex
;
2079 m_LogList
.m_bFilterWithRegex
= m_bFilterWithRegex
;
2081 CheckRegexpTooltip();
2085 m_LogList
.m_nSelectedFilter
= selection
;
2088 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2094 LRESULT
CLogDlg::OnClickedCancelFilter(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2097 KillTimer(LOGFILTER_TIMER
);
2099 m_LogList
.m_sFilterText
.Empty();
2101 theApp
.DoWaitCursor(1);
2102 CStoreSelection
storeselection(this);
2103 FillLogMessageCtrl(false);
2105 m_LogList
.RemoveFilter();
2110 m_LogList
.GetTimeRange(begin
,end
);
2111 m_DateFrom
.SetTime(&begin
);
2112 m_DateTo
.SetTime(&end
);
2114 theApp
.DoWaitCursor(-1);
2115 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2116 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2117 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2118 UpdateLogInfoLabel();
2124 void CLogDlg::SetFilterCueText()
2127 switch (m_LogList
.m_nSelectedFilter
)
2130 temp
.LoadString(IDS_LOG_FILTER_ALL
);
2132 case LOGFILTER_SUBJECT
:
2133 temp
.LoadString(IDS_LOG_FILTER_SUBJECT
);
2135 case LOGFILTER_MESSAGES
:
2136 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
2138 case LOGFILTER_PATHS
:
2139 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
2141 case LOGFILTER_AUTHORS
:
2142 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
2144 case LOGFILTER_REVS
:
2145 temp
.LoadString(IDS_LOG_FILTER_REVS
);
2148 // to make the cue banner text appear more to the right of the edit control
2149 temp
= _T(" ")+temp
;
2150 m_cFilter
.SetCueBanner(temp
);
2153 bool CLogDlg::Validate(LPCTSTR string
)
2155 if (!m_bFilterWithRegex
)
2158 return m_LogList
.ValidateRegexp(string
, pat
, false);
2162 void CLogDlg::OnTimer(UINT_PTR nIDEvent
)
2164 if (nIDEvent
== LOGFTIME_TIMER
)
2166 KillTimer(LOGFTIME_TIMER
);
2168 m_LogList
.Refresh(FALSE
);
2169 FillLogMessageCtrl(false);
2172 if (nIDEvent
== LOGFILTER_TIMER
)
2174 KillTimer(LOGFILTER_TIMER
);
2176 m_LogList
.Refresh(FALSE
);
2177 FillLogMessageCtrl(false);
2180 /* we will use git built-in grep to filter log */
2181 if (this->IsThreadRunning())
2183 // thread still running! So just restart the timer.
2184 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2187 CWnd
* focusWnd
= GetFocus();
2188 bool bSetFocusToFilterControl
= ((focusWnd
!= GetDlgItem(IDC_DATEFROM
))&&(focusWnd
!= GetDlgItem(IDC_DATETO
))
2189 && (focusWnd
!= GetDlgItem(IDC_LOGLIST
)));
2190 if (m_LogList
.m_sFilterText
.IsEmpty())
2192 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2193 // do not return here!
2194 // we also need to run the filter if the filter text is empty:
2195 // 1. to clear an existing filter
2196 // 2. to rebuild the m_arShownList after sorting
2198 theApp
.DoWaitCursor(1);
2199 CStoreSelection
storeselection(this);
2200 KillTimer(LOGFILTER_TIMER
);
2201 FillLogMessageCtrl(false);
2203 // now start filter the log list
2204 m_LogList
.StartFilter();
2206 if ( m_LogList
.GetItemCount()==1 )
2208 m_LogList
.SetSelectionMark(0);
2209 m_LogList
.SetItemState(0, LVIS_SELECTED
, LVIS_SELECTED
);
2211 theApp
.DoWaitCursor(-1);
2212 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2213 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2214 if (bSetFocusToFilterControl
)
2215 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2216 UpdateLogInfoLabel();
2218 } // if (nIDEvent == LOGFILTER_TIMER)
2219 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty() || m_LogList
.m_arShownList
.GetCount() == 1 && m_LogList
.m_bShowWC
))));
2220 __super::OnTimer(nIDEvent
);
2223 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2228 m_DateTo
.GetTime(_time
);
2230 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 23, 59, 59);
2231 if (time
.GetTime() != m_LogList
.m_To
)
2233 m_LogList
.m_To
= (DWORD
)time
.GetTime();
2234 SetTimer(LOGFTIME_TIMER
, 10, NULL
);
2239 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2245 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2251 m_DateFrom
.GetTime(_time
);
2253 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 0, 0, 0);
2254 if (time
.GetTime() != m_LogList
.m_From
)
2256 m_LogList
.m_From
= (DWORD
)time
.GetTime();
2257 SetTimer(LOGFTIME_TIMER
, 10, NULL
);
2262 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2270 CTGitPathList
CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
2272 CTGitPathList pathList
;
2275 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2277 m_sRepositoryRoot
= GetRepositoryRoot(m_path
);
2279 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2282 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2287 int nextpos
= m_LogList
.GetNextSelectedItem(pos
);
2288 if (nextpos
>= m_arShownList
.GetCount())
2290 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(nextpos
));
2291 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
2292 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
2294 LogChangedPath
* cpath
= cpatharray
->SafeGetAt(cpPathIndex
);
2298 if (!bRelativePaths
)
2299 path
.SetFromGit(m_sRepositoryRoot
);
2300 path
.AppendPathString(cpath
->sPath
);
2302 ((m_cHidePaths
.GetState() & 0x0003)!=BST_CHECKED
)||
2303 (cpath
->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0))
2304 pathList
.AddPath(path
);
2309 pathList
.RemoveDuplicates();
2314 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
2322 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscRevSort());
2324 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescRevSort());
2330 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscActionSort());
2332 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescActionSort());
2338 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscAuthorSort());
2340 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescAuthorSort());
2346 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscDateSort());
2348 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescDateSort());
2351 case 4: // Message or bug id
2352 if (m_bShowBugtraqColumn
)
2355 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscBugIDSort());
2357 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescBugIDSort());
2360 // fall through here
2364 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscMessageSort());
2366 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescMessageSort());
2376 void CLogDlg::OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2378 if (this->IsThreadRunning())
2379 return; //no sorting while the arrays are filled
2381 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2382 const int nColumn
= pNMLV
->iSubItem
;
2383 m_bAscending
= nColumn
== m_nSortColumn
? !m_bAscending
: TRUE
;
2384 m_nSortColumn
= nColumn
;
2385 SortByColumn(m_nSortColumn
, m_bAscending
);
2386 SetSortArrow(&m_LogList
, m_nSortColumn
, !!m_bAscending
);
2387 SortShownListArray();
2388 m_LogList
.Invalidate();
2389 UpdateLogInfoLabel();
2391 UNREFERENCED_PARAMETER(pNMHDR
);
2396 void CLogDlg::SortShownListArray()
2398 // make sure the shown list still matches the filter after sorting.
2399 OnTimer(LOGFILTER_TIMER
);
2400 // clear the selection states
2401 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2404 m_LogList
.SetItemState(m_LogList
.GetNextSelectedItem(pos
), 0, LVIS_SELECTED
);
2406 m_LogList
.SetSelectionMark(-1);
2409 void CLogDlg::SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
)
2411 if (control
== NULL
)
2413 // set the sort arrow
2414 CHeaderCtrl
* pHeader
= control
->GetHeaderCtrl();
2415 HDITEM HeaderItem
= {0};
2416 HeaderItem
.mask
= HDI_FORMAT
;
2417 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
2419 pHeader
->GetItem(i
, &HeaderItem
);
2420 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
2421 pHeader
->SetItem(i
, &HeaderItem
);
2425 pHeader
->GetItem(nColumn
, &HeaderItem
);
2426 HeaderItem
.fmt
|= (bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
2427 pHeader
->SetItem(nColumn
, &HeaderItem
);
2430 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
2433 if (this->IsThreadRunning())
2434 return; //no sorting while the arrays are filled
2435 if (m_currentChangedArray
== NULL
)
2437 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2438 const int nColumn
= pNMLV
->iSubItem
;
2439 m_bAscendingPathList
= nColumn
== m_nSortColumnPathList
? !m_bAscendingPathList
: TRUE
;
2440 m_nSortColumnPathList
= nColumn
;
2441 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
2443 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
2444 m_ChangedFileListCtrl
.Invalidate();
2449 int CLogDlg::m_nSortColumnPathList
= 0;
2450 bool CLogDlg::m_bAscendingPathList
= false;
2452 int CLogDlg::SortCompare(const void * /*pElem1*/, const void * /*pElem2*/)
2455 LogChangedPath
* cpath1
= *((LogChangedPath
**)pElem1
);
2456 LogChangedPath
* cpath2
= *((LogChangedPath
**)pElem2
);
2458 if (m_bAscendingPathList
)
2459 std::swap (cpath1
, cpath2
);
2462 switch (m_nSortColumnPathList
)
2465 cmp
= cpath2
->GetAction().Compare(cpath1
->GetAction());
2470 cmp
= cpath2
->sPath
.CompareNoCase(cpath1
->sPath
);
2474 case 2: // copy from path
2475 cmp
= cpath2
->sCopyFromPath
.Compare(cpath1
->sCopyFromPath
);
2479 case 3: // copy from revision
2480 return cpath2
->lCopyFromRev
> cpath1
->lCopyFromRev
;
2486 void CLogDlg::OnBnClickedHidepaths()
2488 FillLogMessageCtrl();
2489 m_ChangedFileListCtrl
.Invalidate();
2494 void CLogDlg::OnBnClickedCheckStoponcopy()
2497 if (!GetDlgItem(IDC_GETALL
)->IsWindowEnabled())
2500 // ignore old fetch limits when switching
2501 // between copy-following and stop-on-copy
2502 // (otherwise stop-on-copy will limit what
2503 // we see immediately after switching to
2508 // now, restart the query
2514 void CLogDlg::UpdateLogInfoLabel()
2519 long selectedrevs
= 0;
2520 int count
=m_LogList
.m_arShownList
.GetCount();
2524 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(0)))->m_CommitHash
;
2525 if(this->m_LogList
.m_bShowWC
&& rev1
.IsEmpty()&&(count
>1))
2527 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(start
)))->m_CommitHash
;
2528 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_arShownList.GetCount()-1));
2529 rev2
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(count
-1)))->m_CommitHash
;
2530 selectedrevs
= m_LogList
.GetSelectedCount();
2533 sTemp
.Format(_T("Showing %ld revision(s), from revision %s to revision %s - %ld revision(s) selected\r\n"),
2535 rev2
.ToString().Left(6), rev1
.ToString().Left(6), selectedrevs
);
2537 if(selectedrevs
== 1)
2539 CString str
=m_ChangedFileListCtrl
.GetStatisticsString(true);
2540 str
.Replace(_T('\n'), _T(' '));
2549 void CLogDlg::ShowContextMenuForChangedpaths(CWnd
* /*pWnd*/, CPoint point
)
2552 int selIndex
= m_ChangedFileListCtrl
.GetSelectionMark();
2553 if ((point
.x
== -1) && (point
.y
== -1))
2556 m_ChangedFileListCtrl
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
2557 m_ChangedFileListCtrl
.ClientToScreen(&rect
);
2558 point
= rect
.CenterPoint();
2562 int s
= m_LogList
.GetSelectionMark();
2565 std::vector
<CString
> changedpaths
;
2566 std::vector
<LogChangedPath
*> changedlogpaths
;
2567 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2569 return; // nothing is selected, get out of here
2571 bool bOneRev
= true;
2572 int sel
=m_LogList
.GetNextSelectedItem(pos
);
2573 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(sel
));
2574 GitRev
* rev1
= pLogEntry
;
2575 GitRev
* rev2
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(sel
+1));
2577 bool bOneRev
= true;
2582 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
2585 rev1
= max(rev1
,(git_revnum_t
)pLogEntry
->Rev
);
2586 rev2
= min(rev2
,(git_revnum_t
)pLogEntry
->Rev
);
2592 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2595 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2596 changedpaths
.push_back(m_currentChangedPathList
[nItem
].GetGitPathString());
2601 // only one revision is selected in the log dialog top pane
2602 // but multiple items could be selected in the changed items list
2605 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
2608 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
2609 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(nItem
);
2611 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2613 if ((changedlogpath
)&&(!changedlogpath
->sCopyFromPath
.IsEmpty()))
2614 rev2
= changedlogpath
->lCopyFromRev
;
2617 // if the path was modified but the parent path was 'added with history'
2618 // then we have to use the copy from revision of the parent path
2619 CTGitPath cpath
= CTGitPath(changedlogpath
->sPath
);
2620 for (int flist
= 0; flist
< pLogEntry
->pArChangedPaths
->GetCount(); ++flist
)
2622 CTGitPath p
= CTGitPath(pLogEntry
->pArChangedPaths
->SafeGetAt(flist
)->sPath
);
2623 if (p
.IsAncestorOf(cpath
))
2625 if (!pLogEntry
->pArChangedPaths
->SafeGetAt(flist
)->sCopyFromPath
.IsEmpty())
2626 rev2
= pLogEntry
->pArChangedPaths
->SafeGetAt(flist
)->lCopyFromRev
;
2631 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
2633 // some items are hidden! So find out which item the user really clicked on
2634 INT_PTR selRealIndex
= -1;
2635 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
2637 if (pLogEntry
->pArChangedPaths
->SafeGetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
2639 if (selRealIndex
== nItem
)
2641 selIndex
= hiddenindex
;
2642 changedlogpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(selIndex
);
2649 changedpaths
.push_back(changedlogpath
->sPath
);
2650 changedlogpaths
.push_back(changedlogpath
);
2655 //entry is selected, now show the popup menu
2657 if (popup
.CreatePopupMenu())
2659 bool bEntryAdded
= false;
2660 if (m_ChangedFileListCtrl
.GetSelectedCount() == 1)
2662 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
2664 popup
.AppendMenuIcon(CGitLogList::ID_DIFF
, IDS_LOG_POPUP_DIFF
, IDI_DIFF
);
2665 popup
.AppendMenuIcon(CGitLogList::ID_BLAMEDIFF
, IDS_LOG_POPUP_BLAMEDIFF
, IDI_BLAME
);
2666 popup
.SetDefaultItem(CGitLogList::ID_DIFF
, FALSE
);
2667 popup
.AppendMenuIcon(CGitLogList::ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
2670 // if (rev2 == rev1-1)
2673 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2674 popup
.AppendMenuIcon(CGitLogList::ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
2675 popup
.AppendMenuIcon(CGitLogList::ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
2676 popup
.AppendMenuIcon(CGitLogList::ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
2677 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2679 popup
.AppendMenuIcon(CGitLogList::ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
2680 popup
.AppendMenuIcon(CGitLogList::ID_POPPROPS
, IDS_REPOBROWSE_SHOWPROP
, IDI_PROPERTIES
); // "Show Properties"
2681 popup
.AppendMenuIcon(CGitLogList::ID_LOG
, IDS_MENULOG
, IDI_LOG
); // "Show Log"
2682 popup
.AppendMenuIcon(CGitLogList::ID_GETMERGELOGS
, IDS_LOG_POPUP_GETMERGELOGS
, IDI_LOG
); // "Show merge log"
2683 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
, IDI_SAVEAS
);
2685 if (!m_ProjectProperties
.sWebViewerPathRev
.IsEmpty())
2687 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2688 popup
.AppendMenuIcon(CGitLogList::ID_VIEWPATHREV
, IDS_LOG_POPUP_VIEWPATHREV
);
2690 if (popup
.GetDefaultItem(0,FALSE
)==-1)
2691 popup
.SetDefaultItem(CGitLogList::ID_OPEN
, FALSE
);
2694 else if (changedlogpaths
.size())
2696 // more than one entry is selected
2697 popup
.AppendMenuIcon(CGitLogList::ID_SAVEAS
, IDS_LOG_POPUP_SAVE
);
2703 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2704 bool bOpenWith
= false;
2705 bool bMergeLog
= false;
2706 m_bCancelled
= false;
2710 case CGitLogList::ID_DIFF
:
2712 DoDiffFromLog(selIndex
, rev1
, rev2
, false, false);
2718 DoDiffFromLog(selIndex
, rev1
, rev2
, true, false);
2723 DoDiffFromLog(selIndex
, rev1
, rev2
, false, true);
2728 SetPromptApp(&theApp
);
2729 theApp
.DoWaitCursor(1);
2731 if (Git::PathIsURL(m_path
))
2733 sUrl
= m_path
.GetGitPathString();
2737 sUrl
= GetURLFromPath(m_path
);
2740 theApp
.DoWaitCursor(-1);
2742 temp
.Format(IDS_ERR_NOURLOFFILE
, m_path
.GetWinPath());
2743 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2745 theApp
.DoWaitCursor(-1);
2749 // find the working copy path of the selected item from the URL
2750 m_bCancelled
= false;
2751 CString sUrlRoot
= GetRepositoryRoot(CTGitPath(sUrl
));
2753 CString fileURL
= changedpaths
[0];
2754 fileURL
= sUrlRoot
+ fileURL
.Trim();
2755 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
2756 // sUrl = http://mydomain.com/repos/trunk/folder
2757 CString sUnescapedUrl
= CPathUtils::PathUnescape(sUrl
);
2758 // find out until which char the urls are identical
2760 while ((i
<fileURL
.GetLength())&&(i
<sUnescapedUrl
.GetLength())&&(fileURL
[i
]==sUnescapedUrl
[i
]))
2762 int leftcount
= m_path
.GetWinPathString().GetLength()-(sUnescapedUrl
.GetLength()-i
);
2763 CString wcPath
= m_path
.GetWinPathString().Left(leftcount
);
2764 wcPath
+= fileURL
.Mid(i
);
2765 wcPath
.Replace('/', '\\');
2766 CGitProgressDlg dlg
;
2767 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
2769 // a deleted path! Since the path isn't there anymore, merge
2770 // won't work. So just do a copy url->wc
2771 dlg
.SetCommand(CGitProgressDlg::GitProgress_Copy
);
2772 dlg
.SetPathList(CTGitPathList(CTGitPath(fileURL
)));
2774 dlg
.SetRevision(rev2
);
2778 if (!PathFileExists(wcPath
))
2780 // seems the path got renamed
2781 // tell the user how to work around this.
2782 CMessageBox::Show(this->m_hWnd
, IDS_LOG_REVERTREV_ERROR
, IDS_APPNAME
, MB_ICONERROR
);
2784 theApp
.DoWaitCursor(-1);
2787 dlg
.SetCommand(CGitProgressDlg::GitProgress_Merge
);
2788 dlg
.SetPathList(CTGitPathList(CTGitPath(wcPath
)));
2789 dlg
.SetUrl(fileURL
);
2790 dlg
.SetSecondUrl(fileURL
);
2791 GitRevRangeArray revarray
;
2792 revarray
.AddRevRange(rev1
, rev2
);
2793 dlg
.SetRevisionRanges(revarray
);
2796 msg
.Format(IDS_LOG_REVERT_CONFIRM
, (LPCTSTR
)wcPath
);
2797 if (CMessageBox::Show(this->m_hWnd
, msg
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
2801 theApp
.DoWaitCursor(-1);
2806 DialogEnableWindow(IDOK
, FALSE
);
2807 SetPromptApp(&theApp
);
2808 theApp
.DoWaitCursor(1);
2810 if (Git::PathIsURL(m_path
))
2812 filepath
= m_path
.GetGitPathString();
2816 filepath
= GetURLFromPath(m_path
);
2817 if (filepath
.IsEmpty())
2819 theApp
.DoWaitCursor(-1);
2821 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
2822 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2823 TRACE(_T("could not retrieve the URL of the file!\n"));
2828 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
2829 filepath
+= changedpaths
[0];
2832 dlg
.m_Path
= CTGitPath(filepath
);
2835 theApp
.DoWaitCursor(-1);
2840 DialogEnableWindow(IDOK
, FALSE
);
2841 SetPromptApp(&theApp
);
2842 theApp
.DoWaitCursor(1);
2844 if (Git::PathIsURL(m_path
))
2846 filepath
= m_path
.GetGitPathString();
2850 filepath
= GetURLFromPath(m_path
);
2851 if (filepath
.IsEmpty())
2853 theApp
.DoWaitCursor(-1);
2855 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
2856 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2857 TRACE(_T("could not retrieve the URL of the file!\n"));
2862 m_bCancelled
= false;
2863 CString sRoot
= GetRepositoryRoot(CTGitPath(filepath
));
2864 // if more than one entry is selected, we save them
2865 // one by one into a folder the user has selected
2866 bool bTargetSelected
= false;
2867 CTGitPath TargetPath
;
2868 if (m_ChangedFileListCtrl
.GetSelectedCount() > 1)
2870 CBrowseFolder browseFolder
;
2871 browseFolder
.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT
)));
2872 browseFolder
.m_style
= BIF_EDITBOX
| BIF_NEWDIALOGSTYLE
| BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
;
2873 CString strSaveAsDirectory
;
2874 if (browseFolder
.Show(GetSafeHwnd(), strSaveAsDirectory
) == CBrowseFolder::OK
)
2876 TargetPath
= CTGitPath(strSaveAsDirectory
);
2877 bTargetSelected
= true;
2882 // Display the Open dialog box.
2883 CString revFilename
;
2885 temp
= CPathUtils::GetFileNameFromPath(changedpaths
[0]);
2886 int rfind
= temp
.ReverseFind('.');
2888 revFilename
.Format(_T("%s-%ld%s"), (LPCTSTR
)temp
.Left(rfind
), rev1
, (LPCTSTR
)temp
.Mid(rfind
));
2890 revFilename
.Format(_T("%s-%ld"), (LPCTSTR
)temp
, rev1
);
2891 bTargetSelected
= CAppUtils::FileOpenSave(revFilename
, NULL
, IDS_LOG_POPUP_SAVE
, IDS_COMMONFILEFILTER
, false, m_hWnd
);
2892 TargetPath
.SetFromWin(revFilename
);
2894 if (bTargetSelected
)
2896 CProgressDlg progDlg
;
2897 progDlg
.SetTitle(IDS_APPNAME
);
2898 progDlg
.SetAnimation(IDR_DOWNLOAD
);
2899 for (std::vector
<LogChangedPath
*>::iterator it
= changedlogpaths
.begin(); it
!= changedlogpaths
.end(); ++it
)
2901 GitRev getrev
= ((*it
)->action
== LOGACTIONS_DELETED
) ? rev2
: rev1
;
2904 sInfoLine
.Format(IDS_PROGRESSGETFILEREVISION
, (LPCTSTR
)filepath
, (LPCTSTR
)getrev
.ToString());
2905 progDlg
.SetLine(1, sInfoLine
, true);
2906 SetAndClearProgressInfo(&progDlg
);
2907 progDlg
.ShowModeless(m_hWnd
);
2909 CTGitPath tempfile
= TargetPath
;
2910 if (changedpaths
.size() > 1)
2912 // if multiple items are selected, then the TargetPath
2913 // points to a folder and we have to append the filename
2914 // to save to to that folder.
2915 CString sName
= (*it
)->sPath
;
2916 int slashpos
= sName
.ReverseFind('/');
2918 sName
= sName
.Mid(slashpos
);
2919 tempfile
.AppendPathString(sName
);
2920 // one problem here:
2921 // a user could have selected multiple items which
2922 // have the same filename but reside in different
2923 // directories, e.g.
2926 // in that case, the second 'file1' will overwrite
2927 // the already saved 'file1'.
2929 // we could maybe find the common root of all selected
2930 // items and then create sub folders to save those files
2932 // But I think we should just leave it that way: to check
2933 // out multiple items at once, the better way is still to
2934 // use the export command from the top pane of the log dialog.
2936 filepath
= sRoot
+ (*it
)->sPath
;
2937 if (!Cat(CTGitPath(filepath
), getrev
, getrev
, tempfile
))
2940 SetAndClearProgressInfo((HWND
)NULL
);
2941 CMessageBox::Show(this->m_hWnd
, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
2943 theApp
.DoWaitCursor(-1);
2948 SetAndClearProgressInfo((HWND
)NULL
);
2951 theApp
.DoWaitCursor(-1);
2958 GitRev getrev
= pLogEntry
->pArChangedPaths
->SafeGetAt(selIndex
)->action
== LOGACTIONS_DELETED
? rev2
: rev1
;
2959 Open(bOpenWith
,changedpaths
[0],getrev
);
2965 if (Git::PathIsURL(m_path
))
2967 filepath
= m_path
.GetGitPathString();
2971 filepath
= GetURLFromPath(m_path
);
2972 if (filepath
.IsEmpty())
2974 theApp
.DoWaitCursor(-1);
2976 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
2977 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
2978 TRACE(_T("could not retrieve the URL of the file!\n"));
2983 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
2984 filepath
+= changedpaths
[0];
2987 if (dlg
.DoModal() == IDOK
)
2992 tempfile
= blame
.BlameToTempFile(CTGitPath(filepath
), dlg
.StartRev
, dlg
.EndRev
, dlg
.EndRev
, logfile
, _T(""), dlg
.m_bIncludeMerge
, TRUE
, TRUE
);
2993 if (!tempfile
.IsEmpty())
2995 if (dlg
.m_bTextView
)
2997 //open the default text editor for the result file
2998 CAppUtils::StartTextViewer(tempfile
);
3002 CString sParams
= _T("/path:\"") + filepath
+ _T("\" ");
3003 if(!CAppUtils::LaunchTortoiseBlame(tempfile
, logfile
, CPathUtils::GetFileNameFromPath(filepath
),sParams
))
3011 CMessageBox::Show(this->m_hWnd
, blame
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3016 case ID_GETMERGELOGS
:
3021 DialogEnableWindow(IDOK
, FALSE
);
3022 SetPromptApp(&theApp
);
3023 theApp
.DoWaitCursor(1);
3025 if (Git::PathIsURL(m_path
))
3027 filepath
= m_path
.GetGitPathString();
3031 filepath
= GetURLFromPath(m_path
);
3032 if (filepath
.IsEmpty())
3034 theApp
.DoWaitCursor(-1);
3036 temp
.Format(IDS_ERR_NOURLOFFILE
, (LPCTSTR
)filepath
);
3037 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3038 TRACE(_T("could not retrieve the URL of the file!\n"));
3043 m_bCancelled
= false;
3044 filepath
= GetRepositoryRoot(CTGitPath(filepath
));
3045 filepath
+= changedpaths
[0];
3046 git_revnum_t logrev
= rev1
;
3047 if (changedlogpaths
[0]->action
== LOGACTIONS_DELETED
)
3049 // if the item got deleted in this revision,
3050 // fetch the log from the previous revision where it
3055 sCmd
.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR
)filepath
, logrev
);
3057 sCmd
+= _T(" /merge");
3058 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
3060 theApp
.DoWaitCursor(-1);
3063 case ID_VIEWPATHREV
:
3065 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetSelectionMark()));
3066 GitRev rev
= pLogEntry
->Rev
;
3067 CString relurl
= changedpaths
[0];
3068 CString url
= m_ProjectProperties
.sWebViewerPathRev
;
3069 url
.Replace(_T("%REVISION%"), rev
.ToString());
3070 url
.Replace(_T("%PATH%"), relurl
);
3071 relurl
= relurl
.Mid(relurl
.Find('/'));
3072 url
.Replace(_T("%PATH1%"), relurl
);
3074 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
3082 } // if (popup.CreatePopupMenu())
3086 void CLogDlg::OnDtnDropdownDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3088 // the date control should not show the "today" button
3089 CMonthCalCtrl
* pCtrl
= m_DateFrom
.GetMonthCalCtrl();
3091 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3095 void CLogDlg::OnDtnDropdownDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
3097 // the date control should not show the "today" button
3098 CMonthCalCtrl
* pCtrl
= m_DateTo
.GetMonthCalCtrl();
3100 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
3104 void CLogDlg::OnSize(UINT nType
, int cx
, int cy
)
3106 __super::OnSize(nType
, cx
, cy
);
3111 void CLogDlg::OnRefresh()
3113 //if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
3117 this->m_LogProgress
.SetPos(0);
3125 void CLogDlg::OnFocusFilter()
3127 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3130 void CLogDlg::OnEditCopy()
3132 if (GetFocus() == &m_ChangedFileListCtrl
)
3133 CopyChangedSelectionToClipBoard();
3135 m_LogList
.CopySelectionToClipBoard();
3138 CString
CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString
& url
)
3140 // is the URL a relative one?
3141 if (url
.Left(2).Compare(_T("^/")) == 0)
3143 // URL is relative to the repository root
3144 CString url1
= m_sRepositoryRoot
+ url
.Mid(1);
3145 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3146 DWORD len
= url
.GetLength();
3147 if (UrlCanonicalize((LPCTSTR
)url1
, buf
, &len
, 0) == S_OK
)
3148 return CString(buf
, len
);
3151 else if (url
[0] == '/')
3153 // URL is relative to the server's hostname
3155 // find the server's hostname
3156 int schemepos
= m_sRepositoryRoot
.Find(_T("//"));
3159 sHost
= m_sRepositoryRoot
.Left(m_sRepositoryRoot
.Find('/', schemepos
+3));
3160 CString url1
= sHost
+ url
;
3161 TCHAR buf
[INTERNET_MAX_URL_LENGTH
];
3162 DWORD len
= url
.GetLength();
3163 if (UrlCanonicalize((LPCTSTR
)url
, buf
, &len
, 0) == S_OK
)
3164 return CString(buf
, len
);
3172 void CLogDlg::OnEnChangeSearchedit()
3175 if (m_LogList
.m_sFilterText
.IsEmpty())
3177 CStoreSelection
storeselection(this);
3178 // clear the filter, i.e. make all entries appear
3179 theApp
.DoWaitCursor(1);
3180 KillTimer(LOGFILTER_TIMER
);
3181 FillLogMessageCtrl(false);
3184 //m_LogList.StartFilter();
3186 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3187 m_arShownList
.RemoveAll();
3188 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3190 if (IsEntryInDateRange(i
))
3191 m_arShownList
.Add(m_logEntries
[i
]);
3193 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3194 m_LogList
.DeleteAllItems();
3195 m_LogList
.SetItemCountEx(ShownCountWithStopped());
3196 m_LogList
.RedrawItems(0, ShownCountWithStopped());
3197 m_LogList
.SetRedraw(false);
3198 ResizeAllListCtrlCols();
3199 m_LogList
.SetRedraw(true);
3201 theApp
.DoWaitCursor(-1);
3202 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
3203 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
3204 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
3205 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
3208 if (Validate(m_LogList
.m_sFilterText
))
3209 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
3211 KillTimer(LOGFILTER_TIMER
);
3215 void CLogDlg::OnBnClickedAllBranch()
3219 if(this->m_bAllBranch
)
3220 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_ALL_BRANCH
;
3222 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_ALL_BRANCH
;
3226 FillLogMessageCtrl(false);
3229 void CLogDlg::OnBnClickedBrowseRef()
3231 CString newRef
= CBrowseRefsDlg::PickRef(false,m_LogList
.GetStartRef());
3232 if(newRef
.IsEmpty())
3235 SetStartRef(newRef
);
3236 ((CButton
*)GetDlgItem(IDC_LOG_ALLBRANCH
))->SetCheck(0);
3238 OnBnClickedAllBranch();
3241 void CLogDlg::ShowStartRef()
3243 //Show ref name on top
3244 if(!::IsWindow(m_hWnd
))
3248 m_staticRef
.SetWindowText(L
"<All Branches>");
3249 m_staticRef
.Invalidate(TRUE
);
3253 CString showStartRef
= m_LogList
.GetStartRef();
3254 if(showStartRef
.IsEmpty())
3257 if (g_Git
.Run(L
"git symbolic-ref HEAD", &showStartRef
, NULL
, CP_UTF8
))
3258 showStartRef
= _T("<No branch>");
3259 showStartRef
.Trim(L
"\r\n\t ");
3263 if(wcsncmp(showStartRef
,L
"refs/",5) == 0)
3264 showStartRef
= showStartRef
.Mid(5);
3265 if(wcsncmp(showStartRef
,L
"heads/",6) == 0)
3266 showStartRef
= showStartRef
.Mid(6);
3268 m_staticRef
.SetWindowText(showStartRef
);
3269 m_staticRef
.Invalidate(TRUE
);
3272 void CLogDlg::SetStartRef(const CString
& StartRef
)
3274 m_LogList
.SetStartRef(StartRef
);
3276 if (m_hightlightRevision
.IsEmpty())
3278 m_hightlightRevision
= g_Git
.GetHash(StartRef
);
3279 m_LogList
.m_lastSelectedHash
= m_hightlightRevision
;
3286 void CLogDlg::OnBnClickedFirstParent()
3290 if(this->m_bFirstParent
)
3291 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_FIRST_PARENT
;
3293 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_FIRST_PARENT
;
3297 FillLogMessageCtrl(false);
3301 void CLogDlg::OnBnClickShowWholeProject()
3305 if(this->m_bWholeProject
)
3307 m_LogList
.m_Path
.Reset();
3312 m_LogList
.m_Path
=m_path
;
3319 FillLogMessageCtrl(false);
3323 LRESULT
CLogDlg::OnRefLogChanged(WPARAM wParam
, LPARAM lParam
)
3325 UNREFERENCED_PARAMETER(wParam
);
3326 UNREFERENCED_PARAMETER(lParam
);
3331 LRESULT
CLogDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3333 m_pTaskbarList
.Release();
3334 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);