OSDN Git Service

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