OSDN Git Service

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