OSDN Git Service

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