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
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
306 m_LogList.DeleteColumn(c--);
\r
307 temp.LoadString(IDS_LOG_REVISION);
\r
308 m_LogList.InsertColumn(0, temp);
\r
310 // make the revision column right aligned
\r
312 Column.mask = LVCF_FMT;
\r
313 Column.fmt = LVCFMT_RIGHT;
\r
314 m_LogList.SetColumn(0, &Column);
\r
317 // g_Git.GetLog(log);
\r
319 temp.LoadString(IDS_LOG_ACTIONS);
\r
320 m_LogList.InsertColumn(1, temp);
\r
321 temp.LoadString(IDS_LOG_AUTHOR);
\r
322 m_LogList.InsertColumn(2, temp);
\r
323 temp.LoadString(IDS_LOG_DATE);
\r
324 m_LogList.InsertColumn(3, temp);
\r
325 if (m_bShowBugtraqColumn)
\r
327 temp = m_ProjectProperties.sLabel;
\r
328 if (temp.IsEmpty())
\r
329 temp.LoadString(IDS_LOG_BUGIDS);
\r
330 m_LogList.InsertColumn(4, temp);
\r
332 temp.LoadString(IDS_LOG_MESSAGE);
\r
333 m_LogList.InsertColumn(m_bShowBugtraqColumn ? 5 : 4, temp);
\r
334 m_LogList.SetRedraw(false);
\r
335 ResizeAllListCtrlCols();
\r
336 m_LogList.SetRedraw(true);
\r
338 m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
339 m_ChangedFileListCtrl.DeleteAllItems();
\r
340 c = ((CHeaderCtrl*)(m_ChangedFileListCtrl.GetDlgItem(0)))->GetItemCount()-1;
\r
342 m_ChangedFileListCtrl.DeleteColumn(c--);
\r
343 temp.LoadString(IDS_PROGRS_ACTION);
\r
344 m_ChangedFileListCtrl.InsertColumn(0, temp);
\r
345 temp.LoadString(IDS_PROGRS_PATH);
\r
346 m_ChangedFileListCtrl.InsertColumn(1, temp);
\r
347 temp.LoadString(IDS_LOG_COPYFROM);
\r
348 m_ChangedFileListCtrl.InsertColumn(2, temp);
\r
349 temp.LoadString(IDS_LOG_REVISION);
\r
350 m_ChangedFileListCtrl.InsertColumn(3, temp);
\r
351 m_ChangedFileListCtrl.SetRedraw(false);
\r
352 CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);
\r
353 m_ChangedFileListCtrl.SetRedraw(true);
\r
356 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
359 m_sMessageBuf.Preallocate(100000);
\r
361 // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"
\r
362 SetDlgTitle(false);
\r
364 m_tooltips.Create(this);
\r
365 CheckRegexpTooltip();
\r
367 SetSplitterRange();
\r
369 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
\r
370 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
\r
371 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
\r
372 m_cFilter.SetValidator(this);
\r
374 AdjustControlSize(IDC_HIDEPATHS);
\r
375 AdjustControlSize(IDC_CHECK_STOPONCOPY);
\r
376 AdjustControlSize(IDC_INCLUDEMERGE);
\r
378 GetClientRect(m_DlgOrigRect);
\r
379 m_LogList.GetClientRect(m_LogListOrigRect);
\r
380 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
\r
381 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
\r
383 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
384 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
\r
387 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
\r
388 AddAnchor(IDC_DATEFROM, TOP_LEFT);
\r
389 AddAnchor(IDC_TOLABEL, TOP_LEFT);
\r
390 AddAnchor(IDC_DATETO, TOP_LEFT);
\r
392 SetFilterCueText();
\r
393 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
\r
395 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
396 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
397 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
398 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
399 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
401 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
402 AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);
\r
403 AddAnchor(IDC_CHECK_STOPONCOPY, BOTTOM_LEFT);
\r
404 AddAnchor(IDC_INCLUDEMERGE, BOTTOM_LEFT);
\r
405 AddAnchor(IDC_GETALL, BOTTOM_LEFT);
\r
406 AddAnchor(IDC_NEXTHUNDRED, BOTTOM_LEFT);
\r
407 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
\r
408 AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);
\r
409 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
410 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
411 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
412 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
414 // SetPromptParentWindow(m_hWnd);
\r
417 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
418 EnableSaveRestore(_T("LogDlg"));
\r
420 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
421 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
422 RECT rcDlg, rcLogList, rcChgMsg;
\r
423 GetClientRect(&rcDlg);
\r
424 m_LogList.GetWindowRect(&rcLogList);
\r
425 ScreenToClient(&rcLogList);
\r
426 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
\r
427 ScreenToClient(&rcChgMsg);
\r
431 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
432 ScreenToClient(&rectSplitter);
\r
433 int delta = yPos1 - rectSplitter.top;
\r
435 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
\r
437 m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);
\r
444 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
445 ScreenToClient(&rectSplitter);
\r
446 int delta = yPos2 - rectSplitter.top;
\r
448 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
\r
450 m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);
\r
458 // the dialog is used to select revisions
\r
459 if (m_bSelectionMustBeContinuous)
\r
460 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(IsSelectionContinuous()));
\r
462 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
466 // the dialog is used to just view log messages
\r
467 GetDlgItemText(IDOK, temp);
\r
468 SetDlgItemText(IDCANCEL, temp);
\r
469 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
\r
472 // set the choices for the "Show All" button
\r
473 temp.LoadString(IDS_LOG_SHOWALL);
\r
474 m_btnShow.AddEntry(temp);
\r
475 temp.LoadString(IDS_LOG_SHOWRANGE);
\r
476 m_btnShow.AddEntry(temp);
\r
477 m_btnShow.SetCurrentEntry((LONG)CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry")));
\r
479 m_mergedRevs.clear();
\r
481 // first start a thread to obtain the log messages without
\r
482 // blocking the dialog
\r
484 m_tFrom = (DWORD)-1;
\r
485 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
486 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
487 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
489 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
490 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
491 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
493 GetDlgItem(IDC_LOGLIST)->SetFocus();
\r
497 void CLogDlg::SetDlgTitle(bool bOffline)
\r
499 if (m_sTitle.IsEmpty())
\r
500 GetWindowText(m_sTitle);
\r
505 if (m_path.IsUrl())
\r
506 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());
\r
507 else if (m_path.IsDirectory())
\r
508 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());
\r
510 sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());
\r
511 SetWindowText(sTemp);
\r
515 if (m_path.IsUrl())
\r
516 SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());
\r
517 else if (m_path.IsDirectory())
\r
518 SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());
\r
520 SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());
\r
524 void CLogDlg::CheckRegexpTooltip()
\r
526 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
\r
527 // Since tooltip describes regexp features, show it only if regexps are enabled.
\r
528 if (m_bFilterWithRegex)
\r
530 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
\r
533 m_tooltips.DelTool(pWnd);
\r
536 void CLogDlg::EnableOKButton()
\r
540 // the dialog is used to select revisions
\r
541 if (m_bSelectionMustBeContinuous)
\r
542 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(IsSelectionContinuous()));
\r
544 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
\r
547 DialogEnableWindow(IDOK, TRUE);
\r
550 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
\r
552 // we fill here the log message rich edit control,
\r
553 // and also populate the changed files list control
\r
554 // according to the selected revision(s).
\r
556 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
557 // empty the log message view
\r
558 pMsgView->SetWindowText(_T(" "));
\r
559 // empty the changed files list
\r
560 m_ChangedFileListCtrl.SetRedraw(FALSE);
\r
561 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
562 m_currentChangedArray = NULL;
\r
563 m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
564 m_ChangedFileListCtrl.DeleteAllItems();
\r
565 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
567 // if we're not here to really show a selected revision, just
\r
568 // get out of here after clearing the views, which is what is intended
\r
569 // if that flag is not set.
\r
573 m_ChangedFileListCtrl.Invalidate();
\r
574 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
575 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
579 // depending on how many revisions are selected, we have to do different
\r
581 int selCount = m_LogList.GetSelectedCount();
\r
584 // if nothing is selected, we have nothing more to do
\r
585 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
586 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
589 else if (selCount == 1)
\r
591 // if one revision is selected, we have to fill the log message view
\r
592 // with the corresponding log message, and also fill the changed files
\r
594 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
595 int selIndex = m_LogList.GetNextSelectedItem(pos);
\r
596 if (selIndex >= m_arShownList.GetCount())
\r
598 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
599 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
602 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(selIndex));
\r
604 // set the log message text
\r
605 pMsgView->SetWindowText(pLogEntry->sMessage);
\r
606 // turn bug ID's into links if the bugtraq: properties have been set
\r
607 // and we can find a match of those in the log message
\r
608 m_ProjectProperties.FindBugID(pLogEntry->sMessage, pMsgView);
\r
609 CAppUtils::FormatTextInRichEditControl(pMsgView);
\r
610 m_currentChangedArray = pLogEntry->pArChangedPaths;
\r
611 if (m_currentChangedArray == NULL)
\r
613 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
614 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
617 // fill in the changed files list control
\r
618 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
620 m_CurrentFilteredChangedArray.RemoveAll();
\r
621 for (INT_PTR c = 0; c < m_currentChangedArray->GetCount(); ++c)
\r
623 LogChangedPath * cpath = m_currentChangedArray->GetAt(c);
\r
626 if (m_currentChangedArray->GetAt(c)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
628 m_CurrentFilteredChangedArray.Add(cpath);
\r
631 m_currentChangedArray = &m_CurrentFilteredChangedArray;
\r
636 // more than one revision is selected:
\r
637 // the log message view must be emptied
\r
638 // the changed files list contains all the changed paths from all
\r
639 // selected revisions, with 'doubles' removed
\r
640 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
\r
643 // redraw the views
\r
644 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
645 if (m_currentChangedArray)
\r
647 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
\r
648 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
\r
650 else if (m_currentChangedPathList.GetCount())
\r
652 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
\r
653 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
\r
657 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
658 m_ChangedFileListCtrl.Invalidate();
\r
660 CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);
\r
661 // sort according to the settings
\r
662 if (m_nSortColumnPathList > 0)
\r
663 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
665 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
\r
666 m_ChangedFileListCtrl.SetRedraw(TRUE);
\r
670 void CLogDlg::OnBnClickedGetall()
\r
675 void CLogDlg::GetAll(bool bForceAll /* = false */)
\r
678 // fetch all requested log messages, either the specified range or
\r
679 // really *all* available log messages.
\r
681 INT_PTR entry = m_btnShow.GetCurrentEntry();
\r
687 case 0: // show all
\r
690 m_startrev = m_LogRevision;
\r
692 m_bShowedAll = true;
\r
695 case 1: // show range
\r
698 // ask for a revision range
\r
699 CRevisionRangeDlg dlg;
\r
700 dlg.SetStartRevision(m_startrev);
\r
701 dlg.SetEndRevision( (m_endrev>=0) ? m_endrev : 0);
\r
702 if (dlg.DoModal()!=IDOK)
\r
706 m_endrev = dlg.GetEndRevision();
\r
707 m_startrev = dlg.GetStartRevision();
\r
708 if (((m_endrev.IsNumber())&&(m_startrev.IsNumber()))||
\r
709 (m_endrev.IsHead()||m_startrev.IsHead()))
\r
711 if (((LONG)m_startrev < (LONG)m_endrev)||
\r
712 (m_endrev.IsHead()))
\r
714 git_revnum_t temp = m_startrev;
\r
715 m_startrev = m_endrev;
\r
719 m_bShowedAll = false;
\r
724 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
725 m_ChangedFileListCtrl.Invalidate();
\r
726 // We need to create CStoreSelection on the heap or else
\r
727 // the variable will run out of the scope before the
\r
728 // thread ends. Therefore we let the thread delete
\r
730 m_pStoreSelection = new CStoreSelection(this);
\r
731 m_LogList.SetItemCountEx(0);
\r
732 m_LogList.Invalidate();
\r
733 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
734 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
735 pMsgView->SetWindowText(_T(""));
\r
737 SetSortArrow(&m_LogList, -1, true);
\r
739 m_LogList.DeleteAllItems();
\r
740 m_arShownList.RemoveAll();
\r
741 m_logEntries.ClearAll();
\r
744 m_bCancelled = FALSE;
\r
746 m_tFrom = (DWORD)-1;
\r
749 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
750 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
752 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
753 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
755 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
756 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
760 void CLogDlg::OnBnClickedRefresh()
\r
766 void CLogDlg::Refresh (bool autoGoOnline)
\r
769 // refreshing means re-downloading the already shown log messages
\r
772 m_childCounter = 0;
\r
774 if ((m_limit == 0)||(m_bStrict)||(int(m_logEntries.size()-1) > m_limit))
\r
776 if (m_logEntries.size() != 0)
\r
778 m_endrev = m_logEntries[m_logEntries.size()-1]->Rev;
\r
782 m_bCancelled = FALSE;
\r
784 // We need to create CStoreSelection on the heap or else
\r
785 // the variable will run out of the scope before the
\r
786 // thread ends. Therefore we let the thread delete
\r
788 m_pStoreSelection = new CStoreSelection(this);
\r
789 m_ChangedFileListCtrl.SetItemCountEx(0);
\r
790 m_ChangedFileListCtrl.Invalidate();
\r
791 m_LogList.SetItemCountEx(0);
\r
792 m_LogList.Invalidate();
\r
793 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
794 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
795 pMsgView->SetWindowText(_T(""));
\r
797 SetSortArrow(&m_LogList, -1, true);
\r
799 m_LogList.DeleteAllItems();
\r
800 m_arShownList.RemoveAll();
\r
801 m_logEntries.ClearAll();
\r
803 // reset the cached HEAD property & go on-line
\r
807 SetDlgTitle (false);
\r
808 logCachePool.GetRepositoryInfo().ResetHeadRevision (m_sUUID, m_sRepositoryRoot);
\r
811 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
812 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
814 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
815 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
817 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
818 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
822 void CLogDlg::OnBnClickedNexthundred()
\r
826 // we have to fetch the next X log messages.
\r
827 if (m_logEntries.size() < 1)
\r
829 // since there weren't any log messages fetched before, just
\r
830 // fetch all since we don't have an 'anchor' to fetch the 'next'
\r
832 return GetAll(true);
\r
834 git_revnum_t rev = m_logEntries[m_logEntries.size()-1]->Rev;
\r
837 return; // do nothing! No more revisions to get
\r
841 m_bCancelled = FALSE;
\r
843 // rev is is revision we already have and we will receive it again
\r
844 // -> fetch one extra revision to get NumberOfLogs *new* revisions
\r
846 m_limit = (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;
\r
847 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
848 SetSortArrow(&m_LogList, -1, true);
\r
849 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
850 // We need to create CStoreSelection on the heap or else
\r
851 // the variable will run out of the scope before the
\r
852 // thread ends. Therefore we let the thread delete
\r
854 m_pStoreSelection = new CStoreSelection(this);
\r
856 // since we fetch the log from the last revision we already have,
\r
857 // we have to remove that revision entry to avoid getting it twice
\r
858 m_logEntries.pop_back();
\r
859 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
861 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
862 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
864 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
865 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
\r
869 BOOL CLogDlg::Cancel()
\r
871 return m_bCancelled;
\r
874 void CLogDlg::SaveSplitterPos()
\r
878 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
\r
879 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
\r
881 m_wndSplitter1.GetWindowRect(&rectSplitter);
\r
882 ScreenToClient(&rectSplitter);
\r
883 regPos1 = rectSplitter.top;
\r
884 m_wndSplitter2.GetWindowRect(&rectSplitter);
\r
885 ScreenToClient(&rectSplitter);
\r
886 regPos2 = rectSplitter.top;
\r
890 void CLogDlg::OnCancel()
\r
892 // canceling means stopping the working thread if it's still running.
\r
893 // we do this by using the Subversion cancel callback.
\r
894 // But canceling can also mean just to close the dialog, depending on the
\r
895 // text shown on the cancel button (it could simply read "OK").
\r
896 CString temp, temp2;
\r
897 GetDlgItemText(IDOK, temp);
\r
898 temp2.LoadString(IDS_MSGBOX_CANCEL);
\r
899 if ((temp.Compare(temp2)==0)||(m_bThreadRunning))
\r
901 m_bCancelled = true;
\r
906 m_regLastStrict = m_bStrict;
\r
907 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
908 reg = m_btnShow.GetCurrentEntry();
\r
910 __super::OnCancel();
\r
913 CString CLogDlg::MakeShortMessage(const CString& message)
\r
915 bool bFoundShort = true;
\r
916 CString sShortMessage = m_ProjectProperties.GetLogSummary(message);
\r
917 if (sShortMessage.IsEmpty())
\r
919 bFoundShort = false;
\r
920 sShortMessage = message;
\r
922 // Remove newlines and tabs 'cause those are not shown nicely in the list control
\r
923 sShortMessage.Replace(_T("\r"), _T(""));
\r
924 sShortMessage.Replace(_T("\t"), _T(" "));
\r
926 // Suppose the first empty line separates 'summary' from the rest of the message.
\r
927 int found = sShortMessage.Find(_T("\n\n"));
\r
928 // To avoid too short 'short' messages
\r
929 // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")
\r
930 // only use the empty newline as a separator if it comes after at least 15 chars.
\r
931 if ((!bFoundShort)&&(found >= 15))
\r
933 sShortMessage = sShortMessage.Left(found);
\r
935 sShortMessage.Replace('\n', ' ');
\r
936 return sShortMessage;
\r
939 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
942 if (rev == SVN_INVALID_REVNUM)
\r
948 // this is the callback function which receives the data for every revision we ask the log for
\r
949 // we store this information here one by one.
\r
951 if (m_startrev == -1)
\r
956 m_LogProgress.SetPos(m_limit - m_limitcounter);
\r
958 else if (m_startrev.IsNumber() && m_startrev.IsNumber())
\r
959 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);
\r
960 __time64_t ttime = time/1000000L;
\r
961 if (m_tTo < (DWORD)ttime)
\r
962 m_tTo = (DWORD)ttime;
\r
963 if (m_tFrom > (DWORD)ttime)
\r
964 m_tFrom = (DWORD)ttime;
\r
965 if ((m_lowestRev > rev)||(m_lowestRev < 0))
\r
967 // Add as many characters from the log message to the list control
\r
968 PLOGENTRYDATA pLogItem = new LOGENTRYDATA;
\r
969 pLogItem->bCopies = !!copies;
\r
971 // find out if this item was copied in the revision
\r
972 BOOL copiedself = FALSE;
\r
975 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)
\r
977 LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);
\r
978 if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))
\r
980 // note: this only works if the log is fetched top-to-bottom
\r
981 // but since we do that, it shouldn't be a problem
\r
982 m_sSelfRelativeURL = cpath->sCopyFromPath;
\r
988 pLogItem->bCopiedSelf = copiedself;
\r
989 pLogItem->tmDate = ttime;
\r
990 pLogItem->sAuthor = author;
\r
991 pLogItem->sDate = date;
\r
992 pLogItem->sShortMessage = MakeShortMessage(message);
\r
993 pLogItem->dwFileChanges = filechanges;
\r
994 pLogItem->actions = actions;
\r
995 pLogItem->haschildren = haschildren;
\r
996 pLogItem->childStackDepth = m_childCounter;
\r
997 m_maxChild = max(m_childCounter, m_maxChild);
\r
1000 pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();
\r
1002 // split multi line log entries and concatenate them
\r
1003 // again but this time with \r\n as line separators
\r
1004 // so that the edit control recognizes them
\r
1007 if (message.GetLength()>0)
\r
1009 m_sMessageBuf = message;
\r
1010 m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));
\r
1011 m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));
\r
1012 if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)
\r
1013 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);
\r
1016 m_sMessageBuf.Empty();
\r
1017 pLogItem->sMessage = m_sMessageBuf;
\r
1018 pLogItem->Rev = rev;
\r
1020 // move-construct path array
\r
1022 pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);
\r
1023 cpaths->RemoveAll();
\r
1025 catch (CException * e)
\r
1027 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);
\r
1029 m_bCancelled = TRUE;
\r
1031 m_logEntries.push_back(pLogItem);
\r
1032 m_arShownList.Add(pLogItem);
\r
1037 //this is the thread function which calls the subversion function
\r
1038 UINT CLogDlg::LogThreadEntry(LPVOID pVoid)
\r
1040 return ((CLogDlg*)pVoid)->LogThread();
\r
1044 //this is the thread function which calls the subversion function
\r
1045 UINT CLogDlg::LogThread()
\r
1048 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1050 //does the user force the cache to refresh (shift or control key down)?
\r
1051 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1052 || (GetKeyState (VK_SHIFT) < 0);
\r
1054 //disable the "Get All" button while we're receiving
\r
1056 DialogEnableWindow(IDC_GETALL, FALSE);
\r
1057 DialogEnableWindow(IDC_NEXTHUNDRED, FALSE);
\r
1058 DialogEnableWindow(IDC_CHECK_STOPONCOPY, FALSE);
\r
1059 DialogEnableWindow(IDC_INCLUDEMERGE, FALSE);
\r
1060 DialogEnableWindow(IDC_STATBUTTON, FALSE);
\r
1061 DialogEnableWindow(IDC_REFRESH, FALSE);
\r
1064 temp.LoadString(IDS_PROGRESSWAIT);
\r
1065 m_LogList.ShowText(temp, true);
\r
1066 // change the text of the close button to "Cancel" since now the thread
\r
1067 // is running, and simply closing the dialog doesn't work.
\r
1068 if (!GetDlgItem(IDOK)->IsWindowVisible())
\r
1070 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1071 SetDlgItemText(IDCANCEL, temp);
\r
1073 // We use a progress bar while getting the logs
\r
1074 m_LogProgress.SetRange32(0, 100);
\r
1075 m_LogProgress.SetPos(0);
\r
1076 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
\r
1077 // git_revnum_t r = -1;
\r
1079 // get the repository root url, because the changed-files-list has the
\r
1080 // paths shown there relative to the repository root.
\r
1081 // CTGitPath rootpath;
\r
1082 // BOOL succeeded = GetRootAndHead(m_path, rootpath, r);
\r
1084 // m_sRepositoryRoot = rootpath.GetGitPathString();
\r
1085 // m_sURL = m_path.GetGitPathString();
\r
1087 // we need the UUID to unambigously identify the log cache
\r
1088 // if (logCachePool.IsEnabled())
\r
1089 // m_sUUID = logCachePool.GetRepositoryInfo().GetRepositoryUUID (rootpath);
\r
1091 // if the log dialog is started from a working copy, we need to turn that
\r
1092 // local path into an url here
\r
1095 // if (!m_path.IsUrl())
\r
1097 // m_sURL = GetURLFromPath(m_path);
\r
1099 // The URL is escaped because Git::logReceiver
\r
1100 // returns the path in a native format
\r
1101 // m_sURL = CPathUtils::PathUnescape(m_sURL);
\r
1103 // m_sRelativeRoot = m_sURL.Mid(CPathUtils::PathUnescape(m_sRepositoryRoot).GetLength());
\r
1104 // m_sSelfRelativeURL = m_sRelativeRoot;
\r
1107 if (succeeded && !m_mergePath.IsEmpty() && m_mergedRevs.empty())
\r
1109 // in case we got a merge path set, retrieve the merge info
\r
1110 // of that path and check whether one of the merge URLs
\r
1111 // match the URL we show the log for.
\r
1112 GitPool localpool(pool);
\r
1113 git_error_clear(Err);
\r
1114 apr_hash_t * mergeinfo = NULL;
\r
1115 if (git_client_mergeinfo_get_merged (&mergeinfo, m_mergePath.GetGitApiPath(localpool), GitRev(GitRev::REV_WC), m_pctx, localpool) == NULL)
\r
1117 // now check the relative paths
\r
1118 apr_hash_index_t *hi;
\r
1124 for (hi = apr_hash_first(localpool, mergeinfo); hi; hi = apr_hash_next(hi))
\r
1126 apr_hash_this(hi, &key, NULL, &val);
\r
1127 if (m_sURL.Compare(CUnicodeUtils::GetUnicode((char*)key)) == 0)
\r
1129 apr_array_header_t * arr = (apr_array_header_t*)val;
\r
1132 for (long i=0; i<arr->nelts; ++i)
\r
1134 git_merge_range_t * pRange = APR_ARRAY_IDX(arr, i, git_merge_range_t*);
\r
1137 for (git_revnum_t r=pRange->start+1; r<=pRange->end; ++r)
\r
1139 m_mergedRevs.insert(r);
\r
1151 m_LogProgress.SetPos(1);
\r
1152 if (m_startrev == GitRev::REV_HEAD)
\r
1156 if (m_endrev == GitRev::REV_HEAD)
\r
1163 m_limitcounter = m_limit;
\r
1164 m_LogProgress.SetRange32(0, m_limit);
\r
1167 m_LogProgress.SetRange32(m_endrev, m_startrev);
\r
1169 if (!m_pegrev.IsValid())
\r
1170 m_pegrev = m_startrev;
\r
1171 size_t startcount = m_logEntries.size();
\r
1173 m_bStrictStopped = false;
\r
1177 succeeded = ReceiveLog (CTGitPathList(m_path), m_pegrev, m_startrev, m_endrev, m_limit, m_bStrict, m_bIncludeMerges, refresh);
\r
1178 if ((!succeeded)&&(!m_path.IsUrl()))
\r
1180 // try again with REV_WC as the start revision, just in case the path doesn't
\r
1181 // exist anymore in HEAD
\r
1182 succeeded = ReceiveLog(CTGitPathList(m_path), GitRev(), GitRev::REV_WC, m_endrev, m_limit, m_bStrict, m_bIncludeMerges, refresh);
\r
1185 m_LogList.ClearText();
\r
1188 m_LogList.ShowText(GetLastErrorMessage(), true);
\r
1192 if (!m_wcRev.IsValid())
\r
1194 // fetch the revision the wc path is on so we can mark it
\r
1195 CTGitPath revWCPath = m_ProjectProperties.GetPropsPath();
\r
1196 if (!m_path.IsUrl())
\r
1197 revWCPath = m_path;
\r
1198 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RecursiveLogRev"), FALSE)))
\r
1200 git_revnum_t minrev, maxrev;
\r
1201 bool switched, modified, sparse;
\r
1202 GetWCRevisionStatus(revWCPath, true, minrev, maxrev, switched, modified, sparse);
\r
1208 CTGitPath dummypath;
\r
1210 git_wc_status2_t * stat = status.GetFirstFileStatus(revWCPath, dummypath, false, git_depth_empty);
\r
1211 if (stat && stat->entry && stat->entry->cmt_rev)
\r
1212 m_wcRev = stat->entry->cmt_rev;
\r
1213 if (stat && stat->entry && (stat->entry->kind == git_node_dir))
\r
1214 m_wcRev = stat->entry->revision;
\r
1218 if (m_bStrict && (m_lowestRev>1) && ((m_limit>0) ? ((startcount + m_limit)>m_logEntries.size()) : (m_endrev<m_lowestRev)))
\r
1219 m_bStrictStopped = true;
\r
1220 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
1222 m_timFrom = (__time64_t(m_tFrom));
\r
1223 m_timTo = (__time64_t(m_tTo));
\r
1224 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
1225 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
1226 m_DateFrom.SetTime(&m_timFrom);
\r
1227 m_DateTo.SetTime(&m_timTo);
\r
1229 DialogEnableWindow(IDC_GETALL, TRUE);
\r
1230 m_LogList.ClearText();
\r
1232 this->m_logEntries.ClearAll();
\r
1233 this->m_logEntries.ParserFromLog();
\r
1234 m_LogList.SetItemCountEx(this->m_logEntries.size());
\r
1236 this->m_arShownList.Add(&g_rev);
\r
1237 g_rev.m_AuthorName.Append(_T("Frank Li"));
\r
1240 if (!m_bShowedAll)
\r
1241 DialogEnableWindow(IDC_NEXTHUNDRED, TRUE);
\r
1243 DialogEnableWindow(IDC_CHECK_STOPONCOPY, TRUE);
\r
1244 DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);
\r
1245 DialogEnableWindow(IDC_STATBUTTON, TRUE);
\r
1246 DialogEnableWindow(IDC_REFRESH, TRUE);
\r
1249 LogCache::CRepositoryInfo& cachedProperties = logCachePool.GetRepositoryInfo();
\r
1250 SetDlgTitle(cachedProperties.IsOffline (m_sUUID, m_sRepositoryRoot, false));
\r
1252 GetDlgItem(IDC_PROGRESS)->ShowWindow(FALSE);
\r
1253 m_bCancelled = true;
\r
1255 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1256 m_LogList.RedrawItems(0, m_arShownList.GetCount());
\r
1257 m_LogList.SetRedraw(false);
\r
1258 ResizeAllListCtrlCols();
\r
1259 m_LogList.SetRedraw(true);
\r
1260 if ( m_pStoreSelection )
\r
1262 // Deleting the instance will restore the
\r
1263 // selection of the CLogDlg.
\r
1264 delete m_pStoreSelection;
\r
1265 m_pStoreSelection = NULL;
\r
1269 // If no selection has been set then this must be the first time
\r
1270 // the revisions are shown. Let's preselect the topmost revision.
\r
1271 if ( m_LogList.GetItemCount()>0 )
\r
1273 m_LogList.SetSelectionMark(0);
\r
1274 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1278 if (!GetDlgItem(IDOK)->IsWindowVisible())
\r
1280 temp.LoadString(IDS_MSGBOX_OK);
\r
1281 SetDlgItemText(IDCANCEL, temp);
\r
1285 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1286 // the log messages
\r
1287 PostMessage(WM_TIMER, LOGFILTER_TIMER);
\r
1292 void CLogDlg::CopySelectionToClipBoard()
\r
1295 CString sClipdata;
\r
1296 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1300 sRev.LoadString(IDS_LOG_REVISION);
\r
1302 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1304 sDate.LoadString(IDS_LOG_DATE);
\r
1306 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1309 CString sLogCopyText;
\r
1311 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1312 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1313 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1315 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1316 sPaths += cpath->GetAction() + _T(" : ") + cpath->sPath;
\r
1317 if (cpath->sCopyFromPath.IsEmpty())
\r
1318 sPaths += _T("\r\n");
\r
1321 CString sCopyFrom;
\r
1322 sCopyFrom.Format(_T(" (%s: %s, %s, %ld)\r\n"), CString(MAKEINTRESOURCE(IDS_LOG_COPYFROM)),
\r
1323 (LPCTSTR)cpath->sCopyFromPath,
\r
1324 (LPCTSTR)CString(MAKEINTRESOURCE(IDS_LOG_REVISION)),
\r
1325 (LPCTSTR)cpath->lCopyFromRev);
\r
1326 sPaths += sCopyFrom;
\r
1330 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
1331 (LPCTSTR)sRev, pLogEntry->Rev,
\r
1332 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->sAuthor,
\r
1333 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->sDate,
\r
1334 (LPCTSTR)sMessage, (LPCTSTR)pLogEntry->sMessage,
\r
1336 sClipdata += sLogCopyText;
\r
1338 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1343 void CLogDlg::CopyChangedSelectionToClipBoard()
\r
1346 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1348 return; // nothing is selected, get out of here
\r
1352 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1355 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
1358 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
1359 sPaths += m_currentChangedPathList[nItem].GetGitPathString();
\r
1360 sPaths += _T("\r\n");
\r
1365 // only one revision is selected in the log dialog top pane
\r
1366 // but multiple items could be selected in the changed items list
\r
1367 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
1370 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
1371 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
1373 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1375 // some items are hidden! So find out which item the user really selected
\r
1376 INT_PTR selRealIndex = -1;
\r
1377 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1379 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1381 if (selRealIndex == nItem)
\r
1383 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);
\r
1388 if (changedlogpath)
\r
1390 sPaths += changedlogpath->sPath;
\r
1391 sPaths += _T("\r\n");
\r
1396 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
\r
1400 BOOL CLogDlg::IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev)
\r
1403 CString added, deleted;
\r
1404 if (changedpath == NULL)
\r
1407 if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))
\r
1409 if (changedpath->action == LOGACTIONS_ADDED) // file is added
\r
1411 if (changedpath->lCopyFromRev == 0)
\r
1412 return FALSE; // but file was not added with history
\r
1420 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
1422 // we have two separate context menus:
\r
1423 // one shown on the log message list control,
\r
1424 // the other shown in the changed-files list control
\r
1425 int selCount = m_LogList.GetSelectedCount();
\r
1426 if (pWnd == &m_LogList)
\r
1428 ShowContextMenuForRevisions(pWnd, point);
\r
1430 else if (pWnd == &m_ChangedFileListCtrl)
\r
1432 ShowContextMenuForChangedpaths(pWnd, point);
\r
1434 else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
1436 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1437 int selIndex = -1;
\r
1439 selIndex = m_LogList.GetNextSelectedItem(pos);
\r
1440 if ((point.x == -1) && (point.y == -1))
\r
1443 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
\r
1444 ClientToScreen(&rect);
\r
1445 point = rect.CenterPoint();
\r
1447 CString sMenuItemText;
\r
1449 if (popup.CreatePopupMenu())
\r
1451 // add the 'default' entries
\r
1452 sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
\r
1453 popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);
\r
1454 sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);
\r
1455 popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);
\r
1457 if (selIndex >= 0)
\r
1459 popup.AppendMenu(MF_SEPARATOR);
\r
1460 sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);
\r
1461 popup.AppendMenu(MF_STRING | MF_ENABLED, ID_EDITAUTHOR, sMenuItemText);
\r
1464 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1468 break; // no command selected
\r
1471 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
\r
1473 case ID_EDITAUTHOR:
\r
1474 EditLogMessage(selIndex);
\r
1481 bool CLogDlg::IsSelectionContinuous()
\r
1483 if ( m_LogList.GetSelectedCount()==1 )
\r
1485 // if only one revision is selected, the selection is of course
\r
1490 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1491 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1494 int itemindex = m_LogList.GetNextSelectedItem(pos);
\r
1497 int nextindex = m_LogList.GetNextSelectedItem(pos);
\r
1498 if (nextindex - itemindex > 1)
\r
1500 bContinuous = false;
\r
1503 itemindex = nextindex;
\r
1506 return bContinuous;
\r
1509 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
1512 ASSERT(m_pFindDialog != NULL);
\r
1514 if (m_pFindDialog->IsTerminating())
\r
1516 // invalidate the handle identifying the dialog box.
\r
1517 m_pFindDialog = NULL;
\r
1521 if(m_pFindDialog->FindNext())
\r
1523 //read data from dialog
\r
1524 CString FindText = m_pFindDialog->GetFindString();
\r
1525 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
\r
1526 bool bFound = false;
\r
1528 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
\r
1530 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
\r
1533 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
\r
1537 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1539 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))
\r
1544 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1545 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1547 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1548 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))
\r
1554 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))
\r
1566 if (m_logEntries[i]->sMessage.Find(FindText) >= 0)
\r
1571 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1572 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1573 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1575 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1576 if (cpath->sCopyFromPath.Find(FindText)>=0)
\r
1582 if (cpath->sPath.Find(FindText)>=0)
\r
1592 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1593 CString msg = pLogEntry->sMessage;
\r
1594 msg = msg.MakeLower();
\r
1595 CString find = FindText.MakeLower();
\r
1596 if (msg.Find(find) >= 0)
\r
1601 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1602 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
1604 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1605 CString lowerpath = cpath->sCopyFromPath;
\r
1606 lowerpath.MakeLower();
\r
1607 if (lowerpath.Find(find)>=0)
\r
1613 lowerpath = cpath->sPath;
\r
1614 lowerpath.MakeLower();
\r
1615 if (lowerpath.Find(find)>=0)
\r
1624 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
\r
1627 this->m_nSearchIndex = (i+1);
\r
1628 m_LogList.EnsureVisible(i, FALSE);
\r
1629 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);
\r
1630 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1631 m_LogList.SetSelectionMark(i);
\r
1632 FillLogMessageCtrl();
\r
1633 UpdateData(FALSE);
\r
1635 if (m_nSearchIndex >= m_arShownList.GetCount())
\r
1636 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
\r
1638 } // if(m_pFindDialog->FindNext())
\r
1639 UpdateLogInfoLabel();
\r
1644 void CLogDlg::OnOK()
\r
1647 // since the log dialog is also used to select revisions for other
\r
1648 // dialogs, we have to do some work before closing this dialog
\r
1649 if (GetFocus() != GetDlgItem(IDOK))
\r
1650 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
\r
1651 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
\r
1652 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
\r
1655 CString buttontext;
\r
1656 GetDlgItemText(IDOK, buttontext);
\r
1657 temp.LoadString(IDS_MSGBOX_CANCEL);
\r
1658 if (temp.Compare(buttontext) != 0)
\r
1659 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
\r
1660 m_bCancelled = TRUE;
\r
1661 m_selectedRevs.Clear();
\r
1662 m_selectedRevsOneRange.Clear();
\r
1663 if (m_pNotifyWindow)
\r
1665 int selIndex = m_LogList.GetSelectionMark();
\r
1666 if (selIndex >= 0)
\r
1668 PLOGENTRYDATA pLogEntry = NULL;
\r
1669 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1670 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1671 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1672 git_revnum_t lowerRev = pLogEntry->Rev;
\r
1673 git_revnum_t higherRev = lowerRev;
\r
1676 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1677 git_revnum_t rev = pLogEntry->Rev;
\r
1678 m_selectedRevs.AddRevision(pLogEntry->Rev);
\r
1679 if (lowerRev > rev)
\r
1681 if (higherRev < rev)
\r
1684 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
\r
1686 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
\r
1688 BOOL bSentMessage = FALSE;
\r
1689 if (m_LogList.GetSelectedCount() == 1)
\r
1691 // if only one revision is selected, check if the path/url with which the dialog was started
\r
1692 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
\r
1693 // if it was copied, use the copy from revision as lowerRev
\r
1694 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
\r
1696 CString sUrl = m_path.GetGitPathString();
\r
1697 if (!m_path.IsUrl())
\r
1699 sUrl = GetURLFromPath(m_path);
\r
1701 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
\r
1702 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
\r
1704 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);
\r
1707 if (sUrl.Compare(pData->sPath) == 0)
\r
1709 if (!pData->sCopyFromPath.IsEmpty())
\r
1711 lowerRev = pData->lCopyFromRev;
\r
1712 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
\r
1713 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
\r
1714 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1715 bSentMessage = TRUE;
\r
1722 if ( !bSentMessage )
\r
1724 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
\r
1725 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
\r
1726 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
\r
1727 if (m_selectedRevsOneRange.GetCount())
\r
1728 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
\r
1733 if (m_bSaveStrict)
\r
1734 m_regLastStrict = m_bStrict;
\r
1735 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));
\r
1736 reg = m_btnShow.GetCurrentEntry();
\r
1737 SaveSplitterPos();
\r
1741 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1743 // a double click on an entry in the changed-files list has happened
\r
1746 DiffSelectedFile();
\r
1749 void CLogDlg::DiffSelectedFile()
\r
1752 if (m_bThreadRunning)
\r
1754 UpdateLogInfoLabel();
\r
1755 INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
1758 if (m_ChangedFileListCtrl.GetSelectedCount() == 0)
\r
1760 // find out if there's an entry selected in the log list
\r
1761 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1762 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1763 git_revnum_t rev1 = pLogEntry->Rev;
\r
1764 git_revnum_t rev2 = rev1;
\r
1769 // there's at least a second entry selected in the log list: several revisions selected!
\r
1770 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1773 rev1 = max(rev1,(long)pLogEntry->Rev);
\r
1774 rev2 = min(rev2,(long)pLogEntry->Rev);
\r
1778 // now we have both revisions selected in the log list, so we can do a diff of the selected
\r
1779 // entry in the changed files list with these two revisions.
\r
1780 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1785 // nothing or only one revision selected in the log list
\r
1786 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1788 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
1790 // some items are hidden! So find out which item the user really clicked on
\r
1791 INT_PTR selRealIndex = -1;
\r
1792 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
1794 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1796 if (selRealIndex == selIndex)
\r
1798 selIndex = hiddenindex;
\r
1799 changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1805 if (IsDiffPossible(changedpath, rev1))
\r
1807 // diffs with renamed files are possible
\r
1808 if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))
\r
1809 rev2 = changedpath->lCopyFromRev;
\r
1812 // if the path was modified but the parent path was 'added with history'
\r
1813 // then we have to use the copy from revision of the parent path
\r
1814 CTGitPath cpath = CTGitPath(changedpath->sPath);
\r
1815 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
1817 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
1818 if (p.IsAncestorOf(cpath))
\r
1820 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
1821 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
1825 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
1829 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1830 CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));
\r
1832 // deleted files must be opened from the revision before the deletion
\r
1833 if (changedpath->action == LOGACTIONS_DELETED)
\r
1835 m_bCancelled = false;
\r
1837 CProgressDlg progDlg;
\r
1838 progDlg.SetTitle(IDS_APPNAME);
\r
1839 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1840 CString sInfoLine;
\r
1841 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());
\r
1842 progDlg.SetLine(1, sInfoLine, true);
\r
1843 SetAndClearProgressInfo(&progDlg);
\r
1844 progDlg.ShowModeless(m_hWnd);
\r
1846 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))
\r
1848 m_bCancelled = false;
\r
1849 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))
\r
1852 SetAndClearProgressInfo((HWND)NULL);
\r
1853 CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1858 SetAndClearProgressInfo((HWND)NULL);
\r
1860 CString sName1, sName2;
\r
1861 sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);
\r
1862 sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);
\r
1863 CAppUtils::DiffFlags flags;
\r
1864 flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1865 if (changedpath->action == LOGACTIONS_DELETED)
\r
1866 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);
\r
1868 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);
\r
1875 void CLogDlg::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1877 // a double click on an entry in the revision list has happened
\r
1880 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1881 DiffSelectedRevWithPrevious();
\r
1884 void CLogDlg::DiffSelectedRevWithPrevious()
\r
1887 if (m_bThreadRunning)
\r
1889 UpdateLogInfoLabel();
\r
1890 int selIndex = m_LogList.GetSelectionMark();
\r
1893 int selCount = m_LogList.GetSelectedCount();
\r
1894 if (selCount != 1)
\r
1897 // Find selected entry in the log list
\r
1898 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1899 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1900 long rev1 = pLogEntry->Rev;
\r
1901 long rev2 = rev1-1;
\r
1902 CTGitPath path = m_path;
\r
1904 // See how many files under the relative root were changed in selected revision
\r
1906 LogChangedPath * changed = NULL;
\r
1907 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1909 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1910 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1917 if (m_path.IsDirectory() && nChanged == 1)
\r
1919 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1920 // Do diff on that file instead of whole directory
\r
1921 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1924 m_bCancelled = FALSE;
\r
1925 DialogEnableWindow(IDOK, FALSE);
\r
1926 SetPromptApp(&theApp);
\r
1927 theApp.DoWaitCursor(1);
\r
1929 if (PromptShown())
\r
1931 GitDiff diff(this, m_hWnd, true);
\r
1932 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1933 diff.SetHEADPeg(m_LogRevision);
\r
1934 diff.ShowCompare(path, rev2, path, rev1);
\r
1938 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1941 theApp.DoWaitCursor(-1);
\r
1946 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, git_revnum_t rev1, git_revnum_t rev2, bool blame, bool unified)
\r
1949 DialogEnableWindow(IDOK, FALSE);
\r
1950 SetPromptApp(&theApp);
\r
1951 theApp.DoWaitCursor(1);
\r
1952 //get the filename
\r
1954 if (Git::PathIsURL(m_path))
\r
1956 filepath = m_path.GetGitPathString();
\r
1960 filepath = GetURLFromPath(m_path);
\r
1961 if (filepath.IsEmpty())
\r
1963 theApp.DoWaitCursor(-1);
\r
1965 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
1966 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
1967 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
1969 theApp.DoWaitCursor(-11);
\r
1973 m_bCancelled = FALSE;
\r
1974 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
1976 CString firstfile, secondfile;
\r
1977 if (m_LogList.GetSelectedCount()==1)
\r
1979 int s = m_LogList.GetSelectionMark();
\r
1980 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));
\r
1981 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
1982 firstfile = changedpath->sPath;
\r
1983 secondfile = firstfile;
\r
1984 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?
\r
1986 secondfile = changedpath->sCopyFromPath;
\r
1987 rev2 = changedpath->lCopyFromRev;
\r
1992 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();
\r
1993 secondfile = firstfile;
\r
1996 firstfile = filepath + firstfile.Trim();
\r
1997 secondfile = filepath + secondfile.Trim();
\r
1999 GitDiff diff(this, this->m_hWnd, true);
\r
2000 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
2001 diff.SetHEADPeg(m_LogRevision);
\r
2004 if (PromptShown())
\r
2005 diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);
\r
2007 CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);
\r
2011 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))
\r
2013 if (firstfile.Compare(secondfile)==0)
\r
2015 git_revnum_t baseRev = 0;
\r
2016 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);
\r
2020 theApp.DoWaitCursor(-1);
\r
2025 BOOL CLogDlg::Open(bool bOpenWith,CString changedpath, git_revnum_t rev)
\r
2028 DialogEnableWindow(IDOK, FALSE);
\r
2029 SetPromptApp(&theApp);
\r
2030 theApp.DoWaitCursor(1);
\r
2032 if (Git::PathIsURL(m_path))
\r
2034 filepath = m_path.GetGitPathString();
\r
2038 filepath = GetURLFromPath(m_path);
\r
2039 if (filepath.IsEmpty())
\r
2041 theApp.DoWaitCursor(-1);
\r
2043 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
2044 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
2045 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
2050 m_bCancelled = false;
\r
2051 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
2052 filepath += changedpath;
\r
2054 CProgressDlg progDlg;
\r
2055 progDlg.SetTitle(IDS_APPNAME);
\r
2056 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
2057 CString sInfoLine;
\r
2058 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());
\r
2059 progDlg.SetLine(1, sInfoLine, true);
\r
2060 SetAndClearProgressInfo(&progDlg);
\r
2061 progDlg.ShowModeless(m_hWnd);
\r
2063 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);
\r
2064 m_bCancelled = false;
\r
2065 if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))
\r
2068 SetAndClearProgressInfo((HWND)NULL);
\r
2069 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2071 theApp.DoWaitCursor(-1);
\r
2075 SetAndClearProgressInfo((HWND)NULL);
\r
2076 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
2079 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
2080 if (ret <= HINSTANCE_ERROR)
\r
2085 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
2086 cmd += tempfile.GetWinPathString() + _T(" ");
\r
2087 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
2090 theApp.DoWaitCursor(-1);
\r
2095 void CLogDlg::EditAuthor(const CLogDataVector& logs)
\r
2100 if (logs.size() == 0)
\r
2102 DialogEnableWindow(IDOK, FALSE);
\r
2103 SetPromptApp(&theApp);
\r
2104 theApp.DoWaitCursor(1);
\r
2105 if (Git::PathIsURL(m_path))
\r
2106 url = m_path.GetGitPathString();
\r
2109 url = GetURLFromPath(m_path);
\r
2111 name = Git_PROP_REVISION_AUTHOR;
\r
2113 CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);
\r
2114 CString sOldValue = value;
\r
2115 value.Replace(_T("\n"), _T("\r\n"));
\r
2116 CInputDlg dlg(this);
\r
2117 dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);
\r
2118 dlg.m_sInputText = value;
\r
2119 dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);
\r
2120 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
2121 dlg.m_bUseLogWidth = false;
\r
2122 if (dlg.DoModal() == IDOK)
\r
2124 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
2126 LogCache::CCachedLogInfo* toUpdate
\r
2127 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
2129 CProgressDlg progDlg;
\r
2130 progDlg.SetTitle(IDS_APPNAME);
\r
2131 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
\r
2132 progDlg.SetTime(true);
\r
2133 progDlg.SetShowProgressBar(true);
\r
2134 progDlg.ShowModeless(m_hWnd);
\r
2135 for (DWORD i=0; i<logs.size(); ++i)
\r
2137 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))
\r
2140 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2146 logs[i]->sAuthor = dlg.m_sInputText;
\r
2147 m_LogList.Invalidate();
\r
2149 // update the log cache
\r
2151 if (toUpdate != NULL)
\r
2153 // log caching is active
\r
2155 LogCache::CCachedLogInfo newInfo;
\r
2156 newInfo.Insert ( logs[i]->Rev
\r
2157 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)
\r
2160 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);
\r
2162 toUpdate->Update (newInfo);
\r
2165 progDlg.SetProgress64(i, logs.size());
\r
2169 theApp.DoWaitCursor(-1);
\r
2174 void CLogDlg::EditLogMessage(int index)
\r
2179 DialogEnableWindow(IDOK, FALSE);
\r
2180 SetPromptApp(&theApp);
\r
2181 theApp.DoWaitCursor(1);
\r
2182 if (Git::PathIsURL(m_path))
\r
2183 url = m_path.GetGitPathString();
\r
2186 url = GetURLFromPath(m_path);
\r
2188 name = Git_PROP_REVISION_LOG;
\r
2190 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
2191 m_bCancelled = FALSE;
\r
2192 CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);
\r
2193 CString sOldValue = value;
\r
2194 value.Replace(_T("\n"), _T("\r\n"));
\r
2195 CInputDlg dlg(this);
\r
2196 dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);
\r
2197 dlg.m_sInputText = value;
\r
2198 dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);
\r
2199 dlg.m_pProjectProperties = &m_ProjectProperties;
\r
2200 dlg.m_bUseLogWidth = true;
\r
2201 if (dlg.DoModal() == IDOK)
\r
2203 dlg.m_sInputText.Replace(_T("\r"), _T(""));
\r
2204 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))
\r
2206 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
2210 pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);
\r
2211 // split multi line log entries and concatenate them
\r
2212 // again but this time with \r\n as line separators
\r
2213 // so that the edit control recognizes them
\r
2214 if (dlg.m_sInputText.GetLength()>0)
\r
2216 m_sMessageBuf = dlg.m_sInputText;
\r
2217 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));
\r
2218 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));
\r
2219 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)
\r
2220 dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);
\r
2223 dlg.m_sInputText.Empty();
\r
2224 pLogEntry->sMessage = dlg.m_sInputText;
\r
2225 pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);
\r
2226 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
\r
2227 pMsgView->SetWindowText(_T(" "));
\r
2228 pMsgView->SetWindowText(dlg.m_sInputText);
\r
2229 m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);
\r
2230 m_LogList.Invalidate();
\r
2232 // update the log cache
\r
2234 LogCache::CCachedLogInfo* toUpdate
\r
2235 = GetLogCache (CTGitPath (m_sRepositoryRoot));
\r
2236 if (toUpdate != NULL)
\r
2238 // log caching is active
\r
2240 LogCache::CCachedLogInfo newInfo;
\r
2241 newInfo.Insert ( pLogEntry->Rev
\r
2243 , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)
\r
2245 , LogCache::CRevisionInfoContainer::HAS_COMMENT);
\r
2247 toUpdate->Update (newInfo);
\r
2251 theApp.DoWaitCursor(-1);
\r
2256 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
\r
2258 // Skip Ctrl-C when copying text out of the log message or search filter
\r
2259 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
2260 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
2262 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
2264 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
2266 DiffSelectedRevWithPrevious();
\r
2270 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
2272 DiffSelectedFile();
\r
2276 if (m_hAccel && !bSkipAccelerator)
\r
2278 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
2283 m_tooltips.RelayEvent(pMsg);
\r
2284 return __super::PreTranslateMessage(pMsg);
\r
2287 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
2289 if (m_bThreadRunning)
\r
2291 // only show the wait cursor over the list control
\r
2293 ((pWnd == GetDlgItem(IDC_LOGLIST))||
\r
2294 (pWnd == GetDlgItem(IDC_MSGVIEW))||
\r
2295 (pWnd == GetDlgItem(IDC_LOGMSG))))
\r
2297 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
2302 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
\r
2303 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
2305 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
2307 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
2310 void CLogDlg::OnBnClickedHelp()
\r
2315 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
2317 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
2319 if (m_bThreadRunning)
\r
2321 if (pNMLV->iItem >= 0)
\r
2323 m_nSearchIndex = pNMLV->iItem;
\r
2324 if (pNMLV->iSubItem != 0)
\r
2326 if ((pNMLV->iItem == m_arShownList.GetCount())&&(m_bStrict)&&(m_bStrictStopped))
\r
2328 // remove the selected state
\r
2329 if (pNMLV->uChanged & LVIF_STATE)
\r
2331 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
\r
2332 FillLogMessageCtrl();
\r
2333 UpdateData(FALSE);
\r
2334 UpdateLogInfoLabel();
\r
2338 if (pNMLV->uChanged & LVIF_STATE)
\r
2340 FillLogMessageCtrl();
\r
2341 UpdateData(FALSE);
\r
2346 FillLogMessageCtrl();
\r
2347 UpdateData(FALSE);
\r
2350 UpdateLogInfoLabel();
\r
2353 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
\r
2355 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
\r
2356 if (pEnLink->msg == WM_LBUTTONUP)
\r
2359 GetDlgItemText(IDC_MSGVIEW, msg);
\r
2360 msg.Replace(_T("\r\n"), _T("\n"));
\r
2361 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
\r
2362 if (!::PathIsURL(url))
\r
2364 url = m_ProjectProperties.GetBugIDUrl(url);
\r
2365 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
2367 if (!url.IsEmpty())
\r
2368 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
2373 void CLogDlg::OnBnClickedStatbutton()
\r
2376 if (m_bThreadRunning)
\r
2378 if (m_arShownList.IsEmpty())
\r
2379 return; // nothing is shown, so no statistics.
\r
2380 // the statistics dialog expects the log entries to be sorted by date
\r
2381 SortByColumn(3, false);
\r
2382 CPtrArray shownlist;
\r
2383 RecalculateShownList(&shownlist);
\r
2384 // create arrays which are aware of the current filter
\r
2385 CStringArray m_arAuthorsFiltered;
\r
2386 CDWordArray m_arDatesFiltered;
\r
2387 CDWordArray m_arFileChangesFiltered;
\r
2388 for (INT_PTR i=0; i<shownlist.GetCount(); ++i)
\r
2390 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(shownlist.GetAt(i));
\r
2391 CString strAuthor = pLogEntry->sAuthor;
\r
2392 if ( strAuthor.IsEmpty() )
\r
2394 strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);
\r
2396 m_arAuthorsFiltered.Add(strAuthor);
\r
2397 m_arDatesFiltered.Add(static_cast<DWORD>(pLogEntry->tmDate));
\r
2398 m_arFileChangesFiltered.Add(pLogEntry->dwFileChanges);
\r
2400 CStatGraphDlg dlg;
\r
2401 dlg.m_parAuthors = &m_arAuthorsFiltered;
\r
2402 dlg.m_parDates = &m_arDatesFiltered;
\r
2403 dlg.m_parFileChanges = &m_arFileChangesFiltered;
\r
2404 dlg.m_path = m_path;
\r
2406 // restore the previous sorting
\r
2407 SortByColumn(m_nSortColumn, m_bAscending);
\r
2408 OnTimer(LOGFILTER_TIMER);
\r
2412 void CLogDlg::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
2415 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
2416 // Take the default processing unless we set this to something else below.
\r
2417 *pResult = CDRF_DODEFAULT;
\r
2419 if (m_bNoDispUpdates)
\r
2422 switch (pLVCD->nmcd.dwDrawStage)
\r
2424 case CDDS_PREPAINT:
\r
2426 *pResult = CDRF_NOTIFYITEMDRAW;
\r
2430 case CDDS_ITEMPREPAINT:
\r
2432 // This is the prepaint stage for an item. Here's where we set the
\r
2433 // item's text color.
\r
2435 // Tell Windows to send draw notifications for each subitem.
\r
2436 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
2438 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
2440 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2442 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
2446 if (data->bCopiedSelf)
\r
2448 // only change the background color if the item is not 'hot' (on vista with themes enabled)
\r
2449 if (!theme.IsAppThemed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
2450 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
2453 if (data->bCopies)
\r
2454 crText = m_Colors.GetColor(CColors::Modified);
\r
2456 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
2457 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
2458 // if (data->Rev == m_wcRev)
\r
2460 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
2461 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
2462 // tells the control to recalculate the extent of the text.
\r
2463 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
2467 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2469 if (m_bStrictStopped)
\r
2470 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2472 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
2473 pLVCD->clrText = crText;
\r
2477 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
2479 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
2481 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
2483 if (pLVCD->iSubItem == 1)
\r
2485 *pResult = CDRF_DODEFAULT;
\r
2487 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2491 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
2492 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
2494 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
2496 // Get the selected state of the
\r
2497 // item being drawn.
\r
2499 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
2500 rItem.mask = LVIF_STATE;
\r
2501 rItem.iItem = pLVCD->nmcd.dwItemSpec;
\r
2502 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
2503 m_LogList.GetItem(&rItem);
\r
2506 m_LogList.GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
2508 // Fill the background
\r
2509 if (theme.IsAppThemed() && m_bVista)
\r
2511 theme.Open(m_hWnd, L"Explorer");
\r
2512 int state = LISS_NORMAL;
\r
2513 if (rItem.state & LVIS_SELECTED)
\r
2515 if (::GetFocus() == m_LogList.m_hWnd)
\r
2516 state |= LISS_SELECTED;
\r
2518 state |= LISS_SELECTEDNOTFOCUS;
\r
2523 if (pLogEntry->bCopiedSelf)
\r
2525 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
2526 // information at this drawing stage. But we can check the whether the
\r
2527 // previous stage changed the background color of the item
\r
2528 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
2531 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2534 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2535 ::DeleteObject(brush);
\r
2542 if (theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
2543 theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);
\r
2545 theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
2550 if (rItem.state & LVIS_SELECTED)
\r
2552 if (::GetFocus() == m_LogList.m_hWnd)
\r
2553 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
2555 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
2559 //if (pLogEntry->bCopiedSelf)
\r
2560 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
2562 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
2564 if (brush == NULL)
\r
2567 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
2568 ::DeleteObject(brush);
\r
2571 // Draw the icon(s) into the compatible DC
\r
2572 if (pLogEntry->actions & LOGACTIONS_MODIFIED)
\r
2573 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2576 if (pLogEntry->actions & LOGACTIONS_ADDED)
\r
2577 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2580 if (pLogEntry->actions & LOGACTIONS_DELETED)
\r
2581 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2584 if (pLogEntry->actions & LOGACTIONS_REPLACED)
\r
2585 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
2588 *pResult = CDRF_SKIPDEFAULT;
\r
2594 *pResult = CDRF_DODEFAULT;
\r
2597 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2600 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
2601 // Take the default processing unless we set this to something else below.
\r
2602 *pResult = CDRF_DODEFAULT;
\r
2604 if (m_bNoDispUpdates)
\r
2607 // First thing - check the draw stage. If it's the control's prepaint
\r
2608 // stage, then tell Windows we want messages for every item.
\r
2610 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2612 *pResult = CDRF_NOTIFYITEMDRAW;
\r
2614 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
\r
2616 // This is the prepaint stage for an item. Here's where we set the
\r
2617 // item's text color. Our return value will tell Windows to draw the
\r
2618 // item itself, but it will use the new color we set here.
\r
2620 // Tell Windows to paint the control itself.
\r
2621 *pResult = CDRF_DODEFAULT;
\r
2623 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
2624 bool bGrayed = false;
\r
2625 if ((m_cHidePaths.GetState() & 0x0003)==BST_INDETERMINATE)
\r
2627 if ((m_currentChangedArray)&&((m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)))
\r
2629 if (m_currentChangedArray->GetAt(pLVCD->nmcd.dwItemSpec)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2631 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2635 else if (m_currentChangedPathList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
2637 if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)
\r
2639 crText = GetSysColor(COLOR_GRAYTEXT);
\r
2645 if ((!bGrayed)&&(m_currentChangedArray)&&(m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
2647 DWORD action = m_currentChangedArray->GetAt(pLVCD->nmcd.dwItemSpec)->action;
\r
2648 if (action == LOGACTIONS_MODIFIED)
\r
2649 crText = m_Colors.GetColor(CColors::Modified);
\r
2650 if (action == LOGACTIONS_REPLACED)
\r
2651 crText = m_Colors.GetColor(CColors::Deleted);
\r
2652 if (action == LOGACTIONS_ADDED)
\r
2653 crText = m_Colors.GetColor(CColors::Added);
\r
2654 if (action == LOGACTIONS_DELETED)
\r
2655 crText = m_Colors.GetColor(CColors::Deleted);
\r
2658 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
2659 pLVCD->clrText = crText;
\r
2664 void CLogDlg::DoSizeV1(int delta)
\r
2667 RemoveAnchor(IDC_LOGLIST);
\r
2668 RemoveAnchor(IDC_SPLITTERTOP);
\r
2669 RemoveAnchor(IDC_MSGVIEW);
\r
2670 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2671 RemoveAnchor(IDC_LOGMSG);
\r
2672 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
\r
2673 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);
\r
2674 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2675 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2676 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2677 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2678 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2681 SetSplitterRange();
\r
2682 m_LogList.Invalidate();
\r
2683 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2687 void CLogDlg::DoSizeV2(int delta)
\r
2690 RemoveAnchor(IDC_LOGLIST);
\r
2691 RemoveAnchor(IDC_SPLITTERTOP);
\r
2692 RemoveAnchor(IDC_MSGVIEW);
\r
2693 RemoveAnchor(IDC_SPLITTERBOTTOM);
\r
2694 RemoveAnchor(IDC_LOGMSG);
\r
2695 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);
\r
2696 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
\r
2697 AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);
\r
2698 AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);
\r
2699 AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);
\r
2700 AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2701 AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
2704 SetSplitterRange();
\r
2705 GetDlgItem(IDC_MSGVIEW)->Invalidate();
\r
2706 m_ChangedFileListCtrl.Invalidate();
\r
2710 void CLogDlg::AdjustMinSize()
\r
2712 // adjust the minimum size of the dialog to prevent the resizing from
\r
2713 // moving the list control too far down.
\r
2714 CRect rcChgListView;
\r
2715 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
\r
2717 m_LogList.GetClientRect(rcLogList);
\r
2719 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
\r
2720 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
\r
2721 +rcChgListView.Height()+rcLogList.Height()+60));
\r
2724 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
2726 switch (message) {
\r
2728 if (wParam == IDC_SPLITTERTOP)
\r
2730 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2731 DoSizeV1(pHdr->delta);
\r
2733 else if (wParam == IDC_SPLITTERBOTTOM)
\r
2735 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
\r
2736 DoSizeV2(pHdr->delta);
\r
2741 return CResizableDialog::DefWindowProc(message, wParam, lParam);
\r
2744 void CLogDlg::SetSplitterRange()
\r
2746 if ((m_LogList)&&(m_ChangedFileListCtrl))
\r
2749 m_LogList.GetWindowRect(rcTop);
\r
2750 ScreenToClient(rcTop);
\r
2752 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);
\r
2753 ScreenToClient(rcMiddle);
\r
2754 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);
\r
2756 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
\r
2757 ScreenToClient(rcBottom);
\r
2758 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);
\r
2762 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
\r
2764 RECT * rect = (LPRECT)lParam;
\r
2767 point = CPoint(rect->left, rect->bottom);
\r
2768 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))
\r
2770 if (popup.CreatePopupMenu())
\r
2772 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2773 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);
\r
2775 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2777 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2778 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
\r
2779 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2780 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
\r
2781 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2782 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
\r
2783 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2784 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
\r
2785 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
\r
2786 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
\r
2788 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
2790 temp.LoadString(IDS_LOG_FILTER_REGEX);
\r
2791 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
\r
2794 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
2795 if (selection != 0)
\r
2798 if (selection == LOGFILTER_REGEX)
\r
2800 m_bFilterWithRegex = !m_bFilterWithRegex;
\r
2801 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
2802 b = m_bFilterWithRegex;
\r
2803 CheckRegexpTooltip();
\r
2807 m_nSelectedFilter = selection;
\r
2808 SetFilterCueText();
\r
2810 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
2816 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
\r
2819 KillTimer(LOGFILTER_TIMER);
\r
2821 m_sFilterText.Empty();
\r
2822 UpdateData(FALSE);
\r
2823 theApp.DoWaitCursor(1);
\r
2824 CStoreSelection storeselection(this);
\r
2825 FillLogMessageCtrl(false);
\r
2826 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2827 m_arShownList.RemoveAll();
\r
2829 // reset the time filter too
\r
2830 m_timFrom = (__time64_t(m_tFrom));
\r
2831 m_timTo = (__time64_t(m_tTo));
\r
2832 m_DateFrom.SetTime(&m_timFrom);
\r
2833 m_DateTo.SetTime(&m_timTo);
\r
2834 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2835 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2837 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2839 m_arShownList.Add(m_logEntries[i]);
\r
2841 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2842 m_LogList.DeleteAllItems();
\r
2843 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
2844 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
2845 m_LogList.SetRedraw(false);
\r
2846 ResizeAllListCtrlCols();
\r
2847 m_LogList.SetRedraw(true);
\r
2848 theApp.DoWaitCursor(-1);
\r
2849 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
2850 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
2851 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
2852 UpdateLogInfoLabel();
\r
2858 void CLogDlg::SetFilterCueText()
\r
2861 switch (m_nSelectedFilter)
\r
2863 case LOGFILTER_ALL:
\r
2864 temp.LoadString(IDS_LOG_FILTER_ALL);
\r
2866 case LOGFILTER_MESSAGES:
\r
2867 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
\r
2869 case LOGFILTER_PATHS:
\r
2870 temp.LoadString(IDS_LOG_FILTER_PATHS);
\r
2872 case LOGFILTER_AUTHORS:
\r
2873 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
\r
2875 case LOGFILTER_REVS:
\r
2876 temp.LoadString(IDS_LOG_FILTER_REVS);
\r
2879 // to make the cue banner text appear more to the right of the edit control
\r
2880 temp = _T(" ")+temp;
\r
2881 m_cFilter.SetCueBanner(temp);
\r
2884 void CLogDlg::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
2886 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
2888 // Create a pointer to the item
\r
2889 LV_ITEM* pItem = &(pDispInfo)->item;
\r
2891 // Do the list need text information?
\r
2892 if (!(pItem->mask & LVIF_TEXT))
\r
2895 // By default, clear text buffer.
\r
2896 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
2898 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
2901 if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)
\r
2904 // Which item number?
\r
2905 int itemid = pItem->iItem;
\r
2906 GitRev * pLogEntry = NULL;
\r
2907 if (itemid < m_arShownList.GetCount())
\r
2908 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
2911 switch (pItem->iSubItem)
\r
2913 case 0: //revision
\r
2917 _stprintf_s(pItem->pszText, pItem->cchTextMax, _T("%ld"), pLogEntry->Rev);
\r
2918 // to make the child entries indented, add spaces
\r
2919 size_t len = _tcslen(pItem->pszText);
\r
2920 TCHAR * pBuf = pItem->pszText + len;
\r
2921 DWORD nSpaces = m_maxChild-pLogEntry->childStackDepth;
\r
2922 while ((pItem->cchTextMax >= (int)len)&&(nSpaces))
\r
2932 case 1: //action -- no text in the column
\r
2936 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
2941 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->sDate, pItem->cchTextMax);
\r
2944 case 4: //message or bug id
\r
2946 if (m_bShowBugtraqColumn)
\r
2949 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->sBugIDs, pItem->cchTextMax);
\r
2953 // fall through here!
\r
2958 // Add as many characters as possible from the short log message
\r
2959 // to the list control. If the message is longer than
\r
2960 // allowed width, add "..." as an indication.
\r
2961 const int dots_len = 3;
\r
2962 if (pLogEntry->sShortMessage.GetLength() >= pItem->cchTextMax && pItem->cchTextMax > dots_len)
\r
2964 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->sShortMessage, pItem->cchTextMax - dots_len);
\r
2965 lstrcpyn(pItem->pszText + pItem->cchTextMax - dots_len - 1, _T("..."), dots_len + 1);
\r
2968 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->sShortMessage, pItem->cchTextMax);
\r
2970 else if ((itemid == m_arShownList.GetCount()) && m_bStrict && m_bStrictStopped)
\r
2973 sTemp.LoadString(IDS_LOG_STOPONCOPY_HINT);
\r
2974 lstrcpyn(pItem->pszText, sTemp, pItem->cchTextMax);
\r
2983 void CLogDlg::OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
2986 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
2988 //Create a pointer to the item
\r
2989 LV_ITEM* pItem= &(pDispInfo)->item;
\r
2992 if ((m_bNoDispUpdates)||(m_bThreadRunning))
\r
2994 if (pItem->mask & LVIF_TEXT)
\r
2995 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
2998 if ((m_currentChangedArray!=NULL)&&(pItem->iItem >= m_currentChangedArray->GetCount()))
\r
3000 if (pItem->mask & LVIF_TEXT)
\r
3001 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3004 if ((m_currentChangedArray==NULL)&&(pItem->iItem >= m_currentChangedPathList.GetCount()))
\r
3006 if (pItem->mask & LVIF_TEXT)
\r
3007 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3010 LogChangedPath * lcpath = NULL;
\r
3011 if (m_currentChangedArray)
\r
3012 lcpath = m_currentChangedArray->GetAt(pItem->iItem);
\r
3013 //Does the list need text information?
\r
3014 if (pItem->mask & LVIF_TEXT)
\r
3017 switch (pItem->iSubItem)
\r
3021 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->GetAction(), pItem->cchTextMax);
\r
3023 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3027 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sPath, pItem->cchTextMax);
\r
3029 lstrcpyn(pItem->pszText, (LPCTSTR)m_currentChangedPathList[pItem->iItem].GetGitPathString(), pItem->cchTextMax);
\r
3031 case 2: //copyfrom path
\r
3033 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sCopyFromPath, pItem->cchTextMax);
\r
3035 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3037 case 3: //revision
\r
3038 if ((lcpath==NULL)||(lcpath->sCopyFromPath.IsEmpty()))
\r
3039 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
3041 _stprintf_s(pItem->pszText, pItem->cchTextMax, _T("%ld"), lcpath->lCopyFromRev);
\r
3050 void CLogDlg::OnEnChangeSearchedit()
\r
3054 if (m_sFilterText.IsEmpty())
\r
3056 CStoreSelection storeselection(this);
\r
3057 // clear the filter, i.e. make all entries appear
\r
3058 theApp.DoWaitCursor(1);
\r
3059 KillTimer(LOGFILTER_TIMER);
\r
3060 FillLogMessageCtrl(false);
\r
3061 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3062 m_arShownList.RemoveAll();
\r
3063 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3065 if (IsEntryInDateRange(i))
\r
3066 m_arShownList.Add(m_logEntries[i]);
\r
3068 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3069 m_LogList.DeleteAllItems();
\r
3070 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3071 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3072 m_LogList.SetRedraw(false);
\r
3073 ResizeAllListCtrlCols();
\r
3074 m_LogList.SetRedraw(true);
\r
3075 theApp.DoWaitCursor(-1);
\r
3076 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3077 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3078 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3079 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));
\r
3082 if (Validate(m_sFilterText))
\r
3083 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3085 KillTimer(LOGFILTER_TIMER);
\r
3089 bool CLogDlg::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
3093 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
3095 type |= tr1::regex_constants::icase;
\r
3096 pat = tr1::wregex(regexp_str, type);
\r
3099 catch (exception) {}
\r
3103 bool CLogDlg::Validate(LPCTSTR string)
\r
3105 if (!m_bFilterWithRegex)
\r
3108 return ValidateRegexp(string, pat, false);
\r
3111 void CLogDlg::RecalculateShownList(CPtrArray * pShownlist)
\r
3114 pShownlist->RemoveAll();
\r
3115 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
3116 bool bRegex = false;
\r
3117 if (m_bFilterWithRegex)
\r
3118 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
3120 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
3122 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3124 if ((bRegex)&&(m_bFilterWithRegex))
\r
3126 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
3128 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
3129 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
3131 pShownlist->Add(m_logEntries[i]);
\r
3135 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
3137 ATLTRACE(_T("messge = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sMessage);
\r
3138 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sMessage), pat, flags)&&IsEntryInDateRange(i))
\r
3140 pShownlist->Add(m_logEntries[i]);
\r
3144 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
3146 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
3148 bool bGoing = true;
\r
3149 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
3151 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
3152 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
3154 pShownlist->Add(m_logEntries[i]);
\r
3158 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
3160 pShownlist->Add(m_logEntries[i]);
\r
3164 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
3166 pShownlist->Add(m_logEntries[i]);
\r
3174 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
3176 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sAuthor), pat, flags)&&IsEntryInDateRange(i))
\r
3178 pShownlist->Add(m_logEntries[i]);
\r
3182 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
3184 sRev.Format(_T("%ld"), m_logEntries[i]->Rev);
\r
3185 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
3187 pShownlist->Add(m_logEntries[i]);
\r
3194 CString find = m_sFilterText;
\r
3196 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
3198 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
3200 sBugIDs = sBugIDs.MakeLower();
\r
3201 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3203 pShownlist->Add(m_logEntries[i]);
\r
3207 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
3209 CString msg = m_logEntries[i]->sMessage;
\r
3211 msg = msg.MakeLower();
\r
3212 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3214 pShownlist->Add(m_logEntries[i]);
\r
3218 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
3220 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
3222 bool bGoing = true;
\r
3223 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
3225 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
3226 CString path = cpath->sCopyFromPath;
\r
3228 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
3230 pShownlist->Add(m_logEntries[i]);
\r
3234 path = cpath->sPath;
\r
3236 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
3238 pShownlist->Add(m_logEntries[i]);
\r
3242 path = cpath->GetAction();
\r
3244 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
3246 pShownlist->Add(m_logEntries[i]);
\r
3252 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
3254 CString msg = m_logEntries[i]->sAuthor;
\r
3255 msg = msg.MakeLower();
\r
3256 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3258 pShownlist->Add(m_logEntries[i]);
\r
3262 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
3264 sRev.Format(_T("%ld"), m_logEntries[i]->Rev);
\r
3265 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
3267 pShownlist->Add(m_logEntries[i]);
\r
3271 } // else (from if (bRegex))
\r
3272 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
3276 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
\r
3278 if (nIDEvent == LOGFILTER_TIMER)
\r
3280 if (m_bThreadRunning)
\r
3282 // thread still running! So just restart the timer.
\r
3283 SetTimer(LOGFILTER_TIMER, 1000, NULL);
\r
3286 CWnd * focusWnd = GetFocus();
\r
3287 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
\r
3288 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
\r
3289 if (m_sFilterText.IsEmpty())
\r
3291 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));
\r
3292 // do not return here!
\r
3293 // we also need to run the filter if the filter text is empty:
\r
3294 // 1. to clear an existing filter
\r
3295 // 2. to rebuild the m_arShownList after sorting
\r
3297 theApp.DoWaitCursor(1);
\r
3298 CStoreSelection storeselection(this);
\r
3299 KillTimer(LOGFILTER_TIMER);
\r
3300 FillLogMessageCtrl(false);
\r
3302 // now start filter the log list
\r
3303 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
3304 RecalculateShownList(&m_arShownList);
\r
3305 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
3308 m_LogList.DeleteAllItems();
\r
3309 m_LogList.SetItemCountEx(ShownCountWithStopped());
\r
3310 m_LogList.RedrawItems(0, ShownCountWithStopped());
\r
3311 m_LogList.SetRedraw(false);
\r
3312 ResizeAllListCtrlCols();
\r
3313 m_LogList.SetRedraw(true);
\r
3314 m_LogList.Invalidate();
\r
3315 if ( m_LogList.GetItemCount()==1 )
\r
3317 m_LogList.SetSelectionMark(0);
\r
3318 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
3320 theApp.DoWaitCursor(-1);
\r
3321 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
\r
3322 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
\r
3323 if (bSetFocusToFilterControl)
\r
3324 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
3325 UpdateLogInfoLabel();
\r
3326 } // if (nIDEvent == LOGFILTER_TIMER)
\r
3327 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));
\r
3328 __super::OnTimer(nIDEvent);
\r
3331 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3334 m_DateTo.GetTime(_time);
\r
3337 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
\r
3338 if (time.GetTime() != m_tTo)
\r
3340 m_tTo = (DWORD)time.GetTime();
\r
3341 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
3344 catch (CAtlException)
\r
3351 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
3354 m_DateFrom.GetTime(_time);
\r
3357 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
\r
3358 if (time.GetTime() != m_tFrom)
\r
3360 m_tFrom = (DWORD)time.GetTime();
\r
3361 SetTimer(LOGFILTER_TIMER, 10, NULL);
\r
3364 catch (CAtlException)
\r
3371 BOOL CLogDlg::IsEntryInDateRange(int i)
\r
3374 __time64_t time = m_logEntries[i]->tmDate;
\r
3375 if ((time >= m_tFrom)&&(time <= m_tTo))
\r
3382 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths /* = false */, bool bUseFilter /* = true */)
\r
3384 CTGitPathList pathList;
\r
3387 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
3389 m_sRepositoryRoot = GetRepositoryRoot(m_path);
\r
3391 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
\r
3394 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3399 int nextpos = m_LogList.GetNextSelectedItem(pos);
\r
3400 if (nextpos >= m_arShownList.GetCount())
\r
3402 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));
\r
3403 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
3404 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
\r
3406 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
3407 if (cpath == NULL)
\r
3410 if (!bRelativePaths)
\r
3411 path.SetFromGit(m_sRepositoryRoot);
\r
3412 path.AppendPathString(cpath->sPath);
\r
3413 if ((!bUseFilter)||
\r
3414 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
\r
3415 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
\r
3416 pathList.AddPath(path);
\r
3421 pathList.RemoveDuplicates();
\r
3426 void CLogDlg::SortByColumn(int nSortColumn, bool bAscending)
\r
3429 switch(nSortColumn)
\r
3431 case 0: // Revision
\r
3434 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
\r
3436 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
\r
3442 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
\r
3444 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
\r
3450 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
\r
3452 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
\r
3458 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
\r
3460 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
\r
3463 case 4: // Message or bug id
\r
3464 if (m_bShowBugtraqColumn)
\r
3467 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
\r
3469 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
\r
3472 // fall through here
\r
3473 case 5: // Message
\r
3476 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
\r
3478 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
\r
3488 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
\r
3490 if (m_bThreadRunning)
\r
3491 return; //no sorting while the arrays are filled
\r
3492 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
3493 const int nColumn = pNMLV->iSubItem;
\r
3494 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
\r
3495 m_nSortColumn = nColumn;
\r
3496 SortByColumn(m_nSortColumn, m_bAscending);
\r
3497 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
\r
3498 SortShownListArray();
\r
3499 m_LogList.Invalidate();
\r
3500 UpdateLogInfoLabel();
\r
3501 // the "next 100" button only makes sense if the log messages
\r
3502 // are sorted by revision in descending order
\r
3503 if ((m_nSortColumn)||(m_bAscending))
\r
3505 DialogEnableWindow(IDC_NEXTHUNDRED, false);
\r
3509 DialogEnableWindow(IDC_NEXTHUNDRED, true);
\r
3514 void CLogDlg::SortShownListArray()
\r
3516 // make sure the shown list still matches the filter after sorting.
\r
3517 OnTimer(LOGFILTER_TIMER);
\r
3518 // clear the selection states
\r
3519 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3522 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
\r
3524 m_LogList.SetSelectionMark(-1);
\r
3527 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
\r
3529 if (control == NULL)
\r
3531 // set the sort arrow
\r
3532 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
\r
3533 HDITEM HeaderItem = {0};
\r
3534 HeaderItem.mask = HDI_FORMAT;
\r
3535 for (int i=0; i<pHeader->GetItemCount(); ++i)
\r
3537 pHeader->GetItem(i, &HeaderItem);
\r
3538 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
\r
3539 pHeader->SetItem(i, &HeaderItem);
\r
3543 pHeader->GetItem(nColumn, &HeaderItem);
\r
3544 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
\r
3545 pHeader->SetItem(nColumn, &HeaderItem);
\r
3548 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)
\r
3550 if (m_bThreadRunning)
\r
3551 return; //no sorting while the arrays are filled
\r
3552 if (m_currentChangedArray == NULL)
\r
3554 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
3555 const int nColumn = pNMLV->iSubItem;
\r
3556 m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;
\r
3557 m_nSortColumnPathList = nColumn;
\r
3558 qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);
\r
3560 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
\r
3561 m_ChangedFileListCtrl.Invalidate();
\r
3565 int CLogDlg::m_nSortColumnPathList = 0;
\r
3566 bool CLogDlg::m_bAscendingPathList = false;
\r
3568 int CLogDlg::SortCompare(const void * pElem1, const void * pElem2)
\r
3571 LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);
\r
3572 LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);
\r
3574 if (m_bAscendingPathList)
\r
3575 std::swap (cpath1, cpath2);
\r
3578 switch (m_nSortColumnPathList)
\r
3581 cmp = cpath2->GetAction().Compare(cpath1->GetAction());
\r
3586 cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);
\r
3590 case 2: // copy from path
\r
3591 cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);
\r
3595 case 3: // copy from revision
\r
3596 return cpath2->lCopyFromRev > cpath1->lCopyFromRev;
\r
3602 void CLogDlg::ResizeAllListCtrlCols()
\r
3605 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
3606 int maxcol = ((CHeaderCtrl*)(m_LogList.GetDlgItem(0)))->GetItemCount()-1;
\r
3607 int nItemCount = m_LogList.GetItemCount();
\r
3608 TCHAR textbuf[MAX_PATH];
\r
3609 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(m_LogList.GetDlgItem(0));
\r
3612 for (int col = 0; col <= maxcol; col++)
\r
3615 hdi.mask = HDI_TEXT;
\r
3616 hdi.pszText = textbuf;
\r
3617 hdi.cchTextMax = sizeof(textbuf);
\r
3618 pHdrCtrl->GetItem(col, &hdi);
\r
3619 int cx = m_LogList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
3620 for (int index = 0; index<nItemCount; ++index)
\r
3622 // get the width of the string and add 14 pixels for the column separator and margins
\r
3623 int linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;
\r
3624 if (index < m_arShownList.GetCount())
\r
3626 PLOGENTRYDATA pCurLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));
\r
3627 if ((pCurLogEntry)&&(pCurLogEntry->Rev == m_wcRev))
\r
3629 // set the bold font and ask for the string width again
\r
3630 m_LogList.SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
3631 linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;
\r
3632 // restore the system font
\r
3633 m_LogList.SendMessage(WM_SETFONT, NULL, NULL);
\r
3638 // add the image size
\r
3639 CImageList * pImgList = m_LogList.GetImageList(LVSIL_SMALL);
\r
3640 if ((pImgList)&&(pImgList->GetImageCount()))
\r
3642 IMAGEINFO imginfo;
\r
3643 pImgList->GetImageInfo(0, &imginfo);
\r
3644 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
3645 linewidth += 3; // 3 pixels between icon and text
\r
3648 if (cx < linewidth)
\r
3651 // Adjust columns "Actions" containing icons
\r
3654 if (cx < nMinimumWidth)
\r
3656 cx = nMinimumWidth;
\r
3660 // keep the bug id column small
\r
3661 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
3663 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
3665 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
3669 m_LogList.SetColumnWidth(col, cx);
\r
3675 void CLogDlg::OnBnClickedHidepaths()
\r
3677 FillLogMessageCtrl();
\r
3678 m_ChangedFileListCtrl.Invalidate();
\r
3682 void CLogDlg::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
3684 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
3687 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
3689 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
3691 if (pFindInfo->lvfi.psz == 0)
\r
3694 CString sCmp = pFindInfo->lvfi.psz;
\r
3696 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
3698 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
3699 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
3700 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
3702 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
3710 if (sCmp.Compare(sRev)==0)
\r
3717 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
3719 for (int i=0; i<pFindInfo->iStart; ++i)
\r
3721 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
3722 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
3723 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
3725 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
3733 if (sCmp.Compare(sRev)==0)
\r
3745 void CLogDlg::OnBnClickedCheckStoponcopy()
\r
3748 if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
3751 // ignore old fetch limits when switching
\r
3752 // between copy-following and stop-on-copy
\r
3753 // (otherwise stop-on-copy will limit what
\r
3754 // we see immediately after switching to
\r
3755 // copy-following)
\r
3759 // now, restart the query
\r
3764 void CLogDlg::OnBnClickedIncludemerge()
\r
3774 void CLogDlg::UpdateLogInfoLabel()
\r
3777 git_revnum_t rev1 = 0;
\r
3778 git_revnum_t rev2 = 0;
\r
3779 long selectedrevs = 0;
\r
3780 if (m_arShownList.GetCount())
\r
3782 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(0));
\r
3783 rev1 = pLogEntry->Rev;
\r
3784 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));
\r
3785 rev2 = pLogEntry->Rev;
\r
3786 selectedrevs = m_LogList.GetSelectedCount();
\r
3789 sTemp.Format(IDS_LOG_LOGINFOSTRING, m_arShownList.GetCount(), rev2, rev1, selectedrevs);
\r
3790 m_sLogInfo = sTemp;
\r
3792 UpdateData(FALSE);
\r
3795 void CLogDlg::ShowContextMenuForRevisions(CWnd* /*pWnd*/, CPoint point)
\r
3798 int selIndex = m_LogList.GetSelectionMark();
\r
3800 return; // nothing selected, nothing to do with a context menu
\r
3802 // if the user selected the info text telling about not all revisions shown due to
\r
3803 // the "stop on copy/rename" option, we also don't show the context menu
\r
3804 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
3807 // if the context menu is invoked through the keyboard, we have to use
\r
3808 // a calculated position on where to anchor the menu on
\r
3809 if ((point.x == -1) && (point.y == -1))
\r
3812 m_LogList.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
3813 m_LogList.ClientToScreen(&rect);
\r
3814 point = rect.CenterPoint();
\r
3816 m_nSearchIndex = selIndex;
\r
3817 m_bCancelled = FALSE;
\r
3819 // calculate some information the context menu commands can use
\r
3820 CString pathURL = GetURLFromPath(m_path);
\r
3821 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3822 int indexNext = m_LogList.GetNextSelectedItem(pos);
\r
3823 if (indexNext < 0)
\r
3825 PLOGENTRYDATA pSelLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(indexNext));
\r
3826 GitRev revSelected = pSelLogEntry->Rev;
\r
3827 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
3828 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
3830 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
3832 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
3833 if (changedpath->lCopyFromRev)
\r
3834 revPrevious = changedpath->lCopyFromRev;
\r
3837 GitRev revSelected2;
\r
3840 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
3841 revSelected2 = pLogEntry->Rev;
\r
3843 bool bAllFromTheSameAuthor = true;
\r
3844 CString firstAuthor;
\r
3845 CLogDataVector selEntries;
\r
3846 GitRev revLowest, revHighest;
\r
3847 GitRevRangeArray revisionRanges;
\r
3849 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
3850 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
3851 revisionRanges.AddRevision(pLogEntry->Rev);
\r
3852 selEntries.push_back(pLogEntry);
\r
3853 firstAuthor = pLogEntry->sAuthor;
\r
3854 revLowest = pLogEntry->Rev;
\r
3855 revHighest = pLogEntry->Rev;
\r
3858 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
3859 revisionRanges.AddRevision(pLogEntry->Rev);
\r
3860 selEntries.push_back(pLogEntry);
\r
3861 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
3862 bAllFromTheSameAuthor = false;
\r
3863 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
3864 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
3870 //entry is selected, now show the popup menu
\r
3872 if (popup.CreatePopupMenu())
\r
3874 if (m_LogList.GetSelectedCount() == 1)
\r
3876 if (!m_path.IsDirectory())
\r
3880 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
3881 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
3883 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
3884 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
3885 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3886 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
3887 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
3888 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
3889 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
3890 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3896 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
3898 // TortoiseMerge could be improved to take a /blame switch
\r
3899 // and then not 'cat' the files from a unified diff but
\r
3901 // But until that's implemented, the context menu entry for
\r
3902 // this feature is commented out.
\r
3903 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
3905 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
3906 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
3907 popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
3908 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3910 if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
3912 popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
3914 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
3916 popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
3918 if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
3919 (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
3921 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3924 popup.AppendMenuIcon(ID_REPOBROWSE, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE);
\r
3925 popup.AppendMenuIcon(ID_COPY, IDS_LOG_POPUP_COPY);
\r
3927 popup.AppendMenuIcon(ID_UPDATE, IDS_LOG_POPUP_UPDATE, IDI_UPDATE);
\r
3929 popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
3931 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
3933 popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
3934 popup.AppendMenuIcon(ID_CHECKOUT, IDS_MENUCHECKOUT, IDI_CHECKOUT);
\r
3935 popup.AppendMenuIcon(ID_EXPORT, IDS_MENUEXPORT, IDI_EXPORT);
\r
3936 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3938 else if (m_LogList.GetSelectedCount() >= 2)
\r
3940 bool bAddSeparator = false;
\r
3941 if (IsSelectionContinuous() || (m_LogList.GetSelectedCount() == 2))
\r
3943 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
3945 if (m_LogList.GetSelectedCount() == 2)
\r
3947 popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
3948 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
3949 bAddSeparator = true;
\r
3953 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
3955 popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
3956 bAddSeparator = true;
\r
3958 if (bAddSeparator)
\r
3959 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3962 if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
3964 popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
3966 if (m_LogList.GetSelectedCount() == 1)
\r
3968 popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
3969 popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
3970 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
3972 if (m_LogList.GetSelectedCount() != 0)
\r
3974 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
3976 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
3978 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
3979 DialogEnableWindow(IDOK, FALSE);
\r
3980 SetPromptApp(&theApp);
\r
3981 theApp.DoWaitCursor(1);
\r
3982 bool bOpenWith = false;
\r
3987 if (PromptShown())
\r
3989 GitDiff diff(this, this->m_hWnd, true);
\r
3990 diff.SetHEADPeg(m_LogRevision);
\r
3991 diff.ShowUnifiedDiff(m_path, revPrevious, m_path, revSelected);
\r
3994 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revPrevious, m_path, revSelected, GitRev(), m_LogRevision);
\r
3999 if (PromptShown())
\r
4001 GitDiff diff(this, this->m_hWnd, true);
\r
4002 diff.SetHEADPeg(m_LogRevision);
\r
4003 diff.ShowUnifiedDiff(m_path, revSelected2, m_path, revSelected);
\r
4006 CAppUtils::StartShowUnifiedDiff(m_hWnd, m_path, revSelected2, m_path, revSelected, GitRev(), m_LogRevision);
\r
4009 case ID_REVERTREV:
\r
4011 // we need an URL to complete this command, so error out if we can't get an URL
\r
4012 if (pathURL.IsEmpty())
\r
4014 CString strMessage;
\r
4015 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4016 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4017 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4021 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
\r
4022 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
4024 CGitProgressDlg dlg;
\r
4025 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4026 dlg.SetPathList(CTGitPathList(m_path));
\r
4027 dlg.SetUrl(pathURL);
\r
4028 dlg.SetSecondUrl(pathURL);
\r
4029 revisionRanges.AdjustForMerge(true);
\r
4030 dlg.SetRevisionRanges(revisionRanges);
\r
4031 dlg.SetPegRevision(m_LogRevision);
\r
4038 // we need an URL to complete this command, so error out if we can't get an URL
\r
4039 if (pathURL.IsEmpty())
\r
4041 CString strMessage;
\r
4042 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4043 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4044 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4048 CString path = m_path.GetWinPathString();
\r
4049 bool bGotSavePath = false;
\r
4050 if ((m_LogList.GetSelectedCount() == 1)&&(!m_path.IsDirectory()))
\r
4052 bGotSavePath = CAppUtils::FileOpenSave(path, NULL, IDS_LOG_MERGETO, IDS_COMMONFILEFILTER, true, GetSafeHwnd());
\r
4056 CBrowseFolder folderBrowser;
\r
4057 folderBrowser.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_MERGETO)));
\r
4058 bGotSavePath = (folderBrowser.Show(GetSafeHwnd(), path, path) == CBrowseFolder::OK);
\r
4062 CGitProgressDlg dlg;
\r
4063 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4064 dlg.SetPathList(CTGitPathList(CTGitPath(path)));
\r
4065 dlg.SetUrl(pathURL);
\r
4066 dlg.SetSecondUrl(pathURL);
\r
4067 revisionRanges.AdjustForMerge(false);
\r
4068 dlg.SetRevisionRanges(revisionRanges);
\r
4069 dlg.SetPegRevision(m_LogRevision);
\r
4074 case ID_REVERTTOREV:
\r
4076 // we need an URL to complete this command, so error out if we can't get an URL
\r
4077 if (pathURL.IsEmpty())
\r
4079 CString strMessage;
\r
4080 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4081 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4082 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4087 msg.Format(IDS_LOG_REVERTTOREV_CONFIRM, m_path.GetWinPath());
\r
4088 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
4090 CGitProgressDlg dlg;
\r
4091 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4092 dlg.SetPathList(CTGitPathList(m_path));
\r
4093 dlg.SetUrl(pathURL);
\r
4094 dlg.SetSecondUrl(pathURL);
\r
4095 GitRevRangeArray revarray;
\r
4096 revarray.AddRevRange(GitRev::REV_HEAD, revSelected);
\r
4097 dlg.SetRevisionRanges(revarray);
\r
4098 dlg.SetPegRevision(m_LogRevision);
\r
4105 // we need an URL to complete this command, so error out if we can't get an URL
\r
4106 if (pathURL.IsEmpty())
\r
4108 CString strMessage;
\r
4109 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
4110 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
4111 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
4116 dlg.m_URL = pathURL;
\r
4117 dlg.m_path = m_path;
\r
4118 dlg.m_CopyRev = revSelected;
\r
4119 if (dlg.DoModal() == IDOK)
\r
4121 // should we show a progress dialog here? Copies are done really fast
\r
4122 // and without much network traffic.
\r
4123 if (!Copy(CTGitPathList(CTGitPath(pathURL)), CTGitPath(dlg.m_URL), dlg.m_CopyRev, dlg.m_CopyRev, dlg.m_sLogMessage))
\r
4124 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4126 CMessageBox::Show(this->m_hWnd, IDS_LOG_COPY_SUCCESS, IDS_APPNAME, MB_ICONINFORMATION);
\r
4132 //user clicked on the menu item "compare with working copy"
\r
4133 if (PromptShown())
\r
4135 GitDiff diff(this, m_hWnd, true);
\r
4136 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4137 diff.SetHEADPeg(m_LogRevision);
\r
4138 diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
\r
4141 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4144 case ID_COMPARETWO:
\r
4146 GitRev r1 = revSelected;
\r
4147 GitRev r2 = revSelected2;
\r
4148 if (m_LogList.GetSelectedCount() > 2)
\r
4153 //user clicked on the menu item "compare revisions"
\r
4154 if (PromptShown())
\r
4156 GitDiff diff(this, m_hWnd, true);
\r
4157 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4158 diff.SetHEADPeg(m_LogRevision);
\r
4159 diff.ShowCompare(CTGitPath(pathURL), r2, CTGitPath(pathURL), r1);
\r
4162 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), r2, CTGitPath(pathURL), r1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4165 case ID_COMPAREWITHPREVIOUS:
\r
4167 if (PromptShown())
\r
4169 GitDiff diff(this, m_hWnd, true);
\r
4170 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4171 diff.SetHEADPeg(m_LogRevision);
\r
4172 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
\r
4175 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
4178 case ID_BLAMECOMPARE:
\r
4180 //user clicked on the menu item "compare with working copy"
\r
4181 //now first get the revision which is selected
\r
4182 if (PromptShown())
\r
4184 GitDiff diff(this, this->m_hWnd, true);
\r
4185 diff.SetHEADPeg(m_LogRevision);
\r
4186 diff.ShowCompare(m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), false, true);
\r
4189 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), m_LogRevision, false, false, true);
\r
4194 //user clicked on the menu item "compare and blame revisions"
\r
4195 if (PromptShown())
\r
4197 GitDiff diff(this, this->m_hWnd, true);
\r
4198 diff.SetHEADPeg(m_LogRevision);
\r
4199 diff.ShowCompare(CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
4202 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
4205 case ID_BLAMEWITHPREVIOUS:
\r
4207 //user clicked on the menu item "Compare and Blame with previous revision"
\r
4208 if (PromptShown())
\r
4210 GitDiff diff(this, this->m_hWnd, true);
\r
4211 diff.SetHEADPeg(m_LogRevision);
\r
4212 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
4215 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
4220 //now first get the revision which is selected
\r
4221 CString revFilename;
\r
4224 CString strWinPath = m_path.GetWinPathString();
\r
4225 int rfind = strWinPath.ReverseFind('.');
\r
4227 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)strWinPath.Left(rfind), (LONG)revSelected, (LPCTSTR)strWinPath.Mid(rfind));
\r
4229 revFilename.Format(_T("%s-%ld"), (LPCTSTR)strWinPath, revSelected);
\r
4231 if (CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd))
\r
4233 CTGitPath tempfile;
\r
4234 tempfile.SetFromWin(revFilename);
\r
4235 CProgressDlg progDlg;
\r
4236 progDlg.SetTitle(IDS_APPNAME);
\r
4237 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
4238 CString sInfoLine;
\r
4239 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
4240 progDlg.SetLine(1, sInfoLine, true);
\r
4241 SetAndClearProgressInfo(&progDlg);
\r
4242 progDlg.ShowModeless(m_hWnd);
\r
4243 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
4245 // try again with another peg revision
\r
4246 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
4249 SetAndClearProgressInfo((HWND)NULL);
\r
4250 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4256 SetAndClearProgressInfo((HWND)NULL);
\r
4264 CProgressDlg progDlg;
\r
4265 progDlg.SetTitle(IDS_APPNAME);
\r
4266 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
4267 CString sInfoLine;
\r
4268 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
4269 progDlg.SetLine(1, sInfoLine, true);
\r
4270 SetAndClearProgressInfo(&progDlg);
\r
4271 progDlg.ShowModeless(m_hWnd);
\r
4272 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, m_path, revSelected);
\r
4273 bool bSuccess = true;
\r
4274 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
4277 // try again, but with the selected revision as the peg revision
\r
4278 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
4281 SetAndClearProgressInfo((HWND)NULL);
\r
4282 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4291 SetAndClearProgressInfo((HWND)NULL);
\r
4292 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
4295 ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
4296 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
4298 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
4299 cmd += tempfile.GetWinPathString() + _T(" ");
\r
4300 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
4308 dlg.EndRev = revSelected;
\r
4309 if (dlg.DoModal() == IDOK)
\r
4314 tempfile = blame.BlameToTempFile(m_path, dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
4315 if (!tempfile.IsEmpty())
\r
4317 if (dlg.m_bTextView)
\r
4319 //open the default text editor for the result file
\r
4320 CAppUtils::StartTextViewer(tempfile);
\r
4324 CString sParams = _T("/path:\"") + m_path.GetGitPathString() + _T("\" ");
\r
4325 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(m_path.GetFileOrDirectoryName()),sParams))
\r
4333 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4341 CString url = _T("tgit:")+pathURL;
\r
4342 sCmd.Format(_T("%s /command:update /path:\"%s\" /rev:%ld"),
\r
4343 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4344 (LPCTSTR)m_path.GetWinPath(), (LONG)revSelected);
\r
4345 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4348 case ID_FINDENTRY:
\r
4350 m_nSearchIndex = m_LogList.GetSelectionMark();
\r
4351 if (m_nSearchIndex < 0)
\r
4352 m_nSearchIndex = 0;
\r
4353 if (m_pFindDialog)
\r
4359 m_pFindDialog = new CFindReplaceDialog();
\r
4360 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
4364 case ID_REPOBROWSE:
\r
4367 sCmd.Format(_T("%s /command:repobrowser /path:\"%s\" /rev:%s"),
\r
4368 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4369 (LPCTSTR)pathURL, (LPCTSTR)revSelected.ToString());
\r
4371 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4376 EditLogMessage(selIndex);
\r
4379 case ID_EDITAUTHOR:
\r
4381 EditAuthor(selEntries);
\r
4386 CEditPropertiesDlg dlg;
\r
4387 dlg.SetProjectProperties(&m_ProjectProperties);
\r
4388 CTGitPathList escapedlist;
\r
4389 dlg.SetPathList(CTGitPathList(CTGitPath(pathURL)));
\r
4390 dlg.SetRevision(revSelected);
\r
4391 dlg.RevProps(true);
\r
4395 case ID_COPYCLIPBOARD:
\r
4397 CopySelectionToClipBoard();
\r
4403 sCmd.Format(_T("%s /command:export /path:\"%s\" /revision:%ld"),
\r
4404 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4405 (LPCTSTR)pathURL, (LONG)revSelected);
\r
4406 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4412 CString url = _T("tgit:")+pathURL;
\r
4413 sCmd.Format(_T("%s /command:checkout /url:\"%s\" /revision:%ld"),
\r
4414 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
4415 (LPCTSTR)url, (LONG)revSelected);
\r
4416 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4421 CString url = m_ProjectProperties.sWebViewerRev;
\r
4422 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
4423 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
4424 if (!url.IsEmpty())
\r
4425 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
4428 case ID_VIEWPATHREV:
\r
4430 CString relurl = pathURL;
\r
4431 CString sRoot = GetRepositoryRoot(CTGitPath(relurl));
\r
4432 relurl = relurl.Mid(sRoot.GetLength());
\r
4433 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
4434 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
4435 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
4436 url.Replace(_T("%PATH%"), relurl);
\r
4437 if (!url.IsEmpty())
\r
4438 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
4444 theApp.DoWaitCursor(-1);
\r
4446 } // if (popup.CreatePopupMenu())
\r
4450 void CLogDlg::ShowContextMenuForChangedpaths(CWnd* /*pWnd*/, CPoint point)
\r
4453 int selIndex = m_ChangedFileListCtrl.GetSelectionMark();
\r
4454 if ((point.x == -1) && (point.y == -1))
\r
4457 m_ChangedFileListCtrl.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
4458 m_ChangedFileListCtrl.ClientToScreen(&rect);
\r
4459 point = rect.CenterPoint();
\r
4463 int s = m_LogList.GetSelectionMark();
\r
4466 std::vector<CString> changedpaths;
\r
4467 std::vector<LogChangedPath*> changedlogpaths;
\r
4468 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
4470 return; // nothing is selected, get out of here
\r
4472 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
4473 git_revnum_t rev1 = pLogEntry->Rev;
\r
4474 git_revnum_t rev2 = rev1;
\r
4475 bool bOneRev = true;
\r
4480 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
4483 rev1 = max(rev1,(git_revnum_t)pLogEntry->Rev);
\r
4484 rev2 = min(rev2,(git_revnum_t)pLogEntry->Rev);
\r
4490 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
4493 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
4494 changedpaths.push_back(m_currentChangedPathList[nItem].GetGitPathString());
\r
4499 // only one revision is selected in the log dialog top pane
\r
4500 // but multiple items could be selected in the changed items list
\r
4503 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
\r
4506 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
\r
4507 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);
\r
4509 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
4511 if ((changedlogpath)&&(!changedlogpath->sCopyFromPath.IsEmpty()))
\r
4512 rev2 = changedlogpath->lCopyFromRev;
\r
4515 // if the path was modified but the parent path was 'added with history'
\r
4516 // then we have to use the copy from revision of the parent path
\r
4517 CTGitPath cpath = CTGitPath(changedlogpath->sPath);
\r
4518 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)
\r
4520 CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);
\r
4521 if (p.IsAncestorOf(cpath))
\r
4523 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())
\r
4524 rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;
\r
4529 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
\r
4531 // some items are hidden! So find out which item the user really clicked on
\r
4532 INT_PTR selRealIndex = -1;
\r
4533 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
\r
4535 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
4537 if (selRealIndex == nItem)
\r
4539 selIndex = hiddenindex;
\r
4540 changedlogpath = pLogEntry->pArChangedPaths->GetAt(selIndex);
\r
4545 if (changedlogpath)
\r
4547 changedpaths.push_back(changedlogpath->sPath);
\r
4548 changedlogpaths.push_back(changedlogpath);
\r
4553 //entry is selected, now show the popup menu
\r
4555 if (popup.CreatePopupMenu())
\r
4557 bool bEntryAdded = false;
\r
4558 if (m_ChangedFileListCtrl.GetSelectedCount() == 1)
\r
4560 if ((!bOneRev)||(IsDiffPossible(changedlogpaths[0], rev1)))
\r
4562 popup.AppendMenuIcon(ID_DIFF, IDS_LOG_POPUP_DIFF, IDI_DIFF);
\r
4563 popup.AppendMenuIcon(ID_BLAMEDIFF, IDS_LOG_POPUP_BLAMEDIFF, IDI_BLAME);
\r
4564 popup.SetDefaultItem(ID_DIFF, FALSE);
\r
4565 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
4566 bEntryAdded = true;
\r
4568 if (rev2 == rev1-1)
\r
4571 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4572 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
4573 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
4574 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
4575 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4577 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
4578 popup.AppendMenuIcon(ID_POPPROPS, IDS_REPOBROWSE_SHOWPROP, IDI_PROPERTIES); // "Show Properties"
\r
4579 popup.AppendMenuIcon(ID_LOG, IDS_MENULOG, IDI_LOG); // "Show Log"
\r
4580 popup.AppendMenuIcon(ID_GETMERGELOGS, IDS_LOG_POPUP_GETMERGELOGS, IDI_LOG); // "Show merge log"
\r
4581 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
4582 bEntryAdded = true;
\r
4583 if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
4585 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
4586 popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
4588 if (popup.GetDefaultItem(0,FALSE)==-1)
\r
4589 popup.SetDefaultItem(ID_OPEN, FALSE);
\r
4592 else if (changedlogpaths.size())
\r
4594 // more than one entry is selected
\r
4595 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE);
\r
4596 bEntryAdded = true;
\r
4601 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
4602 bool bOpenWith = false;
\r
4603 bool bMergeLog = false;
\r
4604 m_bCancelled = false;
\r
4609 DoDiffFromLog(selIndex, rev1, rev2, false, false);
\r
4612 case ID_BLAMEDIFF:
\r
4614 DoDiffFromLog(selIndex, rev1, rev2, true, false);
\r
4619 DoDiffFromLog(selIndex, rev1, rev2, false, true);
\r
4622 case ID_REVERTREV:
\r
4624 SetPromptApp(&theApp);
\r
4625 theApp.DoWaitCursor(1);
\r
4627 if (Git::PathIsURL(m_path))
\r
4629 sUrl = m_path.GetGitPathString();
\r
4633 sUrl = GetURLFromPath(m_path);
\r
4634 if (sUrl.IsEmpty())
\r
4636 theApp.DoWaitCursor(-1);
\r
4638 temp.Format(IDS_ERR_NOURLOFFILE, m_path.GetWinPath());
\r
4639 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4641 theApp.DoWaitCursor(-1);
\r
4645 // find the working copy path of the selected item from the URL
\r
4646 m_bCancelled = false;
\r
4647 CString sUrlRoot = GetRepositoryRoot(CTGitPath(sUrl));
\r
4649 CString fileURL = changedpaths[0];
\r
4650 fileURL = sUrlRoot + fileURL.Trim();
\r
4651 // firstfile = (e.g.) http://mydomain.com/repos/trunk/folder/file1
\r
4652 // sUrl = http://mydomain.com/repos/trunk/folder
\r
4653 CString sUnescapedUrl = CPathUtils::PathUnescape(sUrl);
\r
4654 // find out until which char the urls are identical
\r
4656 while ((i<fileURL.GetLength())&&(i<sUnescapedUrl.GetLength())&&(fileURL[i]==sUnescapedUrl[i]))
\r
4658 int leftcount = m_path.GetWinPathString().GetLength()-(sUnescapedUrl.GetLength()-i);
\r
4659 CString wcPath = m_path.GetWinPathString().Left(leftcount);
\r
4660 wcPath += fileURL.Mid(i);
\r
4661 wcPath.Replace('/', '\\');
\r
4662 CGitProgressDlg dlg;
\r
4663 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
4665 // a deleted path! Since the path isn't there anymore, merge
\r
4666 // won't work. So just do a copy url->wc
\r
4667 dlg.SetCommand(CGitProgressDlg::GitProgress_Copy);
\r
4668 dlg.SetPathList(CTGitPathList(CTGitPath(fileURL)));
\r
4669 dlg.SetUrl(wcPath);
\r
4670 dlg.SetRevision(rev2);
\r
4674 if (!PathFileExists(wcPath))
\r
4676 // seems the path got renamed
\r
4677 // tell the user how to work around this.
\r
4678 CMessageBox::Show(this->m_hWnd, IDS_LOG_REVERTREV_ERROR, IDS_APPNAME, MB_ICONERROR);
\r
4680 theApp.DoWaitCursor(-1);
\r
4683 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
4684 dlg.SetPathList(CTGitPathList(CTGitPath(wcPath)));
\r
4685 dlg.SetUrl(fileURL);
\r
4686 dlg.SetSecondUrl(fileURL);
\r
4687 GitRevRangeArray revarray;
\r
4688 revarray.AddRevRange(rev1, rev2);
\r
4689 dlg.SetRevisionRanges(revarray);
\r
4692 msg.Format(IDS_LOG_REVERT_CONFIRM, (LPCTSTR)wcPath);
\r
4693 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
4697 theApp.DoWaitCursor(-1);
\r
4702 DialogEnableWindow(IDOK, FALSE);
\r
4703 SetPromptApp(&theApp);
\r
4704 theApp.DoWaitCursor(1);
\r
4706 if (Git::PathIsURL(m_path))
\r
4708 filepath = m_path.GetGitPathString();
\r
4712 filepath = GetURLFromPath(m_path);
\r
4713 if (filepath.IsEmpty())
\r
4715 theApp.DoWaitCursor(-1);
\r
4717 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
4718 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4719 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
4724 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
4725 filepath += changedpaths[0];
\r
4728 dlg.m_Path = CTGitPath(filepath);
\r
4731 theApp.DoWaitCursor(-1);
\r
4736 DialogEnableWindow(IDOK, FALSE);
\r
4737 SetPromptApp(&theApp);
\r
4738 theApp.DoWaitCursor(1);
\r
4740 if (Git::PathIsURL(m_path))
\r
4742 filepath = m_path.GetGitPathString();
\r
4746 filepath = GetURLFromPath(m_path);
\r
4747 if (filepath.IsEmpty())
\r
4749 theApp.DoWaitCursor(-1);
\r
4751 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
4752 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4753 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
4758 m_bCancelled = false;
\r
4759 CString sRoot = GetRepositoryRoot(CTGitPath(filepath));
\r
4760 // if more than one entry is selected, we save them
\r
4761 // one by one into a folder the user has selected
\r
4762 bool bTargetSelected = false;
\r
4763 CTGitPath TargetPath;
\r
4764 if (m_ChangedFileListCtrl.GetSelectedCount() > 1)
\r
4766 CBrowseFolder browseFolder;
\r
4767 browseFolder.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_SAVEFOLDERTOHINT)));
\r
4768 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
\r
4769 CString strSaveAsDirectory;
\r
4770 if (browseFolder.Show(GetSafeHwnd(), strSaveAsDirectory) == CBrowseFolder::OK)
\r
4772 TargetPath = CTGitPath(strSaveAsDirectory);
\r
4773 bTargetSelected = true;
\r
4778 // Display the Open dialog box.
\r
4779 CString revFilename;
\r
4781 temp = CPathUtils::GetFileNameFromPath(changedpaths[0]);
\r
4782 int rfind = temp.ReverseFind('.');
\r
4784 revFilename.Format(_T("%s-%ld%s"), (LPCTSTR)temp.Left(rfind), rev1, (LPCTSTR)temp.Mid(rfind));
\r
4786 revFilename.Format(_T("%s-%ld"), (LPCTSTR)temp, rev1);
\r
4787 bTargetSelected = CAppUtils::FileOpenSave(revFilename, NULL, IDS_LOG_POPUP_SAVE, IDS_COMMONFILEFILTER, false, m_hWnd);
\r
4788 TargetPath.SetFromWin(revFilename);
\r
4790 if (bTargetSelected)
\r
4792 CProgressDlg progDlg;
\r
4793 progDlg.SetTitle(IDS_APPNAME);
\r
4794 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
4795 for (std::vector<LogChangedPath*>::iterator it = changedlogpaths.begin(); it!= changedlogpaths.end(); ++it)
\r
4797 GitRev getrev = ((*it)->action == LOGACTIONS_DELETED) ? rev2 : rev1;
\r
4799 CString sInfoLine;
\r
4800 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)getrev.ToString());
\r
4801 progDlg.SetLine(1, sInfoLine, true);
\r
4802 SetAndClearProgressInfo(&progDlg);
\r
4803 progDlg.ShowModeless(m_hWnd);
\r
4805 CTGitPath tempfile = TargetPath;
\r
4806 if (changedpaths.size() > 1)
\r
4808 // if multiple items are selected, then the TargetPath
\r
4809 // points to a folder and we have to append the filename
\r
4810 // to save to to that folder.
\r
4811 CString sName = (*it)->sPath;
\r
4812 int slashpos = sName.ReverseFind('/');
\r
4813 if (slashpos >= 0)
\r
4814 sName = sName.Mid(slashpos);
\r
4815 tempfile.AppendPathString(sName);
\r
4816 // one problem here:
\r
4817 // a user could have selected multiple items which
\r
4818 // have the same filename but reside in different
\r
4819 // directories, e.g.
\r
4822 // in that case, the second 'file1' will overwrite
\r
4823 // the already saved 'file1'.
\r
4825 // we could maybe find the common root of all selected
\r
4826 // items and then create sub folders to save those files
\r
4828 // But I think we should just leave it that way: to check
\r
4829 // out multiple items at once, the better way is still to
\r
4830 // use the export command from the top pane of the log dialog.
\r
4832 filepath = sRoot + (*it)->sPath;
\r
4833 if (!Cat(CTGitPath(filepath), getrev, getrev, tempfile))
\r
4836 SetAndClearProgressInfo((HWND)NULL);
\r
4837 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4839 theApp.DoWaitCursor(-1);
\r
4844 SetAndClearProgressInfo((HWND)NULL);
\r
4847 theApp.DoWaitCursor(-1);
\r
4854 GitRev getrev = pLogEntry->pArChangedPaths->GetAt(selIndex)->action == LOGACTIONS_DELETED ? rev2 : rev1;
\r
4855 Open(bOpenWith,changedpaths[0],getrev);
\r
4861 if (Git::PathIsURL(m_path))
\r
4863 filepath = m_path.GetGitPathString();
\r
4867 filepath = GetURLFromPath(m_path);
\r
4868 if (filepath.IsEmpty())
\r
4870 theApp.DoWaitCursor(-1);
\r
4872 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
4873 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4874 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
4879 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
4880 filepath += changedpaths[0];
\r
4882 dlg.EndRev = rev1;
\r
4883 if (dlg.DoModal() == IDOK)
\r
4888 tempfile = blame.BlameToTempFile(CTGitPath(filepath), dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
4889 if (!tempfile.IsEmpty())
\r
4891 if (dlg.m_bTextView)
\r
4893 //open the default text editor for the result file
\r
4894 CAppUtils::StartTextViewer(tempfile);
\r
4898 CString sParams = _T("/path:\"") + filepath + _T("\" ");
\r
4899 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(filepath),sParams))
\r
4907 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
4912 case ID_GETMERGELOGS:
\r
4917 DialogEnableWindow(IDOK, FALSE);
\r
4918 SetPromptApp(&theApp);
\r
4919 theApp.DoWaitCursor(1);
\r
4921 if (Git::PathIsURL(m_path))
\r
4923 filepath = m_path.GetGitPathString();
\r
4927 filepath = GetURLFromPath(m_path);
\r
4928 if (filepath.IsEmpty())
\r
4930 theApp.DoWaitCursor(-1);
\r
4932 temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);
\r
4933 CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
4934 TRACE(_T("could not retrieve the URL of the file!\n"));
\r
4939 m_bCancelled = false;
\r
4940 filepath = GetRepositoryRoot(CTGitPath(filepath));
\r
4941 filepath += changedpaths[0];
\r
4942 git_revnum_t logrev = rev1;
\r
4943 if (changedlogpaths[0]->action == LOGACTIONS_DELETED)
\r
4945 // if the item got deleted in this revision,
\r
4946 // fetch the log from the previous revision where it
\r
4951 sCmd.Format(_T("\"%s\" /command:log /path:\"%s\" /startrev:%ld"), (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR)filepath, logrev);
\r
4953 sCmd += _T(" /merge");
\r
4954 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
4956 theApp.DoWaitCursor(-1);
\r
4959 case ID_VIEWPATHREV:
\r
4961 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetSelectionMark()));
\r
4962 GitRev rev = pLogEntry->Rev;
\r
4963 CString relurl = changedpaths[0];
\r
4964 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
4965 url.Replace(_T("%REVISION%"), rev.ToString());
\r
4966 url.Replace(_T("%PATH%"), relurl);
\r
4967 relurl = relurl.Mid(relurl.Find('/'));
\r
4968 url.Replace(_T("%PATH1%"), relurl);
\r
4969 if (!url.IsEmpty())
\r
4970 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
4976 } // if (popup.CreatePopupMenu())
\r
4980 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
4982 // the date control should not show the "today" button
\r
4983 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
\r
4985 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
4989 void CLogDlg::OnDtnDropdownDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
4991 // the date control should not show the "today" button
\r
4992 CMonthCalCtrl * pCtrl = m_DateTo.GetMonthCalCtrl();
\r
4994 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
\r
4998 void CLogDlg::OnSize(UINT nType, int cx, int cy)
\r
5000 __super::OnSize(nType, cx, cy);
\r
5002 SetSplitterRange();
\r
5005 void CLogDlg::OnRefresh()
\r
5007 if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())
\r
5014 void CLogDlg::OnFind()
\r
5016 if (!m_pFindDialog)
\r
5018 m_pFindDialog = new CFindReplaceDialog();
\r
5019 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
5023 void CLogDlg::OnFocusFilter()
\r
5025 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
\r
5028 void CLogDlg::OnEditCopy()
\r
5030 if (GetFocus() == &m_ChangedFileListCtrl)
\r
5031 CopyChangedSelectionToClipBoard();
\r
5033 CopySelectionToClipBoard();
\r
5036 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
\r
5038 // is the URL a relative one?
\r
5039 if (url.Left(2).Compare(_T("^/")) == 0)
\r
5041 // URL is relative to the repository root
\r
5042 CString url1 = m_sRepositoryRoot + url.Mid(1);
\r
5043 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
5044 DWORD len = url.GetLength();
\r
5045 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
\r
5046 return CString(buf, len);
\r
5049 else if (url[0] == '/')
\r
5051 // URL is relative to the server's hostname
\r
5053 // find the server's hostname
\r
5054 int schemepos = m_sRepositoryRoot.Find(_T("//"));
\r
5055 if (schemepos >= 0)
\r
5057 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
\r
5058 CString url1 = sHost + url;
\r
5059 TCHAR buf[INTERNET_MAX_URL_LENGTH];
\r
5060 DWORD len = url.GetLength();
\r
5061 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
\r
5062 return CString(buf, len);
\r
5070 int CLogDataVector::ParserFromLog()
\r
5074 g_Git.GetLog(log);
\r
5077 begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
\r
5079 if(log.GetLength()==0)
\r
5087 next=log.Find(begin,start);
\r
5089 length = next - start+4;
\r
5091 length = log.GetLength()-start+4;
\r
5093 CString onelog =log;
\r
5094 onelog=log.Mid(start -4,length);
\r
5095 rev.ParserFromLog(onelog);
\r
5096 this->push_back(rev);
\r