OSDN Git Service

Use new method to update log So the user don't wait for log full log
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / LogDlg.cpp
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseGit\r
4 \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
9 \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
14 \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
18 //\r
19 #include "stdafx.h"\r
20 #include "TortoiseProc.h"\r
21 #include "cursor.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
29 #include "Logdlg.h"\r
30 #include "MessageBox.h"\r
31 #include "Registry.h"\r
32 #include "AppUtils.h"\r
33 #include "PathUtils.h"\r
34 #include "StringUtils.h"\r
35 #include "UnicodeUtils.h"\r
36 #include "TempFile.h"\r
37 //#include "GitInfo.h"\r
38 //#include "GitDiff.h"\r
39 #include "IconMenu.h"\r
40 //#include "RevisionRangeDlg.h"\r
41 //#include "BrowseFolder.h"\r
42 //#include "BlameDlg.h"\r
43 //#include "Blame.h"\r
44 //#include "GitHelpers.h"\r
45 #include "GitStatus.h"\r
46 //#include "LogDlgHelper.h"\r
47 //#include "CachedLogInfo.h"\r
48 //#include "RepositoryInfo.h"\r
49 //#include "EditPropertiesDlg.h"\r
50 #include "FileDiffDlg.h"\r
51 \r
52 \r
53 const UINT CLogDlg::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING);\r
54 \r
55 \r
56 \r
57 \r
58 IMPLEMENT_DYNAMIC(CLogDlg, CResizableStandAloneDialog)\r
59 CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)\r
60         : CResizableStandAloneDialog(CLogDlg::IDD, pParent)\r
61         , m_logcounter(0)\r
62         , m_nSearchIndex(0)\r
63         , m_wParam(0)\r
64         , m_nSelectedFilter(LOGFILTER_ALL)\r
65         , m_currentChangedArray(NULL)\r
66         , m_nSortColumn(0)\r
67         , m_bShowedAll(false)\r
68         , m_bSelect(false)\r
69         , m_regLastStrict(_T("Software\\TortoiseGit\\LastLogStrict"), FALSE)\r
70         \r
71         , m_bSelectionMustBeContinuous(false)\r
72         , m_bShowBugtraqColumn(false)\r
73         , m_lowestRev(_T(""))\r
74         \r
75         , m_sLogInfo(_T(""))\r
76         , m_pFindDialog(NULL)\r
77         , m_bCancelled(FALSE)\r
78         , m_pNotifyWindow(NULL)\r
79         \r
80         , m_bAscending(FALSE)\r
81 \r
82         , m_limit(0)\r
83         , m_childCounter(0)\r
84         , m_maxChild(0)\r
85         , m_bIncludeMerges(FALSE)\r
86         , m_hAccel(NULL)\r
87         , m_bVista(false)\r
88 {\r
89         m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);\r
90         \r
91 }\r
92 \r
93 CLogDlg::~CLogDlg()\r
94 {\r
95         \r
96     m_CurrentFilteredChangedArray.RemoveAll();\r
97         \r
98 \r
99 \r
100         \r
101 }\r
102 \r
103 void CLogDlg::DoDataExchange(CDataExchange* pDX)\r
104 {\r
105         CResizableStandAloneDialog::DoDataExchange(pDX);\r
106         DDX_Control(pDX, IDC_LOGLIST, m_LogList);\r
107         DDX_Control(pDX, IDC_LOGMSG, m_ChangedFileListCtrl);\r
108         DDX_Control(pDX, IDC_PROGRESS, m_LogProgress);\r
109         DDX_Control(pDX, IDC_SPLITTERTOP, m_wndSplitter1);\r
110         DDX_Control(pDX, IDC_SPLITTERBOTTOM, m_wndSplitter2);\r
111         DDX_Check(pDX, IDC_CHECK_STOPONCOPY, m_bStrict);\r
112         DDX_Text(pDX, IDC_SEARCHEDIT, m_sFilterText);\r
113         DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);\r
114         DDX_Control(pDX, IDC_DATETO, m_DateTo);\r
115         DDX_Control(pDX, IDC_HIDEPATHS, m_cHidePaths);\r
116         DDX_Control(pDX, IDC_GETALL, m_btnShow);\r
117         DDX_Text(pDX, IDC_LOGINFO, m_sLogInfo);\r
118         DDX_Check(pDX, IDC_INCLUDEMERGE, m_bIncludeMerges);\r
119         DDX_Control(pDX, IDC_SEARCHEDIT, m_cFilter);\r
120 }\r
121 \r
122 BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)\r
123         ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage) \r
124         ON_BN_CLICKED(IDC_GETALL, OnBnClickedGetall)\r
125         ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)\r
126         ON_WM_CONTEXTMENU()\r
127         ON_WM_SETCURSOR()\r
128         ON_BN_CLICKED(IDHELP, OnBnClickedHelp)\r
129         ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGLIST, OnLvnItemchangedLoglist)\r
130         ON_NOTIFY(EN_LINK, IDC_MSGVIEW, OnEnLinkMsgview)\r
131         ON_BN_CLICKED(IDC_STATBUTTON, OnBnClickedStatbutton)\r
132         \r
133         ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)\r
134         ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)\r
135         \r
136         ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)\r
137         ON_WM_TIMER()\r
138         ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)\r
139         ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)\r
140         ON_BN_CLICKED(IDC_NEXTHUNDRED, OnBnClickedNexthundred)\r
141         ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)\r
142         ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)\r
143         ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST   , OnLvnColumnclick)\r
144         ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)\r
145         ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)\r
146         \r
147         ON_BN_CLICKED(IDC_CHECK_STOPONCOPY, &CLogDlg::OnBnClickedCheckStoponcopy)\r
148         ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)\r
149         ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)\r
150         ON_WM_SIZE()\r
151         ON_BN_CLICKED(IDC_INCLUDEMERGE, &CLogDlg::OnBnClickedIncludemerge)\r
152         ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)\r
153         ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)\r
154         ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)\r
155         ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)\r
156         ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)\r
157 END_MESSAGE_MAP()\r
158 \r
159 void CLogDlg::SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit, BOOL bStrict /* = FALSE */, BOOL bSaveStrict /* = TRUE */)\r
160 {\r
161         m_path = path;\r
162         m_pegrev = pegrev;\r
163         m_startrev = startrev;\r
164         m_LogRevision = startrev;\r
165         m_endrev = endrev;\r
166         m_hasWC = !path.IsUrl();\r
167         m_bStrict = bStrict;\r
168         m_bSaveStrict = bSaveStrict;\r
169         m_limit = limit;\r
170         if (::IsWindow(m_hWnd))\r
171                 UpdateData(FALSE);\r
172 }\r
173 \r
174 BOOL CLogDlg::OnInitDialog()\r
175 {\r
176         CResizableStandAloneDialog::OnInitDialog();\r
177 \r
178         m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));\r
179 \r
180         OSVERSIONINFOEX inf;\r
181         SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));\r
182         inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);\r
183         GetVersionEx((OSVERSIONINFO *)&inf);\r
184         WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);\r
185         m_bVista = (fullver >= 0x0600);\r
186 \r
187         // use the state of the "stop on copy/rename" option from the last time\r
188         if (!m_bStrict)\r
189                 m_bStrict = m_regLastStrict;\r
190         UpdateData(FALSE);\r
191         CString temp;\r
192         if (m_limit)\r
193                 temp.Format(IDS_LOG_SHOWNEXT, m_limit);\r
194         else\r
195                 temp.Format(IDS_LOG_SHOWNEXT, (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100));\r
196 \r
197         SetDlgItemText(IDC_NEXTHUNDRED, temp);\r
198 \r
199         // set the font to use in the log message view, configured in the settings dialog\r
200         CAppUtils::CreateFontForLogs(m_logFont);\r
201         GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);\r
202         // automatically detect URLs in the log message and turn them into links\r
203         GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);\r
204         // make the log message rich edit control send a message when the mouse pointer is over a link\r
205         GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);\r
206         //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);\r
207 \r
208         // the "hide unrelated paths" checkbox should be indeterminate\r
209         m_cHidePaths.SetCheck(BST_INDETERMINATE);\r
210 \r
211         \r
212         // if there is a working copy, load the project properties\r
213         // to get information about the bugtraq: integration\r
214         if (m_hasWC)\r
215                 m_ProjectProperties.ReadProps(m_path);\r
216 \r
217         // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set\r
218         if ((!m_ProjectProperties.sUrl.IsEmpty())||(!m_ProjectProperties.sCheckRe.IsEmpty()))\r
219                 m_bShowBugtraqColumn = true;\r
220 \r
221         //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);\r
222         theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);\r
223 \r
224         // set up the columns\r
225         m_LogList.DeleteAllItems();\r
226         m_LogList.InsertGitColumn();\r
227 \r
228         m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );\r
229         m_ChangedFileListCtrl.DeleteAllItems();\r
230         int c = ((CHeaderCtrl*)(m_ChangedFileListCtrl.GetDlgItem(0)))->GetItemCount()-1;\r
231         while (c>=0)\r
232                 m_ChangedFileListCtrl.DeleteColumn(c--);\r
233         temp.LoadString(IDS_PROGRS_ACTION);\r
234         m_ChangedFileListCtrl.InsertColumn(this->FILELIST_ACTION, temp);\r
235         temp.LoadString(IDS_LOG_FILE_LINE_ADD);\r
236         m_ChangedFileListCtrl.InsertColumn(this->FILELIST_ADD, temp);\r
237         temp.LoadString(IDS_LOG_FILE_LINE_DEL);\r
238         m_ChangedFileListCtrl.InsertColumn(this->FILELIST_DEL, temp);\r
239         temp.LoadString(IDS_PROGRS_PATH);\r
240         m_ChangedFileListCtrl.InsertColumn(this->FILELIST_PATH, temp);\r
241         \r
242         m_ChangedFileListCtrl.SetRedraw(false);\r
243         CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);\r
244         m_ChangedFileListCtrl.SetRedraw(true);\r
245 \r
246 \r
247         GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);\r
248 \r
249         m_logcounter = 0;\r
250         m_sMessageBuf.Preallocate(100000);\r
251 \r
252         // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"\r
253         SetDlgTitle(false);\r
254 \r
255         m_tooltips.Create(this);\r
256         CheckRegexpTooltip();\r
257 \r
258         SetSplitterRange();\r
259         \r
260         // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap\r
261         m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);\r
262         m_cFilter.SetInfoIcon(IDI_LOGFILTER);\r
263         m_cFilter.SetValidator(this);\r
264         \r
265         AdjustControlSize(IDC_HIDEPATHS);\r
266         AdjustControlSize(IDC_CHECK_STOPONCOPY);\r
267         AdjustControlSize(IDC_INCLUDEMERGE);\r
268 \r
269         GetClientRect(m_DlgOrigRect);\r
270         m_LogList.GetClientRect(m_LogListOrigRect);\r
271         GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);\r
272         m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);\r
273 \r
274         m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);\r
275         m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);\r
276 \r
277         // resizable stuff\r
278         AddAnchor(IDC_FROMLABEL, TOP_LEFT);\r
279         AddAnchor(IDC_DATEFROM, TOP_LEFT);\r
280         AddAnchor(IDC_TOLABEL, TOP_LEFT);\r
281         AddAnchor(IDC_DATETO, TOP_LEFT);\r
282 \r
283         SetFilterCueText();\r
284         AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);\r
285         \r
286         AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);\r
287         AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);\r
288         AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);\r
289         AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);\r
290         AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);\r
291 \r
292         AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);      \r
293         AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);  \r
294         AddAnchor(IDC_CHECK_STOPONCOPY, BOTTOM_LEFT);\r
295         AddAnchor(IDC_INCLUDEMERGE, BOTTOM_LEFT);\r
296         AddAnchor(IDC_GETALL, BOTTOM_LEFT);\r
297         AddAnchor(IDC_NEXTHUNDRED, BOTTOM_LEFT);\r
298         AddAnchor(IDC_REFRESH, BOTTOM_LEFT);\r
299         AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);\r
300         AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);\r
301         AddAnchor(IDOK, BOTTOM_RIGHT);\r
302         AddAnchor(IDCANCEL, BOTTOM_RIGHT);\r
303         AddAnchor(IDHELP, BOTTOM_RIGHT);\r
304 \r
305 //      SetPromptParentWindow(m_hWnd);\r
306 \r
307         if (hWndExplorer)\r
308                 CenterWindow(CWnd::FromHandle(hWndExplorer));\r
309         EnableSaveRestore(_T("LogDlg"));\r
310 \r
311         DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));\r
312         DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));\r
313         RECT rcDlg, rcLogList, rcChgMsg;\r
314         GetClientRect(&rcDlg);\r
315         m_LogList.GetWindowRect(&rcLogList);\r
316         ScreenToClient(&rcLogList);\r
317         m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);\r
318         ScreenToClient(&rcChgMsg);\r
319         if (yPos1)\r
320         {\r
321                 RECT rectSplitter;\r
322                 m_wndSplitter1.GetWindowRect(&rectSplitter);\r
323                 ScreenToClient(&rectSplitter);\r
324                 int delta = yPos1 - rectSplitter.top;\r
325 \r
326                 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))\r
327                 {\r
328                         m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);\r
329                         DoSizeV1(delta);\r
330                 }\r
331         }\r
332         if (yPos2)\r
333         {\r
334                 RECT rectSplitter;\r
335                 m_wndSplitter2.GetWindowRect(&rectSplitter);\r
336                 ScreenToClient(&rectSplitter);\r
337                 int delta = yPos2 - rectSplitter.top;\r
338 \r
339                 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))\r
340                 {\r
341                         m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);\r
342                         DoSizeV2(delta);\r
343                 }\r
344         }\r
345 \r
346         \r
347         if (m_bSelect)\r
348         {\r
349                 // the dialog is used to select revisions\r
350                 if (m_bSelectionMustBeContinuous)\r
351                         DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));\r
352                 else\r
353                         DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);\r
354         }\r
355         else\r
356         {\r
357                 // the dialog is used to just view log messages\r
358                 GetDlgItemText(IDOK, temp);\r
359                 SetDlgItemText(IDCANCEL, temp);\r
360                 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);\r
361         }\r
362         \r
363         // set the choices for the "Show All" button\r
364         temp.LoadString(IDS_LOG_SHOWALL);\r
365         m_btnShow.AddEntry(temp);\r
366         temp.LoadString(IDS_LOG_SHOWRANGE);\r
367         m_btnShow.AddEntry(temp);\r
368         m_btnShow.SetCurrentEntry((LONG)CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry")));\r
369 \r
370         m_mergedRevs.clear();\r
371 \r
372         // first start a thread to obtain the log messages without\r
373         // blocking the dialog\r
374         m_tTo = 0;\r
375         m_tFrom = (DWORD)-1;\r
376 \r
377         m_LogList.FetchLogAsync(LogCallBack,this);\r
378 \r
379         GetDlgItem(IDC_LOGLIST)->SetFocus();\r
380         return FALSE;\r
381 }\r
382 \r
383 void CLogDlg::LogRunStatus(int cur)\r
384 {\r
385         if( cur == GITLOG_START )\r
386         {\r
387                 CString temp;\r
388                 temp.LoadString(IDS_PROGRESSWAIT);\r
389 \r
390                 // change the text of the close button to "Cancel" since now the thread\r
391                 // is running, and simply closing the dialog doesn't work.\r
392                 if (!GetDlgItem(IDOK)->IsWindowVisible())\r
393                 {\r
394                         temp.LoadString(IDS_MSGBOX_CANCEL);\r
395                         SetDlgItemText(IDCANCEL, temp);\r
396                 }\r
397 \r
398                 // We use a progress bar while getting the logs \r
399                 m_LogProgress.SetRange32(0, 100);\r
400                 m_LogProgress.SetPos(0);\r
401 \r
402                 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);\r
403 \r
404                 DialogEnableWindow(IDC_GETALL, FALSE);\r
405                 DialogEnableWindow(IDC_NEXTHUNDRED, FALSE);\r
406                 DialogEnableWindow(IDC_CHECK_STOPONCOPY, FALSE);\r
407                 DialogEnableWindow(IDC_INCLUDEMERGE, FALSE);\r
408                 DialogEnableWindow(IDC_STATBUTTON, FALSE);\r
409                 DialogEnableWindow(IDC_REFRESH, FALSE);\r
410         }\r
411 \r
412         if( cur == GITLOG_END)\r
413         {\r
414                 \r
415                 if (!m_bShowedAll)\r
416                         DialogEnableWindow(IDC_NEXTHUNDRED, TRUE);\r
417 \r
418                 DialogEnableWindow(IDC_CHECK_STOPONCOPY, TRUE);\r
419                 DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);\r
420                 DialogEnableWindow(IDC_STATBUTTON, TRUE);\r
421                 DialogEnableWindow(IDC_REFRESH, TRUE);\r
422 \r
423                 PostMessage(WM_TIMER, LOGFILTER_TIMER);\r
424 \r
425         }\r
426 \r
427         m_LogProgress.SetPos(cur);\r
428 }\r
429 void CLogDlg::SetDlgTitle(bool bOffline)\r
430 {\r
431         if (m_sTitle.IsEmpty())\r
432                 GetWindowText(m_sTitle);\r
433 \r
434         if (bOffline)\r
435         {\r
436                 CString sTemp;\r
437                 if (m_path.IsUrl())\r
438                         sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());\r
439                 else if (m_path.IsDirectory())\r
440                         sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());\r
441                 else\r
442                         sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());\r
443                 SetWindowText(sTemp);\r
444         }\r
445         else\r
446         {\r
447                 if (m_path.IsUrl())\r
448                         SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());\r
449                 else if (m_path.IsDirectory())\r
450                         SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());\r
451                 else\r
452                         SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());\r
453         }\r
454 }\r
455 \r
456 void CLogDlg::CheckRegexpTooltip()\r
457 {\r
458         CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);\r
459         // Since tooltip describes regexp features, show it only if regexps are enabled.\r
460         if (m_bFilterWithRegex)\r
461         {\r
462                 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);\r
463         }\r
464         else\r
465                 m_tooltips.DelTool(pWnd);\r
466 }\r
467 \r
468 void CLogDlg::EnableOKButton()\r
469 {\r
470         if (m_bSelect)\r
471         {\r
472                 // the dialog is used to select revisions\r
473                 if (m_bSelectionMustBeContinuous)\r
474                         DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));\r
475                 else\r
476                         DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);\r
477         }\r
478         else\r
479                 DialogEnableWindow(IDOK, TRUE);\r
480 }\r
481 \r
482 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)\r
483 {\r
484         // we fill here the log message rich edit control,\r
485         // and also populate the changed files list control\r
486         // according to the selected revision(s).\r
487 \r
488         CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);\r
489         // empty the log message view\r
490         pMsgView->SetWindowText(_T(" "));\r
491         // empty the changed files list\r
492         m_ChangedFileListCtrl.SetRedraw(FALSE);\r
493 //      InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
494         m_currentChangedArray = NULL;\r
495         m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );\r
496         m_ChangedFileListCtrl.DeleteAllItems();\r
497         m_ChangedFileListCtrl.SetItemCountEx(0);\r
498 \r
499         // if we're not here to really show a selected revision, just\r
500         // get out of here after clearing the views, which is what is intended\r
501         // if that flag is not set.\r
502         if (!bShow)\r
503         {\r
504                 // force a redraw\r
505                 m_ChangedFileListCtrl.Invalidate();\r
506 //              InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
507                 m_ChangedFileListCtrl.SetRedraw(TRUE);\r
508                 return;\r
509         }\r
510 \r
511         // depending on how many revisions are selected, we have to do different\r
512         // tasks.\r
513         int selCount = m_LogList.GetSelectedCount();\r
514         if (selCount == 0)\r
515         {\r
516                 // if nothing is selected, we have nothing more to do\r
517 //              InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
518                 m_ChangedFileListCtrl.SetRedraw(TRUE);\r
519                 return;\r
520         }\r
521         else if (selCount == 1)\r
522         {\r
523                 // if one revision is selected, we have to fill the log message view\r
524                 // with the corresponding log message, and also fill the changed files\r
525                 // list fully.\r
526                 POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
527                 int selIndex = m_LogList.GetNextSelectedItem(pos);\r
528                 if (selIndex >= m_LogList.m_arShownList.GetCount())\r
529                 {\r
530 //                      InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
531                         m_ChangedFileListCtrl.SetRedraw(TRUE);\r
532                         return;\r
533                 }\r
534                 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));\r
535 \r
536                 // set the log message text\r
537                 pMsgView->SetWindowText(_T("*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);\r
538                 // turn bug ID's into links if the bugtraq: properties have been set\r
539                 // and we can find a match of those in the log message\r
540                 m_ProjectProperties.FindBugID(pLogEntry->m_Body, pMsgView);\r
541                 CAppUtils::FormatTextInRichEditControl(pMsgView);\r
542                 m_currentChangedArray = &(pLogEntry->m_Files);\r
543                 if (m_currentChangedArray == NULL)\r
544                 {\r
545 //                      InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
546                         m_ChangedFileListCtrl.SetRedraw(TRUE);\r
547                         return;\r
548                 }\r
549 #if 0\r
550                 // fill in the changed files list control\r
551                 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)\r
552                 {\r
553                         m_CurrentFilteredChangedArray.RemoveAll();\r
554                         for (INT_PTR c = 0; c < m_currentChangedArray->GetCount(); ++c)\r
555                         {\r
556                                 LogChangedPath * cpath = m_currentChangedArray->GetAt(c);\r
557                                 if (cpath == NULL)\r
558                                         continue;\r
559                                 if (m_currentChangedArray->GetAt(c)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)\r
560                                 {\r
561                                         m_CurrentFilteredChangedArray.Add(cpath);\r
562                                 }\r
563                         }\r
564                         m_currentChangedArray = &m_CurrentFilteredChangedArray;\r
565                 }\r
566 #endif\r
567         }\r
568         else\r
569         {\r
570                 // more than one revision is selected:\r
571                 // the log message view must be emptied\r
572                 // the changed files list contains all the changed paths from all\r
573                 // selected revisions, with 'doubles' removed\r
574                 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);\r
575         }\r
576         \r
577         // redraw the views\r
578 //      InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
579         if (m_currentChangedArray)\r
580         {\r
581                 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());\r
582                 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());\r
583         }\r
584         else if (m_currentChangedPathList.GetCount())\r
585         {\r
586                 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());\r
587                 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());\r
588         }\r
589         else\r
590         {\r
591                 m_ChangedFileListCtrl.SetItemCountEx(0);\r
592                 m_ChangedFileListCtrl.Invalidate();\r
593         }\r
594         CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);\r
595         // sort according to the settings\r
596         if (m_nSortColumnPathList > 0)\r
597                 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);\r
598         else\r
599                 SetSortArrow(&m_ChangedFileListCtrl, -1, false);\r
600         m_ChangedFileListCtrl.SetRedraw(TRUE);\r
601 \r
602 }\r
603 \r
604 void CLogDlg::OnBnClickedGetall()\r
605 {\r
606         GetAll();\r
607 }\r
608 \r
609 void CLogDlg::GetAll(bool bForceAll /* = false */)\r
610 {\r
611 #if 0\r
612         // fetch all requested log messages, either the specified range or\r
613         // really *all* available log messages.\r
614         UpdateData();\r
615         INT_PTR entry = m_btnShow.GetCurrentEntry();\r
616         if (bForceAll)\r
617                 entry = 0;\r
618 \r
619         switch (entry)\r
620         {\r
621         case 0: // show all\r
622         \r
623                 m_endrev = 0;\r
624                 m_startrev = m_LogRevision;\r
625                 if (m_bStrict)\r
626                         m_bShowedAll = true;\r
627 \r
628                 break;\r
629         case 1: // show range\r
630                 {\r
631 \r
632                         // ask for a revision range\r
633                         CRevisionRangeDlg dlg;\r
634                         dlg.SetStartRevision(m_startrev);\r
635                         dlg.SetEndRevision( (m_endrev>=0) ? m_endrev : 0);\r
636                         if (dlg.DoModal()!=IDOK)\r
637                         {\r
638                                 return;\r
639                         }\r
640                         m_endrev = dlg.GetEndRevision();\r
641                         m_startrev = dlg.GetStartRevision();\r
642                         if (((m_endrev.IsNumber())&&(m_startrev.IsNumber()))||\r
643                                 (m_endrev.IsHead()||m_startrev.IsHead()))\r
644                         {\r
645                                 if (((LONG)m_startrev < (LONG)m_endrev)||\r
646                                         (m_endrev.IsHead()))\r
647                                 {\r
648                                         git_revnum_t temp = m_startrev;\r
649                                         m_startrev = m_endrev;\r
650                                         m_endrev = temp;\r
651                                 }\r
652                         }\r
653                         m_bShowedAll = false;\r
654                 }\r
655 \r
656                 break;\r
657         }\r
658         m_ChangedFileListCtrl.SetItemCountEx(0);\r
659         m_ChangedFileListCtrl.Invalidate();\r
660         // We need to create CStoreSelection on the heap or else\r
661         // the variable will run out of the scope before the\r
662         // thread ends. Therefore we let the thread delete\r
663         // the instance.\r
664         m_pStoreSelection = new CStoreSelection(this);\r
665         m_LogList.SetItemCountEx(0);\r
666         m_LogList.Invalidate();\r
667         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
668         CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);\r
669         pMsgView->SetWindowText(_T(""));\r
670 \r
671         SetSortArrow(&m_LogList, -1, true);\r
672 \r
673         m_LogList.DeleteAllItems();\r
674         m_arShownList.RemoveAll();\r
675         m_logEntries.ClearAll();\r
676 \r
677         m_logcounter = 0;\r
678         m_bCancelled = FALSE;\r
679         m_tTo = 0;\r
680         m_tFrom = (DWORD)-1;\r
681         m_limit = 0;\r
682 \r
683         InterlockedExchange(&m_bThreadRunning, TRUE);\r
684         if (AfxBeginThread(LogThreadEntry, this)==NULL)\r
685         {\r
686                 InterlockedExchange(&m_bThreadRunning, FALSE);\r
687                 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
688         }\r
689         GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);\r
690         InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
691 #endif\r
692 }\r
693 \r
694 void CLogDlg::OnBnClickedRefresh()\r
695 {\r
696         m_limit = 0;\r
697         Refresh (true);\r
698 }\r
699 \r
700 void CLogDlg::Refresh (bool autoGoOnline)\r
701 {\r
702 #if 0\r
703         // refreshing means re-downloading the already shown log messages\r
704         UpdateData();\r
705         m_maxChild = 0;\r
706         m_childCounter = 0;\r
707 \r
708         if ((m_limit == 0)||(m_bStrict)||(int(m_logEntries.size()-1) > m_limit))\r
709         {\r
710                 if (m_logEntries.size() != 0)\r
711                 {\r
712                         m_endrev = m_logEntries[m_logEntries.size()-1]->Rev;\r
713                 }\r
714         }\r
715         m_startrev = -1;\r
716         m_bCancelled = FALSE;\r
717 \r
718         // We need to create CStoreSelection on the heap or else\r
719         // the variable will run out of the scope before the\r
720         // thread ends. Therefore we let the thread delete\r
721         // the instance.\r
722         m_pStoreSelection = new CStoreSelection(this);\r
723         m_ChangedFileListCtrl.SetItemCountEx(0);\r
724         m_ChangedFileListCtrl.Invalidate();\r
725         m_LogList.SetItemCountEx(0);\r
726         m_LogList.Invalidate();\r
727         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
728         CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);\r
729         pMsgView->SetWindowText(_T(""));\r
730 \r
731         SetSortArrow(&m_LogList, -1, true);\r
732 \r
733         m_LogList.DeleteAllItems();\r
734         m_arShownList.RemoveAll();\r
735         m_logEntries.ClearAll();\r
736 \r
737     // reset the cached HEAD property & go on-line\r
738 \r
739     if (autoGoOnline)\r
740     {\r
741             SetDlgTitle (false);\r
742         logCachePool.GetRepositoryInfo().ResetHeadRevision (m_sUUID, m_sRepositoryRoot);\r
743     }\r
744 \r
745         InterlockedExchange(&m_bThreadRunning, TRUE);\r
746         if (AfxBeginThread(LogThreadEntry, this)==NULL)\r
747         {\r
748                 InterlockedExchange(&m_bThreadRunning, FALSE);\r
749                 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
750         }\r
751         GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);\r
752         InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
753 #endif\r
754 }\r
755 \r
756 void CLogDlg::OnBnClickedNexthundred()\r
757 {\r
758 #if 0\r
759         UpdateData();\r
760         // we have to fetch the next X log messages.\r
761         if (m_logEntries.size() < 1)\r
762         {\r
763                 // since there weren't any log messages fetched before, just\r
764                 // fetch all since we don't have an 'anchor' to fetch the 'next'\r
765                 // messages from.\r
766                 return GetAll(true);\r
767         }\r
768         git_revnum_t rev = m_logEntries[m_logEntries.size()-1]->Rev;\r
769 \r
770         if (rev < 1)\r
771                 return;         // do nothing! No more revisions to get\r
772 \r
773         m_startrev = rev;\r
774         m_endrev = 0;\r
775         m_bCancelled = FALSE;\r
776 \r
777     // rev is is revision we already have and we will receive it again\r
778     // -> fetch one extra revision to get NumberOfLogs *new* revisions\r
779 \r
780         m_limit = (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;\r
781         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
782         SetSortArrow(&m_LogList, -1, true);\r
783         InterlockedExchange(&m_bThreadRunning, TRUE);\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
787         // the instance.\r
788         m_pStoreSelection = new CStoreSelection(this);\r
789 \r
790         // since we fetch the log from the last revision we already have,\r
791         // we have to remove that revision entry to avoid getting it twice\r
792         m_logEntries.pop_back();\r
793         if (AfxBeginThread(LogThreadEntry, this)==NULL)\r
794         {\r
795                 InterlockedExchange(&m_bThreadRunning, FALSE);\r
796                 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
797         }\r
798         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
799         GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);\r
800 #endif\r
801 }\r
802 \r
803 BOOL CLogDlg::Cancel()\r
804 {\r
805         return m_bCancelled;\r
806 }\r
807 \r
808 void CLogDlg::SaveSplitterPos()\r
809 {\r
810         if (!IsIconic())\r
811         {\r
812                 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));\r
813                 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));\r
814                 RECT rectSplitter;\r
815                 m_wndSplitter1.GetWindowRect(&rectSplitter);\r
816                 ScreenToClient(&rectSplitter);\r
817                 regPos1 = rectSplitter.top;\r
818                 m_wndSplitter2.GetWindowRect(&rectSplitter);\r
819                 ScreenToClient(&rectSplitter);\r
820                 regPos2 = rectSplitter.top;\r
821         }\r
822 }\r
823 \r
824 void CLogDlg::OnCancel()\r
825 {\r
826         // canceling means stopping the working thread if it's still running.\r
827         // we do this by using the Subversion cancel callback.\r
828         // But canceling can also mean just to close the dialog, depending on the\r
829         // text shown on the cancel button (it could simply read "OK").\r
830         CString temp, temp2;\r
831         GetDlgItemText(IDOK, temp);\r
832         temp2.LoadString(IDS_MSGBOX_CANCEL);\r
833         if ((temp.Compare(temp2)==0)||(this->IsThreadRunning()))\r
834         {\r
835                 m_bCancelled = true;\r
836                 return;\r
837         }\r
838         UpdateData();\r
839         if (m_bSaveStrict)\r
840                 m_regLastStrict = m_bStrict;\r
841         CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));\r
842         reg = m_btnShow.GetCurrentEntry();\r
843         SaveSplitterPos();\r
844         __super::OnCancel();\r
845 }\r
846 \r
847 CString CLogDlg::MakeShortMessage(const CString& message)\r
848 {\r
849         bool bFoundShort = true;\r
850         CString sShortMessage = m_ProjectProperties.GetLogSummary(message);\r
851         if (sShortMessage.IsEmpty())\r
852         {\r
853                 bFoundShort = false;\r
854                 sShortMessage = message;\r
855         }\r
856         // Remove newlines and tabs 'cause those are not shown nicely in the list control\r
857         sShortMessage.Replace(_T("\r"), _T(""));\r
858         sShortMessage.Replace(_T("\t"), _T(" "));\r
859         \r
860         // Suppose the first empty line separates 'summary' from the rest of the message.\r
861         int found = sShortMessage.Find(_T("\n\n"));\r
862         // To avoid too short 'short' messages \r
863         // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")\r
864         // only use the empty newline as a separator if it comes after at least 15 chars.\r
865         if ((!bFoundShort)&&(found >= 15))\r
866         {\r
867                 sShortMessage = sShortMessage.Left(found);\r
868         }\r
869         sShortMessage.Replace('\n', ' ');\r
870         return sShortMessage;\r
871 }\r
872 \r
873 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
874 {\r
875 #if 0\r
876         if (rev == SVN_INVALID_REVNUM)\r
877         {\r
878                 m_childCounter--;\r
879                 return TRUE;\r
880         }\r
881 \r
882         // this is the callback function which receives the data for every revision we ask the log for\r
883         // we store this information here one by one.\r
884         m_logcounter += 1;\r
885         if (m_startrev == -1)\r
886                 m_startrev = rev;\r
887         if (m_limit != 0)\r
888         {\r
889                 m_limitcounter--;\r
890                 m_LogProgress.SetPos(m_limit - m_limitcounter);\r
891         }\r
892         else if (m_startrev.IsNumber() && m_startrev.IsNumber())\r
893                 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);\r
894         __time64_t ttime = time/1000000L;\r
895         if (m_tTo < (DWORD)ttime)\r
896                 m_tTo = (DWORD)ttime;\r
897         if (m_tFrom > (DWORD)ttime)\r
898                 m_tFrom = (DWORD)ttime;\r
899         if ((m_lowestRev > rev)||(m_lowestRev < 0))\r
900                 m_lowestRev = rev;\r
901         // Add as many characters from the log message to the list control\r
902         PLOGENTRYDATA pLogItem = new LOGENTRYDATA;\r
903         pLogItem->bCopies = !!copies;\r
904         \r
905         // find out if this item was copied in the revision\r
906         BOOL copiedself = FALSE;\r
907         if (copies)\r
908         {\r
909                 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)\r
910                 {\r
911                         LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);\r
912                         if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))\r
913                         {\r
914                                 // note: this only works if the log is fetched top-to-bottom\r
915                                 // but since we do that, it shouldn't be a problem\r
916                                 m_sSelfRelativeURL = cpath->sCopyFromPath;\r
917                                 copiedself = TRUE;\r
918                                 break;\r
919                         }\r
920                 }\r
921         }\r
922         pLogItem->bCopiedSelf = copiedself;\r
923         pLogItem->tmDate = ttime;\r
924         pLogItem->sAuthor = author;\r
925         pLogItem->sDate = date;\r
926         pLogItem->sShortMessage = MakeShortMessage(message);\r
927         pLogItem->dwFileChanges = filechanges;\r
928         pLogItem->actions = actions;\r
929         pLogItem->haschildren = haschildren;\r
930         pLogItem->childStackDepth = m_childCounter;\r
931         m_maxChild = max(m_childCounter, m_maxChild);\r
932         if (haschildren)\r
933                 m_childCounter++;\r
934         pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();\r
935         \r
936         // split multi line log entries and concatenate them\r
937         // again but this time with \r\n as line separators\r
938         // so that the edit control recognizes them\r
939         try\r
940         {\r
941                 if (message.GetLength()>0)\r
942                 {\r
943                         m_sMessageBuf = message;\r
944                         m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));\r
945                         m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));\r
946                         if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)\r
947                                 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);\r
948                 }\r
949                 else\r
950                         m_sMessageBuf.Empty();\r
951         pLogItem->sMessage = m_sMessageBuf;\r
952         pLogItem->Rev = rev;\r
953 \r
954         // move-construct path array\r
955 \r
956         pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);\r
957         cpaths->RemoveAll();\r
958         }\r
959         catch (CException * e)\r
960         {\r
961                 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);\r
962                 e->Delete();\r
963                 m_bCancelled = TRUE;\r
964         }\r
965         m_logEntries.push_back(pLogItem);\r
966         m_arShownList.Add(pLogItem);\r
967 #endif\r
968         return TRUE;\r
969 }\r
970 \r
971 GitRev g_rev;\r
972 //this is the thread function which calls the subversion function\r
973 \r
974 \r
975 \r
976 \r
977 void CLogDlg::CopyChangedSelectionToClipBoard()\r
978 {\r
979 #if 0\r
980         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
981         if (pos == NULL)\r
982                 return; // nothing is selected, get out of here\r
983 \r
984         CString sPaths;\r
985 \r
986         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
987         if (pos)\r
988         {\r
989                 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();\r
990                 while (pos)\r
991                 {\r
992                         int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);\r
993                         sPaths += m_currentChangedPathList[nItem].GetGitPathString();\r
994                         sPaths += _T("\r\n");\r
995                 }\r
996         }\r
997         else\r
998         {\r
999                 // only one revision is selected in the log dialog top pane\r
1000                 // but multiple items could be selected  in the changed items list\r
1001                 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();\r
1002                 while (pos)\r
1003                 {\r
1004                         int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);\r
1005                         LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);\r
1006 \r
1007                         if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)\r
1008                         {\r
1009                                 // some items are hidden! So find out which item the user really selected\r
1010                                 INT_PTR selRealIndex = -1;\r
1011                                 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)\r
1012                                 {\r
1013                                         if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)\r
1014                                                 selRealIndex++;\r
1015                                         if (selRealIndex == nItem)\r
1016                                         {\r
1017                                                 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);\r
1018                                                 break;\r
1019                                         }\r
1020                                 }\r
1021                         }\r
1022                         if (changedlogpath)\r
1023                         {\r
1024                                 sPaths += changedlogpath->sPath;\r
1025                                 sPaths += _T("\r\n");\r
1026                         }\r
1027                 }\r
1028         }\r
1029         sPaths.Trim();\r
1030         CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());\r
1031 #endif\r
1032 }\r
1033 \r
1034 BOOL CLogDlg::IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev)\r
1035 {\r
1036 #if 0\r
1037         CString added, deleted;\r
1038         if (changedpath == NULL)\r
1039                 return false;\r
1040 \r
1041         if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))\r
1042         {\r
1043                 if (changedpath->action == LOGACTIONS_ADDED) // file is added\r
1044                 {\r
1045                         if (changedpath->lCopyFromRev == 0)\r
1046                                 return FALSE; // but file was not added with history\r
1047                 }\r
1048                 return TRUE;\r
1049         }\r
1050 #endif\r
1051         return FALSE;\r
1052 }\r
1053 \r
1054 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)\r
1055 {\r
1056         // we have two separate context menus:\r
1057         // one shown on the log message list control,\r
1058         // the other shown in the changed-files list control\r
1059         int selCount = m_LogList.GetSelectedCount();\r
1060         if (pWnd == &m_LogList)\r
1061         {\r
1062                 //ShowContextMenuForRevisions(pWnd, point);\r
1063         }\r
1064         else if (pWnd == &m_ChangedFileListCtrl)\r
1065         {\r
1066                 ShowContextMenuForChangedpaths(pWnd, point);\r
1067         }\r
1068         else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))\r
1069         {\r
1070                 POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
1071                 int selIndex = -1;\r
1072                 if (pos)\r
1073                         selIndex = m_LogList.GetNextSelectedItem(pos);\r
1074                 if ((point.x == -1) && (point.y == -1))\r
1075                 {\r
1076                         CRect rect;\r
1077                         GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);\r
1078                         ClientToScreen(&rect);\r
1079                         point = rect.CenterPoint();\r
1080                 }\r
1081                 CString sMenuItemText;\r
1082                 CMenu popup;\r
1083                 if (popup.CreatePopupMenu())\r
1084                 {\r
1085                         // add the 'default' entries\r
1086                         sMenuItemText.LoadString(IDS_SCIEDIT_COPY);\r
1087                         popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);\r
1088                         sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);\r
1089                         popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);\r
1090 \r
1091                         if (selIndex >= 0)\r
1092                         {\r
1093                                 popup.AppendMenu(MF_SEPARATOR);\r
1094                                 sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);\r
1095                                 popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);\r
1096                         }\r
1097 \r
1098                         int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
1099                         switch (cmd)\r
1100                         {\r
1101                         case 0:\r
1102                                 break;  // no command selected\r
1103                         case EM_SETSEL:\r
1104                         case WM_COPY:\r
1105                                 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);\r
1106                                 break;\r
1107                         case CGitLogList::ID_EDITAUTHOR:\r
1108                                 EditLogMessage(selIndex);\r
1109                                 break;\r
1110                         }\r
1111                 }\r
1112         }\r
1113 }\r
1114 \r
1115 \r
1116 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)\r
1117 {\r
1118 #if 0\r
1119     ASSERT(m_pFindDialog != NULL);\r
1120 \r
1121     if (m_pFindDialog->IsTerminating())\r
1122     {\r
1123             // invalidate the handle identifying the dialog box.\r
1124         m_pFindDialog = NULL;\r
1125         return 0;\r
1126     }\r
1127 \r
1128     if(m_pFindDialog->FindNext())\r
1129     {\r
1130         //read data from dialog\r
1131         CString FindText = m_pFindDialog->GetFindString();\r
1132         bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);\r
1133                 bool bFound = false;\r
1134                 tr1::wregex pat;\r
1135                 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);\r
1136 \r
1137                 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;\r
1138 \r
1139                 int i;\r
1140                 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)\r
1141                 {\r
1142                         if (bRegex)\r
1143                         {\r
1144                                 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));\r
1145 \r
1146                                 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))\r
1147                                 {\r
1148                                         bFound = true;\r
1149                                         break;\r
1150                                 }\r
1151                                 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
1152                                 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
1153                                 {\r
1154                                         LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
1155                                         if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))\r
1156                                         {\r
1157                                                 bFound = true;\r
1158                                                 --i;\r
1159                                                 break;\r
1160                                         }\r
1161                                         if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))\r
1162                                         {\r
1163                                                 bFound = true;\r
1164                                                 --i;\r
1165                                                 break;\r
1166                                         }\r
1167                                 }\r
1168                         }\r
1169                         else\r
1170                         {\r
1171                                 if (bMatchCase)\r
1172                                 {\r
1173                                         if (m_logEntries[i]->sMessage.Find(FindText) >= 0)\r
1174                                         {\r
1175                                                 bFound = true;\r
1176                                                 break;\r
1177                                         }\r
1178                                         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));\r
1179                                         LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
1180                                         for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
1181                                         {\r
1182                                                 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
1183                                                 if (cpath->sCopyFromPath.Find(FindText)>=0)\r
1184                                                 {\r
1185                                                         bFound = true;\r
1186                                                         --i;\r
1187                                                         break;\r
1188                                                 }\r
1189                                                 if (cpath->sPath.Find(FindText)>=0)\r
1190                                                 {\r
1191                                                         bFound = true;\r
1192                                                         --i;\r
1193                                                         break;\r
1194                                                 }\r
1195                                         }\r
1196                                 }\r
1197                                 else\r
1198                                 {\r
1199                                     PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));\r
1200                                         CString msg = pLogEntry->sMessage;\r
1201                                         msg = msg.MakeLower();\r
1202                                         CString find = FindText.MakeLower();\r
1203                                         if (msg.Find(find) >= 0)\r
1204                                         {\r
1205                                                 bFound = TRUE;\r
1206                                                 break;\r
1207                                         }\r
1208                                         LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
1209                                         for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
1210                                         {\r
1211                                                 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
1212                                                 CString lowerpath = cpath->sCopyFromPath;\r
1213                                                 lowerpath.MakeLower();\r
1214                                                 if (lowerpath.Find(find)>=0)\r
1215                                                 {\r
1216                                                         bFound = TRUE;\r
1217                                                         --i;\r
1218                                                         break;\r
1219                                                 }\r
1220                                                 lowerpath = cpath->sPath;\r
1221                                                 lowerpath.MakeLower();\r
1222                                                 if (lowerpath.Find(find)>=0)\r
1223                                                 {\r
1224                                                         bFound = TRUE;\r
1225                                                         --i;\r
1226                                                         break;\r
1227                                                 }\r
1228                                         }\r
1229                                 } \r
1230                         }\r
1231                 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)\r
1232                 if (bFound)\r
1233                 {\r
1234                         this->m_nSearchIndex = (i+1);\r
1235                         m_LogList.EnsureVisible(i, FALSE);\r
1236                         m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);\r
1237                         m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);\r
1238                         m_LogList.SetSelectionMark(i);\r
1239                         FillLogMessageCtrl();\r
1240                         UpdateData(FALSE);\r
1241                         m_nSearchIndex++;\r
1242                         if (m_nSearchIndex >= m_arShownList.GetCount())\r
1243                                 m_nSearchIndex = (int)m_arShownList.GetCount()-1;\r
1244                 }\r
1245     } // if(m_pFindDialog->FindNext()) \r
1246         UpdateLogInfoLabel();\r
1247 #endif\r
1248     return 0;\r
1249 }\r
1250 \r
1251 void CLogDlg::OnOK()\r
1252 {\r
1253 #if 0 \r
1254         // since the log dialog is also used to select revisions for other\r
1255         // dialogs, we have to do some work before closing this dialog\r
1256         if (GetFocus() != GetDlgItem(IDOK))\r
1257                 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter\r
1258         if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))\r
1259                 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.\r
1260 \r
1261         CString temp;\r
1262         CString buttontext;\r
1263         GetDlgItemText(IDOK, buttontext);\r
1264         temp.LoadString(IDS_MSGBOX_CANCEL);\r
1265         if (temp.Compare(buttontext) != 0)\r
1266                 __super::OnOK();        // only exit if the button text matches, and that will match only if the thread isn't running anymore\r
1267         m_bCancelled = TRUE;\r
1268         m_selectedRevs.Clear();\r
1269         m_selectedRevsOneRange.Clear();\r
1270         if (m_pNotifyWindow)\r
1271         {\r
1272                 int selIndex = m_LogList.GetSelectionMark();\r
1273                 if (selIndex >= 0)\r
1274                 {       \r
1275                     PLOGENTRYDATA pLogEntry = NULL;\r
1276                         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
1277                         pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1278                         m_selectedRevs.AddRevision(pLogEntry->Rev);\r
1279                         git_revnum_t lowerRev = pLogEntry->Rev;\r
1280                         git_revnum_t higherRev = lowerRev;\r
1281                         while (pos)\r
1282                         {\r
1283                             pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1284                                 git_revnum_t rev = pLogEntry->Rev;\r
1285                                 m_selectedRevs.AddRevision(pLogEntry->Rev);\r
1286                                 if (lowerRev > rev)\r
1287                                         lowerRev = rev;\r
1288                                 if (higherRev < rev)\r
1289                                         higherRev = rev;\r
1290                         }\r
1291                         if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())\r
1292                         {\r
1293                                 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);\r
1294                         }\r
1295                         BOOL bSentMessage = FALSE;\r
1296                         if (m_LogList.GetSelectedCount() == 1)\r
1297                         {\r
1298                                 // if only one revision is selected, check if the path/url with which the dialog was started\r
1299                                 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.\r
1300                                 // if it was copied, use the copy from revision as lowerRev\r
1301                                 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))\r
1302                                 {\r
1303                                         CString sUrl = m_path.GetGitPathString();\r
1304                                         if (!m_path.IsUrl())\r
1305                                         {\r
1306                                                 sUrl = GetURLFromPath(m_path);\r
1307                                         }\r
1308                                         sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());\r
1309                                         for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)\r
1310                                         {\r
1311                                                 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);\r
1312                                                 if (pData)\r
1313                                                 {\r
1314                                                         if (sUrl.Compare(pData->sPath) == 0)\r
1315                                                         {\r
1316                                                                 if (!pData->sCopyFromPath.IsEmpty())\r
1317                                                                 {\r
1318                                                                         lowerRev = pData->lCopyFromRev;\r
1319                                                                         m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);\r
1320                                                                         m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);\r
1321                                                                         m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);\r
1322                                                                         bSentMessage = TRUE;\r
1323                                                                 }\r
1324                                                         }\r
1325                                                 }\r
1326                                         }\r
1327                                 }\r
1328                         }\r
1329                         if ( !bSentMessage )\r
1330                         {\r
1331                                 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);\r
1332                                 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);\r
1333                                 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);\r
1334                                 if (m_selectedRevsOneRange.GetCount())\r
1335                                         m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);\r
1336                         }\r
1337                 }\r
1338         }\r
1339         UpdateData();\r
1340         if (m_bSaveStrict)\r
1341                 m_regLastStrict = m_bStrict;\r
1342         CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));\r
1343         reg = m_btnShow.GetCurrentEntry();\r
1344         SaveSplitterPos();\r
1345 #endif \r
1346 }\r
1347 \r
1348 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
1349 {\r
1350         // a double click on an entry in the changed-files list has happened\r
1351         *pResult = 0;\r
1352 \r
1353         DiffSelectedFile();\r
1354 }\r
1355 \r
1356 void CLogDlg::DiffSelectedFile()\r
1357 {\r
1358 #if 0\r
1359         if (m_bThreadRunning)\r
1360                 return;\r
1361         UpdateLogInfoLabel();\r
1362         INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();\r
1363         if (selIndex < 0)\r
1364                 return;\r
1365         if (m_ChangedFileListCtrl.GetSelectedCount() == 0)\r
1366                 return;\r
1367         // find out if there's an entry selected in the log list\r
1368         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
1369         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1370         git_revnum_t rev1 = pLogEntry->Rev;\r
1371         git_revnum_t rev2 = rev1;\r
1372         if (pos)\r
1373         {\r
1374                 while (pos)\r
1375                 {\r
1376                         // there's at least a second entry selected in the log list: several revisions selected!\r
1377                         pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1378                         if (pLogEntry)\r
1379                         {\r
1380                                 rev1 = max(rev1,(long)pLogEntry->Rev);\r
1381                                 rev2 = min(rev2,(long)pLogEntry->Rev);\r
1382                         }\r
1383                 }\r
1384                 rev2--;\r
1385                 // now we have both revisions selected in the log list, so we can do a diff of the selected\r
1386                 // entry in the changed files list with these two revisions.\r
1387                 DoDiffFromLog(selIndex, rev1, rev2, false, false);\r
1388         }\r
1389         else\r
1390         {\r
1391                 rev2 = rev1-1;\r
1392                 // nothing or only one revision selected in the log list\r
1393                 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);\r
1394 \r
1395                 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)\r
1396                 {\r
1397                         // some items are hidden! So find out which item the user really clicked on\r
1398                         INT_PTR selRealIndex = -1;\r
1399                         for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)\r
1400                         {\r
1401                                 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)\r
1402                                         selRealIndex++;\r
1403                                 if (selRealIndex == selIndex)\r
1404                                 {\r
1405                                         selIndex = hiddenindex;\r
1406                                         changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);\r
1407                                         break;\r
1408                                 }\r
1409                         }\r
1410                 }\r
1411 \r
1412                 if (IsDiffPossible(changedpath, rev1))\r
1413                 {\r
1414                         // diffs with renamed files are possible\r
1415                         if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))\r
1416                                 rev2 = changedpath->lCopyFromRev;\r
1417                         else\r
1418                         {\r
1419                                 // if the path was modified but the parent path was 'added with history'\r
1420                                 // then we have to use the copy from revision of the parent path\r
1421                                 CTGitPath cpath = CTGitPath(changedpath->sPath);\r
1422                                 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)\r
1423                                 {\r
1424                                         CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);\r
1425                                         if (p.IsAncestorOf(cpath))\r
1426                                         {\r
1427                                                 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())\r
1428                                                         rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;\r
1429                                         }\r
1430                                 }\r
1431                         }\r
1432                         DoDiffFromLog(selIndex, rev1, rev2, false, false);\r
1433                 }\r
1434                 else \r
1435                 {\r
1436                         CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));\r
1437                         CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));\r
1438                         GitRev r = rev1;\r
1439                         // deleted files must be opened from the revision before the deletion\r
1440                         if (changedpath->action == LOGACTIONS_DELETED)\r
1441                                 r = rev1-1;\r
1442                         m_bCancelled = false;\r
1443 \r
1444                         CProgressDlg progDlg;\r
1445                         progDlg.SetTitle(IDS_APPNAME);\r
1446                         progDlg.SetAnimation(IDR_DOWNLOAD);\r
1447                         CString sInfoLine;\r
1448                         sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());\r
1449                         progDlg.SetLine(1, sInfoLine, true);\r
1450                         SetAndClearProgressInfo(&progDlg);\r
1451                         progDlg.ShowModeless(m_hWnd);\r
1452 \r
1453                         if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))\r
1454                         {\r
1455                                 m_bCancelled = false;\r
1456                                 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))\r
1457                                 {\r
1458                                         progDlg.Stop();\r
1459                                         SetAndClearProgressInfo((HWND)NULL);\r
1460                                         CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1461                                         return;\r
1462                                 }\r
1463                         }\r
1464                         progDlg.Stop();\r
1465                         SetAndClearProgressInfo((HWND)NULL);\r
1466 \r
1467                         CString sName1, sName2;\r
1468                         sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);\r
1469                         sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);\r
1470                         CAppUtils::DiffFlags flags;\r
1471                         flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));\r
1472                         if (changedpath->action == LOGACTIONS_DELETED)\r
1473                                 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);\r
1474                         else\r
1475                                 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);\r
1476                 }\r
1477         }\r
1478 #endif \r
1479 }\r
1480 \r
1481 \r
1482 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)\r
1483 {\r
1484         DialogEnableWindow(IDOK, FALSE);\r
1485 //      SetPromptApp(&theApp);\r
1486         theApp.DoWaitCursor(1);\r
1487 \r
1488         CString temppath;\r
1489         GetTempPath(temppath);\r
1490         \r
1491         CString file1;\r
1492         file1.Format(_T("%s%s_%s%s"),\r
1493                                 temppath,                                               \r
1494                                 (*m_currentChangedArray)[selIndex].GetBaseFilename(),\r
1495                                 rev1->m_CommitHash.Left(6),\r
1496                                 (*m_currentChangedArray)[selIndex].GetFileExtension());\r
1497 \r
1498         CString file2;\r
1499         file2.Format(_T("%s\\%s_%s%s"),\r
1500                                 temppath,                                               \r
1501                                 (*m_currentChangedArray)[selIndex].GetBaseFilename(),\r
1502                                 rev2->m_CommitHash.Left(6),\r
1503                                 (*m_currentChangedArray)[selIndex].GetFileExtension());\r
1504 \r
1505         CString cmd;\r
1506 \r
1507         cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());\r
1508         g_Git.RunLogFile(cmd,file1);\r
1509         cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());\r
1510         g_Git.RunLogFile(cmd,file2);\r
1511 \r
1512         CAppUtils::DiffFlags flags;\r
1513         CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);\r
1514 \r
1515 #if 0\r
1516         //get the filename\r
1517         CString filepath;\r
1518         if (Git::PathIsURL(m_path))\r
1519         {\r
1520                 filepath = m_path.GetGitPathString();\r
1521         }\r
1522         else\r
1523         {\r
1524                 filepath = GetURLFromPath(m_path);\r
1525                 if (filepath.IsEmpty())\r
1526                 {\r
1527                         theApp.DoWaitCursor(-1);\r
1528                         CString temp;\r
1529                         temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);\r
1530                         CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);\r
1531                         TRACE(_T("could not retrieve the URL of the file!\n"));\r
1532                         EnableOKButton();\r
1533                         theApp.DoWaitCursor(-11);\r
1534                         return;         //exit\r
1535                 }\r
1536         }\r
1537         m_bCancelled = FALSE;\r
1538         filepath = GetRepositoryRoot(CTGitPath(filepath));\r
1539 \r
1540         CString firstfile, secondfile;\r
1541         if (m_LogList.GetSelectedCount()==1)\r
1542         {\r
1543                 int s = m_LogList.GetSelectionMark();\r
1544                 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));\r
1545                 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);\r
1546                 firstfile = changedpath->sPath;\r
1547                 secondfile = firstfile;\r
1548                 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?\r
1549                 {\r
1550                         secondfile = changedpath->sCopyFromPath;\r
1551                         rev2 = changedpath->lCopyFromRev;\r
1552                 }\r
1553         }\r
1554         else\r
1555         {\r
1556                 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();\r
1557                 secondfile = firstfile;\r
1558         }\r
1559 \r
1560         firstfile = filepath + firstfile.Trim();\r
1561         secondfile = filepath + secondfile.Trim();\r
1562 \r
1563         GitDiff diff(this, this->m_hWnd, true);\r
1564         diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));\r
1565         diff.SetHEADPeg(m_LogRevision);\r
1566         if (unified)\r
1567         {\r
1568                 if (PromptShown())\r
1569                         diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);\r
1570                 else\r
1571                         CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);\r
1572         }\r
1573         else\r
1574         {\r
1575                 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))\r
1576                 {\r
1577                         if (firstfile.Compare(secondfile)==0)\r
1578                         {\r
1579                                 git_revnum_t baseRev = 0;\r
1580                                 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);\r
1581                         }\r
1582                 }\r
1583         }\r
1584 \r
1585 #endif\r
1586 \r
1587         theApp.DoWaitCursor(-1);\r
1588         EnableOKButton();\r
1589 }\r
1590 \r
1591 BOOL CLogDlg::Open(bool bOpenWith,CString changedpath, git_revnum_t rev)\r
1592 {\r
1593 #if 0\r
1594         DialogEnableWindow(IDOK, FALSE);\r
1595         SetPromptApp(&theApp);\r
1596         theApp.DoWaitCursor(1);\r
1597         CString filepath;\r
1598         if (Git::PathIsURL(m_path))\r
1599         {\r
1600                 filepath = m_path.GetGitPathString();\r
1601         }\r
1602         else\r
1603         {\r
1604                 filepath = GetURLFromPath(m_path);\r
1605                 if (filepath.IsEmpty())\r
1606                 {\r
1607                         theApp.DoWaitCursor(-1);\r
1608                         CString temp;\r
1609                         temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);\r
1610                         CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);\r
1611                         TRACE(_T("could not retrieve the URL of the file!\n"));\r
1612                         EnableOKButton();\r
1613                         return FALSE;\r
1614                 }\r
1615         }\r
1616         m_bCancelled = false;\r
1617         filepath = GetRepositoryRoot(CTGitPath(filepath));\r
1618         filepath += changedpath;\r
1619 \r
1620         CProgressDlg progDlg;\r
1621         progDlg.SetTitle(IDS_APPNAME);\r
1622         progDlg.SetAnimation(IDR_DOWNLOAD);\r
1623         CString sInfoLine;\r
1624         sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());\r
1625         progDlg.SetLine(1, sInfoLine, true);\r
1626         SetAndClearProgressInfo(&progDlg);\r
1627         progDlg.ShowModeless(m_hWnd);\r
1628 \r
1629         CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);\r
1630         m_bCancelled = false;\r
1631         if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))\r
1632         {\r
1633                 progDlg.Stop();\r
1634                 SetAndClearProgressInfo((HWND)NULL);\r
1635                 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1636                 EnableOKButton();\r
1637                 theApp.DoWaitCursor(-1);\r
1638                 return FALSE;\r
1639         }\r
1640         progDlg.Stop();\r
1641         SetAndClearProgressInfo((HWND)NULL);\r
1642         SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);\r
1643         if (!bOpenWith)\r
1644         {\r
1645                 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);\r
1646                 if (ret <= HINSTANCE_ERROR)\r
1647                         bOpenWith = true;\r
1648         }\r
1649         if (bOpenWith)\r
1650         {\r
1651                 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");\r
1652                 cmd += tempfile.GetWinPathString() + _T(" ");\r
1653                 CAppUtils::LaunchApplication(cmd, NULL, false);\r
1654         }\r
1655         EnableOKButton();\r
1656         theApp.DoWaitCursor(-1);\r
1657 #endif\r
1658         return TRUE;\r
1659 }\r
1660 \r
1661 void CLogDlg::EditAuthor(const CLogDataVector& logs)\r
1662 {\r
1663 #if 0\r
1664         CString url;\r
1665         CString name;\r
1666         if (logs.size() == 0)\r
1667                 return;\r
1668         DialogEnableWindow(IDOK, FALSE);\r
1669         SetPromptApp(&theApp);\r
1670         theApp.DoWaitCursor(1);\r
1671         if (Git::PathIsURL(m_path))\r
1672                 url = m_path.GetGitPathString();\r
1673         else\r
1674         {\r
1675                 url = GetURLFromPath(m_path);\r
1676         }\r
1677         name = Git_PROP_REVISION_AUTHOR;\r
1678 \r
1679         CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);\r
1680         CString sOldValue = value;\r
1681         value.Replace(_T("\n"), _T("\r\n"));\r
1682         CInputDlg dlg(this);\r
1683         dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);\r
1684         dlg.m_sInputText = value;\r
1685         dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);\r
1686         dlg.m_pProjectProperties = &m_ProjectProperties;\r
1687         dlg.m_bUseLogWidth = false;\r
1688         if (dlg.DoModal() == IDOK)\r
1689         {\r
1690                 dlg.m_sInputText.Replace(_T("\r"), _T(""));\r
1691 \r
1692                 LogCache::CCachedLogInfo* toUpdate \r
1693                         = GetLogCache (CTGitPath (m_sRepositoryRoot));\r
1694 \r
1695                 CProgressDlg progDlg;\r
1696                 progDlg.SetTitle(IDS_APPNAME);\r
1697                 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));\r
1698                 progDlg.SetTime(true);\r
1699                 progDlg.SetShowProgressBar(true);\r
1700                 progDlg.ShowModeless(m_hWnd);\r
1701                 for (DWORD i=0; i<logs.size(); ++i)\r
1702                 {\r
1703                         if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))\r
1704                         {\r
1705                                 progDlg.Stop();\r
1706                                 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1707                                 break;\r
1708                         }\r
1709                         else\r
1710                         {\r
1711 \r
1712                                 logs[i]->sAuthor = dlg.m_sInputText;\r
1713                                 m_LogList.Invalidate();\r
1714 \r
1715                                 // update the log cache \r
1716 \r
1717                                 if (toUpdate != NULL)\r
1718                                 {\r
1719                                         // log caching is active\r
1720 \r
1721                                         LogCache::CCachedLogInfo newInfo;\r
1722                                         newInfo.Insert ( logs[i]->Rev\r
1723                                                 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)\r
1724                                                 , ""\r
1725                                                 , 0\r
1726                                                 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);\r
1727 \r
1728                                         toUpdate->Update (newInfo);\r
1729                                 }\r
1730                         }\r
1731                         progDlg.SetProgress64(i, logs.size());\r
1732                 }\r
1733                 progDlg.Stop();\r
1734         }\r
1735         theApp.DoWaitCursor(-1);\r
1736         EnableOKButton();\r
1737 #endif\r
1738 }\r
1739 \r
1740 void CLogDlg::EditLogMessage(int index)\r
1741 {\r
1742 #if 0\r
1743         CString url;\r
1744         CString name;\r
1745         DialogEnableWindow(IDOK, FALSE);\r
1746         SetPromptApp(&theApp);\r
1747         theApp.DoWaitCursor(1);\r
1748         if (Git::PathIsURL(m_path))\r
1749                 url = m_path.GetGitPathString();\r
1750         else\r
1751         {\r
1752                 url = GetURLFromPath(m_path);\r
1753         }\r
1754         name = Git_PROP_REVISION_LOG;\r
1755 \r
1756         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));\r
1757         m_bCancelled = FALSE;\r
1758         CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);\r
1759         CString sOldValue = value;\r
1760         value.Replace(_T("\n"), _T("\r\n"));\r
1761         CInputDlg dlg(this);\r
1762         dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);\r
1763         dlg.m_sInputText = value;\r
1764         dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);\r
1765         dlg.m_pProjectProperties = &m_ProjectProperties;\r
1766         dlg.m_bUseLogWidth = true;\r
1767         if (dlg.DoModal() == IDOK)\r
1768         {\r
1769                 dlg.m_sInputText.Replace(_T("\r"), _T(""));\r
1770                 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))\r
1771                 {\r
1772                         CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1773                 }\r
1774                 else\r
1775                 {\r
1776                         pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);\r
1777                         // split multi line log entries and concatenate them\r
1778                         // again but this time with \r\n as line separators\r
1779                         // so that the edit control recognizes them\r
1780                         if (dlg.m_sInputText.GetLength()>0)\r
1781                         {\r
1782                                 m_sMessageBuf = dlg.m_sInputText;\r
1783                                 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));\r
1784                                 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));\r
1785                                 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)\r
1786                                         dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);\r
1787                         } \r
1788                         else\r
1789                                 dlg.m_sInputText.Empty();\r
1790                         pLogEntry->sMessage = dlg.m_sInputText;\r
1791                         pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);\r
1792                         CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);\r
1793                         pMsgView->SetWindowText(_T(" "));\r
1794                         pMsgView->SetWindowText(dlg.m_sInputText);\r
1795                         m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);\r
1796                         m_LogList.Invalidate();\r
1797         \r
1798             // update the log cache \r
1799 \r
1800             LogCache::CCachedLogInfo* toUpdate \r
1801                 = GetLogCache (CTGitPath (m_sRepositoryRoot));\r
1802             if (toUpdate != NULL)\r
1803             {\r
1804                 // log caching is active\r
1805 \r
1806                 LogCache::CCachedLogInfo newInfo;\r
1807                 newInfo.Insert ( pLogEntry->Rev\r
1808                                , ""\r
1809                                , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)\r
1810                                , 0\r
1811                                , LogCache::CRevisionInfoContainer::HAS_COMMENT);\r
1812 \r
1813                 toUpdate->Update (newInfo);\r
1814             }\r
1815         }\r
1816         }\r
1817         theApp.DoWaitCursor(-1);\r
1818         EnableOKButton();\r
1819 #endif\r
1820 }\r
1821 #if 0\r
1822 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)\r
1823 {\r
1824         // Skip Ctrl-C when copying text out of the log message or search filter\r
1825         BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );\r
1826         if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')\r
1827         {\r
1828                 if (GetFocus()==GetDlgItem(IDC_LOGLIST))\r
1829                 {\r
1830                         if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))\r
1831                         {\r
1832                                 DiffSelectedRevWithPrevious();\r
1833                                 return TRUE;\r
1834                         }\r
1835                 }\r
1836                 if (GetFocus()==GetDlgItem(IDC_LOGMSG))\r
1837                 {\r
1838                         DiffSelectedFile();\r
1839                         return TRUE;\r
1840                 }\r
1841         }\r
1842         if (m_hAccel && !bSkipAccelerator)\r
1843         {\r
1844                 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);\r
1845                 if (ret)\r
1846                         return TRUE;\r
1847         }\r
1848         \r
1849         m_tooltips.RelayEvent(pMsg);\r
1850         return __super::PreTranslateMessage(pMsg);\r
1851 }\r
1852 #endif\r
1853 \r
1854 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)\r
1855 {\r
1856         if (this->IsThreadRunning())\r
1857         {\r
1858                 // only show the wait cursor over the list control\r
1859                 if ((pWnd)&&\r
1860                         ((pWnd == GetDlgItem(IDC_LOGLIST))||\r
1861                         (pWnd == GetDlgItem(IDC_MSGVIEW))||\r
1862                         (pWnd == GetDlgItem(IDC_LOGMSG))))\r
1863                 {\r
1864                         HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));\r
1865                         SetCursor(hCur);\r
1866                         return TRUE;\r
1867                 }\r
1868         }\r
1869         if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))\r
1870                 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);\r
1871 \r
1872         HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));\r
1873         SetCursor(hCur);\r
1874         return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);\r
1875 }\r
1876 \r
1877 void CLogDlg::OnBnClickedHelp()\r
1878 {\r
1879         OnHelp();\r
1880 }\r
1881 \r
1882 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
1883 {\r
1884         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1885         *pResult = 0;\r
1886         if (this->IsThreadRunning())\r
1887                 return;\r
1888         if (pNMLV->iItem >= 0)\r
1889         {\r
1890                 m_nSearchIndex = pNMLV->iItem;\r
1891                 if (pNMLV->iSubItem != 0)\r
1892                         return;\r
1893                 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount())&&(m_bStrict)&&(1/*m_bStrictStopped*/))\r
1894                 {\r
1895                         // remove the selected state\r
1896                         if (pNMLV->uChanged & LVIF_STATE)\r
1897                         {\r
1898                                 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);\r
1899                                 FillLogMessageCtrl();\r
1900                                 UpdateData(FALSE);\r
1901                                 UpdateLogInfoLabel();\r
1902                         }\r
1903                         return;\r
1904                 }\r
1905                 if (pNMLV->uChanged & LVIF_STATE)\r
1906                 {\r
1907                         FillLogMessageCtrl();\r
1908                         UpdateData(FALSE);\r
1909                 }\r
1910         }\r
1911         else\r
1912         {\r
1913                 FillLogMessageCtrl();\r
1914                 UpdateData(FALSE);\r
1915         }\r
1916         EnableOKButton();\r
1917         UpdateLogInfoLabel();\r
1918 }\r
1919 \r
1920 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)\r
1921 {\r
1922         ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);\r
1923         if (pEnLink->msg == WM_LBUTTONUP)\r
1924         {\r
1925                 CString url, msg;\r
1926                 GetDlgItemText(IDC_MSGVIEW, msg);\r
1927                 msg.Replace(_T("\r\n"), _T("\n"));\r
1928                 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);\r
1929                 if (!::PathIsURL(url))\r
1930                 {\r
1931                         url = m_ProjectProperties.GetBugIDUrl(url);\r
1932                         url = GetAbsoluteUrlFromRelativeUrl(url);\r
1933                 }\r
1934                 if (!url.IsEmpty())\r
1935                         ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);\r
1936         }\r
1937         *pResult = 0;\r
1938 }\r
1939 \r
1940 void CLogDlg::OnBnClickedStatbutton()\r
1941 {\r
1942 #if 0\r
1943         if (m_bThreadRunning)\r
1944                 return;\r
1945         if (m_arShownList.IsEmpty())\r
1946                 return;         // nothing is shown, so no statistics.\r
1947         // the statistics dialog expects the log entries to be sorted by date\r
1948         SortByColumn(3, false);\r
1949         CPtrArray shownlist;\r
1950         RecalculateShownList(&shownlist);\r
1951         // create arrays which are aware of the current filter\r
1952         CStringArray m_arAuthorsFiltered;\r
1953         CDWordArray m_arDatesFiltered;\r
1954         CDWordArray m_arFileChangesFiltered;\r
1955         for (INT_PTR i=0; i<shownlist.GetCount(); ++i)\r
1956         {\r
1957                 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(shownlist.GetAt(i));\r
1958                 CString strAuthor = pLogEntry->sAuthor;\r
1959                 if ( strAuthor.IsEmpty() )\r
1960                 {\r
1961                         strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);\r
1962                 }\r
1963                 m_arAuthorsFiltered.Add(strAuthor);\r
1964                 m_arDatesFiltered.Add(static_cast<DWORD>(pLogEntry->tmDate));\r
1965                 m_arFileChangesFiltered.Add(pLogEntry->dwFileChanges);\r
1966         }\r
1967         CStatGraphDlg dlg;\r
1968         dlg.m_parAuthors = &m_arAuthorsFiltered;\r
1969         dlg.m_parDates = &m_arDatesFiltered;\r
1970         dlg.m_parFileChanges = &m_arFileChangesFiltered;\r
1971         dlg.m_path = m_path;\r
1972         dlg.DoModal();\r
1973         // restore the previous sorting\r
1974         SortByColumn(m_nSortColumn, m_bAscending);\r
1975         OnTimer(LOGFILTER_TIMER);\r
1976 #endif\r
1977 }\r
1978 \r
1979 #if 0\r
1980 void CLogDlg::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
1981 {\r
1982 \r
1983         NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );\r
1984         // Take the default processing unless we set this to something else below.\r
1985         *pResult = CDRF_DODEFAULT;\r
1986 \r
1987         if (m_bNoDispUpdates)\r
1988                 return;\r
1989 \r
1990         switch (pLVCD->nmcd.dwDrawStage)\r
1991         {\r
1992         case CDDS_PREPAINT:\r
1993                 {\r
1994                         *pResult = CDRF_NOTIFYITEMDRAW;\r
1995                         return;\r
1996                 }\r
1997                 break;\r
1998         case CDDS_ITEMPREPAINT:\r
1999                 {\r
2000                         // This is the prepaint stage for an item. Here's where we set the\r
2001                         // item's text color. \r
2002                         \r
2003                         // Tell Windows to send draw notifications for each subitem.\r
2004                         *pResult = CDRF_NOTIFYSUBITEMDRAW;\r
2005 \r
2006                         COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);\r
2007 \r
2008                         if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
2009                         {\r
2010                                 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);\r
2011                                 if (data)\r
2012                                 {\r
2013 #if 0\r
2014                                         if (data->bCopiedSelf)\r
2015                                         {\r
2016                                                 // only change the background color if the item is not 'hot' (on vista with themes enabled)\r
2017                                                 if (!theme.IsAppThemed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))\r
2018                                                         pLVCD->clrTextBk = GetSysColor(COLOR_MENU);\r
2019                                         }\r
2020 \r
2021                                         if (data->bCopies)\r
2022                                                 crText = m_Colors.GetColor(CColors::Modified);\r
2023 #endif\r
2024 //                                      if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))\r
2025 //                                              crText = GetSysColor(COLOR_GRAYTEXT);\r
2026 //                                      if (data->Rev == m_wcRev)\r
2027 //                                      {\r
2028 //                                              SelectObject(pLVCD->nmcd.hdc, m_boldFont);\r
2029                                                 // We changed the font, so we're returning CDRF_NEWFONT. This\r
2030                                                 // tells the control to recalculate the extent of the text.\r
2031 //                                              *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;\r
2032 //                                      }\r
2033                                 }\r
2034                         }\r
2035                         if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
2036                         {\r
2037                                 if (m_bStrictStopped)\r
2038                                         crText = GetSysColor(COLOR_GRAYTEXT);\r
2039                         }\r
2040                         // Store the color back in the NMLVCUSTOMDRAW struct.\r
2041                         pLVCD->clrText = crText;\r
2042                         return;\r
2043                 }\r
2044                 break;\r
2045         case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:\r
2046                 {\r
2047                         if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))\r
2048                         {\r
2049                                 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);\r
2050                         }\r
2051                         if (pLVCD->iSubItem == 1)\r
2052                         {\r
2053                                 *pResult = CDRF_DODEFAULT;\r
2054 \r
2055                                 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
2056                                         return;\r
2057 \r
2058                                 int             nIcons = 0;\r
2059                                 int             iconwidth = ::GetSystemMetrics(SM_CXSMICON);\r
2060                                 int             iconheight = ::GetSystemMetrics(SM_CYSMICON);\r
2061 \r
2062                                 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));\r
2063 \r
2064                                 // Get the selected state of the\r
2065                                 // item being drawn.\r
2066                                 LVITEM   rItem;\r
2067                                 SecureZeroMemory(&rItem, sizeof(LVITEM));\r
2068                                 rItem.mask  = LVIF_STATE;\r
2069                                 rItem.iItem = pLVCD->nmcd.dwItemSpec;\r
2070                                 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;\r
2071                                 m_LogList.GetItem(&rItem);\r
2072 \r
2073                                 CRect rect;\r
2074                                 m_LogList.GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
2075 \r
2076                                 // Fill the background\r
2077                                 if (theme.IsAppThemed() && m_bVista)\r
2078                                 {\r
2079                                         theme.Open(m_hWnd, L"Explorer");\r
2080                                         int state = LISS_NORMAL;\r
2081                                         if (rItem.state & LVIS_SELECTED)\r
2082                                         {\r
2083                                                 if (::GetFocus() == m_LogList.m_hWnd)\r
2084                                                         state |= LISS_SELECTED;\r
2085                                                 else\r
2086                                                         state |= LISS_SELECTEDNOTFOCUS;\r
2087                                         }\r
2088                                         else\r
2089                                         {\r
2090 #if 0\r
2091                                                 if (pLogEntry->bCopiedSelf)\r
2092                                                 {\r
2093                                                         // unfortunately, the pLVCD->nmcd.uItemState does not contain valid\r
2094                                                         // information at this drawing stage. But we can check the whether the\r
2095                                                         // previous stage changed the background color of the item\r
2096                                                         if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))\r
2097                                                         {\r
2098                                                                 HBRUSH brush;\r
2099                                                                 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
2100                                                                 if (brush)\r
2101                                                                 {\r
2102                                                                         ::FillRect(pLVCD->nmcd.hdc, &rect, brush);\r
2103                                                                         ::DeleteObject(brush);\r
2104                                                                 }\r
2105                                                         }\r
2106                                                 }\r
2107 #endif\r
2108                                         }\r
2109 \r
2110                                         if (theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))\r
2111                                                 theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);\r
2112 \r
2113                                         theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);\r
2114                                 }\r
2115                                 else\r
2116                                 {\r
2117                                         HBRUSH brush;\r
2118                                         if (rItem.state & LVIS_SELECTED)\r
2119                                         {\r
2120                                                 if (::GetFocus() == m_LogList.m_hWnd)\r
2121                                                         brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));\r
2122                                                 else\r
2123                                                         brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));\r
2124                                         }\r
2125                                         else\r
2126                                         {\r
2127                                                 //if (pLogEntry->bCopiedSelf)\r
2128                                                 //      brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
2129                                                 //else\r
2130                                                         brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));\r
2131                                         }\r
2132                                         if (brush == NULL)\r
2133                                                 return;\r
2134 \r
2135                                         ::FillRect(pLVCD->nmcd.hdc, &rect, brush);\r
2136                                         ::DeleteObject(brush);\r
2137                                 }\r
2138 \r
2139                                 // Draw the icon(s) into the compatible DC\r
2140                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)\r
2141                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2142                                 nIcons++;\r
2143 \r
2144                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)\r
2145                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2146                                 nIcons++;\r
2147 \r
2148                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)\r
2149                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2150                                 nIcons++;\r
2151 \r
2152                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)\r
2153                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2154                                 nIcons++;\r
2155                                 *pResult = CDRF_SKIPDEFAULT;\r
2156                                 return;\r
2157                         }\r
2158                 }\r
2159                 break;\r
2160         }\r
2161         *pResult = CDRF_DODEFAULT;\r
2162 \r
2163 }\r
2164 #endif\r
2165 \r
2166 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)\r
2167 {\r
2168 \r
2169         NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );\r
2170         // Take the default processing unless we set this to something else below.\r
2171         *pResult = CDRF_DODEFAULT;\r
2172 \r
2173 //      if (m_bNoDispUpdates)\r
2174 //              return;\r
2175 \r
2176         // First thing - check the draw stage. If it's the control's prepaint\r
2177         // stage, then tell Windows we want messages for every item.\r
2178 \r
2179         if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )\r
2180         {\r
2181                 *pResult = CDRF_NOTIFYITEMDRAW;\r
2182         }\r
2183         else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )\r
2184         {\r
2185                 // This is the prepaint stage for an item. Here's where we set the\r
2186                 // item's text color. Our return value will tell Windows to draw the\r
2187                 // item itself, but it will use the new color we set here.\r
2188 \r
2189                 // Tell Windows to paint the control itself.\r
2190                 *pResult = CDRF_DODEFAULT;\r
2191 \r
2192                 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);\r
2193                 bool bGrayed = false;\r
2194 #if 0\r
2195                 if ((m_cHidePaths.GetState() & 0x0003)==BST_INDETERMINATE)\r
2196                 {\r
2197                         if ((m_currentChangedArray)&&((m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)))\r
2198                         {\r
2199                                 //if ((*m_currentChangedArray)[(pLVCD->nmcd.dwItemSpec)]sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)\r
2200                                 {\r
2201                                         crText = GetSysColor(COLOR_GRAYTEXT);\r
2202                                         bGrayed = true;\r
2203                                 }\r
2204                         }\r
2205                         else if (m_currentChangedPathList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
2206                         {\r
2207                                 //if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)\r
2208                                 {\r
2209                                         crText = GetSysColor(COLOR_GRAYTEXT);\r
2210                                         bGrayed = true;\r
2211                                 }\r
2212                         }\r
2213                 }\r
2214 \r
2215 #endif\r
2216                 if ((!bGrayed)&&(m_currentChangedArray)&&(m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec))\r
2217                 {\r
2218                         DWORD action = ((*m_currentChangedArray)[pLVCD->nmcd.dwItemSpec]).m_Action;\r
2219                         if (action == CTGitPath::LOGACTIONS_MODIFIED)\r
2220                                 crText = m_Colors.GetColor(CColors::Modified);\r
2221                         if (action == CTGitPath::LOGACTIONS_REPLACED)\r
2222                                 crText = m_Colors.GetColor(CColors::Deleted);\r
2223                         if (action == CTGitPath::LOGACTIONS_ADDED)\r
2224                                 crText = m_Colors.GetColor(CColors::Added);\r
2225                         if (action == CTGitPath::LOGACTIONS_DELETED)\r
2226                                 crText = m_Colors.GetColor(CColors::Deleted);\r
2227                 }\r
2228 \r
2229                 // Store the color back in the NMLVCUSTOMDRAW struct.\r
2230                 pLVCD->clrText = crText;\r
2231         }\r
2232 }\r
2233 \r
2234 void CLogDlg::DoSizeV1(int delta)\r
2235 {\r
2236 \r
2237         RemoveAnchor(IDC_LOGLIST);\r
2238         RemoveAnchor(IDC_SPLITTERTOP);\r
2239         RemoveAnchor(IDC_MSGVIEW);\r
2240         RemoveAnchor(IDC_SPLITTERBOTTOM);\r
2241         RemoveAnchor(IDC_LOGMSG);\r
2242         CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);\r
2243         CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);\r
2244         AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);\r
2245         AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);\r
2246         AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);\r
2247         AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2248         AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2249         ArrangeLayout();\r
2250         AdjustMinSize();\r
2251         SetSplitterRange();\r
2252         m_LogList.Invalidate();\r
2253         GetDlgItem(IDC_MSGVIEW)->Invalidate();\r
2254 \r
2255 }\r
2256 \r
2257 void CLogDlg::DoSizeV2(int delta)\r
2258 {\r
2259 \r
2260         RemoveAnchor(IDC_LOGLIST);\r
2261         RemoveAnchor(IDC_SPLITTERTOP);\r
2262         RemoveAnchor(IDC_MSGVIEW);\r
2263         RemoveAnchor(IDC_SPLITTERBOTTOM);\r
2264         RemoveAnchor(IDC_LOGMSG);\r
2265         CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);\r
2266         CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);\r
2267         AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);\r
2268         AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);\r
2269         AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);\r
2270         AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2271         AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2272         ArrangeLayout();\r
2273         AdjustMinSize();\r
2274         SetSplitterRange();\r
2275         GetDlgItem(IDC_MSGVIEW)->Invalidate();\r
2276         m_ChangedFileListCtrl.Invalidate();\r
2277 \r
2278 }\r
2279 \r
2280 void CLogDlg::AdjustMinSize()\r
2281 {\r
2282         // adjust the minimum size of the dialog to prevent the resizing from\r
2283         // moving the list control too far down.\r
2284         CRect rcChgListView;\r
2285         m_ChangedFileListCtrl.GetClientRect(rcChgListView);\r
2286         CRect rcLogList;\r
2287         m_LogList.GetClientRect(rcLogList);\r
2288 \r
2289         SetMinTrackSize(CSize(m_DlgOrigRect.Width(), \r
2290                 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()\r
2291                 +rcChgListView.Height()+rcLogList.Height()+60));\r
2292 }\r
2293 \r
2294 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r
2295 {\r
2296         switch (message) {\r
2297         case WM_NOTIFY:\r
2298                 if (wParam == IDC_SPLITTERTOP)\r
2299                 { \r
2300                         SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;\r
2301                         DoSizeV1(pHdr->delta);\r
2302                 }\r
2303                 else if (wParam == IDC_SPLITTERBOTTOM)\r
2304                 { \r
2305                         SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;\r
2306                         DoSizeV2(pHdr->delta);\r
2307                 }\r
2308                 break;\r
2309         }\r
2310 \r
2311         return CResizableDialog::DefWindowProc(message, wParam, lParam);\r
2312 }\r
2313 \r
2314 void CLogDlg::SetSplitterRange()\r
2315 {\r
2316         if ((m_LogList)&&(m_ChangedFileListCtrl))\r
2317         {\r
2318                 CRect rcTop;\r
2319                 m_LogList.GetWindowRect(rcTop);\r
2320                 ScreenToClient(rcTop);\r
2321                 CRect rcMiddle;\r
2322                 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);\r
2323                 ScreenToClient(rcMiddle);\r
2324                 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);\r
2325                 CRect rcBottom;\r
2326                 m_ChangedFileListCtrl.GetWindowRect(rcBottom);\r
2327                 ScreenToClient(rcBottom);\r
2328                 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);\r
2329         }\r
2330 }\r
2331 \r
2332 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)\r
2333 {\r
2334         RECT * rect = (LPRECT)lParam;\r
2335         CPoint point;\r
2336         CString temp;\r
2337         point = CPoint(rect->left, rect->bottom);\r
2338 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))\r
2339         CMenu popup;\r
2340         if (popup.CreatePopupMenu())\r
2341         {\r
2342                 temp.LoadString(IDS_LOG_FILTER_ALL);\r
2343                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);\r
2344 \r
2345                 popup.AppendMenu(MF_SEPARATOR, NULL);\r
2346                 \r
2347                 temp.LoadString(IDS_LOG_FILTER_MESSAGES);\r
2348                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);\r
2349                 temp.LoadString(IDS_LOG_FILTER_PATHS);\r
2350                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);\r
2351                 temp.LoadString(IDS_LOG_FILTER_AUTHORS);\r
2352                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);\r
2353                 temp.LoadString(IDS_LOG_FILTER_REVS);\r
2354                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);\r
2355                 temp.LoadString(IDS_LOG_FILTER_BUGIDS);\r
2356                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);\r
2357                 \r
2358                 popup.AppendMenu(MF_SEPARATOR, NULL);\r
2359 \r
2360                 temp.LoadString(IDS_LOG_FILTER_REGEX);\r
2361                 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);\r
2362 \r
2363                 m_tooltips.Pop();\r
2364                 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
2365                 if (selection != 0)\r
2366                 {\r
2367 \r
2368                         if (selection == LOGFILTER_REGEX)\r
2369                         {\r
2370                                 m_bFilterWithRegex = !m_bFilterWithRegex;\r
2371                                 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);\r
2372                                 b = m_bFilterWithRegex;\r
2373                                 CheckRegexpTooltip();\r
2374                         }\r
2375                         else\r
2376                         {\r
2377                                 m_nSelectedFilter = selection;\r
2378                                 SetFilterCueText();\r
2379                         }\r
2380                         SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
2381                 }\r
2382         }\r
2383         return 0L;\r
2384 }\r
2385 \r
2386 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)\r
2387 {\r
2388 #if 0\r
2389         KillTimer(LOGFILTER_TIMER);\r
2390 \r
2391         m_sFilterText.Empty();\r
2392         UpdateData(FALSE);\r
2393         theApp.DoWaitCursor(1);\r
2394         CStoreSelection storeselection(this);\r
2395         FillLogMessageCtrl(false);\r
2396         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
2397         m_arShownList.RemoveAll();\r
2398 \r
2399         // reset the time filter too\r
2400         m_timFrom = (__time64_t(m_tFrom));\r
2401         m_timTo = (__time64_t(m_tTo));\r
2402         m_DateFrom.SetTime(&m_timFrom);\r
2403         m_DateTo.SetTime(&m_timTo);\r
2404         m_DateFrom.SetRange(&m_timFrom, &m_timTo);\r
2405         m_DateTo.SetRange(&m_timFrom, &m_timTo);\r
2406 \r
2407         for (DWORD i=0; i<m_logEntries.size(); ++i)\r
2408         {\r
2409                 m_arShownList.Add(m_logEntries[i]);\r
2410         }\r
2411         InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
2412         m_LogList.DeleteAllItems();\r
2413         m_LogList.SetItemCountEx(ShownCountWithStopped());\r
2414         m_LogList.RedrawItems(0, ShownCountWithStopped());\r
2415         m_LogList.SetRedraw(false);\r
2416         ResizeAllListCtrlCols();\r
2417         m_LogList.SetRedraw(true);\r
2418         theApp.DoWaitCursor(-1);\r
2419         GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
2420         GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
2421         GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
2422         UpdateLogInfoLabel();\r
2423 #endif\r
2424         return 0L;      \r
2425 }\r
2426 \r
2427 \r
2428 void CLogDlg::SetFilterCueText()\r
2429 {\r
2430         CString temp;\r
2431         switch (m_nSelectedFilter)\r
2432         {\r
2433         case LOGFILTER_ALL:\r
2434                 temp.LoadString(IDS_LOG_FILTER_ALL);\r
2435                 break;\r
2436         case LOGFILTER_MESSAGES:\r
2437                 temp.LoadString(IDS_LOG_FILTER_MESSAGES);\r
2438                 break;\r
2439         case LOGFILTER_PATHS:\r
2440                 temp.LoadString(IDS_LOG_FILTER_PATHS);\r
2441                 break;\r
2442         case LOGFILTER_AUTHORS:\r
2443                 temp.LoadString(IDS_LOG_FILTER_AUTHORS);\r
2444                 break;\r
2445         case LOGFILTER_REVS:\r
2446                 temp.LoadString(IDS_LOG_FILTER_REVS);\r
2447                 break;\r
2448         }\r
2449         // to make the cue banner text appear more to the right of the edit control\r
2450         temp = _T("   ")+temp;\r
2451         m_cFilter.SetCueBanner(temp);\r
2452 }\r
2453 #if 0\r
2454 void CLogDlg::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
2455 {\r
2456         NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
2457 \r
2458         // Create a pointer to the item\r
2459         LV_ITEM* pItem = &(pDispInfo)->item;\r
2460 \r
2461         // Do the list need text information?\r
2462         if (!(pItem->mask & LVIF_TEXT))\r
2463                 return;\r
2464 \r
2465         // By default, clear text buffer.\r
2466         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2467 \r
2468         bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();\r
2469         \r
2470         *pResult = 0;\r
2471         if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)\r
2472                 return;\r
2473 \r
2474         // Which item number?\r
2475         int itemid = pItem->iItem;\r
2476         GitRev * pLogEntry = NULL;\r
2477         if (itemid < m_arShownList.GetCount())\r
2478                 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));\r
2479     \r
2480         // Which column?\r
2481         switch (pItem->iSubItem)\r
2482         {\r
2483         case this->LOGLIST_GRAPH:       //Graphic\r
2484                 if (pLogEntry)\r
2485                 {\r
2486                 }\r
2487                 break;\r
2488         case this->LOGLIST_ACTION: //action -- no text in the column\r
2489                 break;\r
2490         case this->LOGLIST_MESSAGE: //Message\r
2491                 if (pLogEntry)\r
2492                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);\r
2493                 break;\r
2494         case this->LOGLIST_AUTHOR: //Author\r
2495                 if (pLogEntry)\r
2496                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);\r
2497                 break;\r
2498         case this->LOGLIST_DATE: //Date\r
2499                 if (pLogEntry)\r
2500                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);\r
2501                 break;\r
2502                 \r
2503         case 5:\r
2504 \r
2505                 break;\r
2506         default:\r
2507                 ASSERT(false);\r
2508         }\r
2509 }\r
2510 #endif\r
2511 void CLogDlg::OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)\r
2512 {\r
2513 \r
2514 #if 0\r
2515         NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
2516 \r
2517         //Create a pointer to the item\r
2518         LV_ITEM* pItem= &(pDispInfo)->item;\r
2519 \r
2520         *pResult = 0;\r
2521         if ((m_bNoDispUpdates)||(m_bThreadRunning))\r
2522         {\r
2523                 if (pItem->mask & LVIF_TEXT)\r
2524                         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2525                 return;\r
2526         }\r
2527         if ((m_currentChangedArray!=NULL)&&(pItem->iItem >= m_currentChangedArray->GetCount()))\r
2528         {\r
2529                 if (pItem->mask & LVIF_TEXT)\r
2530                         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2531                 return;\r
2532         }\r
2533         if ((m_currentChangedArray==NULL)&&(pItem->iItem >= m_currentChangedPathList.GetCount()))\r
2534         {\r
2535                 if (pItem->mask & LVIF_TEXT)\r
2536                         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2537                 return;\r
2538         }\r
2539         CTGitPath lcpath = NULL;\r
2540         if (m_currentChangedArray)\r
2541                 lcpath = (*m_currentChangedArray)[pItem->iItem];\r
2542         //Does the list need text information?\r
2543         if (pItem->mask & LVIF_TEXT)\r
2544         {\r
2545                 //Which column?\r
2546                 switch (pItem->iSubItem)\r
2547                 {\r
2548                 case this->FILELIST_ACTION:     //Action\r
2549 #if 0\r
2550                         if (lcpath)\r
2551                                 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->GetAction(), pItem->cchTextMax);\r
2552                         else\r
2553                                 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);                            \r
2554 #endif\r
2555                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetActionName(), pItem->cchTextMax);\r
2556 \r
2557                         break;\r
2558 \r
2559                 case this->FILELIST_ADD: //add\r
2560 #if 0\r
2561                         if (lcpath)\r
2562                                 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sPath, pItem->cchTextMax);\r
2563                         else\r
2564                                 lstrcpyn(pItem->pszText, (LPCTSTR)m_currentChangedPathList[pItem->iItem].GetGitPathString(), pItem->cchTextMax);\r
2565 #endif\r
2566                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatAdd, pItem->cchTextMax);\r
2567                         break;\r
2568 \r
2569                 case this->FILELIST_DEL: //del\r
2570 #if 0\r
2571                         if (lcpath)\r
2572                                 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sCopyFromPath, pItem->cchTextMax);\r
2573                         else\r
2574                                 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2575 #endif\r
2576                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatDel, pItem->cchTextMax);\r
2577                         break;\r
2578                 case this->FILELIST_PATH: //path\r
2579 #if 0\r
2580                         if ((lcpath==NULL)||(lcpath->sCopyFromPath.IsEmpty()))\r
2581                                 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2582                         else\r
2583                                 _stprintf_s(pItem->pszText, pItem->cchTextMax, _T("%ld"), lcpath->lCopyFromRev);\r
2584 #endif\r
2585                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetGitPathString(), pItem->cchTextMax);\r
2586                         break;\r
2587                 }\r
2588         }\r
2589 #endif\r
2590         *pResult = 0;\r
2591 }\r
2592 \r
2593 void CLogDlg::OnEnChangeSearchedit()\r
2594 {\r
2595 #if 0\r
2596         UpdateData();\r
2597         if (m_sFilterText.IsEmpty())\r
2598         {\r
2599                 CStoreSelection storeselection(this);\r
2600                 // clear the filter, i.e. make all entries appear\r
2601                 theApp.DoWaitCursor(1);\r
2602                 KillTimer(LOGFILTER_TIMER);\r
2603                 FillLogMessageCtrl(false);\r
2604                 InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
2605                 m_arShownList.RemoveAll();\r
2606                 for (DWORD i=0; i<m_logEntries.size(); ++i)\r
2607                 {\r
2608                         if (IsEntryInDateRange(i))\r
2609                                 m_arShownList.Add(m_logEntries[i]);\r
2610                 }\r
2611                 InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
2612                 m_LogList.DeleteAllItems();\r
2613                 m_LogList.SetItemCountEx(ShownCountWithStopped());\r
2614                 m_LogList.RedrawItems(0, ShownCountWithStopped());\r
2615                 m_LogList.SetRedraw(false);\r
2616                 ResizeAllListCtrlCols();\r
2617                 m_LogList.SetRedraw(true);\r
2618                 theApp.DoWaitCursor(-1);\r
2619                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
2620                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
2621                 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
2622                 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));\r
2623                 return;\r
2624         }\r
2625         if (Validate(m_sFilterText))\r
2626                 SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
2627         else\r
2628                 KillTimer(LOGFILTER_TIMER);\r
2629 #endif\r
2630 }\r
2631 \r
2632 bool CLogDlg::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)\r
2633 {\r
2634         try\r
2635         {\r
2636                 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;\r
2637                 if (!bMatchCase)\r
2638                         type |= tr1::regex_constants::icase;\r
2639                 pat = tr1::wregex(regexp_str, type);\r
2640                 return true;\r
2641         }\r
2642         catch (exception) {}\r
2643         return false;\r
2644 }\r
2645 \r
2646 bool CLogDlg::Validate(LPCTSTR string)\r
2647 {\r
2648         if (!m_bFilterWithRegex)\r
2649                 return true;\r
2650         tr1::wregex pat;\r
2651         return ValidateRegexp(string, pat, false);\r
2652 }\r
2653 \r
2654 void CLogDlg::RecalculateShownList(CPtrArray * pShownlist)\r
2655 {\r
2656 #if 0\r
2657         pShownlist->RemoveAll();\r
2658         tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);\r
2659         bool bRegex = false;\r
2660         if (m_bFilterWithRegex)\r
2661                 bRegex = ValidateRegexp(m_sFilterText, pat, false);\r
2662 \r
2663         tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;\r
2664         CString sRev;\r
2665         for (DWORD i=0; i<m_logEntries.size(); ++i)\r
2666         {\r
2667                 if ((bRegex)&&(m_bFilterWithRegex))\r
2668                 {\r
2669                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))\r
2670                         {\r
2671                                 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);\r
2672                                 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))\r
2673                                 {\r
2674                                         pShownlist->Add(m_logEntries[i]);\r
2675                                         continue;\r
2676                                 }\r
2677                         }\r
2678                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))\r
2679                         {\r
2680                                 ATLTRACE(_T("messge = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sMessage);\r
2681                                 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sMessage), pat, flags)&&IsEntryInDateRange(i))\r
2682                                 {\r
2683                                         pShownlist->Add(m_logEntries[i]);\r
2684                                         continue;\r
2685                                 }\r
2686                         }\r
2687                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))\r
2688                         {\r
2689                                 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;\r
2690 \r
2691                                 bool bGoing = true;\r
2692                                 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)\r
2693                                 {\r
2694                                         LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
2695                                         if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))\r
2696                                         {\r
2697                                                 pShownlist->Add(m_logEntries[i]);\r
2698                                                 bGoing = false;\r
2699                                                 continue;\r
2700                                         }\r
2701                                         if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))\r
2702                                         {\r
2703                                                 pShownlist->Add(m_logEntries[i]);\r
2704                                                 bGoing = false;\r
2705                                                 continue;\r
2706                                         }\r
2707                                         if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))\r
2708                                         {\r
2709                                                 pShownlist->Add(m_logEntries[i]);\r
2710                                                 bGoing = false;\r
2711                                                 continue;\r
2712                                         }\r
2713                                 }\r
2714                                 if (!bGoing)\r
2715                                         continue;\r
2716                         }\r
2717                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))\r
2718                         {\r
2719                                 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sAuthor), pat, flags)&&IsEntryInDateRange(i))\r
2720                                 {\r
2721                                         pShownlist->Add(m_logEntries[i]);\r
2722                                         continue;\r
2723                                 }\r
2724                         }\r
2725                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))\r
2726                         {\r
2727                                 sRev.Format(_T("%ld"), m_logEntries[i]->Rev);\r
2728                                 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))\r
2729                                 {\r
2730                                         pShownlist->Add(m_logEntries[i]);\r
2731                                         continue;\r
2732                                 }\r
2733                         }\r
2734                 } // if (bRegex)\r
2735                 else\r
2736                 {\r
2737                         CString find = m_sFilterText;\r
2738                         find.MakeLower();\r
2739                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))\r
2740                         {\r
2741                                 CString sBugIDs = m_logEntries[i]->sBugIDs;\r
2742 \r
2743                                 sBugIDs = sBugIDs.MakeLower();\r
2744                                 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))\r
2745                                 {\r
2746                                         pShownlist->Add(m_logEntries[i]);\r
2747                                         continue;\r
2748                                 }\r
2749                         }\r
2750                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))\r
2751                         {\r
2752                                 CString msg = m_logEntries[i]->sMessage;\r
2753 \r
2754                                 msg = msg.MakeLower();\r
2755                                 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))\r
2756                                 {\r
2757                                         pShownlist->Add(m_logEntries[i]);\r
2758                                         continue;\r
2759                                 }\r
2760                         }\r
2761                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))\r
2762                         {\r
2763                                 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;\r
2764 \r
2765                                 bool bGoing = true;\r
2766                                 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)\r
2767                                 {\r
2768                                         LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
2769                                         CString path = cpath->sCopyFromPath;\r
2770                                         path.MakeLower();\r
2771                                         if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))\r
2772                                         {\r
2773                                                 pShownlist->Add(m_logEntries[i]);\r
2774                                                 bGoing = false;\r
2775                                                 continue;\r
2776                                         }\r
2777                                         path = cpath->sPath;\r
2778                                         path.MakeLower();\r
2779                                         if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))\r
2780                                         {\r
2781                                                 pShownlist->Add(m_logEntries[i]);\r
2782                                                 bGoing = false;\r
2783                                                 continue;\r
2784                                         }\r
2785                                         path = cpath->GetAction();\r
2786                                         path.MakeLower();\r
2787                                         if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))\r
2788                                         {\r
2789                                                 pShownlist->Add(m_logEntries[i]);\r
2790                                                 bGoing = false;\r
2791                                                 continue;\r
2792                                         }\r
2793                                 }\r
2794                         }\r
2795                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))\r
2796                         {\r
2797                                 CString msg = m_logEntries[i]->sAuthor;\r
2798                                 msg = msg.MakeLower();\r
2799                                 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))\r
2800                                 {\r
2801                                         pShownlist->Add(m_logEntries[i]);\r
2802                                         continue;\r
2803                                 }\r
2804                         }\r
2805                         if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))\r
2806                         {\r
2807                                 sRev.Format(_T("%ld"), m_logEntries[i]->Rev);\r
2808                                 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))\r
2809                                 {\r
2810                                         pShownlist->Add(m_logEntries[i]);\r
2811                                         continue;\r
2812                                 }\r
2813                         }\r
2814                 } // else (from if (bRegex))    \r
2815         } // for (DWORD i=0; i<m_logEntries.size(); ++i) \r
2816 #endif\r
2817 }\r
2818 \r
2819 void CLogDlg::OnTimer(UINT_PTR nIDEvent)\r
2820 {\r
2821         if (nIDEvent == LOGFILTER_TIMER)\r
2822         {\r
2823                 if (this->IsThreadRunning())\r
2824                 {\r
2825                         // thread still running! So just restart the timer.\r
2826                         SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
2827                         return;\r
2828                 }\r
2829                 CWnd * focusWnd = GetFocus();\r
2830                 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))\r
2831                         && (focusWnd != GetDlgItem(IDC_LOGLIST)));\r
2832                 if (m_sFilterText.IsEmpty())\r
2833                 {\r
2834                         DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));\r
2835                         // do not return here!\r
2836                         // we also need to run the filter if the filter text is empty:\r
2837                         // 1. to clear an existing filter\r
2838                         // 2. to rebuild the m_arShownList after sorting\r
2839                 }\r
2840                 theApp.DoWaitCursor(1);\r
2841                 CStoreSelection storeselection(this);\r
2842                 KillTimer(LOGFILTER_TIMER);\r
2843                 FillLogMessageCtrl(false);\r
2844 \r
2845                 // now start filter the log list\r
2846 //              InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
2847                 RecalculateShownList(&m_LogList.m_arShownList);\r
2848 //              InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
2849 \r
2850 \r
2851                 m_LogList.DeleteAllItems();\r
2852                 m_LogList.SetItemCountEx(m_LogList.ShownCountWithStopped());\r
2853                 m_LogList.RedrawItems(0, m_LogList.ShownCountWithStopped());\r
2854                 m_LogList.SetRedraw(false);\r
2855                 m_LogList.ResizeAllListCtrlCols();\r
2856                 m_LogList.SetRedraw(true);\r
2857                 m_LogList.Invalidate();\r
2858                 if ( m_LogList.GetItemCount()==1 )\r
2859                 {\r
2860                         m_LogList.SetSelectionMark(0);\r
2861                         m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);\r
2862                 }\r
2863                 theApp.DoWaitCursor(-1);\r
2864                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
2865                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
2866                 if (bSetFocusToFilterControl)\r
2867                         GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
2868                 UpdateLogInfoLabel();\r
2869         } // if (nIDEvent == LOGFILTER_TIMER)\r
2870         DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));\r
2871         __super::OnTimer(nIDEvent);\r
2872 }\r
2873 \r
2874 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
2875 {\r
2876         CTime _time;\r
2877         m_DateTo.GetTime(_time);\r
2878         try\r
2879         {\r
2880                 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);\r
2881                 if (time.GetTime() != m_tTo)\r
2882                 {\r
2883                         m_tTo = (DWORD)time.GetTime();\r
2884                         SetTimer(LOGFILTER_TIMER, 10, NULL);\r
2885                 }\r
2886         }\r
2887         catch (CAtlException)\r
2888         {\r
2889         }\r
2890         \r
2891         *pResult = 0;\r
2892 }\r
2893 \r
2894 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
2895 {\r
2896         CTime _time;\r
2897         m_DateFrom.GetTime(_time);\r
2898         try\r
2899         {\r
2900                 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);\r
2901                 if (time.GetTime() != m_tFrom)\r
2902                 {\r
2903                         m_tFrom = (DWORD)time.GetTime();\r
2904                         SetTimer(LOGFILTER_TIMER, 10, NULL);\r
2905                 }\r
2906         }\r
2907         catch (CAtlException)\r
2908         {\r
2909         }\r
2910         \r
2911         *pResult = 0;\r
2912 }\r
2913 \r
2914 BOOL CLogDlg::IsEntryInDateRange(int i)\r
2915 {\r
2916 #if 0\r
2917         __time64_t time = m_logEntries[i]->tmDate;\r
2918         if ((time >= m_tFrom)&&(time <= m_tTo))\r
2919                 return TRUE;\r
2920 #endif\r
2921         return FALSE;\r
2922 \r
2923 }\r
2924 \r
2925 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths /* = false */, bool bUseFilter /* = true */)\r
2926 {\r
2927         CTGitPathList pathList;\r
2928 #if 0\r
2929         \r
2930         if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))\r
2931         {\r
2932                 m_sRepositoryRoot = GetRepositoryRoot(m_path);\r
2933         }\r
2934         if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))\r
2935                 return pathList;\r
2936         \r
2937         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
2938         if (pos != NULL)\r
2939         {\r
2940                 while (pos)\r
2941                 {\r
2942                         int nextpos = m_LogList.GetNextSelectedItem(pos);\r
2943                         if (nextpos >= m_arShownList.GetCount())\r
2944                                 continue;\r
2945                         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));\r
2946                         LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
2947                         for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
2948                         {\r
2949                                 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
2950                                 if (cpath == NULL)\r
2951                                         continue;\r
2952                                 CTGitPath path;\r
2953                                 if (!bRelativePaths)\r
2954                                         path.SetFromGit(m_sRepositoryRoot);\r
2955                                 path.AppendPathString(cpath->sPath);\r
2956                                 if ((!bUseFilter)||\r
2957                                         ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||\r
2958                                         (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))\r
2959                                         pathList.AddPath(path);\r
2960                                 \r
2961                         }\r
2962                 }\r
2963         }\r
2964         pathList.RemoveDuplicates();\r
2965 #endif\r
2966         return pathList;\r
2967 }\r
2968 \r
2969 void CLogDlg::SortByColumn(int nSortColumn, bool bAscending)\r
2970 {\r
2971 #if 0\r
2972         switch(nSortColumn)\r
2973         {\r
2974         case 0: // Revision\r
2975                 {\r
2976                         if(bAscending)\r
2977                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataV