1 // TortoiseGit - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseGit
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "TortoiseProc.h"
\r
22 #include "InputDlg.h"
\r
23 #include "PropDlg.h"
\r
24 #include "SVNProgressDlg.h"
\r
25 #include "ProgressDlg.h"
\r
26 //#include "RepositoryBrowser.h"
\r
27 //#include "CopyDlg.h"
\r
28 //#include "StatGraphDlg.h"
\r
30 #include "MessageBox.h"
\r
31 #include "Registry.h"
\r
32 #include "AppUtils.h"
\r
33 #include "PathUtils.h"
\r
34 #include "StringUtils.h"
\r
35 #include "UnicodeUtils.h"
\r
36 #include "TempFile.h"
\r
37 //#include "GitInfo.h"
\r
38 //#include "GitDiff.h"
\r
39 #include "IconMenu.h"
\r
40 //#include "RevisionRangeDlg.h"
\r
41 //#include "BrowseFolder.h"
\r
42 //#include "BlameDlg.h"
\r
43 //#include "Blame.h"
\r
44 //#include "GitHelpers.h"
\r
45 #include "GitStatus.h"
\r
46 //#include "LogDlgHelper.h"
\r
47 //#include "CachedLogInfo.h"
\r
48 //#include "RepositoryInfo.h"
\r
49 //#include "EditPropertiesDlg.h"
\r
50 #include "FileDiffDlg.h"
\r
52 #if (NTDDI_VERSION < NTDDI_LONGHORN)
\r
54 enum LISTITEMSTATES_MINE {
\r
59 LISS_SELECTEDNOTFOCUS = 5,
\r
60 LISS_HOTSELECTED = 6,
\r
63 #define MCS_NOTRAILINGDATES 0x0040
\r
64 #define MCS_SHORTDAYSOFWEEK 0x0080
\r
65 #define MCS_NOSELCHANGEONNAV 0x0100
\r
67 #define DTM_SETMCSTYLE (DTM_FIRST + 11)
\r
71 #define ICONITEMBORDER 5
\r
73 const UINT CLogDlg::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING);
\r
76 enum LogDlgContextMenuCommands
\r
78 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
\r
107 ID_COMPAREWITHPREVIOUS,
\r
108 ID_BLAMEWITHPREVIOUS,
\r
114 IMPLEMENT_DYNAMIC(CLogDlg, CResizableStandAloneDialog)
\r
115 CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)
\r
116 : CResizableStandAloneDialog(CLogDlg::IDD, pParent)
\r
118 , m_nSearchIndex(0)
\r
120 , m_nSelectedFilter(LOGFILTER_ALL)
\r
121 , m_bNoDispUpdates(FALSE)
\r
122 , m_currentChangedArray(NULL)
\r
124 , m_bShowedAll(false)
\r
126 , m_regLastStrict(_T("Software\\TortoiseGit\\LastLogStrict"), FALSE)
\r
127 , m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
128 , m_bSelectionMustBeContinuous(false)
\r
129 , m_bShowBugtraqColumn(false)
\r
130 , m_lowestRev(_T(""))
\r
131 , m_bStrictStopped(false)
\r
132 , m_sLogInfo(_T(""))
\r
133 , m_pFindDialog(NULL)
\r
134 , m_bCancelled(FALSE)
\r
135 , m_pNotifyWindow(NULL)
\r
136 , m_bThreadRunning(FALSE)
\r
137 , m_bAscending(FALSE)
\r
138 , m_pStoreSelection(NULL)
\r
140 , m_childCounter(0)
\r
142 , m_bIncludeMerges(FALSE)
\r
146 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
147 // use the default GUI font, create a copy of it and
\r
148 // change the copy to BOLD (leave the rest of the font
\r
150 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
152 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
153 lf.lfWeight = FW_BOLD;
\r
154 m_boldFont = CreateFontIndirect(&lf);
\r
157 CLogDlg::~CLogDlg()
\r
159 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
160 m_CurrentFilteredChangedArray.RemoveAll();
\r
161 m_logEntries.ClearAll();
\r
162 DestroyIcon(m_hModifiedIcon);
\r
163 DestroyIcon(m_hReplacedIcon);
\r
164 DestroyIcon(m_hAddedIcon);
\r
165 DestroyIcon(m_hDeletedIcon);
\r
166 if ( m_pStoreSelection )
\r
168 delete m_pStoreSelection;
\r
169 m_pStoreSelection = NULL;
\r
172 DeleteObject(m_boldFont);
\r
175 void CLogDlg::DoDataExchange(CDataExchange* pDX)
\r
177 CResizableStandAloneDialog::DoDataExchange(pDX);
\r
178 DDX_Control(pDX, IDC_LOGLIST, m_LogList);
\r
179 DDX_Control(pDX, IDC_LOGMSG, m_ChangedFileListCtrl);
\r
180 DDX_Control(pDX, IDC_PROGRESS, m_LogProgress);
\r
181 DDX_Control(pDX, IDC_SPLITTERTOP, m_wndSplitter1);
\r
182 DDX_Control(pDX, IDC_SPLITTERBOTTOM, m_wndSplitter2);
\r
183 DDX_Check(pDX, IDC_CHECK_STOPONCOPY, m_bStrict);
\r
184 DDX_Text(pDX, IDC_SEARCHEDIT, m_sFilterText);
\r
185 DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);
\r
186 DDX_Control(pDX, IDC_DATETO, m_DateTo);
\r
187 DDX_Control(pDX, IDC_HIDEPATHS, m_cHidePaths);
\r
188 DDX_Control(pDX, IDC_GETALL, m_btnShow);
\r
189 DDX_Text(pDX, IDC_LOGINFO, m_sLogInfo);
\r
190 DDX_Check(pDX, IDC_INCLUDEMERGE, m_bIncludeMerges);
\r
191 DDX_Control(pDX, IDC_SEARCHEDIT, m_cFilter);
\r
194 BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)
\r
195 ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage)
\r
196 ON_BN_CLICKED(IDC_GETALL, OnBnClickedGetall)
\r
197 ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)
\r
198 ON_NOTIFY(NM_DBLCLK, IDC_LOGLIST, OnNMDblclkLoglist)
\r
199 ON_WM_CONTEXTMENU()
\r
201 ON_BN_CLICKED(IDHELP, OnBnClickedHelp)
\r
202 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGLIST, OnLvnItemchangedLoglist)
\r
203 ON_NOTIFY(EN_LINK, IDC_MSGVIEW, OnEnLinkMsgview)
\r
204 ON_BN_CLICKED(IDC_STATBUTTON, OnBnClickedStatbutton)
\r
205 ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGLIST, OnNMCustomdrawLoglist)
\r
206 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)
\r
207 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)
\r
208 ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGLIST, OnLvnGetdispinfoLoglist)
\r
209 ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)
\r
211 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)
\r
212 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)
\r
213 ON_BN_CLICKED(IDC_NEXTHUNDRED, OnBnClickedNexthundred)
\r
214 ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)
\r
215 ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)
\r
216 ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGLIST, OnLvnColumnclick)
\r
217 ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)
\r
218 ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)
\r
219 ON_NOTIFY(LVN_ODFINDITEM, IDC_LOGLIST, OnLvnOdfinditemLoglist)
\r
220 ON_BN_CLICKED(IDC_CHECK_STOPONCOPY, &CLogDlg::OnBnClickedCheckStoponcopy)
\r
221 ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)
\r
222 ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)
\r
224 ON_BN_CLICKED(IDC_INCLUDEMERGE, &CLogDlg::OnBnClickedIncludemerge)
\r
225 ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)
\r
226 ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)
\r
227 ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)
\r
228 ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)
\r
229 ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)
\r
232 void CLogDlg::SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit, BOOL bStrict /* = FALSE */, BOOL bSaveStrict /* = TRUE */)
\r
236 m_startrev = startrev;
\r
237 m_LogRevision = startrev;
\r
239 m_hasWC = !path.IsUrl();
\r
240 m_bStrict = bStrict;
\r
241 m_bSaveStrict = bSaveStrict;
\r
243 if (::IsWindow(m_hWnd))
\r
247 BOOL CLogDlg::OnInitDialog()
\r
249 CResizableStandAloneDialog::OnInitDialog();
\r
251 m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));
\r
253 OSVERSIONINFOEX inf;
\r
254 SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
\r
255 inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
\r
256 GetVersionEx((OSVERSIONINFO *)&inf);
\r
257 WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);
\r
258 m_bVista = (fullver >= 0x0600);
\r
260 // use the state of the "stop on copy/rename" option from the last time
\r
262 m_bStrict = m_regLastStrict;
\r
266 temp.Format(IDS_LOG_SHOWNEXT, m_limit);
\r
268 temp.Format(IDS_LOG_SHOWNEXT, (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100));
\r
270 SetDlgItemText(IDC_NEXTHUNDRED, temp);
\r
272 // set the font to use in the log message view, configured in the settings dialog
\r
273 CAppUtils::CreateFontForLogs(m_logFont);
\r
274 GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);
\r
275 // automatically detect URLs in the log message and turn them into links
\r
276 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);
\r
277 // make the log message rich edit control send a message when the mouse pointer is over a link
\r
278 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);
\r
279 m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
281 // the "hide unrelated paths" checkbox should be indeterminate
\r
282 m_cHidePaths.SetCheck(BST_INDETERMINATE);
\r
284 // load the icons for the action columns
\r
285 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
286 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
287 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
288 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
290 // if there is a working copy, load the project properties
\r
291 // to get information about the bugtraq: integration
\r
293 m_ProjectProperties.ReadProps(m_path);
\r
295 // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set
\r
296 if ((!m_ProjectProperties.sUrl.IsEmpty())||(!m_ProjectProperties.sCheckRe.IsEmpty()))
\r
297 m_bShowBugtraqColumn = true;
\r
299 theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);
\r
300 theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);
\r
302 // set up the columns
\r
303 m_LogList.DeleteAllItems();
\r
304 int c = ((CHeaderCtrl*)(m_LogList.GetDlgItem(0)))->GetItemCount()-1;
\r
307 m_LogList.DeleteColumn(c--);
\r
308 temp.LoadString(IDS_LOG_GRAPH);
\r
310 m_LogList.InsertColumn(this->LOGLIST_GRAPH, temp);
\r
313 // make the revision column right aligned
\r
315 Column.mask = LVCF_FMT;
\r
316 Column.fmt = LVCFMT_RIGHT;
\r
317 m_LogList.SetColumn(0, &Column);
\r
320 // g_Git.GetLog(log);
\r
322 temp.LoadString(IDS_LOG_ACTIONS);
\r
323 m_LogList.InsertColumn(this->LOGLIST_ACTION, temp);
\r
325 temp.LoadString(IDS_LOG_MESSAGE);
\r
326 m_LogList.InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
328 temp.LoadString(IDS_LOG_AUTHOR);
\r
329 m_LogList.InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
331 temp.LoadString(IDS_LOG_DATE);
\r
332 m_LogList.InsertColumn(this->LOGLIST_DATE, temp);
\r
335 if (m_bShowBugtraqColumn)
\r
337 temp = m_ProjectProperties.sLabel;
\r
338 if (temp.IsEmpty())
\r
339 temp.LoadString(IDS_LOG_BUGIDS);
\r
340 m_LogList.InsertColumn(this->LOGLIST_BUG, temp);
\r
344 m_LogList.SetRedraw(false);
\r
345 ResizeAllListCtrlCols();
\r
346 m_LogList.SetRedraw(true);
\r
348 m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
349 m_ChangedFileListCtrl.DeleteAllItems();
\r
350 c = ((CHeaderCtrl*)(m_ChangedFileListCtrl.GetDlgItem(0)))->GetItemCount()-1;
\r
352 m_ChangedFileListCtrl.DeleteColumn(c--);
\r
353 temp.LoadString(IDS_PROGRS_ACTION);
\r
354 m_ChangedFileListCtrl.InsertColumn(this->FILELIST_ACTION, temp);
\r
355 temp.LoadString(IDS_LOG_FILE_LINE_ADD);
\r
356 m_ChangedFileListCtrl.InsertColumn(this->FILELIST_ADD, temp);
\r
357 temp.LoadString(IDS_LOG_FILE_LINE_DEL);
\r
358 m_ChangedFileListCtrl.InsertColumn(this->FILELIST_DEL, temp);
\r
359 temp.LoadString(IDS_PROGRS_PATH);
\r
360 m_ChangedFileListCtrl.InsertColumn(this->FILELIST_PATH, temp);
\r
362 m_ChangedFileListCtrl.SetRedraw(false);
\r
363 CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);
\r
364 m_ChangedFileListCtrl.SetRedraw(true);
\r
367 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
370 m_sMessageBuf.Preallocate(100000);
\r
372 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
\r
373 SetDlgTitle(false);
\r
375 m_tooltips.Create(this);
\r
376 CheckRegexpTooltip();
\r
378 SetSplitterRange();
\r
380 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
\r
381 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
\r
382 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
\r
383 m_cFilter.SetValidator(this);
\r
385 AdjustControlSize(IDC_HIDEPATHS);
\r
386 AdjustControlSize(IDC_CHECK_STOPONCOPY);
\r
387 AdjustControlSize(IDC_INCLUDEMERGE);
\r
389 GetClientRect(m_DlgOrigRect);
\r
390 m_LogList.GetClientRect(m_LogListOrigRect);
\r
391 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
\r
392 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
\r
394 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
395 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
398 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
\r
399 AddAnchor(IDC_DATEFROM, TOP_LEFT);
\r
400 AddAnchor(IDC_TOLABEL, TOP_LEFT);
\r
401 AddAnchor(IDC_DATETO, TOP_LEFT);
\r
403 SetFilterCueText();
\r
404 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
\r
406 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
407 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
408 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
409 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
410 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
412 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
413 AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);
\r
414 AddAnchor(IDC_CHECK_STOPONCOPY, BOTTOM_LEFT);
\r
415 AddAnchor(IDC_INCLUDEMERGE, BOTTOM_LEFT);
\r
416 AddAnchor(IDC_GETALL, BOTTOM_LEFT);
\r
417 AddAnchor(IDC_NEXTHUNDRED, BOTTOM_LEFT);
\r
418 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
\r
419 AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);
\r
420 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
421 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
422 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
423 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
425 // SetPromptParentWindow(m_hWnd);
\r
428 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
429 EnableSaveRestore(_T("LogDlg"));
\r
431 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
432 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
433 RECT rcDlg, rcLogList, rcChgMsg;
\r
434 GetClientRect(&rcDlg);
\r
435 m_LogList.GetWindowRect(&rcLogList);
\r
436 ScreenToClient(&rcLogList);
\r
437 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
\r
438 ScreenToClient(&rcChgMsg);
\r
442 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
443 ScreenToClient(&rectSplitter);
\r
444 int delta = yPos1 - rectSplitter.top;
\r
446 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
\r
448 m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);
\r
455 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
456 ScreenToClient(&rectSplitter);
\r
457 int delta = yPos2 - rectSplitter.top;
\r
459 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
\r
461 m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);
\r
469 // the dialog is used to select revisions
\r
470 if (m_bSelectionMustBeContinuous)
\r
471 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(IsSelectionContinuous()));
\r
473 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
477 // the dialog is used to just view log messages
\r
478 GetDlgItemText(IDOK, temp);
\r
479 SetDlgItemText(IDCANCEL, temp);
\r
480 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
\r
483 // set the choices for the "Show All" button
\r
484 temp.LoadString(IDS_LOG_SHOWALL);
\r
485 m_btnShow.AddEntry(temp);
\r
486 temp.LoadString(IDS_LOG_SHOWRANGE);
\r
487 m_btnShow.AddEntry(temp);
\r
488 m_btnShow.SetCurrentEntry((LONG)CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry")));
\r
490 m_mergedRevs.clear();
\r
492 // first start a thread to obtain the log messages without
\r
493 // blocking the dialog
\r
495 m_tFrom = (DWORD)-1;
\r
496 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
497 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
498 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
500 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
501 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
502 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
504 GetDlgItem(IDC_LOGLIST)->SetFocus();
\r
508 void CLogDlg::SetDlgTitle(bool bOffline)
\r
510 if (m_sTitle.IsEmpty())
\r
511 GetWindowText(m_sTitle);
\r
516 if (m_path.IsUrl())
\r
517 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());
\r
518 else if (m_path.IsDirectory())
\r
519 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());
\r
521 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());
\r
522 SetWindowText(sTemp);
\r
526 if (m_path.IsUrl())
\r
527 SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());
\r
528 else if (m_path.IsDirectory())
\r
529 SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());
\r
531 SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());
\r
535 void CLogDlg::CheckRegexpTooltip()
\r
537 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
\r
538 // Since tooltip describes regexp features, show it only if regexps are enabled.
\r
539 if (m_bFilterWithRegex)
\r
541 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
\r
544 m_tooltips.DelTool(pWnd);
\r
547 void CLogDlg::EnableOKButton()
\r
551 // the dialog is used to select revisions
\r
552 if (m_bSelectionMustBeContinuous)
\r
553 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(IsSelectionContinuous()));
\r
555 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
558 DialogEnableWindow(IDOK, TRUE);
\r
561 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
\r
563 // we fill here the log message rich edit control,
\r
564 // and also populate the changed files list control
\r
565 // according to the selected revision(s).
\r
567 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
568 // empty the log message view
\r
569 pMsgView->SetWindowText(_T(" "));
\r
570 // empty the changed files list
\r
571 m_ChangedFileListCtrl.SetRedraw(FALSE);
\r
572 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
573 m_currentChangedArray = NULL;
\r
574 m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
575 m_ChangedFileListCtrl.DeleteAllItems();
\r
576 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
578 // if we're not here to really show a selected revision, just
\r
579 // get out of here after clearing the views, which is what is intended
\r
580 // if that flag is not set.
\r
584 m_ChangedFileListCtrl.Invalidate();
\r
585 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
586 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
590 // depending on how many revisions are selected, we have to do different
\r
592 int selCount = m_LogList.GetSelectedCount();
\r
595 // if nothing is selected, we have nothing more to do
\r
596 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
597 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
600 else if (selCount == 1)
\r
602 // if one revision is selected, we have to fill the log message view
\r
603 // with the corresponding log message, and also fill the changed files
\r
605 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
606 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
607 if (selIndex >= m_arShownList.GetCount())
\r
609 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
610 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
613 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(selIndex));
\r
615 // set the log message text
\r
616 pMsgView->SetWindowText(_T("*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);
\r
617 // turn bug ID's into links if the bugtraq: properties have been set
\r
618 // and we can find a match of those in the log message
\r
619 m_ProjectProperties.FindBugID(pLogEntry->m_Body, pMsgView);
\r
620 CAppUtils::FormatTextInRichEditControl(pMsgView);
\r
621 m_currentChangedArray = &(pLogEntry->m_Files);
\r
622 if (m_currentChangedArray == NULL)
\r
624 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
625 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
629 // fill in the changed files list control
\r
630 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
632 m_CurrentFilteredChangedArray.RemoveAll();
\r
633 for (INT_PTR c = 0; c < m_currentChangedArray->GetCount(); ++c)
\r
635 LogChangedPath * cpath = m_currentChangedArray->GetAt(c);
\r
638 if (m_currentChangedArray->GetAt(c)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
640 m_CurrentFilteredChangedArray.Add(cpath);
\r
643 m_currentChangedArray = &m_CurrentFilteredChangedArray;
\r
649 // more than one revision is selected:
\r
650 // the log message view must be emptied
\r
651 // the changed files list contains all the changed paths from all
\r
652 // selected revisions, with 'doubles' removed
\r
653 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
\r
656 // redraw the views
\r
657 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
658 if (m_currentChangedArray)
\r
660 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
\r
661 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
\r
663 else if (m_currentChangedPathList.GetCount())
\r
665 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
\r
666 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
\r
670 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
671 m_ChangedFileListCtrl.Invalidate();
\r
673 CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);
\r
674 // sort according to the settings
\r
675 if (m_nSortColumnPathList > 0)
\r
676 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
678 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
\r
679 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
683 void CLogDlg::OnBnClickedGetall()
\r
688 void CLogDlg::GetAll(bool bForceAll /* = false */)
\r
691 // fetch all requested log messages, either the specified range or
\r
692 // really *all* available log messages.
\r
694 INT_PTR entry = m_btnShow.GetCurrentEntry();
\r
700 case 0: // show all
\r
703 m_startrev = m_LogRevision;
\r
705 m_bShowedAll = true;
\r
708 case 1: // show range
\r
711 // ask for a revision range
\r
712 CRevisionRangeDlg dlg;
\r
713 dlg.SetStartRevision(m_startrev);
\r
714 dlg.SetEndRevision( (m_endrev>=0) ? m_endrev : 0);
\r
715 if (dlg.DoModal()!=IDOK)
\r
719 m_endrev = dlg.GetEndRevision();
\r
720 m_startrev = dlg.GetStartRevision();
\r
721 if (((m_endrev.IsNumber())&&(m_startrev.IsNumber()))||
\r
722 (m_endrev.IsHead()||m_startrev.IsHead()))
\r
724 if (((LONG)m_startrev < (LONG)m_endrev)||
\r
725 (m_endrev.IsHead()))
\r
727 git_revnum_t temp = m_startrev;
\r
728 m_startrev = m_endrev;
\r
732 m_bShowedAll = false;
\r
737 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
738 m_ChangedFileListCtrl.Invalidate();
\r
739 // We need to create CStoreSelection on the heap or else
\r
740 // the variable will run out of the scope before the
\r
741 // thread ends. Therefore we let the thread delete
\r
743 m_pStoreSelection = new CStoreSelection(this);
\r
744 m_LogList.SetItemCountEx(0);
\r
745 m_LogList.Invalidate();
\r
746 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
747 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
748 pMsgView->SetWindowText(_T(""));
\r
750 SetSortArrow(&m_LogList, -1, true);
\r
752 m_LogList.DeleteAllItems();
\r
753 m_arShownList.RemoveAll();
\r
754 m_logEntries.ClearAll();
\r
757 m_bCancelled = FALSE;
\r
759 m_tFrom = (DWORD)-1;
\r
762 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
763 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
765 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
766 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
768 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
769 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
773 void CLogDlg::OnBnClickedRefresh()
\r
779 void CLogDlg::Refresh (bool autoGoOnline)
\r
782 // refreshing means re-downloading the already shown log messages
\r
785 m_childCounter = 0;
\r
787 if ((m_limit == 0)||(m_bStrict)||(int(m_logEntries.size()-1) > m_limit))
\r
789 if (m_logEntries.size() != 0)
\r
791 m_endrev = m_logEntries[m_logEntries.size()-1]->Rev;
\r
795 m_bCancelled = FALSE;
\r
797 // We need to create CStoreSelection on the heap or else
\r
798 // the variable will run out of the scope before the
\r
799 // thread ends. Therefore we let the thread delete
\r
801 m_pStoreSelection = new CStoreSelection(this);
\r
802 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
803 m_ChangedFileListCtrl.Invalidate();
\r
804 m_LogList.SetItemCountEx(0);
\r
805 m_LogList.Invalidate();
\r
806 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
807 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
808 pMsgView->SetWindowText(_T(""));
\r
810 SetSortArrow(&m_LogList, -1, true);
\r
812 m_LogList.DeleteAllItems();
\r
813 m_arShownList.RemoveAll();
\r
814 m_logEntries.ClearAll();
\r
816 // reset the cached HEAD property & go on-line
\r
820 SetDlgTitle (false);
\r
821 logCachePool.GetRepositoryInfo().ResetHeadRevision (m_sUUID, m_sRepositoryRoot);
\r
824 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
825 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
827 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
828 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
830 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
831 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
835 void CLogDlg::OnBnClickedNexthundred()
\r
839 // we have to fetch the next X log messages.
\r
840 if (m_logEntries.size() < 1)
\r
842 // since there weren't any log messages fetched before, just
\r
843 // fetch all since we don't have an 'anchor' to fetch the 'next'
\r
845 return GetAll(true);
\r
847 git_revnum_t rev = m_logEntries[m_logEntries.size()-1]->Rev;
\r
850 return; // do nothing! No more revisions to get
\r
854 m_bCancelled = FALSE;
\r
856 // rev is is revision we already have and we will receive it again
\r
857 // -> fetch one extra revision to get NumberOfLogs *new* revisions
\r
859 m_limit = (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;
\r
860 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
861 SetSortArrow(&m_LogList, -1, true);
\r
862 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
863 // We need to create CStoreSelection on the heap or else
\r
864 // the variable will run out of the scope before the
\r
865 // thread ends. Therefore we let the thread delete
\r
867 m_pStoreSelection = new CStoreSelection(this);
\r
869 // since we fetch the log from the last revision we already have,
\r
870 // we have to remove that revision entry to avoid getting it twice
\r
871 m_logEntries.pop_back();
\r
872 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
874 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
875 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
877 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
878 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
882 BOOL CLogDlg::Cancel()
\r
884 return m_bCancelled;
\r
887 void CLogDlg::SaveSplitterPos()
\r
891 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
892 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
894 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
895 ScreenToClient(&rectSplitter);
\r
896 regPos1 = rectSplitter.top;
\r
897 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
898 ScreenToClient(&rectSplitter);
\r
899 regPos2 = rectSplitter.top;
\r
903 void CLogDlg::OnCancel()
\r
905 // canceling means stopping the working thread if it's still running.
\r
906 // we do this by using the Subversion cancel callback.
\r
907 // But canceling can also mean just to close the dialog, depending on the
\r
908 // text shown on the cancel button (it could simply read "OK").
\r
909 CString temp, temp2;
\r
910 GetDlgItemText(IDOK, temp);
\r
911 temp2.LoadString(IDS_MSGBOX_CANCEL);
\r
912 if ((temp.Compare(temp2)==0)||(m_bThreadRunning))
\r
914 m_bCancelled = true;
\r
919 m_regLastStrict = m_bStrict;
\r
920 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
921 reg = m_btnShow.GetCurrentEntry();
\r
923 __super::OnCancel();
\r
926 CString CLogDlg::MakeShortMessage(const CString& message)
\r
928 bool bFoundShort = true;
\r
929 CString sShortMessage = m_ProjectProperties.GetLogSummary(message);
\r
930 if (sShortMessage.IsEmpty())
\r
932 bFoundShort = false;
\r
933 sShortMessage = message;
\r
935 // Remove newlines and tabs 'cause those are not shown nicely in the list control
\r
936 sShortMessage.Replace(_T("\r"), _T(""));
\r
937 sShortMessage.Replace(_T("\t"), _T(" "));
\r
939 // Suppose the first empty line separates 'summary' from the rest of the message.
\r
940 int found = sShortMessage.Find(_T("\n\n"));
\r
941 // To avoid too short 'short' messages
\r
942 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
\r
943 // only use the empty newline as a separator if it comes after at least 15 chars.
\r
944 if ((!bFoundShort)&&(found >= 15))
\r
946 sShortMessage = sShortMessage.Left(found);
\r
948 sShortMessage.Replace('\n', ' ');
\r
949 return sShortMessage;
\r
952 BOOL CLogDlg::Log(git_revnum_t rev, const CString& author, const CString& date, const CString& message, LogChangedPathArray * cpaths, int filechanges, BOOL copies, DWORD actions, BOOL haschildren)
\r
955 if (rev == SVN_INVALID_REVNUM)
\r
961 // this is the callback function which receives the data for every revision we ask the log for
\r
962 // we store this information here one by one.
\r
964 if (m_startrev == -1)
\r
969 m_LogProgress.SetPos(m_limit - m_limitcounter);
\r
971 else if (m_startrev.IsNumber() && m_startrev.IsNumber())
\r
972 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);
\r
973 __time64_t ttime = time/1000000L;
\r
974 if (m_tTo < (DWORD)ttime)
\r
975 m_tTo = (DWORD)ttime;
\r
976 if (m_tFrom > (DWORD)ttime)
\r
977 m_tFrom = (DWORD)ttime;
\r
978 if ((m_lowestRev > rev)||(m_lowestRev < 0))
\r
980 // Add as many characters from the log message to the list control
\r
981 PLOGENTRYDATA pLogItem = new LOGENTRYDATA;
\r
982 pLogItem->bCopies = !!copies;
\r
984 // find out if this item was copied in the revision
\r
985 BOOL copiedself = FALSE;
\r
988 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)
\r
990 LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);
\r
991 if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))
\r
993 // note: this only works if the log is fetched top-to-bottom
\r
994 // but since we do that, it shouldn't be a problem
\r
995 m_sSelfRelativeURL = cpath->sCopyFromPath;
\r
1001 pLogItem->bCopiedSelf = copiedself;
\r
1002 pLogItem->tmDate = ttime;
\r
1003 pLogItem->sAuthor = author;
\r
1004 pLogItem->sDate = date;
\r
1005 pLogItem->sShortMessage = MakeShortMessage(message);
\r
1006 pLogItem->dwFileChanges = filechanges;
\r
1007 pLogItem->actions = actions;
\r
1008 pLogItem->haschildren = haschildren;
\r
1009 pLogItem->childStackDepth = m_childCounter;
\r
1010 m_maxChild = max(m_childCounter, m_maxChild);
\r
1013 pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();
\r
1015 // split multi line log entries and concatenate them
\r
1016 // again but this time with \r\n as line separators
\r
1017 // so that the edit control recognizes them
\r
1020 if (message.GetLength()>0)
\r
1022 m_sMessageBuf = message;
\r
1023 m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));
\r
1024 m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));
\r
1025 if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)
\r
1026 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);
\r
1029 m_sMessageBuf.Empty();
\r
1030 pLogItem->sMessage = m_sMessageBuf;
\r
1031 pLogItem->Rev = rev;
\r
1033 // move-construct path array
\r
1035 pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);
\r
1036 cpaths->RemoveAll();
\r
1038 catch (CException * e)
\r
1040 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);
\r
1042 m_bCancelled = TRUE;
\r
1044 m_logEntries.push_back(pLogItem);
\r
1045 m_arShownList.Add(pLogItem);
\r
1050 //this is the thread function which calls the subversion function
\r
1051 UINT CLogDlg::LogThreadEntry(LPVOID pVoid)
\r
1053 return ((CLogDlg*)pVoid)->LogThread();
\r
1057 //this is the thread function which calls the subversion function
\r
1058 UINT CLogDlg::LogThread()
\r
1061 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1063 //does the user force the cache to refresh (shift or control key down)?
\r
1064 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1065 || (GetKeyState (VK_SHIFT) < 0);
\r
1067 //disable the "Get All" button while we're receiving
\r
1069 DialogEnableWindow(IDC_GETALL, FALSE);
\r
1070 DialogEnableWindow(IDC_NEXTHUNDRED, FALSE);
\r
1071 DialogEnableWindow(IDC_CHECK_STOPONCOPY, FALSE);
\r
1072 DialogEnableWindow(IDC_INCLUDEMERGE, FALSE);
\r
1073 DialogEnableWindow(IDC_STATBUTTON, FALSE);
\r
1074 DialogEnableWindow(IDC_REFRESH, FALSE);
\r
1077 temp.LoadString(IDS_PROGRESSWAIT);
\r
1078 m_LogList.ShowText(temp, true);
\r
1079 // change the text of the close button to "Cancel" since now the thread
\r
1080 // is running, and simply closing the dialog doesn't work.
\r
1081 if (!GetDlgItem(IDOK)->IsWindowVisible())
\r
1083 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1084 SetDlgItemText(IDCANCEL, temp);
\r
1086 // We use a progress bar while getting the logs
\r
1087 m_LogProgress.SetRange32(0, 100);
\r
1088 m_LogProgress.SetPos(0);
\r
1089 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
\r
1090 // git_revnum_t r = -1;
\r
1092 // get the repository root url, because the changed-files-list has the
\r
1093 // paths shown there relative to the repository root.
\r
1094 // CTGitPath rootpath;
\r
1095 // BOOL succeeded = GetRootAndHead(m_path, rootpath, r);
\r
1097 // m_sRepositoryRoot = rootpath.GetGitPathString();
\r
1098 // m_sURL = m_path.GetGitPathString();
\r
1100 // we need the UUID to unambigously identify the log cache
\r
1101 // if (logCachePool.IsEnabled())
\r
1102 // m_sUUID = logCachePool.GetRepositoryInfo().GetRepositoryUUID (rootpath);
\r
1104 // if the log dialog is started from a working copy, we need to turn that
\r
1105 // local path into an url here
\r
1108 // if (!m_path.IsUrl())
\r
1110 // m_sURL = GetURLFromPath(m_path);
\r
1112 // The URL is escaped because Git::logReceiver
\r
1113 // returns the path in a native format
\r
1114 // m_sURL = CPathUtils::PathUnescape(m_sURL);
\r
1116 // m_sRelativeRoot = m_sURL.Mid(CPathUtils::PathUnescape(m_sRepositoryRoot).GetLength());
\r
1117 // m_sSelfRelativeURL = m_sRelativeRoot;
\r
1120 if (succeeded && !m_mergePath.IsEmpty() && m_mergedRevs.empty())
\r
1122 // in case we got a merge path set, retrieve the merge info
\r
1123 // of that path and check whether one of the merge URLs
\r
1124 // match the URL we show the log for.
\r
1125 GitPool localpool(pool);
\r
1126 git_error_clear(Err);
\r
1127 apr_hash_t * mergeinfo = NULL;
\r
1128 if (git_client_mergeinfo_get_merged (&mergeinfo, m_mergePath.GetGitApiPath(localpool), GitRev(GitRev::REV_WC), m_pctx, localpool) == NULL)
\r
1130 // now check the relative paths
\r
1131 apr_hash_index_t *hi;
\r
1137 for (hi = apr_hash_first(localpool, mergeinfo); hi; hi = apr_hash_next(hi))
\r
1139 apr_hash_this(hi, &key, NULL, &val);
\r
1140 if (m_sURL.Compare(CUnicodeUtils::GetUnicode((char*)key)) == 0)
\r
1142 apr_array_header_t * arr = (apr_array_header_t*)val;
\r
1145 for (long i=0; i<arr->nelts; ++i)
\r
1147 git_merge_range_t * pRange = APR_ARRAY_IDX(arr, i, git_merge_range_t*);
\r
1150 for (git_revnum_t r=pRange->start+1; r<=pRange->end; ++r)
\r
1152 m_mergedRevs.insert(r);
\r
1164 m_LogProgress.SetPos(1);
\r
1165 if (m_startrev == GitRev::REV_HEAD)
\r
1169 if (m_endrev == GitRev::REV_HEAD)
\r
1176 m_limitcounter = m_limit;
\r
1177 m_LogProgress.SetRange32(0, m_limit);
\r
1180 m_LogProgress.SetRange32(m_endrev, m_startrev);
\r
1182 if (!m_pegrev.IsValid())
\r
1183 m_pegrev = m_startrev;
\r
1184 size_t startcount = m_logEntries.size();
\r
1186 m_bStrictStopped = false;
\r
1190 succeeded = ReceiveLog (CTGitPathList(m_path), m_pegrev, m_startrev, m_endrev, m_limit, m_bStrict, m_bIncludeMerges, refresh);
\r
1191 if ((!succeeded)&&(!m_path.IsUrl()))
\r
1193 // try again with REV_WC as the start revision, just in case the path doesn't
\r
1194 // exist anymore in HEAD
\r
1195 succeeded = ReceiveLog(CTGitPathList(m_path), GitRev(), GitRev::REV_WC, m_endrev, m_limit, m_bStrict, m_bIncludeMerges, refresh);
\r
1198 m_LogList.ClearText();
\r
1201 m_LogList.ShowText(GetLastErrorMessage(), true);
\r
1205 if (!m_wcRev.IsValid())
\r
1207 // fetch the revision the wc path is on so we can mark it
\r
1208 CTGitPath revWCPath = m_ProjectProperties.GetPropsPath();
\r
1209 if (!m_path.IsUrl())
\r
1210 revWCPath = m_path;
\r
1211 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RecursiveLogRev"), FALSE)))
\r
1213 git_revnum_t minrev, maxrev;
\r
1214 bool switched, modified, sparse;
\r
1215 GetWCRevisionStatus(revWCPath, true, minrev, maxrev, switched, modified, sparse);
\r
1221 CTGitPath dummypath;
\r
1223 git_wc_status2_t * stat = status.GetFirstFileStatus(revWCPath, dummypath, false, git_depth_empty);
\r
1224 if (stat && stat->entry && stat->entry->cmt_rev)
\r
1225 m_wcRev = stat->entry->cmt_rev;
\r
1226 if (stat && stat->entry && (stat->entry->kind == git_node_dir))
\r
1227 m_wcRev = stat->entry->revision;
\r
1231 if (m_bStrict && (m_lowestRev>1) && ((m_limit>0) ? ((startcount + m_limit)>m_logEntries.size()) : (m_endrev<m_lowestRev)))
\r
1232 m_bStrictStopped = true;
\r
1233 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
1235 m_timFrom = (__time64_t(m_tFrom));
\r
1236 m_timTo = (__time64_t(m_tTo));
\r
1237 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
1238 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
1239 m_DateFrom.SetTime(&m_timFrom);
\r
1240 m_DateTo.SetTime(&m_timTo);
\r
1242 DialogEnableWindow(IDC_GETALL, TRUE);
\r
1243 m_LogList.ClearText();
\r
1245 this->m_logEntries.ClearAll();
\r
1246 this->m_logEntries.ParserFromLog();
\r
1247 m_LogList.SetItemCountEx(this->m_logEntries.size());
\r
1249 this->m_arShownList.RemoveAll();
\r
1251 for(int i=0;i<m_logEntries.size();i++)
\r
1252 this->m_arShownList.Add(&m_logEntries[i]);
\r
1255 if (!m_bShowedAll)
\r
1256 DialogEnableWindow(IDC_NEXTHUNDRED, TRUE);
\r
1258 DialogEnableWindow(IDC_CHECK_STOPONCOPY, TRUE);
\r
1259 DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);
\r
1260 DialogEnableWindow(IDC_STATBUTTON, TRUE);
\r
1261 DialogEnableWindow(IDC_REFRESH, TRUE);
\r
1264 LogCache::CRepositoryInfo& cachedProperties = logCachePool.GetRepositoryInfo();
\r
1265 SetDlgTitle(cachedProperties.IsOffline (m_sUUID, m_sRepositoryRoot, false));
\r
1267 GetDlgItem(IDC_PROGRESS)->ShowWindow(FALSE);
\r
1268 m_bCancelled = true;
\r
1270 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1271 m_LogList.RedrawItems(0, m_arShownList.GetCount());
\r
1272 m_LogList.SetRedraw(false);
\r
1273 ResizeAllListCtrlCols();
\r
1274 m_LogList.SetRedraw(true);
\r
1275 if ( m_pStoreSelection )
\r
1277 // Deleting the instance will restore the
\r
1278 // selection of the CLogDlg.
\r
1279 delete m_pStoreSelection;
\r
1280 m_pStoreSelection = NULL;
\r
1284 // If no selection has been set then this must be the first time
\r
1285 // the revisions are shown. Let's preselect the topmost revision.
\r
1286 if ( m_LogList.GetItemCount()>0 )
\r
1288 m_LogList.SetSelectionMark(0);
\r
1289 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1293 if (!GetDlgItem(IDOK)->IsWindowVisible())
\r
1295 temp.LoadString(IDS_MSGBOX_OK);
\r
1296 SetDlgItemText(IDCANCEL, temp);
\r
1300 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1301 // the log messages
\r
1302 PostMessage(WM_TIMER, LOGFILTER_TIMER);
\r
1307 void CLogDlg::CopySelectionToClipBoard()
\r
1310 CString sClipdata;
\r
1311 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1315 sRev.LoadString(IDS_LOG_REVISION);
\r
1317 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1319 sDate.LoadString(IDS_LOG_DATE);
\r
1321 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1324 CString sLogCopyText;
\r
1326 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1327 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1328 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1330 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1331 sPaths += cpath->GetAction() + _T(" : ") + cpath->sPath;
\r
1332 if (cpath->sCopyFromPath.IsEmpty())
\r
1333 sPaths += _T("\r\n");
\r
1336 CString sCopyFrom;
\r
1337 sCopyFrom.Format(_T(" (%s: %s, %s, %ld)\r\n"), CString(MAKEINTRESOURCE(IDS_LOG_COPYFROM)),
\r
1338 (LPCTSTR)cpath->sCopyFromPath,
\r
1339 (LPCTSTR)CString(MAKEINTRESOURCE(IDS_LOG_REVISION)),
\r
1340 (LPCTSTR)cpath->lCopyFromRev);
\r
1341 sPaths += sCopyFrom;
\r
1345 sLogCopyText.Format(_T("%s: %d\r\n%s: %s\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),
\r
1346 (LPCTSTR)sRev, pLogEntry->Rev,
\r
1347 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->sAuthor,
\r
1348 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->sDate,
\r
1349 (LPCTSTR)sMessage, (LPCTSTR)pLogEntry->sMessage,
\r
1351 sClipdata += sLogCopyText;
\r
1353 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1358 void CLogDlg::CopyChangedSelectionToClipBoard()
\r
1361 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1363 return; // nothing is selected, get out of here
\r
1367 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1370 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
1373 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
1374 sPaths += m_currentChangedPathList[nItem].GetGitPathString();
\r
1375 sPaths += _T("\r\n");
\r
1380 // only one revision is selected in the log dialog top pane
\r
1381 // but multiple items could be selected in the changed items list
\r
1382 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
1385 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
1386 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
1388 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1390 // some items are hidden! So find out which item the user really selected
\r
1391 INT_PTR selRealIndex = -1;
\r
1392 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1394 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1396 if (selRealIndex == nItem)
\r
1398 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);
\r
1403 if (changedlogpath)
\r
1405 sPaths += changedlogpath->sPath;
\r
1406 sPaths += _T("\r\n");
\r
1411 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
\r
1415 BOOL CLogDlg::IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev)
\r
1418 CString added, deleted;
\r
1419 if (changedpath == NULL)
\r
1422 if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))
\r
1424 if (changedpath->action == LOGACTIONS_ADDED) // file is added
\r
1426 if (changedpath->lCopyFromRev == 0)
\r
1427 return FALSE; // but file was not added with history
\r
1435 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
1437 // we have two separate context menus:
\r
1438 // one shown on the log message list control,
\r
1439 // the other shown in the changed-files list control
\r
1440 int selCount = m_LogList.GetSelectedCount();
\r
1441 if (pWnd == &m_LogList)
\r
1443 ShowContextMenuForRevisions(pWnd, point);
\r
1445 else if (pWnd == &m_ChangedFileListCtrl)
\r
1447 ShowContextMenuForChangedpaths(pWnd, point);
\r
1449 else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1451 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1452 int selIndex = -1;
\r
1454 selIndex = m_LogList.GetNextSelectedItem(pos);
\r
1455 if ((point.x == -1) && (point.y == -1))
\r
1458 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
\r
1459 ClientToScreen(&rect);
\r
1460 point = rect.CenterPoint();
\r
1462 CString sMenuItemText;
\r
1464 if (popup.CreatePopupMenu())
\r
1466 // add the 'default' entries
\r
1467 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
\r
1468 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
\r
1469 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
\r
1470 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
\r
1472 if (selIndex >= 0)
\r
1474 popup.AppendMenu(MF_SEPARATOR);
\r
1475 sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
\r
1476 popup.AppendMenu(MF_STRING | MF_ENABLED, ID_EDITAUTHOR, sMenuItemText);
\r
1479 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1483 break; // no command selected
\r
1486 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
\r
1488 case ID_EDITAUTHOR:
\r
1489 EditLogMessage(selIndex);
\r
1496 bool CLogDlg::IsSelectionContinuous()
\r
1498 if ( m_LogList.GetSelectedCount()==1 )
\r
1500 // if only one revision is selected, the selection is of course
\r
1505 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1506 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1509 int itemindex = m_LogList.GetNextSelectedItem(pos);
\r
1512 int nextindex = m_LogList.GetNextSelectedItem(pos);
\r
1513 if (nextindex - itemindex > 1)
\r
1515 bContinuous = false;
\r
1518 itemindex = nextindex;
\r
1521 return bContinuous;
\r
1524 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
1527 ASSERT(m_pFindDialog != NULL);
\r
1529 if (m_pFindDialog->IsTerminating())
\r
1531 // invalidate the handle identifying the dialog box.
\r
1532 m_pFindDialog = NULL;
\r
1536 if(m_pFindDialog->FindNext())
\r
1538 //read data from dialog
\r
1539 CString FindText = m_pFindDialog->GetFindString();
\r
1540 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
\r
1541 bool bFound = false;
\r
1543 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
\r
1545 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
\r
1548 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
\r
1552 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1554 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))
\r
1559 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1560 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1562 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1563 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))
\r
1569 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))
\r
1581 if (m_logEntries[i]->sMessage.Find(FindText) >= 0)
\r
1586 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1587 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1588 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1590 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1591 if (cpath->sCopyFromPath.Find(FindText)>=0)
\r
1597 if (cpath->sPath.Find(FindText)>=0)
\r
1607 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1608 CString msg = pLogEntry->sMessage;
\r
1609 msg = msg.MakeLower();
\r
1610 CString find = FindText.MakeLower();
\r
1611 if (msg.Find(find) >= 0)
\r
1616 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1617 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1619 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1620 CString lowerpath = cpath->sCopyFromPath;
\r
1621 lowerpath.MakeLower();
\r
1622 if (lowerpath.Find(find)>=0)
\r
1628 lowerpath = cpath->sPath;
\r
1629 lowerpath.MakeLower();
\r
1630 if (lowerpath.Find(find)>=0)
\r
1639 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
\r
1642 this->m_nSearchIndex = (i+1);
\r
1643 m_LogList.EnsureVisible(i, FALSE);
\r
1644 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);
\r
1645 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1646 m_LogList.SetSelectionMark(i);
\r
1647 FillLogMessageCtrl();
\r
1648 UpdateData(FALSE);
\r
1650 if (m_nSearchIndex >= m_arShownList.GetCount())
\r
1651 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
\r
1653 } // if(m_pFindDialog->FindNext())
\r
1654 UpdateLogInfoLabel();
\r
1659 void CLogDlg::OnOK()
\r
1662 // since the log dialog is also used to select revisions for other
\r
1663 // dialogs, we have to do some work before closing this dialog
\r
1664 if (GetFocus() != GetDlgItem(IDOK))
\r
1665 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
\r
1666 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
\r
1667 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
\r
1670 CString buttontext;
\r
1671 GetDlgItemText(IDOK, buttontext);
\r
1672 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1673 if (temp.Compare(buttontext) != 0)
\r
1674 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
\r
1675 m_bCancelled = TRUE;
\r
1676 m_selectedRevs.Clear();
\r
1677 m_selectedRevsOneRange.Clear();
\r
1678 if (m_pNotifyWindow)
\r
1680 int selIndex = m_LogList.GetSelectionMark();
\r
1681 if (selIndex >= 0)
\r
1683 PLOGENTRYDATA pLogEntry = NULL;
\r
1684 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1685 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1686 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1687 git_revnum_t lowerRev = pLogEntry->Rev;
\r
1688 git_revnum_t higherRev = lowerRev;
\r
1691 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1692 git_revnum_t rev = pLogEntry->Rev;
\r
1693 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1694 if (lowerRev > rev)
\r
1696 if (higherRev < rev)
\r
1699 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
\r
1701 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
\r
1703 BOOL bSentMessage = FALSE;
\r
1704 if (m_LogList.GetSelectedCount() == 1)
\r
1706 // if only one revision is selected, check if the path/url with which the dialog was started
\r
1707 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
\r
1708 // if it was copied, use the copy from revision as lowerRev
\r
1709 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
\r
1711 CString sUrl = m_path.GetGitPathString();
\r
1712 if (!m_path.IsUrl())
\r
1714 sUrl = GetURLFromPath(m_path);
\r
1716 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
\r
1717 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
\r
1719 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);
\r
1722 if (sUrl.Compare(pData->sPath) == 0)
\r
1724 if (!pData->sCopyFromPath.IsEmpty())
\r
1726 lowerRev = pData->lCopyFromRev;
\r
1727 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
\r
1728 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
\r
1729 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1730 bSentMessage = TRUE;
\r
1737 if ( !bSentMessage )
\r
1739 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
\r
1740 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
\r
1741 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1742 if (m_selectedRevsOneRange.GetCount())
\r
1743 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
\r
1748 if (m_bSaveStrict)
\r
1749 m_regLastStrict = m_bStrict;
\r
1750 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
1751 reg = m_btnShow.GetCurrentEntry();
\r
1752 SaveSplitterPos();
\r
1756 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1758 // a double click on an entry in the changed-files list has happened
\r
1761 DiffSelectedFile();
\r
1764 void CLogDlg::DiffSelectedFile()
\r
1767 if (m_bThreadRunning)
\r
1769 UpdateLogInfoLabel();
\r
1770 INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
1773 if (m_ChangedFileListCtrl.GetSelectedCount() == 0)
\r
1775 // find out if there's an entry selected in the log list
\r
1776 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1777 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1778 git_revnum_t rev1 = pLogEntry->Rev;
\r
1779 git_revnum_t rev2 = rev1;
\r
1784 // there's at least a second entry selected in the log list: several revisions selected!
\r
1785 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1788 rev1 = max(rev1,(long)pLogEntry->Rev);
\r
1789 rev2 = min(rev2,(long)pLogEntry->Rev);
\r
1793 // now we have both revisions selected in the log list, so we can do a diff of the selected
\r
1794 // entry in the changed files list with these two revisions.
\r
1795 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1800 // nothing or only one revision selected in the log list
\r
1801 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1803 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1805 // some items are hidden! So find out which item the user really clicked on
\r
1806 INT_PTR selRealIndex = -1;
\r
1807 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1809 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1811 if (selRealIndex == selIndex)
\r
1813 selIndex = hiddenindex;
\r
1814 changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1820 if (IsDiffPossible(changedpath, rev1))
\r
1822 // diffs with renamed files are possible
\r
1823 if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))
\r
1824 rev2 = changedpath->lCopyFromRev;
\r
1827 // if the path was modified but the parent path was 'added with history'
\r
1828 // then we have to use the copy from revision of the parent path
\r
1829 CTGitPath cpath = CTGitPath(changedpath->sPath);
\r
1830 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
1832 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
1833 if (p.IsAncestorOf(cpath))
\r
1835 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
1836 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
1840 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1844 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1845 CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1847 // deleted files must be opened from the revision before the deletion
\r
1848 if (changedpath->action == LOGACTIONS_DELETED)
\r
1850 m_bCancelled = false;
\r
1852 CProgressDlg progDlg;
\r
1853 progDlg.SetTitle(IDS_APPNAME);
\r
1854 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1855 CString sInfoLine;
\r
1856 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());
\r
1857 progDlg.SetLine(1, sInfoLine, true);
\r
1858 SetAndClearProgressInfo(&progDlg);
\r
1859 progDlg.ShowModeless(m_hWnd);
\r
1861 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))
\r
1863 m_bCancelled = false;
\r
1864 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))
\r
1867 SetAndClearProgressInfo((HWND)NULL);
\r
1868 CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1873 SetAndClearProgressInfo((HWND)NULL);
\r
1875 CString sName1, sName2;
\r
1876 sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);
\r
1877 sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);
\r
1878 CAppUtils::DiffFlags flags;
\r
1879 flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1880 if (changedpath->action == LOGACTIONS_DELETED)
\r
1881 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);
\r
1883 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);
\r
1890 void CLogDlg::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1892 // a double click on an entry in the revision list has happened
\r
1895 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1896 DiffSelectedRevWithPrevious();
\r
1899 void CLogDlg::DiffSelectedRevWithPrevious()
\r
1902 if (m_bThreadRunning)
\r
1904 UpdateLogInfoLabel();
\r
1905 int selIndex = m_LogList.GetSelectionMark();
\r
1908 int selCount = m_LogList.GetSelectedCount();
\r
1909 if (selCount != 1)
\r
1912 // Find selected entry in the log list
\r
1913 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1914 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1915 long rev1 = pLogEntry->Rev;
\r
1916 long rev2 = rev1-1;
\r
1917 CTGitPath path = m_path;
\r
1919 // See how many files under the relative root were changed in selected revision
\r
1921 LogChangedPath * changed = NULL;
\r
1922 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1924 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1925 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1932 if (m_path.IsDirectory() && nChanged == 1)
\r
1934 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1935 // Do diff on that file instead of whole directory
\r
1936 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1939 m_bCancelled = FALSE;
\r
1940 DialogEnableWindow(IDOK, FALSE);
\r
1941 SetPromptApp(&theApp);
\r
1942 theApp.DoWaitCursor(1);
\r
1944 if (PromptShown())
\r
1946 GitDiff diff(this, m_hWnd, true);
\r
1947 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1948 diff.SetHEADPeg(m_LogRevision);
\r
1949 diff.ShowCompare(path, rev2, path, rev1);
\r
1953 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1956 theApp.DoWaitCursor(-1);
\r
1961 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)
\r
1963 DialogEnableWindow(IDOK, FALSE);
\r
1964 // SetPromptApp(&theApp);
\r
1965 theApp.DoWaitCursor(1);
\r
1968 GetTempPath(temppath);
\r
1971 file1.Format(_T("%s%s_%s%s"),
\r
1973 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1974 rev1->m_CommitHash.Left(6),
\r
1975 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1978 file2.Format(_T("%s\\%s_%s%s"),
\r
1980 (*m_currentChangedArray)[selIndex].GetBaseFilename(),
\r
1981 rev2->m_CommitHash.Left(6),
\r
1982 (*m_currentChangedArray)[selIndex].GetFileExtension());
\r
1986 cmd.Format(_T("git.cmd cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1987 g_Git.RunLogFile(cmd,file1);
\r
1988 cmd.Format(_T("git.cmd cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());
\r
1989 g_Git.RunLogFile(cmd,file2);
\r
1991 CAppUtils::DiffFlags flags;
\r
1992 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);
\r
1995 //get the filename
\r
1997 if (Git::PathIsURL(m_path))
\r
1999 filepath = m_path.GetGitPathString();
\r
2003 filepath = GetURLFromPath(m_path);
\r
2004 if (filepath.IsEmpty())
\r
2006 theApp.DoWaitCursor(-1);
\r
2008 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2009 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2010 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2012 theApp.DoWaitCursor(-11);
\r
2016 m_bCancelled = FALSE;
\r
2017 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2019 CString firstfile, secondfile;
\r
2020 if (m_LogList.GetSelectedCount()==1)
\r
2022 int s = m_LogList.GetSelectionMark();
\r
2023 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));
\r
2024 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
2025 firstfile = changedpath->sPath;
\r
2026 secondfile = firstfile;
\r
2027 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?
\r
2029 secondfile = changedpath->sCopyFromPath;
\r
2030 rev2 = changedpath->lCopyFromRev;
\r
2035 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();
\r
2036 secondfile = firstfile;
\r
2039 firstfile = filepath + firstfile.Trim();
\r
2040 secondfile = filepath + secondfile.Trim();
\r
2042 GitDiff diff(this, this->m_hWnd, true);
\r
2043 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
2044 diff.SetHEADPeg(m_LogRevision);
\r
2047 if (PromptShown())
\r
2048 diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);
\r
2050 CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);
\r
2054 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))
\r
2056 if (firstfile.Compare(secondfile)==0)
\r
2058 git_revnum_t baseRev = 0;
\r
2059 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);
\r
2066 theApp.DoWaitCursor(-1);
\r
2070 BOOL CLogDlg::Open(bool bOpenWith,CString changedpath, git_revnum_t rev)
\r
2073 DialogEnableWindow(IDOK, FALSE);
\r
2074 SetPromptApp(&theApp);
\r
2075 theApp.DoWaitCursor(1);
\r
2077 if (Git::PathIsURL(m_path))
\r
2079 filepath = m_path.GetGitPathString();
\r
2083 filepath = GetURLFromPath(m_path);
\r
2084 if (filepath.IsEmpty())
\r
2086 theApp.DoWaitCursor(-1);
\r
2088 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2089 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2090 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2095 m_bCancelled = false;
\r
2096 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2097 filepath += changedpath;
\r
2099 CProgressDlg progDlg;
\r
2100 progDlg.SetTitle(IDS_APPNAME);
\r
2101 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
2102 CString sInfoLine;
\r
2103 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());
\r
2104 progDlg.SetLine(1, sInfoLine, true);
\r
2105 SetAndClearProgressInfo(&progDlg);
\r
2106 progDlg.ShowModeless(m_hWnd);
\r
2108 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);
\r
2109 m_bCancelled = false;
\r
2110 if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))
\r
2113 SetAndClearProgressInfo((HWND)NULL);
\r
2114 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2116 theApp.DoWaitCursor(-1);
\r
2120 SetAndClearProgressInfo((HWND)NULL);
\r
2121 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
2124 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
2125 if (ret <= HINSTANCE_ERROR)
\r
2130 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
2131 cmd += tempfile.GetWinPathString() + _T(" ");
\r
2132 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
2135 theApp.DoWaitCursor(-1);
\r
2140 void CLogDlg::EditAuthor(const CLogDataVector& logs)
\r
2145 if (logs.size() == 0)
\r
2147 DialogEnableWindow(IDOK, FALSE);
\r
2148 SetPromptApp(&theApp);
\r
2149 theApp.DoWaitCursor(1);
\r
2150 if (Git::PathIsURL(m_path))
\r
2151 url = m_path.GetGitPathString();
\r
2154 url = GetURLFromPath(m_path);
\r
2156 name = Git_PROP_REVISION_AUTHOR;
\r
2158 CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);
\r
2159 CString sOldValue = value;
\r
2160 value.Replace(_T("\n"), _T("\r\n"));
\r
2161 CInputDlg dlg(this);
\r
2162 dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);
\r
2163 dlg.m_sInputText = value;
\r
2164 dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);
\r
2165 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
2166 dlg.m_bUseLogWidth = false;
\r
2167 if (dlg.DoModal() == IDOK)
\r
2169 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
2171 LogCache::CCachedLogInfo* toUpdate
\r
2172 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
2174 CProgressDlg progDlg;
\r
2175 progDlg.SetTitle(IDS_APPNAME);
\r
2176 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
\r
2177 progDlg.SetTime(true);
\r
2178 progDlg.SetShowProgressBar(true);
\r
2179 progDlg.ShowModeless(m_hWnd);
\r
2180 for (DWORD i=0; i<logs.size(); ++i)
\r
2182 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))
\r
2185 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2191 logs[i]->sAuthor = dlg.m_sInputText;
\r
2192 m_LogList.Invalidate();
\r
2194 // update the log cache
\r
2196 if (toUpdate != NULL)
\r
2198 // log caching is active
\r
2200 LogCache::CCachedLogInfo newInfo;
\r
2201 newInfo.Insert ( logs[i]->Rev
\r
2202 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)
\r
2205 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);
\r
2207 toUpdate->Update (newInfo);
\r
2210 progDlg.SetProgress64(i, logs.size());
\r
2214 theApp.DoWaitCursor(-1);
\r
2219 void CLogDlg::EditLogMessage(int index)
\r
2224 DialogEnableWindow(IDOK, FALSE);
\r
2225 SetPromptApp(&theApp);
\r
2226 theApp.DoWaitCursor(1);
\r
2227 if (Git::PathIsURL(m_path))
\r
2228 url = m_path.GetGitPathString();
\r
2231 url = GetURLFromPath(m_path);
\r
2233 name = Git_PROP_REVISION_LOG;
\r
2235 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
2236 m_bCancelled = FALSE;
\r
2237 CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);
\r
2238 CString sOldValue = value;
\r
2239 value.Replace(_T("\n"), _T("\r\n"));
\r
2240 CInputDlg dlg(this);
\r
2241 dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);
\r
2242 dlg.m_sInputText = value;
\r
2243 dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);
\r
2244 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
2245 dlg.m_bUseLogWidth = true;
\r
2246 if (dlg.DoModal() == IDOK)
\r
2248 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
2249 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))
\r
2251 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2255 pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);
\r
2256 // split multi line log entries and concatenate them
\r
2257 // again but this time with \r\n as line separators
\r
2258 // so that the edit control recognizes them
\r
2259 if (dlg.m_sInputText.GetLength()>0)
\r
2261 m_sMessageBuf = dlg.m_sInputText;
\r
2262 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));
\r
2263 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));
\r
2264 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)
\r
2265 dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);
\r
2268 dlg.m_sInputText.Empty();
\r
2269 pLogEntry->sMessage = dlg.m_sInputText;
\r
2270 pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);
\r
2271 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
2272 pMsgView->SetWindowText(_T(" "));
\r
2273 pMsgView->SetWindowText(dlg.m_sInputText);
\r
2274 m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);
\r
2275 m_LogList.Invalidate();
\r
2277 // update the log cache
\r
2279 LogCache::CCachedLogInfo* toUpdate
\r
2280 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
2281 if (toUpdate != NULL)
\r
2283 // log caching is active
\r
2285 LogCache::CCachedLogInfo newInfo;
\r
2286 newInfo.Insert ( pLogEntry->Rev
\r
2288 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)
\r
2290 , LogCache::CRevisionInfoContainer::HAS_COMMENT);
\r
2292 toUpdate->Update (newInfo);
\r
2296 theApp.DoWaitCursor(-1);
\r
2301 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
\r
2303 // Skip Ctrl-C when copying text out of the log message or search filter
\r
2304 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
2305 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
2307 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
2309 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
2311 DiffSelectedRevWithPrevious();
\r
2315 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
2317 DiffSelectedFile();
\r
2321 if (m_hAccel && !bSkipAccelerator)
\r
2323 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
2328 m_tooltips.RelayEvent(pMsg);
\r
2329 return __super::PreTranslateMessage(pMsg);
\r
2332 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
2334 if (m_bThreadRunning)
\r
2336 // only show the wait cursor over the list control
\r
2338 ((pWnd == GetDlgItem(IDC_LOGLIST))||
\r
2339 (pWnd == GetDlgItem(IDC_MSGVIEW))||
\r
2340 (pWnd == GetDlgItem(IDC_LOGMSG))))
\r
2342 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
2347 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
2348 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
2350 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
2352 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
2355 void CLogDlg::OnBnClickedHelp()
\r
2360 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
2362 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2364 if (m_bThreadRunning)
\r
2366 if (pNMLV->iItem >= 0)
\r
2368 m_nSearchIndex = pNMLV->iItem;
\r
2369 if (pNMLV->iSubItem != 0)
\r
2371 if ((pNMLV->iItem == m_arShownList.GetCount())&&(m_bStrict)&&(m_bStrictStopped))
\r
2373 // remove the selected state
\r
2374 if (pNMLV->uChanged & LVIF_STATE)
\r
2376 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
\r
2377 FillLogMessageCtrl();
\r
2378 UpdateData(FALSE);
\r
2379 UpdateLogInfoLabel();
\r
2383 if (pNMLV->uChanged & LVIF_STATE)
\r
2385 FillLogMessageCtrl();
\r
2386 UpdateData(FALSE);
\r
2391 FillLogMessageCtrl();
\r
2392 UpdateData(FALSE);
\r
2395 UpdateLogInfoLabel();
\r
2398 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
\r
2400 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
\r
2401 if (pEnLink->msg == WM_LBUTTONUP)
\r
2404 GetDlgItemText(IDC_MSGVIEW, msg);
\r
2405 msg.Replace(_T("\r\n"), _T("\n"));
\r
2406 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
\r
2407 if (!::PathIsURL(url))
\r
2409 url = m_ProjectProperties.GetBugIDUrl(url);
\r
2410 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
2412 if (!url.IsEmpty())
\r
2413 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
2418 void CLogDlg::OnBnClickedStatbutton()
\r
2421 if (m_bThreadRunning)
\r
2423 if (m_arShownList.IsEmpty())
\r
2424 return; // nothing is shown, so no statistics.
\r
2425 // the statistics dialog expects the log entries to be sorted by date
\r
2426 SortByColumn(3, false);
\r
2427 CPtrArray shownlist;
\r
2428 RecalculateShownList(&shownlist);
\r
2429 // create arrays which are aware of the current filter
\r
2430 CStringArray m_arAuthorsFiltered;
\r
2431 CDWordArray m_arDatesFiltered;
\r
2432 CDWordArray m_arFileChangesFiltered;
\r
2433 for (INT_PTR i=0; i<shownlist.GetCount(); ++i)
\r
2435 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(shownlist.GetAt(i));
\r
2436 CString strAuthor = pLogEntry->sAuthor;
\r
2437 if ( strAuthor.IsEmpty() )
\r
2439 strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);
\r
2441 m_arAuthorsFiltered.Add(strAuthor);
\r
2442 m_arDatesFiltered.Add(static_cast<DWORD>(pLogEntry->tmDate));
\r
2443 m_arFileChangesFiltered.Add(pLogEntry->dwFileChanges);
\r
2445 CStatGraphDlg dlg;
\r
2446 dlg.m_parAuthors = &m_arAuthorsFiltered;
\r
2447 dlg.m_parDates = &m_arDatesFiltered;
\r
2448 dlg.m_parFileChanges = &m_arFileChangesFiltered;
\r
2449 dlg.m_path = m_path;
\r
2451 // restore the previous sorting
\r
2452 SortByColumn(m_nSortColumn, m_bAscending);
\r
2453 OnTimer(LOGFILTER_TIMER);
\r
2457 void CLogDlg::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
2460 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
2461 // Take the default processing unless we set this to something else below.
\r
2462 *pResult = CDRF_DODEFAULT;
\r
2464 if (m_bNoDispUpdates)
\r
2467 switch (pLVCD->nmcd.dwDrawStage)
\r
2469 case CDDS_PREPAINT:
\r
2471 *pResult = CDRF_NOTIFYITEMDRAW;
\r
2475 case CDDS_ITEMPREPAINT:
\r
2477 // This is the prepaint stage for an item. Here's where we set the
\r
2478 // item's text color.
\r
2480 // Tell Windows to send draw notifications for each subitem.
\r
2481 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
2483 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
2485 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2487 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
2491 if (data->bCopiedSelf)
\r
2493 // only change the background color if the item is not 'hot' (on vista with themes enabled)
\r
2494 if (!theme.IsAppThemed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
2495 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
2498 if (data->bCopies)
\r
2499 crText = m_Colors.GetColor(CColors::Modified);
\r
2501 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
2502 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
2503 // if (data->Rev == m_wcRev)
\r
2505 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
2506 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
2507 // tells the control to recalculate the extent of the text.
\r
2508 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
2512 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2514 if (m_bStrictStopped)
\r
2515 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2517 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
2518 pLVCD->clrText = crText;
\r
2522 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
2524 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
2526 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
2528 if (pLVCD->iSubItem == 1)
\r
2530 *pResult = CDRF_DODEFAULT;
\r
2532 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2536 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
2537 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
2539 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
2541 // Get the selected state of the
\r
2542 // item being drawn.
\r
2544 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
2545 rItem.mask = LVIF_STATE;
\r
2546 rItem.iItem = pLVCD->nmcd.dwItemSpec;
\r
2547 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
2548 m_LogList.GetItem(&rItem);
\r
2551 m_LogList.GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
2553 // Fill the background
\r
2554 if (theme.IsAppThemed() && m_bVista)
\r
2556 theme.Open(m_hWnd, L"Explorer");
\r
2557 int state = LISS_NORMAL;
\r
2558 if (rItem.state & LVIS_SELECTED)
\r
2560 if (::GetFocus() == m_LogList.m_hWnd)
\r
2561 state |= LISS_SELECTED;
\r
2563 state |= LISS_SELECTEDNOTFOCUS;
\r
2568 if (pLogEntry->bCopiedSelf)
\r
2570 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
2571 // information at this drawing stage. But we can check the whether the
\r
2572 // previous stage changed the background color of the item
\r
2573 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
2576 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2579 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2580 ::DeleteObject(brush);
\r
2587 if (theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
2588 theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);
\r
2590 theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
2595 if (rItem.state & LVIS_SELECTED)
\r
2597 if (::GetFocus() == m_LogList.m_hWnd)
\r
2598 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
2600 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
2604 //if (pLogEntry->bCopiedSelf)
\r
2605 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2607 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
2609 if (brush == NULL)
\r
2612 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2613 ::DeleteObject(brush);
\r
2616 // Draw the icon(s) into the compatible DC
\r
2617 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
2618 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2621 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
2622 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2625 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
2626 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2629 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
2630 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2632 *pResult = CDRF_SKIPDEFAULT;
\r
2638 *pResult = CDRF_DODEFAULT;
\r
2641 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2644 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
2645 // Take the default processing unless we set this to something else below.
\r
2646 *pResult = CDRF_DODEFAULT;
\r
2648 if (m_bNoDispUpdates)
\r
2651 // First thing - check the draw stage. If it's the control's prepaint
\r
2652 // stage, then tell Windows we want messages for every item.
\r
2654 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2656 *pResult = CDRF_NOTIFYITEMDRAW;
\r
2658 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2660 // This is the prepaint stage for an item. Here's where we set the
\r
2661 // item's text color. Our return value will tell Windows to draw the
\r
2662 // item itself, but it will use the new color we set here.
\r
2664 // Tell Windows to paint the control itself.
\r
2665 *pResult = CDRF_DODEFAULT;
\r
2667 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
2668 bool bGrayed = false;
\r
2670 if ((m_cHidePaths.GetState() & 0x0003)==BST_INDETERMINATE)
\r
2672 if ((m_currentChangedArray)&&((m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)))
\r
2674 //if ((*m_currentChangedArray)[(pLVCD->nmcd.dwItemSpec)]sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2676 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2680 else if (m_currentChangedPathList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2682 //if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2684 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2691 if ((!bGrayed)&&(m_currentChangedArray)&&(m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
2693 DWORD action = ((*m_currentChangedArray)[pLVCD->nmcd.dwItemSpec]).m_Action;
\r
2694 if (action == CTGitPath::LOGACTIONS_MODIFIED)
\r
2695 crText = m_Colors.GetColor(CColors::Modified);
\r
2696 if (action == CTGitPath::LOGACTIONS_REPLACED)
\r
2697 crText = m_Colors.GetColor(CColors::Deleted);
\r
2698 if (action == CTGitPath::LOGACTIONS_ADDED)
\r
2699 crText = m_Colors.GetColor(CColors::Added);
\r
2700 if (action == CTGitPath::LOGACTIONS_DELETED)
\r
2701 crText = m_Colors.GetColor(CColors::Deleted);
\r
2704 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
2705 pLVCD->clrText = crText;
\r
2709 void CLogDlg::DoSizeV1(int delta)
\r
2712 RemoveAnchor(IDC_LOGLIST);
\r
2713 RemoveAnchor(IDC_SPLITTERTOP);
\r
2714 RemoveAnchor(IDC_MSGVIEW);
\r
2715 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2716 RemoveAnchor(IDC_LOGMSG);
\r
2717 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
\r
2718 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
\r
2719 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2720 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2721 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2722 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2723 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2726 SetSplitterRange();
\r
2727 m_LogList.Invalidate();
\r
2728 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2732 void CLogDlg::DoSizeV2(int delta)
\r
2735 RemoveAnchor(IDC_LOGLIST);
\r
2736 RemoveAnchor(IDC_SPLITTERTOP);
\r
2737 RemoveAnchor(IDC_MSGVIEW);
\r
2738 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2739 RemoveAnchor(IDC_LOGMSG);
\r
2740 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
\r
2741 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
\r
2742 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2743 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2744 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2745 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2746 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2749 SetSplitterRange();
\r
2750 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2751 m_ChangedFileListCtrl.Invalidate();
\r
2755 void CLogDlg::AdjustMinSize()
\r
2757 // adjust the minimum size of the dialog to prevent the resizing from
\r
2758 // moving the list control too far down.
\r
2759 CRect rcChgListView;
\r
2760 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
\r
2762 m_LogList.GetClientRect(rcLogList);
\r
2764 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
\r
2765 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
\r
2766 +rcChgListView.Height()+rcLogList.Height()+60));
\r
2769 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
2771 switch (message) {
\r
2773 if (wParam == IDC_SPLITTERTOP)
\r
2775 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2776 DoSizeV1(pHdr->delta);
\r
2778 else if (wParam == IDC_SPLITTERBOTTOM)
\r
2780 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2781 DoSizeV2(pHdr->delta);
\r
2786 return CResizableDialog::DefWindowProc(message, wParam, lParam);
\r
2789 void CLogDlg::SetSplitterRange()
\r
2791 if ((m_LogList)&&(m_ChangedFileListCtrl))
\r
2794 m_LogList.GetWindowRect(rcTop);
\r
2795 ScreenToClient(rcTop);
\r
2797 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
\r
2798 ScreenToClient(rcMiddle);
\r
2799 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
\r
2801 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
\r
2802 ScreenToClient(rcBottom);
\r
2803 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
\r
2807 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
\r
2809 RECT * rect = (LPRECT)lParam;
\r
2812 point = CPoint(rect->left, rect->bottom);
\r
2813 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
\r
2815 if (popup.CreatePopupMenu())
\r
2817 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2818 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);
\r
2820 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2822 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2823 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
\r
2824 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2825 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
\r
2826 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2827 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
\r
2828 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2829 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
\r
2830 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
\r
2831 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
\r
2833 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2835 temp.LoadString(IDS_LOG_FILTER_REGEX);
\r
2836 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
\r
2839 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2840 if (selection != 0)
\r
2843 if (selection == LOGFILTER_REGEX)
\r
2845 m_bFilterWithRegex = !m_bFilterWithRegex;
\r
2846 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
2847 b = m_bFilterWithRegex;
\r
2848 CheckRegexpTooltip();
\r
2852 m_nSelectedFilter = selection;
\r
2853 SetFilterCueText();
\r
2855 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2861 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
2864 KillTimer(LOGFILTER_TIMER);
\r
2866 m_sFilterText.Empty();
\r
2867 UpdateData(FALSE);
\r
2868 theApp.DoWaitCursor(1);
\r
2869 CStoreSelection storeselection(this);
\r
2870 FillLogMessageCtrl(false);
\r
2871 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2872 m_arShownList.RemoveAll();
\r
2874 // reset the time filter too
\r
2875 m_timFrom = (__time64_t(m_tFrom));
\r
2876 m_timTo = (__time64_t(m_tTo));
\r
2877 m_DateFrom.SetTime(&m_timFrom);
\r
2878 m_DateTo.SetTime(&m_timTo);
\r
2879 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2880 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2882 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2884 m_arShownList.Add(m_logEntries[i]);
\r
2886 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2887 m_LogList.DeleteAllItems();
\r
2888 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
2889 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
2890 m_LogList.SetRedraw(false);
\r
2891 ResizeAllListCtrlCols();
\r
2892 m_LogList.SetRedraw(true);
\r
2893 theApp.DoWaitCursor(-1);
\r
2894 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2895 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2896 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2897 UpdateLogInfoLabel();
\r
2903 void CLogDlg::SetFilterCueText()
\r
2906 switch (m_nSelectedFilter)
\r
2908 case LOGFILTER_ALL:
\r
2909 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2911 case LOGFILTER_MESSAGES:
\r
2912 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2914 case LOGFILTER_PATHS:
\r
2915 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2917 case LOGFILTER_AUTHORS:
\r
2918 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2920 case LOGFILTER_REVS:
\r
2921 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2924 // to make the cue banner text appear more to the right of the edit control
\r
2925 temp = _T(" ")+temp;
\r
2926 m_cFilter.SetCueBanner(temp);
\r
2929 void CLogDlg::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
2931 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
2933 // Create a pointer to the item
\r
2934 LV_ITEM* pItem = &(pDispInfo)->item;
\r
2936 // Do the list need text information?
\r
2937 if (!(pItem->mask & LVIF_TEXT))
\r
2940 // By default, clear text buffer.
\r
2941 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
2943 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
2946 if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)
\r
2949 // Which item number?
\r
2950 int itemid = pItem->iItem;
\r
2951 GitRev * pLogEntry = NULL;
\r
2952 if (itemid < m_arShownList.GetCount())
\r
2953 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
2956 switch (pItem->iSubItem)
\r
2958 case this->LOGLIST_GRAPH: //Graphic
\r
2963 case this->LOGLIST_ACTION: //action -- no text in the column
\r
2965 case this->LOGLIST_MESSAGE: //Message
\r
2967 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
2969 case this->LOGLIST_AUTHOR: //Author
\r
2971 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
2973 case this->LOGLIST_DATE: //Date
\r
2975 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
2986 void CLogDlg::OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2989 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
2991 //Create a pointer to the item
\r
2992 LV_ITEM* pItem= &(pDispInfo)->item;
\r
2995 if ((m_bNoDispUpdates)||(m_bThreadRunning))
\r
2997 if (pItem->mask & LVIF_TEXT)
\r
2998 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3001 if ((m_currentChangedArray!=NULL)&&(pItem->iItem >= m_currentChangedArray->GetCount()))
\r
3003 if (pItem->mask & LVIF_TEXT)
\r
3004 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3007 if ((m_currentChangedArray==NULL)&&(pItem->iItem >= m_currentChangedPathList.GetCount()))
\r
3009 if (pItem->mask & LVIF_TEXT)
\r
3010 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3013 CTGitPath lcpath = NULL;
\r
3014 if (m_currentChangedArray)
\r
3015 lcpath = (*m_currentChangedArray)[pItem->iItem];
\r
3016 //Does the list need text information?
\r
3017 if (pItem->mask & LVIF_TEXT)
\r
3020 switch (pItem->iSubItem)
\r
3022 case this->FILELIST_ACTION: //Action
\r
3025 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->GetAction(), pItem->cchTextMax);
\r
3027 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3029 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetActionName(), pItem->cchTextMax);
\r
3033 case this->FILELIST_ADD: //add
\r
3036 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sPath, pItem->cchTextMax);
\r
3038 lstrcpyn(pItem->pszText, (LPCTSTR)m_currentChangedPathList[pItem->iItem].GetGitPathString(), pItem->cchTextMax);
\r
3040 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatAdd, pItem->cchTextMax);
\r
3043 case this->FILELIST_DEL: //del
\r
3046 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sCopyFromPath, pItem->cchTextMax);
\r
3048 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3050 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatDel, pItem->cchTextMax);
\r
3052 case this->FILELIST_PATH: //path
\r
3054 if ((lcpath==NULL)||(lcpath->sCopyFromPath.IsEmpty()))
\r
3055 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3057 _stprintf_s(pItem->pszText, pItem->cchTextMax, _T("%ld"), lcpath->lCopyFromRev);
\r
3059 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetGitPathString(), pItem->cchTextMax);
\r
3067 void CLogDlg::OnEnChangeSearchedit()
\r
3071 if (m_sFilterText.IsEmpty())
\r
3073 CStoreSelection storeselection(this);
\r
3074 // clear the filter, i.e. make all entries appear
\r
3075 theApp.DoWaitCursor(1);
\r
3076 KillTimer(LOGFILTER_TIMER);
\r
3077 FillLogMessageCtrl(false);
\r
3078 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3079 m_arShownList.RemoveAll();
\r
3080 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3082 if (IsEntryInDateRange(i))
\r
3083 m_arShownList.Add(m_logEntries[i]);
\r
3085 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3086 m_LogList.DeleteAllItems();
\r
3087 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3088 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3089 m_LogList.SetRedraw(false);
\r
3090 ResizeAllListCtrlCols();
\r
3091 m_LogList.SetRedraw(true);
\r
3092 theApp.DoWaitCursor(-1);
\r
3093 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3094 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3095 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3096 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));
\r
3099 if (Validate(m_sFilterText))
\r
3100 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3102 KillTimer(LOGFILTER_TIMER);
\r
3106 bool CLogDlg::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
3110 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
3112 type |= tr1::regex_constants::icase;
\r
3113 pat = tr1::wregex(regexp_str, type);
\r
3116 catch (exception) {}
\r
3120 bool CLogDlg::Validate(LPCTSTR string)
\r
3122 if (!m_bFilterWithRegex)
\r
3125 return ValidateRegexp(string, pat, false);
\r
3128 void CLogDlg::RecalculateShownList(CPtrArray * pShownlist)
\r
3131 pShownlist->RemoveAll();
\r
3132 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
3133 bool bRegex = false;
\r
3134 if (m_bFilterWithRegex)
\r
3135 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
3137 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
3139 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3141 if ((bRegex)&&(m_bFilterWithRegex))
\r
3143 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
3145 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
3146 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
3148 pShownlist->Add(m_logEntries[i]);
\r
3152 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
3154 ATLTRACE(_T("messge = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sMessage);
\r
3155 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sMessage), pat, flags)&&IsEntryInDateRange(i))
\r
3157 pShownlist->Add(m_logEntries[i]);
\r
3161 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
3163 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
3165 bool bGoing = true;
\r
3166 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
3168 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
3169 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
3171 pShownlist->Add(m_logEntries[i]);
\r
3175 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
3177 pShownlist->Add(m_logEntries[i]);
\r
3181 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
3183 pShownlist->Add(m_logEntries[i]);
\r
3191 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
3193 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sAuthor), pat, flags)&&IsEntryInDateRange(i))
\r
3195 pShownlist->Add(m_logEntries[i]);
\r
3199 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
3201 sRev.Format(_T("%ld"), m_logEntries[i]->Rev);
\r
3202 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
3204 pShownlist->Add(m_logEntries[i]);
\r
3211 CString find = m_sFilterText;
\r
3213 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
3215 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
3217 sBugIDs = sBugIDs.MakeLower();
\r
3218 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3220 pShownlist->Add(m_logEntries[i]);
\r
3224 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
3226 CString msg = m_logEntries[i]->sMessage;
\r
3228 msg = msg.MakeLower();
\r
3229 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3231 pShownlist->Add(m_logEntries[i]);
\r
3235 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
3237 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
3239 bool bGoing = true;
\r
3240 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
3242 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
3243 CString path = cpath->sCopyFromPath;
\r
3245 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
3247 pShownlist->Add(m_logEntries[i]);
\r
3251 path = cpath->sPath;
\r
3253 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
3255 pShownlist->Add(m_logEntries[i]);
\r
3259 path = cpath->GetAction();
\r
3261 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
3263 pShownlist->Add(m_logEntries[i]);
\r
3269 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
3271 CString msg = m_logEntries[i]->sAuthor;
\r
3272 msg = msg.MakeLower();
\r
3273 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3275 pShownlist->Add(m_logEntries[i]);
\r
3279 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
3281 sRev.Format(_T("%ld"), m_logEntries[i]->Rev);
\r
3282 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3284 pShownlist->Add(m_logEntries[i]);
\r
3288 } // else (from if (bRegex))
\r
3289 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3293 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
\r
3295 if (nIDEvent == LOGFILTER_TIMER)
\r
3297 if (m_bThreadRunning)
\r
3299 // thread still running! So just restart the timer.
\r
3300 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3303 CWnd * focusWnd = GetFocus();
\r
3304 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
\r
3305 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
\r
3306 if (m_sFilterText.IsEmpty())
\r
3308 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));
\r
3309 // do not return here!
\r
3310 // we also need to run the filter if the filter text is empty:
\r
3311 // 1. to clear an existing filter
\r
3312 // 2. to rebuild the m_arShownList after sorting
\r
3314 theApp.DoWaitCursor(1);
\r
3315 CStoreSelection storeselection(this);
\r
3316 KillTimer(LOGFILTER_TIMER);
\r
3317 FillLogMessageCtrl(false);
\r
3319 // now start filter the log list
\r
3320 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3321 RecalculateShownList(&m_arShownList);
\r
3322 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3325 m_LogList.DeleteAllItems();
\r
3326 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3327 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3328 m_LogList.SetRedraw(false);
\r
3329 ResizeAllListCtrlCols();
\r
3330 m_LogList.SetRedraw(true);
\r
3331 m_LogList.Invalidate();
\r
3332 if ( m_LogList.GetItemCount()==1 )
\r
3334 m_LogList.SetSelectionMark(0);
\r
3335 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
3337 theApp.DoWaitCursor(-1);
\r
3338 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3339 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3340 if (bSetFocusToFilterControl)
\r
3341 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3342 UpdateLogInfoLabel();
\r
3343 } // if (nIDEvent == LOGFILTER_TIMER)
\r
3344 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));
\r
3345 __super::OnTimer(nIDEvent);
\r
3348 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3351 m_DateTo.GetTime(_time);
\r
3354 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
\r
3355 if (time.GetTime() != m_tTo)
\r
3357 m_tTo = (DWORD)time.GetTime();
\r
3358 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
3361 catch (CAtlException)
\r
3368 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3371 m_DateFrom.GetTime(_time);
\r
3374 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
\r
3375 if (time.GetTime() != m_tFrom)
\r
3377 m_tFrom = (DWORD)time.GetTime();
\r
3378 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
3381 catch (CAtlException)
\r
3388 BOOL CLogDlg::IsEntryInDateRange(int i)
\r
3391 __time64_t time = m_logEntries[i]->tmDate;
\r
3392 if ((time >= m_tFrom)&&(time <= m_tTo))
\r
3399 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths /* = false */, bool bUseFilter /* = true */)
\r
3401 CTGitPathList pathList;
\r
3404 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
3406 m_sRepositoryRoot = GetRepositoryRoot(m_path);
\r
3408 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
3411 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3416 int nextpos = m_LogList.GetNextSelectedItem(pos);
\r
3417 if (nextpos >= m_arShownList.GetCount())
\r
3419 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));
\r
3420 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
3421 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
3423 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
3424 if (cpath == NULL)
\r
3427 if (!bRelativePaths)
\r
3428 path.SetFromGit(m_sRepositoryRoot);
\r
3429 path.AppendPathString(cpath->sPath);
\r
3430 if ((!bUseFilter)||
\r
3431 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
\r
3432 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
\r
3433 pathList.AddPath(path);
\r
3438 pathList.RemoveDuplicates();
\r
3443 void CLogDlg::SortByColumn(int nSortColumn, bool bAscending)
\r
3446 switch(nSortColumn)
\r
3448 case 0: // Revision
\r
3451 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
\r
3453 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
\r
3459 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
\r
3461 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
\r
3467 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
\r
3469 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
\r
3475 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
\r
3477 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
\r
3480 case 4: // Message or bug id
\r
3481 if (m_bShowBugtraqColumn)
\r
3484 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
\r
3486 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
\r
3489 // fall through here
\r
3490 case 5: // Message
\r
3493 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
\r
3495 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
\r
3505 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
\r
3507 if (m_bThreadRunning)
\r
3508 return; //no sorting while the arrays are filled
\r
3509 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
3510 const int nColumn = pNMLV->iSubItem;
\r
3511 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
\r
3512 m_nSortColumn = nColumn;
\r
3513 SortByColumn(m_nSortColumn, m_bAscending);
\r
3514 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
\r
3515 SortShownListArray();
\r
3516 m_LogList.Invalidate();
\r
3517 UpdateLogInfoLabel();
\r
3518 // the "next 100" button only makes sense if the log messages
\r
3519 // are sorted by revision in descending order
\r
3520 if ((m_nSortColumn)||(m_bAscending))
\r
3522 DialogEnableWindow(IDC_NEXTHUNDRED, false);
\r
3526 DialogEnableWindow(IDC_NEXTHUNDRED, true);
\r
3531 void CLogDlg::SortShownListArray()
\r
3533 // make sure the shown list still matches the filter after sorting.
\r
3534 OnTimer(LOGFILTER_TIMER);
\r
3535 // clear the selection states
\r
3536 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3539 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
\r
3541 m_LogList.SetSelectionMark(-1);
\r
3544 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
\r
3546 if (control == NULL)
\r
3548 // set the sort arrow
\r
3549 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
\r
3550 HDITEM HeaderItem = {0};
\r
3551 HeaderItem.mask = HDI_FORMAT;
\r
3552 for (int i=0; i<pHeader->GetItemCount(); ++i)
\r
3554 pHeader->GetItem(i, &HeaderItem);
\r
3555 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
\r
3556 pHeader->SetItem(i, &HeaderItem);
\r
3560 pHeader->GetItem(nColumn, &HeaderItem);
\r
3561 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
\r
3562 pHeader->SetItem(nColumn, &HeaderItem);
\r
3565 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
3567 if (m_bThreadRunning)
\r
3568 return; //no sorting while the arrays are filled
\r
3569 if (m_currentChangedArray == NULL)
\r
3571 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
3572 const int nColumn = pNMLV->iSubItem;
\r
3573 m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;
\r
3574 m_nSortColumnPathList = nColumn;
\r
3575 // qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
\r
3577 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
3578 m_ChangedFileListCtrl.Invalidate();
\r
3582 int CLogDlg::m_nSortColumnPathList = 0;
\r
3583 bool CLogDlg::m_bAscendingPathList = false;
\r
3585 int CLogDlg::SortCompare(const void * pElem1, const void * pElem2)
\r
3588 LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);
\r
3589 LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);
\r
3591 if (m_bAscendingPathList)
\r
3592 std::swap (cpath1, cpath2);
\r
3595 switch (m_nSortColumnPathList)
\r
3598 cmp = cpath2->GetAction().Compare(cpath1->GetAction());
\r
3603 cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);
\r
3607 case 2: // copy from path
\r
3608 cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);
\r
3612 case 3: // copy from revision
\r
3613 return cpath2->lCopyFromRev > cpath1->lCopyFromRev;
\r
3619 void CLogDlg::ResizeAllListCtrlCols()
\r
3622 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
3623 int maxcol = ((CHeaderCtrl*)(m_LogList.GetDlgItem(0)))->GetItemCount()-1;
\r
3624 int nItemCount = m_LogList.GetItemCount();
\r
3625 TCHAR textbuf[MAX_PATH];
\r
3626 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(m_LogList.GetDlgItem(0));
\r
3629 for (int col = 0; col <= maxcol; col++)
\r
3632 hdi.mask = HDI_TEXT;
\r
3633 hdi.pszText = textbuf;
\r
3634 hdi.cchTextMax = sizeof(textbuf);
\r
3635 pHdrCtrl->GetItem(col, &hdi);
\r
3636 int cx = m_LogList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
3637 for (int index = 0; index<nItemCount; ++index)
\r
3639 // get the width of the string and add 14 pixels for the column separator and margins
\r
3640 int linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;
\r
3641 if (index < m_arShownList.GetCount())
\r
3643 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
3644 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
3646 // set the bold font and ask for the string width again
\r
3647 m_LogList.SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
3648 linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;
\r
3649 // restore the system font
\r
3650 m_LogList.SendMessage(WM_SETFONT, NULL, NULL);
\r
3655 // add the image size
\r
3656 CImageList * pImgList = m_LogList.GetImageList(LVSIL_SMALL);
\r
3657 if ((pImgList)&&(pImgList->GetImageCount()))
\r
3659 IMAGEINFO imginfo;
\r
3660 pImgList->GetImageInfo(0, &imginfo);
\r
3661 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
3662 linewidth += 3; // 3 pixels between icon and text
\r
3665 if (cx < linewidth)
\r
3668 // Adjust columns "Actions" containing icons
\r
3669 if (col == this->LOGLIST_ACTION)
\r
3671 if (cx < nMinimumWidth)
\r
3673 cx = nMinimumWidth;
\r
3677 if (col == this->LOGLIST_MESSAGE)
\r
3679 if (cx > LOGLIST_MESSAGE_MAX)
\r
3681 cx = LOGLIST_MESSAGE_MAX;
\r
3685 // keep the bug id column small
\r
3686 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
3688 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
3690 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
3694 m_LogList.SetColumnWidth(col, cx);
\r
3700 void CLogDlg::OnBnClickedHidepaths()
\r
3702 FillLogMessageCtrl();
\r
3703 m_ChangedFileListCtrl.Invalidate();
\r
3707 void CLogDlg::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
3709 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
3712 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
3714 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
3716 if (pFindInfo->lvfi.psz == 0)
\r
3719 CString sCmp = pFindInfo->lvfi.psz;
\r
3721 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
3723 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
3724 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
3725 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
3727 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
3735 if (sCmp.Compare(sRev)==0)
\r
3742 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
3744 for (int i=0; i<pFindInfo->iStart; ++i)
\r
3746 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
3747 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
3748 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
3750 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
3758 if (sCmp.Compare(sRev)==0)
\r
3770 void CLogDlg::OnBnClickedCheckStoponcopy()
\r
3773 if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
3776 // ignore old fetch limits when switching
\r
3777 // between copy-following and stop-on-copy
\r
3778 // (otherwise stop-on-copy will limit what
\r
3779 // we see immediately after switching to
\r
3780 // copy-following)
\r
3784 // now, restart the query
\r
3789 void CLogDlg::OnBnClickedIncludemerge()
\r
3799 void CLogDlg::UpdateLogInfoLabel()
\r
3802 git_revnum_t rev1 = 0;
\r
3803 git_revnum_t rev2 = 0;
\r
3804 long selectedrevs = 0;
\r
3805 if (m_arShownList.GetCount())
\r
3807 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(0));
\r
3808 rev1 = pLogEntry->Rev;
\r
3809 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
\r
3810 rev2 = pLogEntry->Rev;
\r
3811 selectedrevs = m_LogList.GetSelectedCount();
\r
3814 sTemp.Format(IDS_LOG_LOGINFOSTRING, m_arShownList.GetCount(), rev2, rev1, selectedrevs);
\r
3815 m_sLogInfo = sTemp;
\r
3817 UpdateData(FALSE);
\r
3820 void CLogDlg::ShowContextMenuForRevisions(CWnd* /*pWnd*/, CPoint point)
\r
3823 int selIndex = m_LogList.GetSelectionMark();
\r
3825 return; // nothing selected, nothing to do with a context menu
\r
3827 // if the user selected the info text telling about not all revisions shown due to
\r
3828 // the "stop on copy/rename" option, we also don't show the context menu
\r
3829 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
3832 // if the context menu is invoked through the keyboard, we have to use
\r
3833 // a calculated position on where to anchor the menu on
\r
3834 if ((point.x == -1) && (point.y == -1))
\r
3837 m_LogList.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
3838 m_LogList.ClientToScreen(&rect);
\r
3839 point = rect.CenterPoint();
\r
3841 m_nSearchIndex = selIndex;
\r
3842 m_bCancelled = FALSE;
\r
3844 // calculate some information the context menu commands can use
\r
3845 // CString pathURL = GetURLFromPath(m_path);
\r
3847 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3848 int indexNext = m_LogList.GetNextSelectedItem(pos);
\r
3849 if (indexNext < 0)
\r
3852 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
3854 GitRev revSelected = pSelLogEntry->Rev;
\r
3855 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
3856 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
3858 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
3860 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
3861 if (changedpath->lCopyFromRev)
\r
3862 revPrevious = changedpath->lCopyFromRev;
\r
3865 GitRev revSelected2;
\r
3868 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
3869 revSelected2 = pLogEntry->Rev;
\r
3871 bool bAllFromTheSameAuthor = true;
\r
3872 CString firstAuthor;
\r
3873 CLogDataVector selEntries;
\r
3874 GitRev revLowest, revHighest;
\r
3875 GitRevRangeArray revisionRanges;
\r
3877 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3878 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
3879 revisionRanges.AddRevision(pLogEntry->Rev);
\r
3880 selEntries.push_back(pLogEntry);
\r
3881 firstAuthor = pLogEntry->sAuthor;
\r
3882 revLowest = pLogEntry->Rev;
\r
3883 revHighest = pLogEntry->Rev;
\r
3886 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
3887 revisionRanges.AddRevision(pLogEntry->Rev);
\r
3888 selEntries.push_back(pLogEntry);
\r
3889 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
3890 bAllFromTheSameAuthor = false;
\r
3891 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
3892 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
3898 int FirstSelect=-1, LastSelect=-1;
\r
3899 pos = m_LogList.GetFirstSelectedItemPosition();
\r
3900 FirstSelect = m_LogList.GetNextSelectedItem(pos);
\r
3903 LastSelect = m_LogList.GetNextSelectedItem(pos);
\r
3905 //entry is selected, now show the popup menu
\r
3907 if (popup.CreatePopupMenu())
\r
3909 if (m_LogList.GetSelectedCount() == 1)
\r
3912 if (!m_path.IsDirectory())
\r
3916 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
3917 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
3919 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
3920 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
3921 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3922 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
3923 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
3924 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
3925 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
3926 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3933 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
3935 // TortoiseMerge could be improved to take a /blame switch
\r
3936 // and then not 'cat' the files from a unified diff but
\r
3938 // But until that's implemented, the context menu entry for
\r
3939 // this feature is commented out.
\r
3940 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
3942 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
3943 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
3944 popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
3945 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3948 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
3950 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
3952 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
3954 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
3956 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
3957 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
3959 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3962 // popup.AppendMenuIcon(ID_REPOBROWSE, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE);
\r
3963 // popup.AppendMenuIcon(ID_COPY, IDS_LOG_POPUP_COPY);
\r
3965 // popup.AppendMenuIcon(ID_UPDATE, IDS_LOG_POPUP_UPDATE, IDI_UPDATE);
\r
3967 popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
3969 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
3971 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
3972 popup.AppendMenuIcon(ID_CHECKOUT, IDS_MENUCHECKOUT, IDI_CHECKOUT);
\r
3973 popup.AppendMenuIcon(ID_EXPORT, IDS_MENUEXPORT, IDI_EXPORT);
\r
3974 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3976 else if (m_LogList.GetSelectedCount() >= 2)
\r
3978 bool bAddSeparator = false;
\r
3979 if (IsSelectionContinuous() || (m_LogList.GetSelectedCount() == 2))
\r
3981 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
3983 if (m_LogList.GetSelectedCount() == 2)
\r
3985 popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
3986 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
3987 bAddSeparator = true;
\r
3991 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
3993 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
3994 bAddSeparator = true;
\r
3996 if (bAddSeparator)
\r
3997 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4000 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
4002 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
4004 // if (m_LogList.GetSelectedCount() == 1)
\r
4006 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
4007 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
4008 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4011 if (m_LogList.GetSelectedCount() != 0)
\r
4013 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
4015 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
4017 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
4018 DialogEnableWindow(IDOK, FALSE);
\r
4019 // SetPromptApp(&theApp);
\r
4020 theApp.DoWaitCursor(1);
\r
4021 bool bOpenWith = false;
\r
4027 CString tempfile=GetTempFile();
\r
4029 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
4030 cmd.Format(_T("git.cmd diff-tree -r -p --stat %s"),r1->m_CommitHash);
\r
4031 g_Git.RunLogFile(cmd,tempfile);
\r
4032 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r1->m_Subject);
\r
4038 CString tempfile=GetTempFile();
\r
4040 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
4041 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
4042 cmd.Format(_T("git.cmd diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash);
\r
4043 g_Git.RunLogFile(cmd,tempfile);
\r
4044 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r2->m_CommitHash.Left(6));
\r
4049 case ID_COMPARETWO:
\r
4051 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
4052 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
4054 dlg.SetDiff(NULL,*r1,*r2);
\r
4063 if (PromptShown())
\r
4065 GitDiff diff(this, this->m_hWnd, true);
\r
4066 diff.SetHEADPeg(m_LogRevision);
\r
4067 diff.ShowUnifiedDiff(m_path, revPrevious, m_path, revSelected);
\r
4070 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revPrevious, m_path, revSelected, GitRev(), m_LogRevision);
\r
4076 if (PromptShown())
\r
4078 GitDiff diff(this, this->m_hWnd, true);
\r
4079 diff.SetHEADPeg(m_LogRevision);
\r
4080 diff.ShowUnifiedDiff(m_path, revSelected2, m_path, revSelected);
\r
4083 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revSelected2, m_path, revSelected, GitRev(), m_LogRevision);
\r
4086 case ID_REVERTREV:
\r
4088 // we need an URL to complete this command, so error out if we can't get an URL
\r
4089 if (pathURL.IsEmpty())
\r
4091 CString strMessage;
\r
4092 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4093 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4094 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4098 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
\r
4099 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
4101 CGitProgressDlg dlg;
\r
4102 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4103 dlg.SetPathList(CTGitPathList(m_path));
\r
4104 dlg.SetUrl(pathURL);
\r
4105 dlg.SetSecondUrl(pathURL);
\r
4106 revisionRanges.AdjustForMerge(true);
\r
4107 dlg.SetRevisionRanges(revisionRanges);
\r
4108 dlg.SetPegRevision(m_LogRevision);
\r
4115 // we need an URL to complete this command, so error out if we can't get an URL
\r
4116 if (pathURL.IsEmpty())
\r
4118 CString strMessage;
\r
4119 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4120 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4121 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4125 CString path = m_path.GetWinPathString();
\r
4126 bool bGotSavePath = false;
\r
4127 if ((m_LogList.GetSelectedCount() == 1)&&(!m_path.IsDirectory()))
\r
4129 bGotSavePath = CAppUtils::FileOpenSave(path, NULL, IDS_LOG_MERGETO, IDS_COMMONFILEFILTER, true, GetSafeHwnd());
\r
4133 CBrowseFolder folderBrowser;
\r
4134 folderBrowser.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_MERGETO)));
\r
4135 bGotSavePath = (folderBrowser.Show(GetSafeHwnd(), path, path) == CBrowseFolder::OK);
\r
4139 CGitProgressDlg dlg;
\r
4140 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4141 dlg.SetPathList(CTGitPathList(CTGitPath(path)));
\r
4142 dlg.SetUrl(pathURL);
\r
4143 dlg.SetSecondUrl(pathURL);
\r
4144 revisionRanges.AdjustForMerge(false);
\r
4145 dlg.SetRevisionRanges(revisionRanges);
\r
4146 dlg.SetPegRevision(m_LogRevision);
\r
4151 case ID_REVERTTOREV:
\r
4153 // we need an URL to complete this command, so error out if we can't get an URL
\r
4154 if (pathURL.IsEmpty())
\r
4156 CString strMessage;
\r
4157 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4158 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4159 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4164 msg.Format(IDS_LOG_REVERTTOREV_CONFIRM, m_path.GetWinPath());
\r
4165 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
4167 CGitProgressDlg dlg;
\r
4168 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4169 dlg.SetPathList(CTGitPathList(m_path));
\r
4170 dlg.SetUrl(pathURL);
\r
4171 dlg.SetSecondUrl(pathURL);
\r
4172 GitRevRangeArray revarray;
\r
4173 revarray.AddRevRange(GitRev::REV_HEAD, revSelected);
\r
4174 dlg.SetRevisionRanges(revarray);
\r
4175 dlg.SetPegRevision(m_LogRevision);
\r
4182 // we need an URL to complete this command, so error out if we can't get an URL
\r
4183 if (pathURL.IsEmpty())
\r
4185 CString strMessage;
\r
4186 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4187 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4188 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4193 dlg.m_URL = pathURL;
\r
4194 dlg.m_path = m_path;
\r
4195 dlg.m_CopyRev = revSelected;
\r
4196 if (dlg.DoModal() == IDOK)
\r
4198 // should we show a progress dialog here? Copies are done really fast
\r
4199 // and without much network traffic.
\r
4200 if (!Copy(CTGitPathList(CTGitPath(pathURL)), CTGitPath(dlg.m_URL), dlg.m_CopyRev, dlg.m_CopyRev, dlg.m_sLogMessage))
\r
4201 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4203 CMessageBox::Show(this->m_hWnd, IDS_LOG_COPY_SUCCESS, IDS_APPNAME, MB_ICONINFORMATION);
\r
4209 //user clicked on the menu item "compare with working copy"
\r
4210 if (PromptShown())
\r
4212 GitDiff diff(this, m_hWnd, true);
\r
4213 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4214 diff.SetHEADPeg(m_LogRevision);
\r
4215 diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
\r
4218 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4221 case ID_COMPARETWO:
\r
4223 GitRev r1 = revSelected;
\r
4224 GitRev r2 = revSelected2;
\r
4225 if (m_LogList.GetSelectedCount() > 2)
\r
4230 //user clicked on the menu item "compare revisions"
\r
4231 if (PromptShown())
\r
4233 GitDiff diff(this, m_hWnd, true);
\r
4234 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4235 diff.SetHEADPeg(m_LogRevision);
\r
4236 diff.ShowCompare(CTGitPath(pathURL), r2, CTGitPath(pathURL), r1);
\r
4239 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), r2, CTGitPath(pathURL), r1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4242 case ID_COMPAREWITHPREVIOUS:
\r
4244 if (PromptShown())
\r
4246 GitDiff diff(this, m_hWnd, true);
\r
4247 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4248 diff.SetHEADPeg(m_LogRevision);
\r
4249 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
\r
4252 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4255 case ID_BLAMECOMPARE:
\r
4257 //user clicked on the menu item "compare with working copy"
\r
4258 //now first get the revision which is selected
\r
4259 if (PromptShown())
\r
4261 GitDiff diff(this, this->m_hWnd, true);
\r
4262 diff.SetHEADPeg(m_LogRevision);
\r
4263 diff.ShowCompare(m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), false, true);
\r
4266 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), m_LogRevision, false, false, true);
\r
4271 //user clicked on the menu item "compare and blame revisions"
\r
4272 if (PromptShown())
\r
4274 GitDiff diff(this, this->m_hWnd, true);
\r
4275 diff.SetHEADPeg(m_LogRevision);
\r
4276 diff.ShowCompare(CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
4279 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
4282 case ID_BLAMEWITHPREVIOUS:
\r
4284 //user clicked on the menu item "Compare and Blame with previous revision"
\r
4285 if (PromptShown())
\r
4287 GitDiff diff(this, this->m_hWnd, true);
\r
4288 diff.SetHEADPeg(m_LogRevision);
\r
4289 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
4292 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
4297 //now first get the revision which is selected
\r
4298 CString revFilename;
\r
4301 CString strWinPath = m_path.GetWinPathString();
\r
4302 int rfind = strWinPath.ReverseFind('.');
\r
4304 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)strWinPath.Left(rfind), (LONG)revSelected, (LPCTSTR)strWinPath.Mid(rfind));
\r
4306 revFilename.Format(_T("%s-%ld"), (LPCTSTR)strWinPath, revSelected);
\r
4308 if (CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd))
\r
4310 CTGitPath tempfile;
\r
4311 tempfile.SetFromWin(revFilename);
\r
4312 CProgressDlg progDlg;
\r
4313 progDlg.SetTitle(IDS_APPNAME);
\r
4314 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
4315 CString sInfoLine;
\r
4316 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
4317 progDlg.SetLine(1, sInfoLine, true);
\r
4318 SetAndClearProgressInfo(&progDlg);
\r
4319 progDlg.ShowModeless(m_hWnd);
\r
4320 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
4322 // try again with another peg revision
\r
4323 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
4326 SetAndClearProgressInfo((HWND)NULL);
\r
4327 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4333 SetAndClearProgressInfo((HWND)NULL);
\r
4341 CProgressDlg progDlg;
\r
4342 progDlg.SetTitle(IDS_APPNAME);
\r
4343 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
4344 CString sInfoLine;
\r
4345 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
4346 progDlg.SetLine(1, sInfoLine, true);
\r
4347 SetAndClearProgressInfo(&progDlg);
\r
4348 progDlg.ShowModeless(m_hWnd);
\r
4349 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, m_path, revSelected);
\r
4350 bool bSuccess = true;
\r
4351 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
4354 // try again, but with the selected revision as the peg revision
\r
4355 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
4358 SetAndClearProgressInfo((HWND)NULL);
\r
4359 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4368 SetAndClearProgressInfo((HWND)NULL);
\r
4369 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
4372 ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
4373 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
4375 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
4376 cmd += tempfile.GetWinPathString() + _T(" ");
\r
4377 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
4385 dlg.EndRev = revSelected;
\r
4386 if (dlg.DoModal() == IDOK)
\r
4391 tempfile = blame.BlameToTempFile(m_path, dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
4392 if (!tempfile.IsEmpty())
\r
4394 if (dlg.m_bTextView)
\r
4396 //open the default text editor for the result file
\r
4397 CAppUtils::StartTextViewer(tempfile);
\r
4401 CString sParams = _T("/path:\"") + m_path.GetGitPathString() + _T("\" ");
\r
4402 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(m_path.GetFileOrDirectoryName()),sParams))
\r
4410 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4418 CString url = _T("tgit:")+pathURL;
\r
4419 sCmd.Format(_T("%s /command:update /path:\"%s\" /rev:%ld"),
\r
4420 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4421 (LPCTSTR)m_path.GetWinPath(), (LONG)revSelected);
\r
4422 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4425 case ID_FINDENTRY:
\r
4427 m_nSearchIndex = m_LogList.GetSelectionMark();
\r
4428 if (m_nSearchIndex < 0)
\r
4429 m_nSearchIndex = 0;
\r
4430 if (m_pFindDialog)
\r
4436 m_pFindDialog = new CFindReplaceDialog();
\r
4437 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
4441 case ID_REPOBROWSE:
\r
4444 sCmd.Format(_T("%s /command:repobrowser /path:\"%s\" /rev:%s"),
\r
4445 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4446 (LPCTSTR)pathURL, (LPCTSTR)revSelected.ToString());
\r
4448 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4453 EditLogMessage(selIndex);
\r
4456 case ID_EDITAUTHOR:
\r
4458 EditAuthor(selEntries);
\r
4463 CEditPropertiesDlg dlg;
\r
4464 dlg.SetProjectProperties(&m_ProjectProperties);
\r
4465 CTGitPathList escapedlist;
\r
4466 dlg.SetPathList(CTGitPathList(CTGitPath(pathURL)));
\r
4467 dlg.SetRevision(revSelected);
\r
4468 dlg.RevProps(true);
\r
4472 case ID_COPYCLIPBOARD:
\r
4474 CopySelectionToClipBoard();
\r
4480 sCmd.Format(_T("%s /command:export /path:\"%s\" /revision:%ld"),
\r
4481 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4482 (LPCTSTR)pathURL, (LONG)revSelected);
\r
4483 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4489 CString url = _T("tgit:")+pathURL;
\r
4490 sCmd.Format(_T("%s /command:checkout /url:\"%s\" /revision:%ld"),
\r
4491 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4492 (LPCTSTR)url, (LONG)revSelected);
\r
4493 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4498 CString url = m_ProjectProperties.sWebViewerRev;
\r
4499 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
4500 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
4501 if (!url.IsEmpty())
\r
4502 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
4505 case ID_VIEWPATHREV:
\r
4507 CString relurl = pathURL;
\r
4508 CString sRoot = GetRepositoryRoot(CTGitPath(relurl));
\r
4509 relurl = relurl.Mid(sRoot.GetLength());
\r
4510 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
4511 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
4512 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
4513 url.Replace(_T("%PATH%"), relurl);
\r
4514 if (!url.IsEmpty())
\r
4515 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
4522 theApp.DoWaitCursor(-1);
\r
4524 } // if (popup.CreatePopupMenu())
\r
4527 void CLogDlg::ShowContextMenuForChangedpaths(CWnd* /*pWnd*/, CPoint point)
\r
4530 int selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
4531 if ((point.x == -1) && (point.y == -1))
\r
4534 m_ChangedFileListCtrl.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
4535 m_ChangedFileListCtrl.ClientToScreen(&rect);
\r
4536 point = rect.CenterPoint();
\r
4540 int s = m_LogList.GetSelectionMark();
\r
4543 std::vector<CString> changedpaths;
\r
4544 std::vector<LogChangedPath*> changedlogpaths;
\r
4545 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
4547 return; // nothing is selected, get out of here
\r
4549 bool bOneRev = true;
\r
4550 int sel=m_LogList.GetNextSelectedItem(pos);
\r
4551 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(sel));
\r
4552 GitRev * rev1 = pLogEntry;
\r
4553 GitRev * rev2 = reinterpret_cast<GitRev *>(m_arShownList.GetAt(sel+1));
\r
4555 bool bOneRev = true;
\r
4560 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
4563 rev1 = max(rev1,(git_revnum_t)pLogEntry->Rev);
\r
4564 rev2 = min(rev2,(git_revnum_t)pLogEntry->Rev);
\r
4570 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
4573 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
4574 changedpaths.push_back(m_currentChangedPathList[nItem].GetGitPathString());
\r
4579 // only one revision is selected in the log dialog top pane
\r
4580 // but multiple items could be selected in the changed items list
\r
4583 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
4586 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
4587 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
4589 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
4591 if ((changedlogpath)&&(!changedlogpath->sCopyFromPath.IsEmpty()))
\r
4592 rev2 = changedlogpath->lCopyFromRev;
\r
4595 // if the path was modified but the parent path was 'added with history'
\r
4596 // then we have to use the copy from revision of the parent path
\r
4597 CTGitPath cpath = CTGitPath(changedlogpath->sPath);
\r
4598 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
4600 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
4601 if (p.IsAncestorOf(cpath))
\r
4603 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
4604 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
4609 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
4611 // some items are hidden! So find out which item the user really clicked on
\r
4612 INT_PTR selRealIndex = -1;
\r
4613 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
4615 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
4617 if (selRealIndex == nItem)
\r
4619 selIndex = hiddenindex;
\r
4620 changedlogpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
4625 if (changedlogpath)
\r
4627 changedpaths.push_back(changedlogpath->sPath);
\r
4628 changedlogpaths.push_back(changedlogpath);
\r
4633 //entry is selected, now show the popup menu
\r
4635 if (popup.CreatePopupMenu())
\r
4637 bool bEntryAdded = false;
\r
4638 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
4640 // if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
\r
4642 popup.AppendMenuIcon(ID_DIFF, IDS_LOG_POPUP_DIFF, IDI_DIFF);
\r
4643 popup.AppendMenuIcon(ID_BLAMEDIFF, IDS_LOG_POPUP_BLAMEDIFF, IDI_BLAME);
\r
4644 popup.SetDefaultItem(ID_DIFF, FALSE);
\r
4645 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
4646 bEntryAdded = true;
\r
4648 // if (rev2 == rev1-1)
\r
4651 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4652 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
4653 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
4654 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
4655 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4657 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
4658 popup.AppendMenuIcon(ID_POPPROPS, IDS_REPOBROWSE_SHOWPROP, IDI_PROPERTIES); // "Show Properties"
\r
4659 popup.AppendMenuIcon(ID_LOG, IDS_MENULOG, IDI_LOG); // "Show Log"
\r
4660 popup.AppendMenuIcon(ID_GETMERGELOGS, IDS_LOG_POPUP_GETMERGELOGS, IDI_LOG); // "Show merge log"
\r
4661 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
4662 bEntryAdded = true;
\r
4663 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
4665 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4666 popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
4668 if (popup.GetDefaultItem(0,FALSE)==-1)
\r
4669 popup.SetDefaultItem(ID_OPEN, FALSE);
\r
4672 else if (changedlogpaths.size())
\r
4674 // more than one entry is selected
\r
4675 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE);
\r
4676 bEntryAdded = true;
\r
4681 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
4682 bool bOpenWith = false;
\r
4683 bool bMergeLog = false;
\r
4684 m_bCancelled = false;
\r
4690 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
4694 case ID_BLAMEDIFF:
\r
4696 DoDiffFromLog(selIndex, rev1, rev2, true, false);
\r
4701 DoDiffFromLog(selIndex, rev1, rev2, false, true);
\r
4704 case ID_REVERTREV:
\r
4706 SetPromptApp(&theApp);
\r
4707 theApp.DoWaitCursor(1);
\r
4709 if (Git::PathIsURL(m_path))
\r
4711 sUrl = m_path.GetGitPathString();
\r
4715 sUrl = GetURLFromPath(m_path);
\r
4716 if (sUrl.IsEmpty())
\r
4718 theApp.DoWaitCursor(-1);
\r
4720 temp.Format(IDS_ERR_NOURLOFFILE, m_path.GetWinPath());
\r
4721 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4723 theApp.DoWaitCursor(-1);
\r
4727 // find the working copy path of the selected item from the URL
\r
4728 m_bCancelled = false;
\r
4729 CString sUrlRoot = GetRepositoryRoot(CTGitPath(sUrl));
\r
4731 CString fileURL = changedpaths[0];
\r
4732 fileURL = sUrlRoot + fileURL.Trim();
\r
4733 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
\r
4734 // sUrl = http://mydomain.com/repos/trunk/folder
\r
4735 CString sUnescapedUrl = CPathUtils::PathUnescape(sUrl);
\r
4736 // find out until which char the urls are identical
\r
4738 while ((i<fileURL.GetLength())&&(i<sUnescapedUrl.GetLength())&&(fileURL[i]==sUnescapedUrl[i]))
\r
4740 int leftcount = m_path.GetWinPathString().GetLength()-(sUnescapedUrl.GetLength()-i);
\r
4741 CString wcPath = m_path.GetWinPathString().Left(leftcount);
\r
4742 wcPath += fileURL.Mid(i);
\r
4743 wcPath.Replace('/', '\\');
\r
4744 CGitProgressDlg dlg;
\r
4745 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
4747 // a deleted path! Since the path isn't there anymore, merge
\r
4748 // won't work. So just do a copy url->wc
\r
4749 dlg.SetCommand(CGitProgressDlg::GitProgress_Copy);
\r
4750 dlg.SetPathList(CTGitPathList(CTGitPath(fileURL)));
\r
4751 dlg.SetUrl(wcPath);
\r
4752 dlg.SetRevision(rev2);
\r
4756 if (!PathFileExists(wcPath))
\r
4758 // seems the path got renamed
\r
4759 // tell the user how to work around this.
\r
4760 CMessageBox::Show(this->m_hWnd, IDS_LOG_REVERTREV_ERROR, IDS_APPNAME, MB_ICONERROR);
\r
4762 theApp.DoWaitCursor(-1);
\r
4765 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4766 dlg.SetPathList(CTGitPathList(CTGitPath(wcPath)));
\r
4767 dlg.SetUrl(fileURL);
\r
4768 dlg.SetSecondUrl(fileURL);
\r
4769 GitRevRangeArray revarray;
\r
4770 revarray.AddRevRange(rev1, rev2);
\r
4771 dlg.SetRevisionRanges(revarray);
\r
4774 msg.Format(IDS_LOG_REVERT_CONFIRM, (LPCTSTR)wcPath);
\r
4775 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
4779 theApp.DoWaitCursor(-1);
\r
4784 DialogEnableWindow(IDOK, FALSE);
\r
4785 SetPromptApp(&theApp);
\r
4786 theApp.DoWaitCursor(1);
\r
4788 if (Git::PathIsURL(m_path))
\r
4790 filepath = m_path.GetGitPathString();
\r
4794 filepath = GetURLFromPath(m_path);
\r
4795 if (filepath.IsEmpty())
\r
4797 theApp.DoWaitCursor(-1);
\r
4799 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
4800 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4801 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
4806 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
4807 filepath += changedpaths[0];
\r
4810 dlg.m_Path = CTGitPath(filepath);
\r
4813 theApp.DoWaitCursor(-1);
\r
4818 DialogEnableWindow(IDOK, FALSE);
\r
4819 SetPromptApp(&theApp);
\r
4820 theApp.DoWaitCursor(1);
\r
4822 if (Git::PathIsURL(m_path))
\r
4824 filepath = m_path.GetGitPathString();
\r
4828 filepath = GetURLFromPath(m_path);
\r
4829 if (filepath.IsEmpty())
\r
4831 theApp.DoWaitCursor(-1);
\r
4833 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
4834 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4835 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
4840 m_bCancelled = false;
\r
4841 CString sRoot = GetRepositoryRoot(CTGitPath(filepath));
\r
4842 // if more than one entry is selected, we save them
\r
4843 // one by one into a folder the user has selected
\r
4844 bool bTargetSelected = false;
\r
4845 CTGitPath TargetPath;
\r
4846 if (m_ChangedFileListCtrl.GetSelectedCount() > 1)
\r
4848 CBrowseFolder browseFolder;
\r
4849 browseFolder.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT)));
\r
4850 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
\r
4851 CString strSaveAsDirectory;
\r
4852 if (browseFolder.Show(GetSafeHwnd(), strSaveAsDirectory) == CBrowseFolder::OK)
\r
4854 TargetPath = CTGitPath(strSaveAsDirectory);
\r
4855 bTargetSelected = true;
\r
4860 // Display the Open dialog box.
\r
4861 CString revFilename;
\r
4863 temp = CPathUtils::GetFileNameFromPath(changedpaths[0]);
\r
4864 int rfind = temp.ReverseFind('.');
\r
4866 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)temp.Left(rfind), rev1, (LPCTSTR)temp.Mid(rfind));
\r
4868 revFilename.Format(_T("%s-%ld"), (LPCTSTR)temp, rev1);
\r
4869 bTargetSelected = CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd);
\r
4870 TargetPath.SetFromWin(revFilename);
\r
4872 if (bTargetSelected)
\r
4874 CProgressDlg progDlg;
\r
4875 progDlg.SetTitle(IDS_APPNAME);
\r
4876 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
4877 for (std::vector<LogChangedPath*>::iterator it = changedlogpaths.begin(); it!= changedlogpaths.end(); ++it)
\r
4879 GitRev getrev = ((*it)->action == LOGACTIONS_DELETED) ? rev2 : rev1;
\r
4881 CString sInfoLine;
\r
4882 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)getrev.ToString());
\r
4883 progDlg.SetLine(1, sInfoLine, true);
\r
4884 SetAndClearProgressInfo(&progDlg);
\r
4885 progDlg.ShowModeless(m_hWnd);
\r
4887 CTGitPath tempfile = TargetPath;
\r
4888 if (changedpaths.size() > 1)
\r
4890 // if multiple items are selected, then the TargetPath
\r
4891 // points to a folder and we have to append the filename
\r
4892 // to save to to that folder.
\r
4893 CString sName = (*it)->sPath;
\r
4894 int slashpos = sName.ReverseFind('/');
\r
4895 if (slashpos >= 0)
\r
4896 sName = sName.Mid(slashpos);
\r
4897 tempfile.AppendPathString(sName);
\r
4898 // one problem here:
\r
4899 // a user could have selected multiple items which
\r
4900 // have the same filename but reside in different
\r
4901 // directories, e.g.
\r
4904 // in that case, the second 'file1' will overwrite
\r
4905 // the already saved 'file1'.
\r
4907 // we could maybe find the common root of all selected
\r
4908 // items and then create sub folders to save those files
\r
4910 // But I think we should just leave it that way: to check
\r
4911 // out multiple items at once, the better way is still to
\r
4912 // use the export command from the top pane of the log dialog.
\r
4914 filepath = sRoot + (*it)->sPath;
\r
4915 if (!Cat(CTGitPath(filepath), getrev, getrev, tempfile))
\r
4918 SetAndClearProgressInfo((HWND)NULL);
\r
4919 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4921 theApp.DoWaitCursor(-1);
\r
4926 SetAndClearProgressInfo((HWND)NULL);
\r
4929 theApp.DoWaitCursor(-1);
\r
4936 GitRev getrev = pLogEntry->pArChangedPaths->GetAt(selIndex)->action == LOGACTIONS_DELETED ? rev2 : rev1;
\r
4937 Open(bOpenWith,changedpaths[0],getrev);
\r
4943 if (Git::PathIsURL(m_path))
\r
4945 filepath = m_path.GetGitPathString();
\r
4949 filepath = GetURLFromPath(m_path);
\r
4950 if (filepath.IsEmpty())
\r
4952 theApp.DoWaitCursor(-1);
\r
4954 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
4955 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4956 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
4961 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
4962 filepath += changedpaths[0];
\r
4964 dlg.EndRev = rev1;
\r
4965 if (dlg.DoModal() == IDOK)
\r
4970 tempfile = blame.BlameToTempFile(CTGitPath(filepath), dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
4971 if (!tempfile.IsEmpty())
\r
4973 if (dlg.m_bTextView)
\r
4975 //open the default text editor for the result file
\r
4976 CAppUtils::StartTextViewer(tempfile);
\r
4980 CString sParams = _T("/path:\"") + filepath + _T("\" ");
\r
4981 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(filepath),sParams))
\r
4989 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4994 case ID_GETMERGELOGS:
\r
4999 DialogEnableWindow(IDOK, FALSE);
\r
5000 SetPromptApp(&theApp);
\r
5001 theApp.DoWaitCursor(1);
\r
5003 if (Git::PathIsURL(m_path))
\r
5005 filepath = m_path.GetGitPathString();
\r
5009 filepath = GetURLFromPath(m_path);
\r
5010 if (filepath.IsEmpty())
\r
5012 theApp.DoWaitCursor(-1);
\r
5014 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
5015 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
5016 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
5021 m_bCancelled = false;
\r
5022 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
5023 filepath += changedpaths[0];
\r
5024 git_revnum_t logrev = rev1;
\r
5025 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
5027 // if the item got deleted in this revision,
\r
5028 // fetch the log from the previous revision where it
\r
5033 sCmd.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR)filepath, logrev);
\r
5035 sCmd += _T(" /merge");
\r
5036 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
5038 theApp.DoWaitCursor(-1);
\r
5041 case ID_VIEWPATHREV:
\r
5043 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetSelectionMark()));
\r
5044 GitRev rev = pLogEntry->Rev;
\r
5045 CString relurl = changedpaths[0];
\r
5046 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
5047 url.Replace(_T("%REVISION%"), rev.ToString());
\r
5048 url.Replace(_T("%PATH%"), relurl);
\r
5049 relurl = relurl.Mid(relurl.Find('/'));
\r
5050 url.Replace(_T("%PATH1%"), relurl);
\r
5051 if (!url.IsEmpty())
\r
5052 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
5060 } // if (popup.CreatePopupMenu())
\r
5063 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
5065 // the date control should not show the "today" button
\r
5066 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
\r
5068 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
5072 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
5074 // the date control should not show the "today" button
\r
5075 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
\r
5077 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
5081 void CLogDlg::OnSize(UINT nType, int cx, int cy)
\r
5083 __super::OnSize(nType, cx, cy);
\r
5085 SetSplitterRange();
\r
5088 void CLogDlg::OnRefresh()
\r
5090 if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
5097 void CLogDlg::OnFind()
\r
5099 if (!m_pFindDialog)
\r
5101 m_pFindDialog = new CFindReplaceDialog();
\r
5102 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
5106 void CLogDlg::OnFocusFilter()
\r
5108 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
5111 void CLogDlg::OnEditCopy()
\r
5113 if (GetFocus() == &m_ChangedFileListCtrl)
\r
5114 CopyChangedSelectionToClipBoard();
\r
5116 CopySelectionToClipBoard();
\r
5119 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
\r
5121 // is the URL a relative one?
\r
5122 if (url.Left(2).Compare(_T("^/")) == 0)
\r
5124 // URL is relative to the repository root
\r
5125 CString url1 = m_sRepositoryRoot + url.Mid(1);
\r
5126 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
5127 DWORD len = url.GetLength();
\r
5128 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
\r
5129 return CString(buf, len);
\r
5132 else if (url[0] == '/')
\r
5134 // URL is relative to the server's hostname
\r
5136 // find the server's hostname
\r
5137 int schemepos = m_sRepositoryRoot.Find(_T("//"));
\r
5138 if (schemepos >= 0)
\r
5140 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
\r
5141 CString url1 = sHost + url;
\r
5142 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
5143 DWORD len = url.GetLength();
\r
5144 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
\r
5145 return CString(buf, len);
\r
5153 int CLogDataVector::ParserFromLog()
\r
5157 g_Git.GetLog(log);
\r
5160 begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
\r
5162 if(log.GetLength()==0)
\r
5170 next=log.Find(begin,start);
\r
5172 length = next - start+4;
\r
5174 length = log.GetLength()-start+4;
\r
5176 CString onelog =log;
\r
5177 onelog=log.Mid(start -4,length);
\r
5178 rev.ParserFromLog(onelog);
\r
5179 this->push_back(rev);
\r