1 // GitLogList.cpp : implementation file
\r
4 Description: qgit revision list view
\r
6 Author: Marco Costalba (C) 2005-2007
\r
8 Copyright: See COPYING file that comes with this distribution
\r
12 #include "TortoiseProc.h"
\r
13 #include "GitLogList.h"
\r
15 //#include "VssStyle.h"
\r
16 #include "IconMenu.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
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
52 IMPLEMENT_DYNAMIC(CGitLogList, CHintListCtrl)
\r
54 CGitLogList::CGitLogList():CHintListCtrl()
\r
55 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
57 ,m_bNoDispUpdates(FALSE)
\r
58 , m_bThreadRunning(FALSE)
\r
59 , m_bStrictStopped(false)
\r
60 , m_pStoreSelection(NULL)
\r
61 , m_nSelectedFilter(LOGFILTER_ALL)
\r
63 // use the default GUI font, create a copy of it and
\r
64 // change the copy to BOLD (leave the rest of the font
\r
66 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
68 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
69 lf.lfWeight = FW_BOLD;
\r
70 m_boldFont = CreateFontIndirect(&lf);
\r
72 m_wcRev.m_CommitHash=GIT_REV_ZERO;
\r
73 m_wcRev.m_Subject=_T("Working Copy");
\r
75 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
76 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
77 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
78 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
80 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
82 g_Git.GetMapHashToFriendName(m_HashMap);
\r
84 m_From=CTime(1970,1,2,0,0,0);
\r
85 m_To=CTime::GetCurrentTime();
\r
88 CGitLogList::~CGitLogList()
\r
90 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
92 DestroyIcon(m_hModifiedIcon);
\r
93 DestroyIcon(m_hReplacedIcon);
\r
94 DestroyIcon(m_hAddedIcon);
\r
95 DestroyIcon(m_hDeletedIcon);
\r
96 m_logEntries.ClearAll();
\r
99 DeleteObject(m_boldFont);
\r
101 if ( m_pStoreSelection )
\r
103 delete m_pStoreSelection;
\r
104 m_pStoreSelection = NULL;
\r
109 BEGIN_MESSAGE_MAP(CGitLogList, CHintListCtrl)
\r
110 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
111 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
112 ON_WM_CONTEXTMENU()
\r
113 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
114 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
118 int CGitLogList:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
120 PreSubclassWindow();
\r
121 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
124 void CGitLogList::PreSubclassWindow()
\r
126 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
127 // load the icons for the action columns
\r
128 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
129 CHintListCtrl::PreSubclassWindow();
\r
132 void CGitLogList::InsertGitColumn()
\r
136 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
140 temp.LoadString(IDS_LOG_GRAPH);
\r
142 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
145 // make the revision column right aligned
\r
147 Column.mask = LVCF_FMT;
\r
148 Column.fmt = LVCFMT_RIGHT;
\r
149 SetColumn(0, &Column);
\r
152 // g_Git.GetLog(log);
\r
154 temp.LoadString(IDS_LOG_ACTIONS);
\r
155 InsertColumn(this->LOGLIST_ACTION, temp);
\r
157 temp.LoadString(IDS_LOG_MESSAGE);
\r
158 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
160 temp.LoadString(IDS_LOG_AUTHOR);
\r
161 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
163 temp.LoadString(IDS_LOG_DATE);
\r
164 InsertColumn(this->LOGLIST_DATE, temp);
\r
167 if (m_bShowBugtraqColumn)
\r
169 // temp = m_ProjectProperties.sLabel;
\r
170 if (temp.IsEmpty())
\r
171 temp.LoadString(IDS_LOG_BUGIDS);
\r
172 InsertColumn(this->LOGLIST_BUG, temp);
\r
177 ResizeAllListCtrlCols();
\r
182 void CGitLogList::ResizeAllListCtrlCols()
\r
185 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
186 int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
187 int nItemCount = GetItemCount();
\r
188 TCHAR textbuf[MAX_PATH];
\r
189 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
192 for (int col = 0; col <= maxcol; col++)
\r
195 hdi.mask = HDI_TEXT;
\r
196 hdi.pszText = textbuf;
\r
197 hdi.cchTextMax = sizeof(textbuf);
\r
198 pHdrCtrl->GetItem(col, &hdi);
\r
199 int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
200 for (int index = 0; index<nItemCount; ++index)
\r
202 // get the width of the string and add 14 pixels for the column separator and margins
\r
203 int linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
204 if (index < m_arShownList.GetCount())
\r
206 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
207 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
209 // set the bold font and ask for the string width again
\r
210 SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
211 linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
212 // restore the system font
\r
213 SendMessage(WM_SETFONT, NULL, NULL);
\r
218 // add the image size
\r
219 CImageList * pImgList = GetImageList(LVSIL_SMALL);
\r
220 if ((pImgList)&&(pImgList->GetImageCount()))
\r
223 pImgList->GetImageInfo(0, &imginfo);
\r
224 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
225 linewidth += 3; // 3 pixels between icon and text
\r
228 if (cx < linewidth)
\r
231 // Adjust columns "Actions" containing icons
\r
232 if (col == this->LOGLIST_ACTION)
\r
234 if (cx < nMinimumWidth)
\r
236 cx = nMinimumWidth;
\r
240 if (col == this->LOGLIST_MESSAGE)
\r
242 if (cx > LOGLIST_MESSAGE_MAX)
\r
244 cx = LOGLIST_MESSAGE_MAX;
\r
246 if (cx < LOGLIST_MESSAGE_MIN)
\r
248 cx = LOGLIST_MESSAGE_MIN;
\r
252 // keep the bug id column small
\r
253 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
255 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
257 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
261 SetColumnWidth(col, cx);
\r
268 BOOL CGitLogList::GetShortName(CString ref, CString &shortname,CString prefix)
\r
270 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
271 if(ref.Left(prefix.GetLength()) == prefix)
\r
273 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
274 if(shortname.Right(3)==_T("^{}"))
\r
275 shortname=shortname.Left(shortname.GetLength()-3);
\r
280 void CGitLogList::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
284 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
285 rItem.mask = LVIF_STATE;
\r
286 rItem.iItem = Index;
\r
287 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
290 if (m_Theme.IsAppThemed() && m_bVista)
\r
292 m_Theme.Open(m_hWnd, L"Explorer");
\r
293 int state = LISS_NORMAL;
\r
294 if (rItem.state & LVIS_SELECTED)
\r
296 if (::GetFocus() == m_hWnd)
\r
297 state |= LISS_SELECTED;
\r
299 state |= LISS_SELECTEDNOTFOCUS;
\r
304 if (pLogEntry->bCopiedSelf)
\r
306 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
307 // information at this drawing stage. But we can check the whether the
\r
308 // previous stage changed the background color of the item
\r
309 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
312 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
315 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
316 ::DeleteObject(brush);
\r
323 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
324 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
326 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
331 if (rItem.state & LVIS_SELECTED)
\r
333 if (::GetFocus() == m_hWnd)
\r
334 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
336 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
340 //if (pLogEntry->bCopiedSelf)
\r
341 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
343 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
348 ::FillRect(hdc, &rect, brush);
\r
349 ::DeleteObject(brush);
\r
354 void CGitLogList::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
356 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
359 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
360 rItem.mask = LVIF_STATE;
\r
361 rItem.iItem = index;
\r
362 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
365 for(int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
368 str=m_HashMap[data->m_CommitHash][i];
\r
373 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
375 brush = ::CreateSolidBrush(RGB(0xff, 0, 0));
\r
376 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
378 brush = ::CreateSolidBrush(RGB(0xff, 0xff, 0));
\r
380 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
382 brush = ::CreateSolidBrush(RGB(0, 0, 0xff));
\r
385 if(!shortname.IsEmpty())
\r
388 memset(&size,0,sizeof(SIZE));
\r
389 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
391 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
393 ::FillRect(hdc, &rt, brush);
\r
394 if (rItem.state & LVIS_SELECTED)
\r
396 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
397 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
398 ::SetTextColor(hdc,clrOld);
\r
401 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
405 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
406 ::LineTo(hdc,rt.right,rt.top);
\r
407 ::LineTo(hdc,rt.right,rt.bottom);
\r
408 ::LineTo(hdc,rt.left,rt.bottom);
\r
409 ::LineTo(hdc,rt.left,rt.top);
\r
411 rt.left=rt.right+3;
\r
414 ::DeleteObject(brush);
\r
416 rt.right=rect.right;
\r
418 if (rItem.state & LVIS_SELECTED)
\r
420 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
421 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
422 ::SetTextColor(hdc,clrOld);
\r
425 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
430 void CGitLogList::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
431 const COLORREF& col,int top
\r
434 int h = laneHeight / 2;
\r
435 int m = (x1 + x2) / 2;
\r
436 int r = (x2 - x1) / 3;
\r
439 #define P_CENTER m , h+top
\r
440 #define P_0 x2, h+top
\r
441 #define P_90 m , 0+top
\r
442 #define P_180 x1, h+top
\r
443 #define P_270 m , 2 * h+top
\r
444 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
446 //static QPen myPen(Qt::black, 2); // fast path here
\r
448 pen.CreatePen(PS_SOLID,2,col);
\r
449 //myPen.setColor(col);
\r
450 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
452 //p->setPen(myPen);
\r
456 case Lanes::ACTIVE:
\r
457 case Lanes::NOT_ACTIVE:
\r
458 case Lanes::MERGE_FORK:
\r
459 case Lanes::MERGE_FORK_R:
\r
460 case Lanes::MERGE_FORK_L:
\r
462 case Lanes::JOIN_R:
\r
463 case Lanes::JOIN_L:
\r
464 DrawLine(hdc,P_90,P_270);
\r
465 //p->drawLine(P_90, P_270);
\r
468 case Lanes::HEAD_R:
\r
469 case Lanes::HEAD_L:
\r
470 case Lanes::BRANCH:
\r
471 DrawLine(hdc,P_CENTER,P_270);
\r
472 //p->drawLine(P_CENTER, P_270);
\r
475 case Lanes::TAIL_R:
\r
476 case Lanes::TAIL_L:
\r
477 case Lanes::INITIAL:
\r
478 case Lanes::BOUNDARY:
\r
479 case Lanes::BOUNDARY_C:
\r
480 case Lanes::BOUNDARY_R:
\r
481 case Lanes::BOUNDARY_L:
\r
482 DrawLine(hdc,P_90, P_CENTER);
\r
483 //p->drawLine(P_90, P_CENTER);
\r
491 case Lanes::MERGE_FORK:
\r
496 case Lanes::CROSS_EMPTY:
\r
497 case Lanes::BOUNDARY_C:
\r
498 DrawLine(hdc,P_180,P_0);
\r
499 //p->drawLine(P_180, P_0);
\r
501 case Lanes::MERGE_FORK_R:
\r
502 case Lanes::JOIN_R:
\r
503 case Lanes::HEAD_R:
\r
504 case Lanes::TAIL_R:
\r
505 case Lanes::BOUNDARY_R:
\r
506 DrawLine(hdc,P_180,P_CENTER);
\r
507 //p->drawLine(P_180, P_CENTER);
\r
509 case Lanes::MERGE_FORK_L:
\r
510 case Lanes::JOIN_L:
\r
511 case Lanes::HEAD_L:
\r
512 case Lanes::TAIL_L:
\r
513 case Lanes::BOUNDARY_L:
\r
514 DrawLine(hdc,P_CENTER,P_0);
\r
515 //p->drawLine(P_CENTER, P_0);
\r
522 brush.CreateSolidBrush(col);
\r
523 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
524 // center symbol, e.g. rect or ellipse
\r
526 case Lanes::ACTIVE:
\r
527 case Lanes::INITIAL:
\r
528 case Lanes::BRANCH:
\r
530 //p->setPen(Qt::NoPen);
\r
531 //p->setBrush(col);
\r
532 ::Ellipse(hdc, R_CENTER);
\r
533 //p->drawEllipse(R_CENTER);
\r
535 case Lanes::MERGE_FORK:
\r
536 case Lanes::MERGE_FORK_R:
\r
537 case Lanes::MERGE_FORK_L:
\r
538 //p->setPen(Qt::NoPen);
\r
539 //p->setBrush(col);
\r
540 //p->drawRect(R_CENTER);
\r
541 Rectangle(hdc,R_CENTER);
\r
543 case Lanes::UNAPPLIED:
\r
545 //p->setPen(Qt::NoPen);
\r
546 //p->setBrush(Qt::red);
\r
547 //p->drawRect(m - r, h - 1, d, 2);
\r
548 ::Rectangle(hdc,m-r,h-1,d,2);
\r
550 case Lanes::APPLIED:
\r
552 //p->setPen(Qt::NoPen);
\r
553 //p->setBrush(DARK_GREEN);
\r
554 //p->drawRect(m - r, h - 1, d, 2);
\r
555 //p->drawRect(m - 1, h - r, 2, d);
\r
556 ::Rectangle(hdc,m-r,h-1,d,2);
\r
557 ::Rectangle(hdc,m-1,h-r,2,d);
\r
559 case Lanes::BOUNDARY:
\r
560 //p->setBrush(back);
\r
561 //p->drawEllipse(R_CENTER);
\r
562 ::Ellipse(hdc, R_CENTER);
\r
564 case Lanes::BOUNDARY_C:
\r
565 case Lanes::BOUNDARY_R:
\r
566 case Lanes::BOUNDARY_L:
\r
567 //p->setBrush(back);
\r
568 //p->drawRect(R_CENTER);
\r
569 ::Rectangle(hdc,R_CENTER);
\r
575 ::SelectObject(hdc,oldpen);
\r
576 ::SelectObject(hdc,oldbrush);
\r
585 void CGitLogList::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
589 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
592 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
593 rItem.mask = LVIF_STATE;
\r
594 rItem.iItem = index;
\r
595 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
598 static const COLORREF colors[Lanes::COLORS_NUM] = { RGB(0,0,0), RGB(0xFF,0,0), RGB(0,0xFF,0),
\r
599 RGB(0,0,0xFF), RGB(128,128,128), RGB(128,128,0),
\r
600 RGB(0,128,128), RGB(128,0,128) };
\r
603 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
607 if (data->m_Lanes.size() == 0)
\r
608 m_logEntries.setLane(data->m_CommitHash);
\r
610 std::vector<int>& lanes=data->m_Lanes;
\r
611 UINT laneNum = lanes.size();
\r
612 UINT mergeLane = 0;
\r
613 for (UINT i = 0; i < laneNum; i++)
\r
614 if (Lanes::isMerge(lanes[i])) {
\r
619 int x1 = 0, x2 = 0;
\r
620 int maxWidth = rect.Width();
\r
621 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
622 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
628 if (ln == Lanes::EMPTY)
\r
631 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
632 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
634 if (ln == Lanes::CROSS) {
\r
635 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
636 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, colors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
638 paintGraphLane(hdc, rect.Height(),ln, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
641 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
644 void CGitLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
647 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
648 // Take the default processing unless we set this to something else below.
\r
649 *pResult = CDRF_DODEFAULT;
\r
651 if (m_bNoDispUpdates)
\r
656 switch (pLVCD->nmcd.dwDrawStage)
\r
658 case CDDS_PREPAINT:
\r
660 *pResult = CDRF_NOTIFYITEMDRAW;
\r
664 case CDDS_ITEMPREPAINT:
\r
666 // This is the prepaint stage for an item. Here's where we set the
\r
667 // item's text color.
\r
669 // Tell Windows to send draw notifications for each subitem.
\r
670 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
672 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
674 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
676 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
680 if (data->bCopiedSelf)
\r
682 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
683 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
684 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
688 crText = m_Colors.GetColor(CColors::Modified);
\r
690 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
691 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
692 // if (data->Rev == m_wcRev)
\r
694 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
695 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
696 // tells the control to recalculate the extent of the text.
\r
697 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
701 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
703 if (m_bStrictStopped)
\r
704 crText = GetSysColor(COLOR_GRAYTEXT);
\r
706 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
707 pLVCD->clrText = crText;
\r
711 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
713 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
715 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
718 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
720 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
723 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
725 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
726 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
728 *pResult = CDRF_SKIPDEFAULT;
\r
734 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
736 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
738 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
739 if(!data->m_IsFull)
\r
741 if(data->SafeFetchFullInfo(&g_Git))
\r
742 this->Invalidate();
\r
743 TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
746 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
750 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
752 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
753 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
755 *pResult = CDRF_SKIPDEFAULT;
\r
762 if (pLVCD->iSubItem == 1)
\r
764 *pResult = CDRF_DODEFAULT;
\r
766 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
770 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
771 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
773 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
775 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
776 // Get the selected state of the
\r
777 // item being drawn.
\r
779 // Fill the background
\r
780 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
782 // Draw the icon(s) into the compatible DC
\r
783 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
784 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
787 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
788 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
791 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
792 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
795 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
796 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
798 *pResult = CDRF_SKIPDEFAULT;
\r
804 *pResult = CDRF_DODEFAULT;
\r
808 // CGitLogList message handlers
\r
810 void CGitLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
812 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
814 // Create a pointer to the item
\r
815 LV_ITEM* pItem = &(pDispInfo)->item;
\r
817 // Do the list need text information?
\r
818 if (!(pItem->mask & LVIF_TEXT))
\r
821 // By default, clear text buffer.
\r
822 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
824 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
827 if (m_bNoDispUpdates || bOutOfRange)
\r
830 // Which item number?
\r
831 int itemid = pItem->iItem;
\r
832 GitRev * pLogEntry = NULL;
\r
833 if (itemid < m_arShownList.GetCount())
\r
834 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
838 switch (pItem->iSubItem)
\r
840 case this->LOGLIST_GRAPH: //Graphic
\r
845 case this->LOGLIST_ACTION: //action -- no text in the column
\r
847 case this->LOGLIST_MESSAGE: //Message
\r
849 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
851 case this->LOGLIST_AUTHOR: //Author
\r
853 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
855 case this->LOGLIST_DATE: //Date
\r
857 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
868 void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
\r
871 int selIndex = GetSelectionMark();
\r
873 return; // nothing selected, nothing to do with a context menu
\r
875 // if the user selected the info text telling about not all revisions shown due to
\r
876 // the "stop on copy/rename" option, we also don't show the context menu
\r
877 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
880 // if the context menu is invoked through the keyboard, we have to use
\r
881 // a calculated position on where to anchor the menu on
\r
882 if ((point.x == -1) && (point.y == -1))
\r
885 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
886 ClientToScreen(&rect);
\r
887 point = rect.CenterPoint();
\r
889 m_nSearchIndex = selIndex;
\r
890 m_bCancelled = FALSE;
\r
892 // calculate some information the context menu commands can use
\r
893 // CString pathURL = GetURLFromPath(m_path);
\r
895 POSITION pos = GetFirstSelectedItemPosition();
\r
896 int indexNext = GetNextSelectedItem(pos);
\r
900 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
902 GitRev revSelected = pSelLogEntry->Rev;
\r
903 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
904 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
906 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
908 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
909 if (changedpath->lCopyFromRev)
\r
910 revPrevious = changedpath->lCopyFromRev;
\r
913 GitRev revSelected2;
\r
916 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
917 revSelected2 = pLogEntry->Rev;
\r
919 bool bAllFromTheSameAuthor = true;
\r
920 CString firstAuthor;
\r
921 CLogDataVector selEntries;
\r
922 GitRev revLowest, revHighest;
\r
923 GitRevRangeArray revisionRanges;
\r
925 POSITION pos = GetFirstSelectedItemPosition();
\r
926 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
927 revisionRanges.AddRevision(pLogEntry->Rev);
\r
928 selEntries.push_back(pLogEntry);
\r
929 firstAuthor = pLogEntry->sAuthor;
\r
930 revLowest = pLogEntry->Rev;
\r
931 revHighest = pLogEntry->Rev;
\r
934 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
935 revisionRanges.AddRevision(pLogEntry->Rev);
\r
936 selEntries.push_back(pLogEntry);
\r
937 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
938 bAllFromTheSameAuthor = false;
\r
939 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
940 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
946 int FirstSelect=-1, LastSelect=-1;
\r
947 pos = GetFirstSelectedItemPosition();
\r
948 FirstSelect = GetNextSelectedItem(pos);
\r
951 LastSelect = GetNextSelectedItem(pos);
\r
953 //entry is selected, now show the popup menu
\r
955 if (popup.CreatePopupMenu())
\r
957 if (GetSelectedCount() == 1)
\r
960 if (!m_path.IsDirectory())
\r
964 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
965 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
967 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
968 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
969 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
970 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
971 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
972 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
973 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
974 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
981 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
983 // TortoiseMerge could be improved to take a /blame switch
\r
984 // and then not 'cat' the files from a unified diff but
\r
986 // But until that's implemented, the context menu entry for
\r
987 // this feature is commented out.
\r
988 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
990 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
991 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
992 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
993 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
996 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
998 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1000 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1002 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1004 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1005 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1007 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1011 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1013 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1015 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1017 popup.AppendMenuIcon(ID_SWITCHTOREV, _T("Switch/Checkout to this") , IDI_SWITCH);
\r
1018 popup.AppendMenuIcon(ID_CREATE_BRANCH, _T("Create Branch at this version") , IDI_COPY);
\r
1019 popup.AppendMenuIcon(ID_CREATE_TAG, _T("Create Tag at this version"), IDI_COPY);
\r
1020 popup.AppendMenuIcon(ID_CHERRY_PICK, _T("Cherry Pick this version"), IDI_EXPORT);
\r
1021 popup.AppendMenuIcon(ID_EXPORT, _T("Export this version"), IDI_EXPORT);
\r
1024 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1026 else if (GetSelectedCount() >= 2)
\r
1028 bool bAddSeparator = false;
\r
1029 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1031 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1033 if (GetSelectedCount() == 2)
\r
1035 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1036 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1037 bAddSeparator = true;
\r
1041 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1043 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1044 bAddSeparator = true;
\r
1046 if (bAddSeparator)
\r
1047 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1050 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1052 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1054 // if (GetSelectedCount() == 1)
\r
1056 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1057 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1058 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1063 if (GetSelectedCount() == 1)
\r
1065 popup.AppendMenuIcon(ID_COPYHASH, _T("Copy Commit Hash"));
\r
1067 if (GetSelectedCount() != 0)
\r
1069 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1071 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1073 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1074 // DialogEnableWindow(IDOK, FALSE);
\r
1075 // SetPromptApp(&theApp);
\r
1076 theApp.DoWaitCursor(1);
\r
1077 bool bOpenWith = false;
\r
1083 CString tempfile=GetTempFile();
\r
1085 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
1086 cmd.Format(_T("git.exe diff-tree -r -p --stat %s"),r1->m_CommitHash);
\r
1087 g_Git.RunLogFile(cmd,tempfile);
\r
1088 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r1->m_Subject);
\r
1094 CString tempfile=GetTempFile();
\r
1096 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
1097 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1098 cmd.Format(_T("git.exe diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash);
\r
1099 g_Git.RunLogFile(cmd,tempfile);
\r
1100 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r2->m_CommitHash.Left(6));
\r
1105 case ID_COMPARETWO:
\r
1107 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
1108 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1110 dlg.SetDiff(NULL,*r1,*r2);
\r
1119 GitRev * r1 = &m_wcRev;
\r
1120 GitRev * r2 = pSelLogEntry;
\r
1122 dlg.SetDiff(NULL,*r1,*r2);
\r
1125 //user clicked on the menu item "compare with working copy"
\r
1126 //if (PromptShown())
\r
1128 // GitDiff diff(this, m_hWnd, true);
\r
1129 // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1130 // diff.SetHEADPeg(m_LogRevision);
\r
1131 // diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
\r
1134 // CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1138 case ID_COMPAREWITHPREVIOUS:
\r
1143 if(pSelLogEntry->m_ParentHash.size()>0)
\r
1144 //if(m_logEntries.m_HashMap[pSelLogEntry->m_ParentHash[0]]>=0)
\r
1146 dlg.SetDiff(NULL,pSelLogEntry->m_CommitHash,pSelLogEntry->m_ParentHash[0]);
\r
1150 CMessageBox::Show(NULL,_T("No previous version"),_T("TortoiseGit"),MB_OK);
\r
1152 //if (PromptShown())
\r
1154 // GitDiff diff(this, m_hWnd, true);
\r
1155 // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1156 // diff.SetHEADPeg(m_LogRevision);
\r
1157 // diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
\r
1160 // CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1163 case ID_COPYCLIPBOARD:
\r
1165 CopySelectionToClipBoard();
\r
1170 CopySelectionToClipBoard(TRUE);
\r
1174 CAppUtils::Export(&pSelLogEntry->m_CommitHash);
\r
1176 case ID_CREATE_BRANCH:
\r
1177 CAppUtils::CreateBranchTag(FALSE,&pSelLogEntry->m_CommitHash);
\r
1178 m_HashMap.clear();
\r
1179 g_Git.GetMapHashToFriendName(m_HashMap);
\r
1182 case ID_CREATE_TAG:
\r
1183 CAppUtils::CreateBranchTag(TRUE,&pSelLogEntry->m_CommitHash);
\r
1184 m_HashMap.clear();
\r
1185 g_Git.GetMapHashToFriendName(m_HashMap);
\r
1188 case ID_SWITCHTOREV:
\r
1189 CAppUtils::Switch(&pSelLogEntry->m_CommitHash);
\r
1190 m_HashMap.clear();
\r
1191 g_Git.GetMapHashToFriendName(m_HashMap);
\r
1196 //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);
\r
1200 case ID_REVERTREV:
\r
1202 // we need an URL to complete this command, so error out if we can't get an URL
\r
1203 if (pathURL.IsEmpty())
\r
1205 CString strMessage;
\r
1206 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
1207 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
1208 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
1212 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
\r
1213 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
1215 CGitProgressDlg dlg;
\r
1216 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
1217 dlg.SetPathList(CTGitPathList(m_path));
\r
1218 dlg.SetUrl(pathURL);
\r
1219 dlg.SetSecondUrl(pathURL);
\r
1220 revisionRanges.AdjustForMerge(true);
\r
1221 dlg.SetRevisionRanges(revisionRanges);
\r
1222 dlg.SetPegRevision(m_LogRevision);
\r
1229 // we need an URL to complete this command, so error out if we can't get an URL
\r
1230 if (pathURL.IsEmpty())
\r
1232 CString strMessage;
\r
1233 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
1234 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
1235 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
1239 CString path = m_path.GetWinPathString();
\r
1240 bool bGotSavePath = false;
\r
1241 if ((GetSelectedCount() == 1)&&(!m_path.IsDirectory()))
\r
1243 bGotSavePath = CAppUtils::FileOpenSave(path, NULL, IDS_LOG_MERGETO, IDS_COMMONFILEFILTER, true, GetSafeHwnd());
\r
1247 CBrowseFolder folderBrowser;
\r
1248 folderBrowser.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_MERGETO)));
\r
1249 bGotSavePath = (folderBrowser.Show(GetSafeHwnd(), path, path) == CBrowseFolder::OK);
\r
1253 CGitProgressDlg dlg;
\r
1254 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
1255 dlg.SetPathList(CTGitPathList(CTGitPath(path)));
\r
1256 dlg.SetUrl(pathURL);
\r
1257 dlg.SetSecondUrl(pathURL);
\r
1258 revisionRanges.AdjustForMerge(false);
\r
1259 dlg.SetRevisionRanges(revisionRanges);
\r
1260 dlg.SetPegRevision(m_LogRevision);
\r
1265 case ID_REVERTTOREV:
\r
1267 // we need an URL to complete this command, so error out if we can't get an URL
\r
1268 if (pathURL.IsEmpty())
\r
1270 CString strMessage;
\r
1271 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
1272 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
1273 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
1278 msg.Format(IDS_LOG_REVERTTOREV_CONFIRM, m_path.GetWinPath());
\r
1279 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
1281 CGitProgressDlg dlg;
\r
1282 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
1283 dlg.SetPathList(CTGitPathList(m_path));
\r
1284 dlg.SetUrl(pathURL);
\r
1285 dlg.SetSecondUrl(pathURL);
\r
1286 GitRevRangeArray revarray;
\r
1287 revarray.AddRevRange(GitRev::REV_HEAD, revSelected);
\r
1288 dlg.SetRevisionRanges(revarray);
\r
1289 dlg.SetPegRevision(m_LogRevision);
\r
1297 case ID_BLAMECOMPARE:
\r
1299 //user clicked on the menu item "compare with working copy"
\r
1300 //now first get the revision which is selected
\r
1301 if (PromptShown())
\r
1303 GitDiff diff(this, this->m_hWnd, true);
\r
1304 diff.SetHEADPeg(m_LogRevision);
\r
1305 diff.ShowCompare(m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), false, true);
\r
1308 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), m_LogRevision, false, false, true);
\r
1313 //user clicked on the menu item "compare and blame revisions"
\r
1314 if (PromptShown())
\r
1316 GitDiff diff(this, this->m_hWnd, true);
\r
1317 diff.SetHEADPeg(m_LogRevision);
\r
1318 diff.ShowCompare(CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
1321 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
1324 case ID_BLAMEWITHPREVIOUS:
\r
1326 //user clicked on the menu item "Compare and Blame with previous revision"
\r
1327 if (PromptShown())
\r
1329 GitDiff diff(this, this->m_hWnd, true);
\r
1330 diff.SetHEADPeg(m_LogRevision);
\r
1331 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
1334 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
1342 CProgressDlg progDlg;
\r
1343 progDlg.SetTitle(IDS_APPNAME);
\r
1344 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1345 CString sInfoLine;
\r
1346 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
1347 progDlg.SetLine(1, sInfoLine, true);
\r
1348 SetAndClearProgressInfo(&progDlg);
\r
1349 progDlg.ShowModeless(m_hWnd);
\r
1350 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, m_path, revSelected);
\r
1351 bool bSuccess = true;
\r
1352 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
1355 // try again, but with the selected revision as the peg revision
\r
1356 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
1359 SetAndClearProgressInfo((HWND)NULL);
\r
1360 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1369 SetAndClearProgressInfo((HWND)NULL);
\r
1370 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1373 ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1374 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
1376 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1377 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1378 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1386 dlg.EndRev = revSelected;
\r
1387 if (dlg.DoModal() == IDOK)
\r
1392 tempfile = blame.BlameToTempFile(m_path, dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
1393 if (!tempfile.IsEmpty())
\r
1395 if (dlg.m_bTextView)
\r
1397 //open the default text editor for the result file
\r
1398 CAppUtils::StartTextViewer(tempfile);
\r
1402 CString sParams = _T("/path:\"") + m_path.GetGitPathString() + _T("\" ");
\r
1403 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(m_path.GetFileOrDirectoryName()),sParams))
\r
1411 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1419 CString url = _T("tgit:")+pathURL;
\r
1420 sCmd.Format(_T("%s /command:update /path:\"%s\" /rev:%ld"),
\r
1421 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1422 (LPCTSTR)m_path.GetWinPath(), (LONG)revSelected);
\r
1423 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1426 case ID_FINDENTRY:
\r
1428 m_nSearchIndex = GetSelectionMark();
\r
1429 if (m_nSearchIndex < 0)
\r
1430 m_nSearchIndex = 0;
\r
1431 if (m_pFindDialog)
\r
1437 m_pFindDialog = new CFindReplaceDialog();
\r
1438 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
1442 case ID_REPOBROWSE:
\r
1445 sCmd.Format(_T("%s /command:repobrowser /path:\"%s\" /rev:%s"),
\r
1446 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1447 (LPCTSTR)pathURL, (LPCTSTR)revSelected.ToString());
\r
1449 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1454 EditLogMessage(selIndex);
\r
1457 case ID_EDITAUTHOR:
\r
1459 EditAuthor(selEntries);
\r
1464 CEditPropertiesDlg dlg;
\r
1465 dlg.SetProjectProperties(&m_ProjectProperties);
\r
1466 CTGitPathList escapedlist;
\r
1467 dlg.SetPathList(CTGitPathList(CTGitPath(pathURL)));
\r
1468 dlg.SetRevision(revSelected);
\r
1469 dlg.RevProps(true);
\r
1477 sCmd.Format(_T("%s /command:export /path:\"%s\" /revision:%ld"),
\r
1478 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1479 (LPCTSTR)pathURL, (LONG)revSelected);
\r
1480 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1486 CString url = _T("tgit:")+pathURL;
\r
1487 sCmd.Format(_T("%s /command:checkout /url:\"%s\" /revision:%ld"),
\r
1488 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1489 (LPCTSTR)url, (LONG)revSelected);
\r
1490 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1495 CString url = m_ProjectProperties.sWebViewerRev;
\r
1496 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1497 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1498 if (!url.IsEmpty())
\r
1499 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1502 case ID_VIEWPATHREV:
\r
1504 CString relurl = pathURL;
\r
1505 CString sRoot = GetRepositoryRoot(CTGitPath(relurl));
\r
1506 relurl = relurl.Mid(sRoot.GetLength());
\r
1507 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
1508 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1509 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1510 url.Replace(_T("%PATH%"), relurl);
\r
1511 if (!url.IsEmpty())
\r
1512 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1518 theApp.DoWaitCursor(-1);
\r
1519 // EnableOKButton();
\r
1520 } // if (popup.CreatePopupMenu())
\r
1524 bool CGitLogList::IsSelectionContinuous()
\r
1526 if ( GetSelectedCount()==1 )
\r
1528 // if only one revision is selected, the selection is of course
\r
1533 POSITION pos = GetFirstSelectedItemPosition();
\r
1534 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1537 int itemindex = GetNextSelectedItem(pos);
\r
1540 int nextindex = GetNextSelectedItem(pos);
\r
1541 if (nextindex - itemindex > 1)
\r
1543 bContinuous = false;
\r
1546 itemindex = nextindex;
\r
1549 return bContinuous;
\r
1552 void CGitLogList::CopySelectionToClipBoard(bool HashOnly)
\r
1555 CString sClipdata;
\r
1556 POSITION pos = GetFirstSelectedItemPosition();
\r
1560 sRev.LoadString(IDS_LOG_REVISION);
\r
1562 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1564 sDate.LoadString(IDS_LOG_DATE);
\r
1566 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1569 CString sLogCopyText;
\r
1571 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1575 //pLogEntry->m_Files
\r
1576 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1578 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1580 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1581 sPaths += _T("\r\n");
\r
1584 sLogCopyText.Format(_T("%s: %s\r\n%s: %s\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),
\r
1585 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1586 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1587 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),
\r
1588 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1590 sClipdata += sLogCopyText;
\r
1593 sClipdata += pLogEntry->m_CommitHash;
\r
1598 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1603 void CGitLogList::DiffSelectedRevWithPrevious()
\r
1606 if (m_bThreadRunning)
\r
1608 UpdateLogInfoLabel();
\r
1609 int selIndex = m_LogList.GetSelectionMark();
\r
1612 int selCount = m_LogList.GetSelectedCount();
\r
1613 if (selCount != 1)
\r
1616 // Find selected entry in the log list
\r
1617 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1618 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1619 long rev1 = pLogEntry->Rev;
\r
1620 long rev2 = rev1-1;
\r
1621 CTGitPath path = m_path;
\r
1623 // See how many files under the relative root were changed in selected revision
\r
1625 LogChangedPath * changed = NULL;
\r
1626 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1628 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1629 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1636 if (m_path.IsDirectory() && nChanged == 1)
\r
1638 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1639 // Do diff on that file instead of whole directory
\r
1640 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1643 m_bCancelled = FALSE;
\r
1644 DialogEnableWindow(IDOK, FALSE);
\r
1645 SetPromptApp(&theApp);
\r
1646 theApp.DoWaitCursor(1);
\r
1648 if (PromptShown())
\r
1650 GitDiff diff(this, m_hWnd, true);
\r
1651 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1652 diff.SetHEADPeg(m_LogRevision);
\r
1653 diff.ShowCompare(path, rev2, path, rev1);
\r
1657 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1660 theApp.DoWaitCursor(-1);
\r
1665 void CGitLogList::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1667 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1670 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1672 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1674 if (pFindInfo->lvfi.psz == 0)
\r
1677 CString sCmp = pFindInfo->lvfi.psz;
\r
1679 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1681 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1682 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1683 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1685 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1693 if (sCmp.Compare(sRev)==0)
\r
1700 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1702 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1704 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1705 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1706 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1708 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1716 if (sCmp.Compare(sRev)==0)
\r
1728 int CGitLogList::FillGitShortLog()
\r
1732 this->m_logEntries.ClearAll();
\r
1733 this->m_logEntries.ParserShortLog();
\r
1735 //this->m_logEntries.ParserFromLog();
\r
1736 SetItemCountEx(this->m_logEntries.size());
\r
1738 this->m_arShownList.RemoveAll();
\r
1740 for(int i=0;i<m_logEntries.size();i++)
\r
1741 this->m_arShownList.Add(&m_logEntries[i]);
\r
1746 BOOL CGitLogList::PreTranslateMessage(MSG* pMsg)
\r
1748 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1749 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1750 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1752 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1754 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1756 DiffSelectedRevWithPrevious();
\r
1761 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1763 DiffSelectedFile();
\r
1770 if (m_hAccel && !bSkipAccelerator)
\r
1772 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1778 //m_tooltips.RelayEvent(pMsg);
\r
1779 return __super::PreTranslateMessage(pMsg);
\r
1782 void CGitLogList::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1784 // a double click on an entry in the revision list has happened
\r
1787 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1788 DiffSelectedRevWithPrevious();
\r
1791 int CGitLogList::FetchLogAsync(CALLBACK_PROCESS *proc,void * data)
\r
1793 m_ProcCallBack=proc;
\r
1796 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1797 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1798 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1800 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1801 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1802 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1808 //this is the thread function which calls the subversion function
\r
1809 UINT CGitLogList::LogThreadEntry(LPVOID pVoid)
\r
1811 return ((CGitLogList*)pVoid)->LogThread();
\r
1814 void CGitLogList::GetTimeRange(CTime &oldest, CTime &latest)
\r
1817 oldest=CTime::GetCurrentTime();
\r
1818 latest=CTime(1971,1,2,0,0,0);
\r
1819 for(int i=0;i<m_logEntries.size();i++)
\r
1821 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1822 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1824 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1825 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1830 UINT CGitLogList::LogThread()
\r
1833 if(m_ProcCallBack)
\r
1834 m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1836 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1837 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1839 //does the user force the cache to refresh (shift or control key down)?
\r
1840 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1841 || (GetKeyState (VK_SHIFT) < 0);
\r
1843 //disable the "Get All" button while we're receiving
\r
1847 temp.LoadString(IDS_PROGRESSWAIT);
\r
1848 ShowText(temp, true);
\r
1850 FillGitShortLog();
\r
1854 RedrawItems(0, m_arShownList.GetCount());
\r
1856 ResizeAllListCtrlCols();
\r
1859 if ( m_pStoreSelection )
\r
1861 // Deleting the instance will restore the
\r
1862 // selection of the CLogDlg.
\r
1863 delete m_pStoreSelection;
\r
1864 m_pStoreSelection = NULL;
\r
1868 // If no selection has been set then this must be the first time
\r
1869 // the revisions are shown. Let's preselect the topmost revision.
\r
1870 if ( GetItemCount()>0 )
\r
1872 SetSelectionMark(0);
\r
1873 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1876 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1883 for(int i=0;i<m_logEntries.size();i++)
\r
1885 if(!m_logEntries.FetchFullInfo(i))
\r
1890 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1891 if(percent == GITLOG_END)
\r
1892 percent == GITLOG_END -1;
\r
1894 if(m_ProcCallBack)
\r
1895 m_ProcCallBack(m_ProcData,percent);
\r
1897 if(updated==m_logEntries.size())
\r
1901 //RefreshCursor();
\r
1902 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1903 // the log messages
\r
1907 if(m_ProcCallBack)
\r
1908 m_ProcCallBack(m_ProcData,GITLOG_END);
\r
1910 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1915 void CGitLogList::Refresh()
\r
1917 if(!m_bThreadRunning)
\r
1919 this->SetItemCountEx(0);
\r
1920 m_logEntries.clear();
\r
1921 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1922 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1923 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1925 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1926 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1927 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1929 m_sFilterText.Empty();
\r
1930 m_From=CTime(1970,1,2,0,0,0);
\r
1931 m_To=CTime::GetCurrentTime();
\r
1934 bool CGitLogList::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1938 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1940 type |= tr1::regex_constants::icase;
\r
1941 pat = tr1::wregex(regexp_str, type);
\r
1944 catch (exception) {}
\r
1948 void CGitLogList::RecalculateShownList(CPtrArray * pShownlist)
\r
1951 pShownlist->RemoveAll();
\r
1952 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1953 bool bRegex = false;
\r
1954 if (m_bFilterWithRegex)
\r
1955 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1957 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1959 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1961 if ((bRegex)&&(m_bFilterWithRegex))
\r
1964 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1966 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1967 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1969 pShownlist->Add(m_logEntries[i]);
\r
1974 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1976 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1977 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1979 pShownlist->Add(&m_logEntries[i]);
\r
1983 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1984 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1986 pShownlist->Add(&m_logEntries[i]);
\r
1991 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1993 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1995 bool bGoing = true;
\r
1996 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1998 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1999 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
2001 pShownlist->Add(m_logEntries[i]);
\r
2005 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
2007 pShownlist->Add(m_logEntries[i]);
\r
2011 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
2013 pShownlist->Add(m_logEntries[i]);
\r
2022 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2024 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
2026 pShownlist->Add(&m_logEntries[i]);
\r
2030 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2032 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
2033 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
2035 pShownlist->Add(&m_logEntries[i]);
\r
2042 CString find = m_sFilterText;
\r
2045 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2047 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
2049 sBugIDs = sBugIDs.MakeLower();
\r
2050 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2052 pShownlist->Add(m_logEntries[i]);
\r
2057 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2059 CString msg = m_logEntries[i].m_Subject;
\r
2061 msg = msg.MakeLower();
\r
2062 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2064 pShownlist->Add(&m_logEntries[i]);
\r
2067 msg = m_logEntries[i].m_Body;
\r
2069 msg = msg.MakeLower();
\r
2070 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2072 pShownlist->Add(&m_logEntries[i]);
\r
2077 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2079 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2081 bool bGoing = true;
\r
2082 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2084 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2085 CString path = cpath->sCopyFromPath;
\r
2087 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2089 pShownlist->Add(m_logEntries[i]);
\r
2093 path = cpath->sPath;
\r
2095 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2097 pShownlist->Add(m_logEntries[i]);
\r
2101 path = cpath->GetAction();
\r
2103 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2105 pShownlist->Add(m_logEntries[i]);
\r
2112 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2114 CString msg = m_logEntries[i].m_AuthorName;
\r
2115 msg = msg.MakeLower();
\r
2116 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2118 pShownlist->Add(&m_logEntries[i]);
\r
2122 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2124 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
2125 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2127 pShownlist->Add(&m_logEntries[i]);
\r
2131 } // else (from if (bRegex))
\r
2132 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2136 BOOL CGitLogList::IsEntryInDateRange(int i)
\r
2138 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2139 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2146 void CGitLogList::StartFilter()
\r
2148 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2149 RecalculateShownList(&m_arShownList);
\r
2150 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2154 SetItemCountEx(ShownCountWithStopped());
\r
2155 RedrawItems(0, ShownCountWithStopped());
\r
2157 //ResizeAllListCtrlCols();
\r
2161 void CGitLogList::RemoveFilter()
\r
2164 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2166 m_arShownList.RemoveAll();
\r
2168 // reset the time filter too
\r
2170 m_timFrom = (__time64_t(m_tFrom));
\r
2171 m_timTo = (__time64_t(m_tTo));
\r
2172 m_DateFrom.SetTime(&m_timFrom);
\r
2173 m_DateTo.SetTime(&m_timTo);
\r
2174 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2175 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2178 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2180 m_arShownList.Add(&m_logEntries[i]);
\r
2182 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2184 SetItemCountEx(ShownCountWithStopped());
\r
2185 RedrawItems(0, ShownCountWithStopped());
\r
2187 ResizeAllListCtrlCols();
\r
2190 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r