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 "GitLogListBase.h"
\r
14 //#include "VssStyle.h"
\r
15 #include "IconMenu.h"
\r
18 #include "InputDlg.h"
\r
19 #include "PropDlg.h"
\r
20 #include "SVNProgressDlg.h"
\r
21 #include "ProgressDlg.h"
\r
22 //#include "RepositoryBrowser.h"
\r
23 //#include "CopyDlg.h"
\r
24 //#include "StatGraphDlg.h"
\r
26 #include "MessageBox.h"
\r
27 #include "Registry.h"
\r
28 #include "AppUtils.h"
\r
29 #include "PathUtils.h"
\r
30 #include "StringUtils.h"
\r
31 #include "UnicodeUtils.h"
\r
32 #include "TempFile.h"
\r
33 //#include "GitInfo.h"
\r
34 //#include "GitDiff.h"
\r
35 #include "IconMenu.h"
\r
36 //#include "RevisionRangeDlg.h"
\r
37 //#include "BrowseFolder.h"
\r
38 //#include "BlameDlg.h"
\r
39 //#include "Blame.h"
\r
40 //#include "GitHelpers.h"
\r
41 #include "GitStatus.h"
\r
42 //#include "LogDlgHelper.h"
\r
43 //#include "CachedLogInfo.h"
\r
44 //#include "RepositoryInfo.h"
\r
45 //#include "EditPropertiesDlg.h"
\r
46 #include "FileDiffDlg.h"
\r
47 #include "..\\TortoiseShell\\Resource.h"
\r
50 IMPLEMENT_DYNAMIC(CGitLogListBase, CHintListCtrl)
\r
52 CGitLogListBase::CGitLogListBase():CHintListCtrl()
\r
53 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
55 ,m_bNoDispUpdates(FALSE)
\r
56 , m_bThreadRunning(FALSE)
\r
57 , m_bStrictStopped(false)
\r
58 , m_pStoreSelection(NULL)
\r
59 , m_nSelectedFilter(LOGFILTER_ALL)
\r
62 // use the default GUI font, create a copy of it and
\r
63 // change the copy to BOLD (leave the rest of the font
\r
65 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
67 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
68 lf.lfWeight = FW_BOLD;
\r
69 m_boldFont = CreateFontIndirect(&lf);
\r
71 m_bShowBugtraqColumn=0;
\r
73 m_IsIDReplaceAction=FALSE;
\r
75 m_wcRev.m_CommitHash=GIT_REV_ZERO;
\r
76 m_wcRev.m_Subject=_T("Working Copy");
\r
78 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
79 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
80 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
81 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
83 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
85 g_Git.GetMapHashToFriendName(m_HashMap);
\r
86 m_CurrentBranch=g_Git.GetCurrentBranch();
\r
87 this->m_HeadHash=g_Git.GetHash(CString(_T("HEAD"))).Left(40);
\r
89 m_From=CTime(1970,1,2,0,0,0);
\r
90 m_To=CTime::GetCurrentTime();
\r
92 m_LoadingThread = NULL;
\r
94 m_bExitThread=FALSE;
\r
95 m_IsOldFirst = FALSE;
\r
96 m_IsRebaseReplaceGraph = FALSE;
\r
99 for(int i=0;i<Lanes::COLORS_NUM;i++)
\r
101 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
\r
103 // get short/long datetime setting from registry
\r
104 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
\r
105 if ( RegUseShortDateFormat )
\r
107 m_DateFormat = DATE_SHORTDATE;
\r
111 m_DateFormat = DATE_LONGDATE;
\r
113 // get relative time display setting from registry
\r
114 DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);
\r
115 m_bRelativeTimes = (regRelativeTimes != 0);
\r
116 m_ContextMenuMask = 0xFFFFFFFFFFFFFFFF;
\r
118 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_PICK);
\r
119 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SQUASH);
\r
120 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT);
\r
121 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP);
\r
123 OSVERSIONINFOEX inf;
\r
124 SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
\r
125 inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
\r
126 GetVersionEx((OSVERSIONINFO *)&inf);
\r
127 WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);
\r
128 m_bVista = (fullver >= 0x0600);
\r
130 m_ColumnRegKey=_T("log");
\r
133 CGitLogListBase::~CGitLogListBase()
\r
135 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
137 DestroyIcon(m_hModifiedIcon);
\r
138 DestroyIcon(m_hReplacedIcon);
\r
139 DestroyIcon(m_hAddedIcon);
\r
140 DestroyIcon(m_hDeletedIcon);
\r
141 m_logEntries.ClearAll();
\r
144 DeleteObject(m_boldFont);
\r
146 if ( m_pStoreSelection )
\r
148 delete m_pStoreSelection;
\r
149 m_pStoreSelection = NULL;
\r
152 if(this->m_bThreadRunning)
\r
154 m_bExitThread=true;
\r
155 WaitForSingleObject(m_LoadingThread->m_hThread,1000);
\r
161 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
162 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
163 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
164 ON_WM_CONTEXTMENU()
\r
165 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
166 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
169 ON_MESSAGE(MSG_LOADED,OnLoad)
\r
170 ON_WM_MEASUREITEM()
\r
171 ON_WM_MEASUREITEM_REFLECT()
\r
174 void CGitLogListBase::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
\r
176 // TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
\r
178 CListCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
\r
181 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
\r
183 //if (m_nRowHeight>0)
\r
185 lpMeasureItemStruct->itemHeight = 50;
\r
189 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
191 PreSubclassWindow();
\r
192 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
195 void CGitLogListBase::PreSubclassWindow()
\r
197 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
198 // load the icons for the action columns
\r
199 // m_Theme.Open(m_hWnd, L"ListView");
\r
200 m_Theme.Open(m_hWnd, L"Explorer::ListView;ListView");
\r
201 m_Theme.SetWindowTheme(m_hWnd, L"Explorer", NULL);
\r
202 CHintListCtrl::PreSubclassWindow();
\r
205 void CGitLogListBase::InsertGitColumn()
\r
209 int c = GetHeaderCtrl()->GetItemCount()-1;
\r
213 temp.LoadString(IDS_LOG_GRAPH);
\r
215 if(m_IsRebaseReplaceGraph)
\r
221 temp.LoadString(IDS_LOG_GRAPH);
\r
223 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
226 // make the revision column right aligned
\r
228 Column.mask = LVCF_FMT;
\r
229 Column.fmt = LVCFMT_RIGHT;
\r
230 SetColumn(0, &Column);
\r
233 // g_Git.GetLog(log);
\r
235 if(m_IsIDReplaceAction)
\r
237 temp.LoadString(IDS_LOG_ID);
\r
238 InsertColumn(this->LOGLIST_ACTION, temp);
\r
242 temp.LoadString(IDS_LOG_ACTIONS);
\r
243 InsertColumn(this->LOGLIST_ACTION, temp);
\r
245 temp.LoadString(IDS_LOG_MESSAGE);
\r
246 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
248 temp.LoadString(IDS_LOG_AUTHOR);
\r
249 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
251 temp.LoadString(IDS_LOG_DATE);
\r
252 InsertColumn(this->LOGLIST_DATE, temp);
\r
255 if (m_bShowBugtraqColumn)
\r
257 // temp = m_ProjectProperties.sLabel;
\r
258 if (temp.IsEmpty())
\r
259 temp.LoadString(IDS_LOG_BUGIDS);
\r
260 InsertColumn(this->LOGLIST_BUG, temp);
\r
265 ResizeAllListCtrlCols();
\r
271 * Resizes all columns in a list control to values in registry.
\r
273 void CGitLogListBase::ResizeAllListCtrlCols()
\r
275 // column max and min widths to allow
\r
276 static const int nMinimumWidth = 10;
\r
277 static const int nMaximumWidth = 1000;
\r
278 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
281 int numcols = pHdrCtrl->GetItemCount();
\r
282 for (int col = 0; col < numcols; col++)
\r
284 // get width for this col last time from registry
\r
286 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
287 CRegDWORD regwidth(regentry, 0);
\r
291 // no saved value, setup sensible defaults
\r
292 if (col == this->LOGLIST_MESSAGE)
\r
294 cx = LOGLIST_MESSAGE_MIN;
\r
298 cx = ICONITEMBORDER+16*4;
\r
301 if (cx < nMinimumWidth)
\r
303 cx = nMinimumWidth;
\r
304 } else if (cx > nMaximumWidth)
\r
306 cx = nMaximumWidth;
\r
309 SetColumnWidth(col, cx);
\r
316 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
318 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
319 if(ref.Left(prefix.GetLength()) == prefix)
\r
321 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
322 if(shortname.Right(3)==_T("^{}"))
\r
323 shortname=shortname.Left(shortname.GetLength()-3);
\r
329 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
333 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
334 rItem.mask = LVIF_STATE;
\r
335 rItem.iItem = Index;
\r
336 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
339 GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index);
\r
340 HBRUSH brush = NULL;
\r
343 if (m_Theme.IsAppThemed() && m_bVista)
\r
345 int state = LISS_NORMAL;
\r
346 if (rItem.state & LVIS_SELECTED)
\r
348 if (::GetFocus() == m_hWnd)
\r
349 state |= LISS_SELECTED;
\r
351 state |= LISS_SELECTEDNOTFOCUS;
\r
355 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
356 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
357 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
358 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
363 ::FillRect(hdc, &rect, brush);
\r
364 ::DeleteObject(brush);
\r
368 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTITEM, state))
\r
369 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
371 CRect rectDraw = rect;
\r
372 if(rItem.state & LVIS_SELECTED)
\r
373 rectDraw.InflateRect(1,0);
\r
375 rectDraw.InflateRect(1,1);
\r
377 m_Theme.DrawBackground(hdc, LVP_LISTITEM, state, rectDraw, &rect);
\r
383 if (rItem.state & LVIS_SELECTED)
\r
385 if (::GetFocus() == m_hWnd)
\r
386 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
388 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
392 //if (pLogEntry->bCopiedSelf)
\r
393 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
395 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
396 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
397 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
398 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
400 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
405 ::FillRect(hdc, &rect, brush);
\r
406 ::DeleteObject(brush);
\r
411 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
413 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
416 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
417 rItem.mask = LVIF_STATE;
\r
418 rItem.iItem = index;
\r
419 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
422 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
425 str=m_HashMap[data->m_CommitHash][i];
\r
429 shortname = _T("");
\r
430 COLORREF colRef = 0;
\r
432 //Determine label color
\r
433 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
435 if( shortname == m_CurrentBranch )
\r
436 colRef = m_Colors.GetColor(CColors::CurrentBranch);
\r
438 colRef = m_Colors.GetColor(CColors::LocalBranch);
\r
440 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
442 colRef = m_Colors.GetColor(CColors::RemoteBranch);
\r
444 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
446 colRef = m_Colors.GetColor(CColors::Tag);
\r
448 else if(GetShortName(str,shortname,_T("refs/stash")))
\r
450 colRef = m_Colors.GetColor(CColors::Stash);
\r
451 shortname=_T("stash");
\r
454 //When row selected, ajust label color
\r
455 if (!(m_Theme.IsAppThemed() && m_bVista))
\r
456 if (rItem.state & LVIS_SELECTED)
\r
457 colRef = CColors::MixColors(colRef, ::GetSysColor(COLOR_HIGHLIGHT), 150);
\r
459 brush = ::CreateSolidBrush(colRef);
\r
462 if(!shortname.IsEmpty())
\r
465 memset(&size,0,sizeof(SIZE));
\r
466 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
468 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
471 //Fill interior of ref label
\r
472 ::FillRect(hdc, &rt, brush);
\r
474 //Draw edge of label
\r
478 CRect rectEdge = rt;
\r
480 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,100), m_Colors.Darken(colRef,100));
\r
481 rectEdge.DeflateRect(1,1);
\r
482 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,50), m_Colors.Darken(colRef,50));
\r
486 //Draw text inside label
\r
487 if (m_Theme.IsAppThemed() && m_bVista)
\r
489 int txtState = LISS_NORMAL;
\r
490 if (rItem.state & LVIS_SELECTED)
\r
491 txtState = LISS_SELECTED;
\r
493 m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, shortname, -1, DT_CENTER | DT_SINGLELINE | DT_VCENTER, 0, &rt);
\r
497 if (rItem.state & LVIS_SELECTED)
\r
499 COLORREF clrNew = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
\r
500 COLORREF clrOld = ::SetTextColor(hdc,clrNew);
\r
501 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER);
\r
502 ::SetTextColor(hdc,clrOld);
\r
505 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER);
\r
510 //::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
511 //::LineTo(hdc,rt.right,rt.top);
\r
512 //::LineTo(hdc,rt.right,rt.bottom);
\r
513 //::LineTo(hdc,rt.left,rt.bottom);
\r
514 //::LineTo(hdc,rt.left,rt.top);
\r
517 rt.left=rt.right+1;
\r
520 ::DeleteObject(brush);
\r
522 rt.right=rect.right;
\r
524 if (m_Theme.IsAppThemed() && m_bVista)
\r
526 int txtState = LISS_NORMAL;
\r
527 if (rItem.state & LVIS_SELECTED)
\r
528 txtState = LISS_SELECTED;
\r
530 m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, data->m_Subject, -1, DT_LEFT | DT_SINGLELINE | DT_VCENTER, 0, &rt);
\r
534 if (rItem.state & LVIS_SELECTED)
\r
536 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
537 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER);
\r
538 ::SetTextColor(hdc,clrOld);
\r
541 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER);
\r
546 static COLORREF blend(const COLORREF& col1, const COLORREF& col2, int amount = 128) {
\r
548 // Returns ((256 - amount)*col1 + amount*col2) / 256;
\r
549 return RGB(((256 - amount)*GetRValue(col1) + amount*GetRValue(col2) ) / 256,
\r
550 ((256 - amount)*GetGValue(col1) + amount*GetGValue(col2) ) / 256,
\r
551 ((256 - amount)*GetBValue(col1) + amount*GetBValue(col2) ) / 256);
\r
554 Gdiplus::Color GetGdiColor(COLORREF col)
\r
556 return Gdiplus::Color(GetRValue(col),GetGValue(col),GetBValue(col));
\r
558 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
559 const COLORREF& col,const COLORREF& activeColor, int top
\r
562 int h = laneHeight / 2;
\r
563 int m = (x1 + x2) / 2;
\r
564 int r = (x2 - x1) / 3;
\r
567 #define P_CENTER m , h+top
\r
568 #define P_0 x2, h+top
\r
569 #define P_90 m , 0+top
\r
570 #define P_180 x1, h+top
\r
571 #define P_270 m , 2 * h+top
\r
572 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
575 #define DELTA_UR_B 2*(x1 - m), 2*h +top
\r
576 #define DELTA_UR_E 0*16, 90*16 +top // -,
\r
578 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
\r
579 #define DELTA_DR_E 270*16, 90*16 +top // -'
\r
581 #define DELTA_UL_B 2*(x2 - m), 2*h +top
\r
582 #define DELTA_UL_E 90*16, 90*16 +top // ,-
\r
584 #define DELTA_DL_B 2*(x2 - m),2*-h +top
\r
585 #define DELTA_DL_E 180*16, 90*16 // '-
\r
587 #define CENTER_UR x1, 2*h, 225
\r
588 #define CENTER_DR x1, 0 , 135
\r
589 #define CENTER_UL x2, 2*h, 315
\r
590 #define CENTER_DL x2, 0 , 45
\r
593 Gdiplus::Graphics graphics( hdc );
\r
598 case Lanes::JOIN_R:
\r
600 case Lanes::HEAD_R:
\r
602 Gdiplus::LinearGradientBrush gradient(
\r
603 Gdiplus::Point(x1-2, h+top-2),
\r
604 Gdiplus::Point(P_270),
\r
605 GetGdiColor(activeColor),GetGdiColor(col));
\r
608 Gdiplus::Pen mypen(&gradient,2);
\r
609 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
\r
611 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
\r
612 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top+h-1, x2-x1+1,laneHeight+1,270,90);
\r
613 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
\r
617 case Lanes::JOIN_L:
\r
620 Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
\r
623 graphics.DrawArc(&mypen,x1,top+h, x2-x1,laneHeight,270,90);
\r
628 case Lanes::TAIL_R:
\r
631 Gdiplus::LinearGradientBrush gradient(
\r
632 Gdiplus::Point(x1-2, h+top-2),
\r
633 Gdiplus::Point(P_90),
\r
634 GetGdiColor(activeColor),GetGdiColor(col));
\r
637 Gdiplus::Pen mypen(&gradient,2);
\r
639 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top-h-1, x2-x1+1,laneHeight+1,0,90);
\r
643 QConicalGradient gradient(CENTER_DR);
\r
644 gradient.setColorAt(0.375, activeCol);
\r
645 gradient.setColorAt(0.625, col);
\r
646 myPen.setBrush(gradient);
\r
648 p->drawArc(P_CENTER, DELTA_DR);
\r
657 //static QPen myPen(Qt::black, 2); // fast path here
\r
659 pen.CreatePen(PS_SOLID,2,col);
\r
660 //myPen.setColor(col);
\r
661 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
663 Gdiplus::Pen myPen(GetGdiColor(col),2);
\r
665 //p->setPen(myPen);
\r
669 case Lanes::ACTIVE:
\r
670 case Lanes::NOT_ACTIVE:
\r
671 case Lanes::MERGE_FORK:
\r
672 case Lanes::MERGE_FORK_R:
\r
673 case Lanes::MERGE_FORK_L:
\r
675 case Lanes::JOIN_R:
\r
676 case Lanes::JOIN_L:
\r
678 //DrawLine(hdc,P_90,P_270);
\r
679 graphics.DrawLine(&myPen,P_90,P_270);
\r
680 //p->drawLine(P_90, P_270);
\r
682 case Lanes::HEAD_L:
\r
683 case Lanes::BRANCH:
\r
684 //DrawLine(hdc,P_CENTER,P_270);
\r
685 graphics.DrawLine(&myPen,P_CENTER,P_270);
\r
686 //p->drawLine(P_CENTER, P_270);
\r
688 case Lanes::TAIL_L:
\r
689 case Lanes::INITIAL:
\r
690 case Lanes::BOUNDARY:
\r
691 case Lanes::BOUNDARY_C:
\r
692 case Lanes::BOUNDARY_R:
\r
693 case Lanes::BOUNDARY_L:
\r
694 //DrawLine(hdc,P_90, P_CENTER);
\r
695 graphics.DrawLine(&myPen,P_90,P_CENTER);
\r
696 //p->drawLine(P_90, P_CENTER);
\r
702 myPen.SetColor(GetGdiColor(activeColor));
\r
706 case Lanes::MERGE_FORK:
\r
711 case Lanes::CROSS_EMPTY:
\r
712 case Lanes::BOUNDARY_C:
\r
713 //DrawLine(hdc,P_180,P_0);
\r
714 graphics.DrawLine(&myPen,P_180,P_0);
\r
715 //p->drawLine(P_180, P_0);
\r
717 case Lanes::MERGE_FORK_R:
\r
718 case Lanes::BOUNDARY_R:
\r
719 //DrawLine(hdc,P_180,P_CENTER);
\r
720 graphics.DrawLine(&myPen,P_180,P_CENTER);
\r
721 //p->drawLine(P_180, P_CENTER);
\r
723 case Lanes::MERGE_FORK_L:
\r
724 case Lanes::HEAD_L:
\r
725 case Lanes::TAIL_L:
\r
726 case Lanes::BOUNDARY_L:
\r
727 //DrawLine(hdc,P_CENTER,P_0);
\r
728 graphics.DrawLine(&myPen,P_CENTER,P_0);
\r
729 //p->drawLine(P_CENTER, P_0);
\r
736 brush.CreateSolidBrush(col);
\r
737 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
738 // center symbol, e.g. rect or ellipse
\r
740 case Lanes::ACTIVE:
\r
741 case Lanes::INITIAL:
\r
742 case Lanes::BRANCH:
\r
744 //p->setPen(Qt::NoPen);
\r
745 //p->setBrush(col);
\r
746 ::Ellipse(hdc, R_CENTER);
\r
747 //p->drawEllipse(R_CENTER);
\r
749 case Lanes::MERGE_FORK:
\r
750 case Lanes::MERGE_FORK_R:
\r
751 case Lanes::MERGE_FORK_L:
\r
752 //p->setPen(Qt::NoPen);
\r
753 //p->setBrush(col);
\r
754 //p->drawRect(R_CENTER);
\r
755 Rectangle(hdc,R_CENTER);
\r
757 case Lanes::UNAPPLIED:
\r
759 //p->setPen(Qt::NoPen);
\r
760 //p->setBrush(Qt::red);
\r
761 //p->drawRect(m - r, h - 1, d, 2);
\r
762 ::Rectangle(hdc,m-r,h-1,d,2);
\r
764 case Lanes::APPLIED:
\r
766 //p->setPen(Qt::NoPen);
\r
767 //p->setBrush(DARK_GREEN);
\r
768 //p->drawRect(m - r, h - 1, d, 2);
\r
769 //p->drawRect(m - 1, h - r, 2, d);
\r
770 ::Rectangle(hdc,m-r,h-1,d,2);
\r
771 ::Rectangle(hdc,m-1,h-r,2,d);
\r
773 case Lanes::BOUNDARY:
\r
774 //p->setBrush(back);
\r
775 //p->drawEllipse(R_CENTER);
\r
776 ::Ellipse(hdc, R_CENTER);
\r
778 case Lanes::BOUNDARY_C:
\r
779 case Lanes::BOUNDARY_R:
\r
780 case Lanes::BOUNDARY_L:
\r
781 //p->setBrush(back);
\r
782 //p->drawRect(R_CENTER);
\r
783 ::Rectangle(hdc,R_CENTER);
\r
789 ::SelectObject(hdc,oldpen);
\r
790 ::SelectObject(hdc,oldbrush);
\r
799 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
803 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
804 if(data->m_CommitHash.IsEmpty())
\r
809 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
810 rItem.mask = LVIF_STATE;
\r
811 rItem.iItem = index;
\r
812 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
816 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
820 if (data->m_Lanes.size() == 0)
\r
821 m_logEntries.setLane(data->m_CommitHash);
\r
823 std::vector<int>& lanes=data->m_Lanes;
\r
824 UINT laneNum = lanes.size();
\r
825 UINT activeLane = 0;
\r
826 for (UINT i = 0; i < laneNum; i++)
\r
827 if (Lanes::isMerge(lanes[i])) {
\r
832 int x1 = 0, x2 = 0;
\r
833 int maxWidth = rect.Width();
\r
834 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
836 COLORREF activeColor = m_LineColors[activeLane % Lanes::COLORS_NUM];
\r
837 //if (opt.state & QStyle::State_Selected)
\r
838 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
\r
841 for (unsigned int i = 0; i < laneNum && x2 < maxWidth; i++)
\r
848 if (ln == Lanes::EMPTY)
\r
851 COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM];
\r
852 paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top);
\r
856 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
862 if (ln == Lanes::EMPTY)
\r
865 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
866 || ln ==Lanes:: CROSS_EMPTY) ? activeLane : i;
\r
868 if (ln == Lanes::CROSS) {
\r
869 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
870 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[activeLane % Lanes::COLORS_NUM],rect.top);
\r
872 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
878 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
881 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
882 // Take the default processing unless we set this to something else below.
\r
883 *pResult = CDRF_DODEFAULT;
\r
885 if (m_bNoDispUpdates)
\r
890 switch (pLVCD->nmcd.dwDrawStage)
\r
892 case CDDS_PREPAINT:
\r
894 *pResult = CDRF_NOTIFYITEMDRAW;
\r
898 case CDDS_ITEMPREPAINT:
\r
900 // This is the prepaint stage for an item. Here's where we set the
\r
901 // item's text color.
\r
903 // Tell Windows to send draw notifications for each subitem.
\r
904 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
906 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
908 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
910 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
914 if (data->bCopiedSelf)
\r
916 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
917 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
918 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
922 crText = m_Colors.GetColor(CColors::Modified);
\r
924 if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
\r
925 crText = RGB(128,128,128);
\r
927 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
928 pLVCD->clrTextBk = RGB(156,156,156);
\r
929 else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
930 pLVCD->clrTextBk = RGB(200,200,128);
\r
932 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
\r
934 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)
\r
936 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
937 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
940 if(data->m_CommitHash == m_HeadHash)
\r
942 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
943 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
946 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
947 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
948 // if (data->Rev == m_wcRev)
\r
950 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
951 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
952 // tells the control to recalculate the extent of the text.
\r
953 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
957 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
959 if (m_bStrictStopped)
\r
960 crText = GetSysColor(COLOR_GRAYTEXT);
\r
962 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
963 pLVCD->clrText = crText;
\r
967 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
969 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
971 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
974 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
976 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
\r
979 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
980 if(pLVCD->iSubItem == 0)
\r
983 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem+1, LVIR_BOUNDS, second);
\r
984 rect.right=second.left;
\r
987 TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
\r
988 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
989 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
991 *pResult = CDRF_SKIPDEFAULT;
\r
997 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
999 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1001 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
1002 //if(!data->m_IsFull)
\r
1004 //if(data->SafeFetchFullInfo(&g_Git))
\r
1005 // this->Invalidate();
\r
1006 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
1009 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
1013 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
1015 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
1016 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
1018 *pResult = CDRF_SKIPDEFAULT;
\r
1025 if (pLVCD->iSubItem == 1)
\r
1027 if(this->m_IsIDReplaceAction)
\r
1029 *pResult = CDRF_DODEFAULT;
\r
1032 *pResult = CDRF_DODEFAULT;
\r
1034 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1038 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
1039 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
1041 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
1043 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
1044 TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
\r
1045 // Get the selected state of the
\r
1046 // item being drawn.
\r
1048 // Fill the background
\r
1049 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
1051 // Draw the icon(s) into the compatible DC
\r
1052 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
1053 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1056 if (pLogEntry->m_Action & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
\r
1057 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1060 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
1061 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1064 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
1065 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1067 *pResult = CDRF_SKIPDEFAULT;
\r
1073 *pResult = CDRF_DODEFAULT;
\r
1077 // CGitLogListBase message handlers
\r
1079 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1081 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
1083 // Create a pointer to the item
\r
1084 LV_ITEM* pItem = &(pDispInfo)->item;
\r
1086 // Do the list need text information?
\r
1087 if (!(pItem->mask & LVIF_TEXT))
\r
1090 // By default, clear text buffer.
\r
1091 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
1093 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
1096 if (m_bNoDispUpdates || bOutOfRange)
\r
1099 // Which item number?
\r
1100 int itemid = pItem->iItem;
\r
1101 GitRev * pLogEntry = NULL;
\r
1102 if (itemid < m_arShownList.GetCount())
\r
1103 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
1108 temp.Format(_T("%d"),pItem->iItem+1);
\r
1112 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
1116 switch (pItem->iSubItem)
\r
1118 case this->LOGLIST_GRAPH: //Graphic
\r
1121 if(this->m_IsRebaseReplaceGraph)
\r
1124 path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
\r
1126 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
\r
1130 case this->LOGLIST_ACTION: //action -- no text in the column
\r
1131 if(this->m_IsIDReplaceAction)
\r
1132 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
1134 case this->LOGLIST_MESSAGE: //Message
\r
1136 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
1138 case this->LOGLIST_AUTHOR: //Author
\r
1140 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
1142 case this->LOGLIST_DATE: //Date
\r
1144 lstrcpyn(pItem->pszText,
\r
1145 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1146 pItem->cchTextMax);
\r
1157 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
1160 int selIndex = GetSelectionMark();
\r
1162 return; // nothing selected, nothing to do with a context menu
\r
1164 // if the user selected the info text telling about not all revisions shown due to
\r
1165 // the "stop on copy/rename" option, we also don't show the context menu
\r
1166 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
1169 // if the context menu is invoked through the keyboard, we have to use
\r
1170 // a calculated position on where to anchor the menu on
\r
1171 if ((point.x == -1) && (point.y == -1))
\r
1174 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
1175 ClientToScreen(&rect);
\r
1176 point = rect.CenterPoint();
\r
1178 m_nSearchIndex = selIndex;
\r
1179 m_bCancelled = FALSE;
\r
1181 // calculate some information the context menu commands can use
\r
1182 // CString pathURL = GetURLFromPath(m_path);
\r
1184 POSITION pos = GetFirstSelectedItemPosition();
\r
1185 int indexNext = GetNextSelectedItem(pos);
\r
1186 if (indexNext < 0)
\r
1189 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
1191 GitRev revSelected = pSelLogEntry->Rev;
\r
1192 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
1193 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
1195 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
1197 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
1198 if (changedpath->lCopyFromRev)
\r
1199 revPrevious = changedpath->lCopyFromRev;
\r
1202 GitRev revSelected2;
\r
1205 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1206 revSelected2 = pLogEntry->Rev;
\r
1208 bool bAllFromTheSameAuthor = true;
\r
1209 CString firstAuthor;
\r
1210 CLogDataVector selEntries;
\r
1211 GitRev revLowest, revHighest;
\r
1212 GitRevRangeArray revisionRanges;
\r
1214 POSITION pos = GetFirstSelectedItemPosition();
\r
1215 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1216 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1217 selEntries.push_back(pLogEntry);
\r
1218 firstAuthor = pLogEntry->sAuthor;
\r
1219 revLowest = pLogEntry->Rev;
\r
1220 revHighest = pLogEntry->Rev;
\r
1223 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1224 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1225 selEntries.push_back(pLogEntry);
\r
1226 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
1227 bAllFromTheSameAuthor = false;
\r
1228 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
1229 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
1235 int FirstSelect=-1, LastSelect=-1;
\r
1236 pos = GetFirstSelectedItemPosition();
\r
1237 FirstSelect = GetNextSelectedItem(pos);
\r
1240 LastSelect = GetNextSelectedItem(pos);
\r
1242 //entry is selected, now show the popup menu
\r
1244 CIconMenu submenu;
\r
1245 if (popup.CreatePopupMenu())
\r
1248 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
\r
1249 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_PICK, IDI_PICK);
\r
1251 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
\r
1252 popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH);
\r
1254 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
\r
1255 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
\r
1257 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
\r
1258 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
\r
1260 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
\r
1261 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
\r
1262 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1264 if (GetSelectedCount() == 1)
\r
1269 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))
\r
1270 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1272 // TortoiseMerge could be improved to take a /blame switch
\r
1273 // and then not 'cat' the files from a unified diff but
\r
1275 // But until that's implemented, the context menu entry for
\r
1276 // this feature is commented out.
\r
1277 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1279 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))
\r
1280 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1282 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
\r
1283 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1284 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1285 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1288 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1290 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1292 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1294 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1296 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1297 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1299 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1303 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1305 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1307 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1309 CString str,format;
\r
1310 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
\r
1311 str.Format(format,g_Git.GetCurrentBranch());
\r
1313 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))
\r
1314 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1316 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))
\r
1317 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
\r
1319 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
\r
1320 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
\r
1322 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
\r
1323 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);
\r
1325 format.LoadString(IDS_REBASE_THIS_FORMAT);
\r
1326 str.Format(format,g_Git.GetCurrentBranch());
\r
1328 if(pSelLogEntry->m_CommitHash != m_HeadHash)
\r
1329 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
\r
1330 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
\r
1332 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
\r
1333 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
\r
1336 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1340 if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1)
\r
1342 popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE);
\r
1343 popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE);
\r
1344 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1347 if (GetSelectedCount() >= 2)
\r
1349 bool bAddSeparator = false;
\r
1350 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1352 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO))
\r
1353 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1356 if (GetSelectedCount() == 2)
\r
1358 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1359 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2))
\r
1360 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1361 bAddSeparator = true;
\r
1366 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1368 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1369 bAddSeparator = true;
\r
1371 if (bAddSeparator)
\r
1372 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1375 if ( GetSelectedCount() >0 )
\r
1377 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
\r
1379 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT))
\r
1383 headindex = this->GetHeadIndex();
\r
1386 head.Format(_T("HEAD~%d"),LastSelect-headindex);
\r
1387 CString hash=g_Git.GetHash(head);
\r
1388 hash=hash.Left(40);
\r
1389 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1390 if(pLastEntry->m_CommitHash == hash)
\r
1391 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
\r
1395 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))
\r
1396 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
\r
1398 if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))
\r
1399 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH))
\r
1400 popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH);
\r
1402 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1408 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1410 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1412 // if (GetSelectedCount() == 1)
\r
1414 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1415 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1416 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1421 if (GetSelectedCount() == 1)
\r
1423 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
\r
1424 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH);
\r
1426 if (GetSelectedCount() != 0)
\r
1428 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
\r
1429 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1432 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
\r
1433 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1436 if (GetSelectedCount() == 1)
\r
1438 if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE))
\r
1440 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() )
\r
1443 str.LoadString(IDS_DELETE_BRANCHTAG);
\r
1444 if( m_HashMap[pSelLogEntry->m_CommitHash].size() == 1 )
\r
1447 str+=m_HashMap[pSelLogEntry->m_CommitHash].at(0);
\r
1448 popup.AppendMenuIcon(ID_DELETE,str+_T("..."),IDI_DELETE);
\r
1450 else if( m_HashMap[pSelLogEntry->m_CommitHash].size() > 1 )
\r
1453 submenu.CreatePopupMenu();
\r
1454 for(int i=0;i<m_HashMap[pSelLogEntry->m_CommitHash].size();i++)
\r
1456 submenu.AppendMenuIcon(ID_DELETE+(i<<16),m_HashMap[pSelLogEntry->m_CommitHash][i]+_T("..."));
\r
1459 popup.AppendMenu(MF_BYPOSITION|MF_POPUP|MF_STRING,(UINT) submenu.m_hMenu,str);
\r
1467 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1468 // DialogEnableWindow(IDOK, FALSE);
\r
1469 // SetPromptApp(&theApp);
\r
1471 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1473 // EnableOKButton();
\r
1474 } // if (popup.CreatePopupMenu())
\r
1478 bool CGitLogListBase::IsSelectionContinuous()
\r
1480 if ( GetSelectedCount()==1 )
\r
1482 // if only one revision is selected, the selection is of course
\r
1487 POSITION pos = GetFirstSelectedItemPosition();
\r
1488 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1491 int itemindex = GetNextSelectedItem(pos);
\r
1494 int nextindex = GetNextSelectedItem(pos);
\r
1495 if (nextindex - itemindex > 1)
\r
1497 bContinuous = false;
\r
1500 itemindex = nextindex;
\r
1503 return bContinuous;
\r
1506 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1509 CString sClipdata;
\r
1510 POSITION pos = GetFirstSelectedItemPosition();
\r
1514 sRev.LoadString(IDS_LOG_REVISION);
\r
1516 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1518 sDate.LoadString(IDS_LOG_DATE);
\r
1520 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1523 CString sLogCopyText;
\r
1525 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1529 //pLogEntry->m_Files
\r
1530 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1532 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1534 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1535 sPaths += _T("\r\n");
\r
1538 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
1539 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1540 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1542 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1543 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1545 sClipdata += sLogCopyText;
\r
1548 sClipdata += pLogEntry->m_CommitHash;
\r
1553 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1558 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1560 if (m_bThreadRunning)
\r
1563 int FirstSelect=-1, LastSelect=-1;
\r
1564 POSITION pos = GetFirstSelectedItemPosition();
\r
1565 FirstSelect = GetNextSelectedItem(pos);
\r
1568 LastSelect = GetNextSelectedItem(pos);
\r
1571 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect);
\r
1574 UpdateLogInfoLabel();
\r
1575 int selIndex = m_LogList.GetSelectionMark();
\r
1578 int selCount = m_LogList.GetSelectedCount();
\r
1579 if (selCount != 1)
\r
1582 // Find selected entry in the log list
\r
1583 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1584 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1585 long rev1 = pLogEntry->Rev;
\r
1586 long rev2 = rev1-1;
\r
1587 CTGitPath path = m_path;
\r
1589 // See how many files under the relative root were changed in selected revision
\r
1591 LogChangedPath * changed = NULL;
\r
1592 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1594 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1595 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1602 if (m_path.IsDirectory() && nChanged == 1)
\r
1604 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1605 // Do diff on that file instead of whole directory
\r
1606 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1609 m_bCancelled = FALSE;
\r
1610 DialogEnableWindow(IDOK, FALSE);
\r
1611 SetPromptApp(&theApp);
\r
1612 theApp.DoWaitCursor(1);
\r
1614 if (PromptShown())
\r
1616 GitDiff diff(this, m_hWnd, true);
\r
1617 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1618 diff.SetHEADPeg(m_LogRevision);
\r
1619 diff.ShowCompare(path, rev2, path, rev1);
\r
1623 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1626 theApp.DoWaitCursor(-1);
\r
1631 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1633 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1636 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1638 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1640 if (pFindInfo->lvfi.psz == 0)
\r
1643 CString sCmp = pFindInfo->lvfi.psz;
\r
1645 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1647 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1648 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1649 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1651 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1659 if (sCmp.Compare(sRev)==0)
\r
1666 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1668 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1670 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1671 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1672 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1674 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1682 if (sCmp.Compare(sRev)==0)
\r
1694 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
\r
1698 this->m_logEntries.ClearAll();
\r
1699 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
\r
1701 //this->m_logEntries.ParserFromLog();
\r
1702 SetItemCountEx(this->m_logEntries.size());
\r
1704 this->m_arShownList.RemoveAll();
\r
1706 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1710 m_logEntries[m_logEntries.size()-i-1].m_IsFull=TRUE;
\r
1711 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
1715 m_logEntries[i].m_IsFull=TRUE;
\r
1716 this->m_arShownList.Add(&m_logEntries[i]);
\r
1726 int CGitLogListBase::FillGitShortLog()
\r
1730 this->m_logEntries.ClearAll();
\r
1732 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1735 if(this->m_Path.IsEmpty())
\r
1738 path=&this->m_Path;
\r
1742 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1743 // if(this->m_bAllBranch)
\r
1744 mask |= m_ShowMask;
\r
1746 this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask);
\r
1748 //this->m_logEntries.ParserFromLog();
\r
1749 if(IsInWorkingThread())
\r
1750 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
\r
1752 SetItemCountEx(this->m_logEntries.size());
\r
1754 this->m_arShownList.RemoveAll();
\r
1756 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1758 m_logEntries[i].m_Subject=_T("parser...");
\r
1759 if(this->m_IsOldFirst)
\r
1761 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);
\r
1765 this->m_arShownList.Add(&m_logEntries[i]);
\r
1771 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1773 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1774 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1775 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1777 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1779 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1781 DiffSelectedRevWithPrevious();
\r
1786 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1788 DiffSelectedFile();
\r
1795 if (m_hAccel && !bSkipAccelerator)
\r
1797 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1803 //m_tooltips.RelayEvent(pMsg);
\r
1804 return __super::PreTranslateMessage(pMsg);
\r
1807 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1809 // a double click on an entry in the revision list has happened
\r
1812 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1813 DiffSelectedRevWithPrevious();
\r
1816 int CGitLogListBase::FetchLogAsync(void * data)
\r
1819 m_bExitThread=FALSE;
\r
1820 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1821 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1822 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1823 if (m_LoadingThread ==NULL)
\r
1825 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1826 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1827 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1833 //this is the thread function which calls the subversion function
\r
1834 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1836 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1839 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1842 oldest=CTime::GetCurrentTime();
\r
1843 latest=CTime(1971,1,2,0,0,0);
\r
1844 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1846 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1847 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1849 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1850 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1855 //Helper class for FetchFullLogInfo()
\r
1856 class CGitCall_FetchFullLogInfo : public CGitCall
\r
1859 CGitCall_FetchFullLogInfo(CGitLogListBase* ploglist):m_ploglist(ploglist),m_CollectedCount(0){}
\r
1860 virtual bool OnOutputData(const BYTE* data, size_t size)
\r
1863 return m_ploglist->m_bExitThread;
\r
1864 //Add received data to byte collector
\r
1865 m_ByteCollector.append(data,size);
\r
1867 //Find loginfo endmarker
\r
1868 static const BYTE dataToFind[]={0,0,'#','<'};
\r
1869 int found=m_ByteCollector.findData(dataToFind,4);
\r
1871 return m_ploglist->m_bExitThread;//Not found
\r
1872 found+=2;//Position after loginfo end-marker
\r
1874 //Prepare data for OnLogInfo and call it
\r
1875 BYTE_VECTOR logInfo;
\r
1876 logInfo.append(&*m_ByteCollector.begin(),found);
\r
1877 OnLogInfo(logInfo);
\r
1879 //Remove loginfo from bytecollector
\r
1880 m_ByteCollector.erase(m_ByteCollector.begin(),m_ByteCollector.begin()+found);
\r
1882 return m_ploglist->m_bExitThread;
\r
1884 virtual void OnEnd()
\r
1886 //Rest should be a complete log line.
\r
1887 if(!m_ByteCollector.empty())
\r
1888 OnLogInfo(m_ByteCollector);
\r
1892 void OnLogInfo(BYTE_VECTOR& logInfo)
\r
1895 fullRev.ParserFromLog(logInfo);
\r
1896 MAP_HASH_REV::iterator itRev=m_ploglist->m_logEntries.m_HashMap.find(fullRev.m_CommitHash);
\r
1897 if(itRev==m_ploglist->m_logEntries.m_HashMap.end())
\r
1899 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
\r
1903 int rev=itRev->second;
\r
1904 GitRev* revInVector=&m_ploglist->m_logEntries[rev];
\r
1907 if(revInVector->m_IsFull)
\r
1910 if(!m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev]))
\r
1912 ++m_CollectedCount;
\r
1913 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsUpdateing,FALSE);
\r
1914 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsFull,TRUE);
\r
1915 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1919 // fullRev.m_IsUpdateing=TRUE;
\r
1920 // fullRev.m_IsFull=TRUE;
\r
1923 if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE))
\r
1924 return;//Cannot update this row now. Ignore.
\r
1925 TCHAR oldmark=revInVector->m_Mark;
\r
1926 GIT_REV_LIST oldlist=revInVector->m_ParentHash;
\r
1927 // CString oldhash=m_CommitHash;
\r
1929 //Parse new rev info
\r
1930 revInVector->ParserFromLog(logInfo);
\r
1933 revInVector->m_Mark=oldmark; //parser full log will cause old mark overwrited.
\r
1934 //So we need keep old bound mark.
\r
1935 revInVector->m_ParentHash=oldlist;
\r
1938 m_ploglist->m_LogCache.AddCacheEntry(*revInVector);
\r
1941 InterlockedExchange(&revInVector->m_IsFull,TRUE);
\r
1942 InterlockedExchange(&revInVector->m_IsUpdateing,FALSE);
\r
1944 //Notify listcontrol and update progress bar
\r
1945 ++m_CollectedCount;
\r
1947 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1949 DWORD percent=m_CollectedCount*68/m_ploglist->m_logEntries.size() + GITLOG_START+1+30;
\r
1950 if(percent == GITLOG_END)
\r
1951 percent = GITLOG_END -1;
\r
1953 ::PostMessage(m_ploglist->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1956 CGitLogListBase* m_ploglist;
\r
1957 BYTE_VECTOR m_ByteCollector;
\r
1958 int m_CollectedCount;
\r
1962 void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to)
\r
1964 CGitCall_FetchFullLogInfo fetcher(this);
\r
1966 CGit::LOG_INFO_STAT|
\r
1967 CGit::LOG_INFO_FILESTATE|
\r
1968 CGit::LOG_INFO_DETECT_COPYRENAME|
\r
1969 CGit::LOG_INFO_SHOW_MERGEDFILE |
\r
1973 if(this->m_Path.IsEmpty())
\r
1976 path=&this->m_Path;
\r
1978 g_Git.GetLog(&fetcher,CString(),path,-1,mask,&from,&to);
\r
1981 void CGitLogListBase::FetchLastLogInfo()
\r
1983 unsigned int updated=0;
\r
1987 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1989 if(m_logEntries[i].m_IsFull)
\r
1992 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1994 if(!m_logEntries.FetchFullInfo(i))
\r
1998 m_LogCache.AddCacheEntry(m_logEntries[i]);
\r
2003 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
2004 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
2007 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
\r
2011 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2012 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2019 UINT CGitLogListBase::LogThread()
\r
2022 // if(m_ProcCallBack)
\r
2023 // m_ProcCallBack(m_ProcData,GITLOG_START);
\r
2024 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
2026 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
2027 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2029 //does the user force the cache to refresh (shift or control key down)?
\r
2030 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
2031 || (GetKeyState (VK_SHIFT) < 0);
\r
2033 //disable the "Get All" button while we're receiving
\r
2036 FillGitShortLog();
\r
2038 if(this->m_bExitThread)
\r
2040 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2041 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2044 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2045 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START_ALL, 0);
\r
2047 int start=0; CString firstcommit,lastcommit;
\r
2049 for(int i=0;i<m_logEntries.size();i++)
\r
2051 start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start);
\r
2052 m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i;
\r
2054 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
2056 if(firstcommit.IsEmpty())
\r
2057 firstcommit=m_logEntries[i].m_CommitHash;
\r
2058 lastcommit=m_logEntries[i].m_CommitHash;
\r
2062 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
2063 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
2068 if(start>=m_logEntries.m_RawlogData.size())
\r
2071 int percent=i*30/m_logEntries.size() + GITLOG_START+1;
\r
2073 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0);
\r
2074 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0);
\r
2076 if(this->m_bExitThread)
\r
2078 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2079 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2083 if(!lastcommit.IsEmpty())
\r
2084 FetchFullLogInfo(lastcommit,firstcommit);
\r
2086 this->FetchLastLogInfo();
\r
2089 RedrawItems(0, m_arShownList.GetCount());
\r
2090 // SetRedraw(false);
\r
2091 // ResizeAllListCtrlCols();
\r
2092 // SetRedraw(true);
\r
2094 if ( m_pStoreSelection )
\r
2096 // Deleting the instance will restore the
\r
2097 // selection of the CLogDlg.
\r
2098 delete m_pStoreSelection;
\r
2099 m_pStoreSelection = NULL;
\r
2103 // If no selection has been set then this must be the first time
\r
2104 // the revisions are shown. Let's preselect the topmost revision.
\r
2105 if ( GetItemCount()>0 )
\r
2107 SetSelectionMark(0);
\r
2108 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
2115 //FetchFullLogInfo();
\r
2116 //FetchFullLogInfoOrig();
\r
2117 //RefreshCursor();
\r
2118 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
2119 // the log messages
\r
2121 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
2123 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2128 void CGitLogListBase::Refresh()
\r
2130 m_bExitThread=TRUE;
\r
2131 if(m_LoadingThread!=NULL)
\r
2133 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2134 if(ret == WAIT_TIMEOUT)
\r
2135 TerminateThread();
\r
2140 //Update branch and Tag info
\r
2142 //Assume Thread have exited
\r
2143 //if(!m_bThreadRunning)
\r
2145 this->SetItemCountEx(0);
\r
2146 m_logEntries.clear();
\r
2147 m_bExitThread=FALSE;
\r
2148 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
2149 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2150 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
2152 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2153 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2154 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
2156 m_sFilterText.Empty();
\r
2157 m_From=CTime(1970,1,2,0,0,0);
\r
2158 m_To=CTime::GetCurrentTime();
\r
2161 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
2165 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
2167 type |= tr1::regex_constants::icase;
\r
2168 pat = tr1::wregex(regexp_str, type);
\r
2171 catch (exception) {}
\r
2175 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
2178 pShownlist->RemoveAll();
\r
2179 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
2180 bool bRegex = false;
\r
2181 if (m_bFilterWithRegex)
\r
2182 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
2184 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
2186 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2188 if ((bRegex)&&(m_bFilterWithRegex))
\r
2191 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2193 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
2194 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
2196 pShownlist->Add(m_logEntries[i]);
\r
2201 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2203 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
2204 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
2206 pShownlist->Add(&m_logEntries[i]);
\r
2210 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
2211 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
2213 pShownlist->Add(&m_logEntries[i]);
\r
2218 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2220 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2222 bool bGoing = true;
\r
2223 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2225 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2226 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
2228 pShownlist->Add(m_logEntries[i]);
\r
2232 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
2234 pShownlist->Add(m_logEntries[i]);
\r
2238 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
2240 pShownlist->Add(m_logEntries[i]);
\r
2249 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2251 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
2253 pShownlist->Add(&m_logEntries[i]);
\r
2257 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2259 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2260 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
2262 pShownlist->Add(&m_logEntries[i]);
\r
2269 CString find = m_sFilterText;
\r
2272 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2274 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
2276 sBugIDs = sBugIDs.MakeLower();
\r
2277 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2279 pShownlist->Add(m_logEntries[i]);
\r
2284 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2286 CString msg = m_logEntries[i].m_Subject;
\r
2288 msg = msg.MakeLower();
\r
2289 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2291 pShownlist->Add(&m_logEntries[i]);
\r
2294 msg = m_logEntries[i].m_Body;
\r
2296 msg = msg.MakeLower();
\r
2297 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2299 pShownlist->Add(&m_logEntries[i]);
\r
2304 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2306 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2308 bool bGoing = true;
\r
2309 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2311 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2312 CString path = cpath->sCopyFromPath;
\r
2314 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2316 pShownlist->Add(m_logEntries[i]);
\r
2320 path = cpath->sPath;
\r
2322 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2324 pShownlist->Add(m_logEntries[i]);
\r
2328 path = cpath->GetAction();
\r
2330 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2332 pShownlist->Add(m_logEntries[i]);
\r
2339 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2341 CString msg = m_logEntries[i].m_AuthorName;
\r
2342 msg = msg.MakeLower();
\r
2343 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2345 pShownlist->Add(&m_logEntries[i]);
\r
2349 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2351 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2352 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2354 pShownlist->Add(&m_logEntries[i]);
\r
2358 } // else (from if (bRegex))
\r
2359 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2363 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
2365 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2366 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2373 void CGitLogListBase::StartFilter()
\r
2375 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2376 RecalculateShownList(&m_arShownList);
\r
2377 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2381 SetItemCountEx(ShownCountWithStopped());
\r
2382 RedrawItems(0, ShownCountWithStopped());
\r
2384 //ResizeAllListCtrlCols();
\r
2389 void CGitLogListBase::RemoveFilter()
\r
2392 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2394 m_arShownList.RemoveAll();
\r
2396 // reset the time filter too
\r
2398 m_timFrom = (__time64_t(m_tFrom));
\r
2399 m_timTo = (__time64_t(m_tTo));
\r
2400 m_DateFrom.SetTime(&m_timFrom);
\r
2401 m_DateTo.SetTime(&m_timTo);
\r
2402 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2403 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2406 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2408 if(this->m_IsOldFirst)
\r
2410 m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
2413 m_arShownList.Add(&m_logEntries[i]);
\r
2416 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2418 SetItemCountEx(ShownCountWithStopped());
\r
2419 RedrawItems(0, ShownCountWithStopped());
\r
2420 // SetRedraw(false);
\r
2421 // ResizeAllListCtrlCols();
\r
2422 // SetRedraw(true);
\r
2424 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2427 void CGitLogListBase::Clear()
\r
2429 m_arShownList.RemoveAll();
\r
2432 m_logEntries.ClearAll();
\r
2436 void CGitLogListBase::OnDestroy()
\r
2438 // save the column widths to the registry
\r
2439 SaveColumnWidths();
\r
2441 if(this->m_bThreadRunning)
\r
2443 this->m_bExitThread=true;
\r
2444 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2445 if(ret == WAIT_TIMEOUT)
\r
2446 TerminateThread();
\r
2448 while(m_LogCache.SaveCache())
\r
2450 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
\r
2451 MB_YESNO) == IDNO)
\r
2454 CHintListCtrl::OnDestroy();
\r
2457 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
\r
2460 int i=(int)wParam;
\r
2461 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
2462 this->InvalidateRect(rect);
\r
2467 * Save column widths to the registry
\r
2469 void CGitLogListBase::SaveColumnWidths()
\r
2471 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
2474 int numcols = pHdrCtrl->GetItemCount();
\r
2475 for (int col = 0; col < numcols; col++)
\r
2477 int width = GetColumnWidth( col );
\r
2479 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
2480 CRegDWORD regwidth(regentry, 0);
\r
2481 regwidth = width; // this writes it to reg
\r
2486 int CGitLogListBase::GetHeadIndex()
\r
2488 if(m_HeadHash.IsEmpty())
\r
2491 for(int i=0;i<m_arShownList.GetCount();i++)
\r
2493 GitRev *pRev = (GitRev*)m_arShownList[i];
\r
2496 if(pRev->m_CommitHash == m_HeadHash )
\r