OSDN Git Service

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