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 , m_logEntries(&m_LogCache)
\r
64 // use the default GUI font, create a copy of it and
\r
65 // change the copy to BOLD (leave the rest of the font
\r
67 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
69 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
70 lf.lfWeight = FW_BOLD;
\r
71 m_boldFont = CreateFontIndirect(&lf);
\r
73 m_bShowBugtraqColumn=0;
\r
75 m_IsIDReplaceAction=FALSE;
\r
77 m_wcRev.m_CommitHash.Empty();
\r
78 m_wcRev.m_Subject=_T("Working dir changes");
\r
79 m_wcRev.m_ParentHash.clear();
\r
80 m_wcRev.m_Mark=_T('-');
\r
81 m_wcRev.m_IsUpdateing=FALSE;
\r
82 m_wcRev.m_IsFull = TRUE;
\r
84 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
85 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
86 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
87 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
89 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
91 g_Git.GetMapHashToFriendName(m_HashMap);
\r
92 m_CurrentBranch=g_Git.GetCurrentBranch();
\r
93 this->m_HeadHash=g_Git.GetHash(CString(_T("HEAD"))).Left(40);
\r
95 m_From=CTime(1970,1,2,0,0,0);
\r
96 m_To=CTime::GetCurrentTime();
\r
98 m_LoadingThread = NULL;
\r
100 m_bExitThread=FALSE;
\r
101 m_IsOldFirst = FALSE;
\r
102 m_IsRebaseReplaceGraph = FALSE;
\r
105 for(int i=0;i<Lanes::COLORS_NUM;i++)
\r
107 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
\r
109 // get short/long datetime setting from registry
\r
110 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
\r
111 if ( RegUseShortDateFormat )
\r
113 m_DateFormat = DATE_SHORTDATE;
\r
117 m_DateFormat = DATE_LONGDATE;
\r
119 // get relative time display setting from registry
\r
120 DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);
\r
121 m_bRelativeTimes = (regRelativeTimes != 0);
\r
122 m_ContextMenuMask = 0xFFFFFFFFFFFFFFFF;
\r
124 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_PICK);
\r
125 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SQUASH);
\r
126 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT);
\r
127 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP);
\r
129 OSVERSIONINFOEX inf;
\r
130 SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
\r
131 inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
\r
132 GetVersionEx((OSVERSIONINFO *)&inf);
\r
133 WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);
\r
134 m_bVista = (fullver >= 0x0600);
\r
136 m_ColumnRegKey=_T("log");
\r
139 CGitLogListBase::~CGitLogListBase()
\r
141 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
143 DestroyIcon(m_hModifiedIcon);
\r
144 DestroyIcon(m_hReplacedIcon);
\r
145 DestroyIcon(m_hAddedIcon);
\r
146 DestroyIcon(m_hDeletedIcon);
\r
147 m_logEntries.ClearAll();
\r
150 DeleteObject(m_boldFont);
\r
152 if ( m_pStoreSelection )
\r
154 delete m_pStoreSelection;
\r
155 m_pStoreSelection = NULL;
\r
158 if(this->m_bThreadRunning)
\r
160 m_bExitThread=true;
\r
161 WaitForSingleObject(m_LoadingThread->m_hThread,1000);
\r
167 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
168 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
169 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
170 ON_WM_CONTEXTMENU()
\r
171 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
172 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
175 ON_MESSAGE(MSG_LOADED,OnLoad)
\r
176 ON_WM_MEASUREITEM()
\r
177 ON_WM_MEASUREITEM_REFLECT()
\r
180 void CGitLogListBase::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
\r
182 // TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
\r
184 CListCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
\r
187 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
\r
189 //if (m_nRowHeight>0)
\r
191 lpMeasureItemStruct->itemHeight = 50;
\r
195 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
197 PreSubclassWindow();
\r
198 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
201 void CGitLogListBase::PreSubclassWindow()
\r
203 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
204 // load the icons for the action columns
\r
205 // m_Theme.Open(m_hWnd, L"ListView");
\r
206 m_Theme.Open(m_hWnd, L"Explorer::ListView;ListView");
\r
207 m_Theme.SetWindowTheme(m_hWnd, L"Explorer", NULL);
\r
208 CHintListCtrl::PreSubclassWindow();
\r
211 void CGitLogListBase::InsertGitColumn()
\r
215 int c = GetHeaderCtrl()->GetItemCount()-1;
\r
219 temp.LoadString(IDS_LOG_GRAPH);
\r
221 if(m_IsRebaseReplaceGraph)
\r
227 temp.LoadString(IDS_LOG_GRAPH);
\r
229 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
232 // make the revision column right aligned
\r
234 Column.mask = LVCF_FMT;
\r
235 Column.fmt = LVCFMT_RIGHT;
\r
236 SetColumn(0, &Column);
\r
239 // g_Git.GetLog(log);
\r
241 if(m_IsIDReplaceAction)
\r
243 temp.LoadString(IDS_LOG_ID);
\r
244 InsertColumn(this->LOGLIST_ACTION, temp);
\r
248 temp.LoadString(IDS_LOG_ACTIONS);
\r
249 InsertColumn(this->LOGLIST_ACTION, temp);
\r
251 temp.LoadString(IDS_LOG_MESSAGE);
\r
252 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
254 temp.LoadString(IDS_LOG_AUTHOR);
\r
255 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
257 temp.LoadString(IDS_LOG_DATE);
\r
258 InsertColumn(this->LOGLIST_DATE, temp);
\r
261 if (m_bShowBugtraqColumn)
\r
263 // temp = m_ProjectProperties.sLabel;
\r
264 if (temp.IsEmpty())
\r
265 temp.LoadString(IDS_LOG_BUGIDS);
\r
266 InsertColumn(this->LOGLIST_BUG, temp);
\r
271 ResizeAllListCtrlCols();
\r
277 * Resizes all columns in a list control to values in registry.
\r
279 void CGitLogListBase::ResizeAllListCtrlCols()
\r
281 // column max and min widths to allow
\r
282 static const int nMinimumWidth = 10;
\r
283 static const int nMaximumWidth = 1000;
\r
284 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
287 int numcols = pHdrCtrl->GetItemCount();
\r
288 for (int col = 0; col < numcols; col++)
\r
290 // get width for this col last time from registry
\r
292 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
293 CRegDWORD regwidth(regentry, 0);
\r
297 // no saved value, setup sensible defaults
\r
298 if (col == this->LOGLIST_MESSAGE)
\r
300 cx = LOGLIST_MESSAGE_MIN;
\r
304 cx = ICONITEMBORDER+16*4;
\r
307 if (cx < nMinimumWidth)
\r
309 cx = nMinimumWidth;
\r
310 } else if (cx > nMaximumWidth)
\r
312 cx = nMaximumWidth;
\r
315 SetColumnWidth(col, cx);
\r
322 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
324 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
325 if(ref.Left(prefix.GetLength()) == prefix)
\r
327 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
328 if(shortname.Right(3)==_T("^{}"))
\r
329 shortname=shortname.Left(shortname.GetLength()-3);
\r
335 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
339 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
340 rItem.mask = LVIF_STATE;
\r
341 rItem.iItem = Index;
\r
342 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
345 GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index);
\r
346 HBRUSH brush = NULL;
\r
349 if (m_Theme.IsAppThemed() && m_bVista)
\r
351 int state = LISS_NORMAL;
\r
352 if (rItem.state & LVIS_SELECTED)
\r
354 if (::GetFocus() == m_hWnd)
\r
355 state |= LISS_SELECTED;
\r
357 state |= LISS_SELECTEDNOTFOCUS;
\r
361 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
362 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
363 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
364 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
369 ::FillRect(hdc, &rect, brush);
\r
370 ::DeleteObject(brush);
\r
374 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTITEM, state))
\r
375 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
377 CRect rectDraw = rect;
\r
378 if(rItem.state & LVIS_SELECTED)
\r
379 rectDraw.InflateRect(1,0);
\r
381 rectDraw.InflateRect(1,1);
\r
383 m_Theme.DrawBackground(hdc, LVP_LISTITEM, state, rectDraw, &rect);
\r
389 if (rItem.state & LVIS_SELECTED)
\r
391 if (::GetFocus() == m_hWnd)
\r
392 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
394 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
398 //if (pLogEntry->bCopiedSelf)
\r
399 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
401 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
402 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
403 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
404 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
406 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
411 ::FillRect(hdc, &rect, brush);
\r
412 ::DeleteObject(brush);
\r
417 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
419 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
422 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
423 rItem.mask = LVIF_STATE;
\r
424 rItem.iItem = index;
\r
425 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
428 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
431 str=m_HashMap[data->m_CommitHash][i];
\r
435 shortname = _T("");
\r
436 COLORREF colRef = 0;
\r
438 //Determine label color
\r
439 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
441 if( shortname == m_CurrentBranch )
\r
442 colRef = m_Colors.GetColor(CColors::CurrentBranch);
\r
444 colRef = m_Colors.GetColor(CColors::LocalBranch);
\r
446 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
448 colRef = m_Colors.GetColor(CColors::RemoteBranch);
\r
450 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
452 colRef = m_Colors.GetColor(CColors::Tag);
\r
454 else if(GetShortName(str,shortname,_T("refs/stash")))
\r
456 colRef = m_Colors.GetColor(CColors::Stash);
\r
457 shortname=_T("stash");
\r
460 //When row selected, ajust label color
\r
461 if (!(m_Theme.IsAppThemed() && m_bVista))
\r
462 if (rItem.state & LVIS_SELECTED)
\r
463 colRef = CColors::MixColors(colRef, ::GetSysColor(COLOR_HIGHLIGHT), 150);
\r
465 brush = ::CreateSolidBrush(colRef);
\r
468 if(!shortname.IsEmpty())
\r
471 memset(&size,0,sizeof(SIZE));
\r
472 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
474 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
477 //Fill interior of ref label
\r
478 ::FillRect(hdc, &rt, brush);
\r
480 //Draw edge of label
\r
484 CRect rectEdge = rt;
\r
486 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,100), m_Colors.Darken(colRef,100));
\r
487 rectEdge.DeflateRect(1,1);
\r
488 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,50), m_Colors.Darken(colRef,50));
\r
492 //Draw text inside label
\r
493 if (m_Theme.IsAppThemed() && m_bVista)
\r
495 int txtState = LISS_NORMAL;
\r
496 if (rItem.state & LVIS_SELECTED)
\r
497 txtState = LISS_SELECTED;
\r
499 m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, shortname, -1, DT_CENTER | DT_SINGLELINE | DT_VCENTER, 0, &rt);
\r
503 if (rItem.state & LVIS_SELECTED)
\r
505 COLORREF clrNew = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
\r
506 COLORREF clrOld = ::SetTextColor(hdc,clrNew);
\r
507 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER);
\r
508 ::SetTextColor(hdc,clrOld);
\r
511 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER);
\r
516 //::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
517 //::LineTo(hdc,rt.right,rt.top);
\r
518 //::LineTo(hdc,rt.right,rt.bottom);
\r
519 //::LineTo(hdc,rt.left,rt.bottom);
\r
520 //::LineTo(hdc,rt.left,rt.top);
\r
523 rt.left=rt.right+1;
\r
526 ::DeleteObject(brush);
\r
528 rt.right=rect.right;
\r
530 if (m_Theme.IsAppThemed() && m_bVista)
\r
532 int txtState = LISS_NORMAL;
\r
533 if (rItem.state & LVIS_SELECTED)
\r
534 txtState = LISS_SELECTED;
\r
536 m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, data->m_Subject, -1, DT_LEFT | DT_SINGLELINE | DT_VCENTER, 0, &rt);
\r
540 if (rItem.state & LVIS_SELECTED)
\r
542 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
543 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER);
\r
544 ::SetTextColor(hdc,clrOld);
\r
547 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER);
\r
552 static COLORREF blend(const COLORREF& col1, const COLORREF& col2, int amount = 128) {
\r
554 // Returns ((256 - amount)*col1 + amount*col2) / 256;
\r
555 return RGB(((256 - amount)*GetRValue(col1) + amount*GetRValue(col2) ) / 256,
\r
556 ((256 - amount)*GetGValue(col1) + amount*GetGValue(col2) ) / 256,
\r
557 ((256 - amount)*GetBValue(col1) + amount*GetBValue(col2) ) / 256);
\r
560 Gdiplus::Color GetGdiColor(COLORREF col)
\r
562 return Gdiplus::Color(GetRValue(col),GetGValue(col),GetBValue(col));
\r
564 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
565 const COLORREF& col,const COLORREF& activeColor, int top
\r
568 int h = laneHeight / 2;
\r
569 int m = (x1 + x2) / 2;
\r
570 int r = (x2 - x1) / 3;
\r
573 #define P_CENTER m , h+top
\r
574 #define P_0 x2, h+top
\r
575 #define P_90 m , 0+top
\r
576 #define P_180 x1, h+top
\r
577 #define P_270 m , 2 * h+top
\r
578 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
581 #define DELTA_UR_B 2*(x1 - m), 2*h +top
\r
582 #define DELTA_UR_E 0*16, 90*16 +top // -,
\r
584 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
\r
585 #define DELTA_DR_E 270*16, 90*16 +top // -'
\r
587 #define DELTA_UL_B 2*(x2 - m), 2*h +top
\r
588 #define DELTA_UL_E 90*16, 90*16 +top // ,-
\r
590 #define DELTA_DL_B 2*(x2 - m),2*-h +top
\r
591 #define DELTA_DL_E 180*16, 90*16 // '-
\r
593 #define CENTER_UR x1, 2*h, 225
\r
594 #define CENTER_DR x1, 0 , 135
\r
595 #define CENTER_UL x2, 2*h, 315
\r
596 #define CENTER_DL x2, 0 , 45
\r
599 Gdiplus::Graphics graphics( hdc );
\r
604 case Lanes::JOIN_R:
\r
606 case Lanes::HEAD_R:
\r
608 Gdiplus::LinearGradientBrush gradient(
\r
609 Gdiplus::Point(x1-2, h+top-2),
\r
610 Gdiplus::Point(P_270),
\r
611 GetGdiColor(activeColor),GetGdiColor(col));
\r
614 Gdiplus::Pen mypen(&gradient,2);
\r
615 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
\r
617 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
\r
618 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top+h-1, x2-x1+1,laneHeight+1,270,90);
\r
619 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
\r
623 case Lanes::JOIN_L:
\r
626 Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
\r
629 graphics.DrawArc(&mypen,x1,top+h, x2-x1,laneHeight,270,90);
\r
634 case Lanes::TAIL_R:
\r
637 Gdiplus::LinearGradientBrush gradient(
\r
638 Gdiplus::Point(x1-2, h+top-2),
\r
639 Gdiplus::Point(P_90),
\r
640 GetGdiColor(activeColor),GetGdiColor(col));
\r
643 Gdiplus::Pen mypen(&gradient,2);
\r
645 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top-h-1, x2-x1+1,laneHeight+1,0,90);
\r
649 QConicalGradient gradient(CENTER_DR);
\r
650 gradient.setColorAt(0.375, activeCol);
\r
651 gradient.setColorAt(0.625, col);
\r
652 myPen.setBrush(gradient);
\r
654 p->drawArc(P_CENTER, DELTA_DR);
\r
663 //static QPen myPen(Qt::black, 2); // fast path here
\r
665 pen.CreatePen(PS_SOLID,2,col);
\r
666 //myPen.setColor(col);
\r
667 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
669 Gdiplus::Pen myPen(GetGdiColor(col),2);
\r
671 //p->setPen(myPen);
\r
675 case Lanes::ACTIVE:
\r
676 case Lanes::NOT_ACTIVE:
\r
677 case Lanes::MERGE_FORK:
\r
678 case Lanes::MERGE_FORK_R:
\r
679 case Lanes::MERGE_FORK_L:
\r
681 case Lanes::JOIN_R:
\r
682 case Lanes::JOIN_L:
\r
684 //DrawLine(hdc,P_90,P_270);
\r
685 graphics.DrawLine(&myPen,P_90,P_270);
\r
686 //p->drawLine(P_90, P_270);
\r
688 case Lanes::HEAD_L:
\r
689 case Lanes::BRANCH:
\r
690 //DrawLine(hdc,P_CENTER,P_270);
\r
691 graphics.DrawLine(&myPen,P_CENTER,P_270);
\r
692 //p->drawLine(P_CENTER, P_270);
\r
694 case Lanes::TAIL_L:
\r
695 case Lanes::INITIAL:
\r
696 case Lanes::BOUNDARY:
\r
697 case Lanes::BOUNDARY_C:
\r
698 case Lanes::BOUNDARY_R:
\r
699 case Lanes::BOUNDARY_L:
\r
700 //DrawLine(hdc,P_90, P_CENTER);
\r
701 graphics.DrawLine(&myPen,P_90,P_CENTER);
\r
702 //p->drawLine(P_90, P_CENTER);
\r
708 myPen.SetColor(GetGdiColor(activeColor));
\r
712 case Lanes::MERGE_FORK:
\r
717 case Lanes::CROSS_EMPTY:
\r
718 case Lanes::BOUNDARY_C:
\r
719 //DrawLine(hdc,P_180,P_0);
\r
720 graphics.DrawLine(&myPen,P_180,P_0);
\r
721 //p->drawLine(P_180, P_0);
\r
723 case Lanes::MERGE_FORK_R:
\r
724 case Lanes::BOUNDARY_R:
\r
725 //DrawLine(hdc,P_180,P_CENTER);
\r
726 graphics.DrawLine(&myPen,P_180,P_CENTER);
\r
727 //p->drawLine(P_180, P_CENTER);
\r
729 case Lanes::MERGE_FORK_L:
\r
730 case Lanes::HEAD_L:
\r
731 case Lanes::TAIL_L:
\r
732 case Lanes::BOUNDARY_L:
\r
733 //DrawLine(hdc,P_CENTER,P_0);
\r
734 graphics.DrawLine(&myPen,P_CENTER,P_0);
\r
735 //p->drawLine(P_CENTER, P_0);
\r
742 brush.CreateSolidBrush(col);
\r
743 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
744 // center symbol, e.g. rect or ellipse
\r
746 case Lanes::ACTIVE:
\r
747 case Lanes::INITIAL:
\r
748 case Lanes::BRANCH:
\r
750 //p->setPen(Qt::NoPen);
\r
751 //p->setBrush(col);
\r
752 ::Ellipse(hdc, R_CENTER);
\r
753 //p->drawEllipse(R_CENTER);
\r
755 case Lanes::MERGE_FORK:
\r
756 case Lanes::MERGE_FORK_R:
\r
757 case Lanes::MERGE_FORK_L:
\r
758 //p->setPen(Qt::NoPen);
\r
759 //p->setBrush(col);
\r
760 //p->drawRect(R_CENTER);
\r
761 Rectangle(hdc,R_CENTER);
\r
763 case Lanes::UNAPPLIED:
\r
765 //p->setPen(Qt::NoPen);
\r
766 //p->setBrush(Qt::red);
\r
767 //p->drawRect(m - r, h - 1, d, 2);
\r
768 ::Rectangle(hdc,m-r,h-1,d,2);
\r
770 case Lanes::APPLIED:
\r
772 //p->setPen(Qt::NoPen);
\r
773 //p->setBrush(DARK_GREEN);
\r
774 //p->drawRect(m - r, h - 1, d, 2);
\r
775 //p->drawRect(m - 1, h - r, 2, d);
\r
776 ::Rectangle(hdc,m-r,h-1,d,2);
\r
777 ::Rectangle(hdc,m-1,h-r,2,d);
\r
779 case Lanes::BOUNDARY:
\r
780 //p->setBrush(back);
\r
781 //p->drawEllipse(R_CENTER);
\r
782 ::Ellipse(hdc, R_CENTER);
\r
784 case Lanes::BOUNDARY_C:
\r
785 case Lanes::BOUNDARY_R:
\r
786 case Lanes::BOUNDARY_L:
\r
787 //p->setBrush(back);
\r
788 //p->drawRect(R_CENTER);
\r
789 ::Rectangle(hdc,R_CENTER);
\r
795 ::SelectObject(hdc,oldpen);
\r
796 ::SelectObject(hdc,oldbrush);
\r
805 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
809 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
810 if(data->m_CommitHash.IsEmpty())
\r
815 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
816 rItem.mask = LVIF_STATE;
\r
817 rItem.iItem = index;
\r
818 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
822 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
826 if (data->m_Lanes.size() == 0)
\r
827 m_logEntries.setLane(data->m_CommitHash);
\r
829 std::vector<int>& lanes=data->m_Lanes;
\r
830 UINT laneNum = lanes.size();
\r
831 UINT activeLane = 0;
\r
832 for (UINT i = 0; i < laneNum; i++)
\r
833 if (Lanes::isMerge(lanes[i])) {
\r
838 int x1 = 0, x2 = 0;
\r
839 int maxWidth = rect.Width();
\r
840 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
842 COLORREF activeColor = m_LineColors[activeLane % Lanes::COLORS_NUM];
\r
843 //if (opt.state & QStyle::State_Selected)
\r
844 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
\r
847 for (unsigned int i = 0; i < laneNum && x2 < maxWidth; i++)
\r
854 if (ln == Lanes::EMPTY)
\r
857 COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM];
\r
858 paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top);
\r
862 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
868 if (ln == Lanes::EMPTY)
\r
871 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
872 || ln ==Lanes:: CROSS_EMPTY) ? activeLane : i;
\r
874 if (ln == Lanes::CROSS) {
\r
875 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
876 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[activeLane % Lanes::COLORS_NUM],rect.top);
\r
878 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
884 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
887 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
888 // Take the default processing unless we set this to something else below.
\r
889 *pResult = CDRF_DODEFAULT;
\r
891 if (m_bNoDispUpdates)
\r
896 switch (pLVCD->nmcd.dwDrawStage)
\r
898 case CDDS_PREPAINT:
\r
900 *pResult = CDRF_NOTIFYITEMDRAW;
\r
904 case CDDS_ITEMPREPAINT:
\r
906 // This is the prepaint stage for an item. Here's where we set the
\r
907 // item's text color.
\r
909 // Tell Windows to send draw notifications for each subitem.
\r
910 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
912 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
914 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
916 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
920 if (data->bCopiedSelf)
\r
922 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
923 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
924 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
928 crText = m_Colors.GetColor(CColors::Modified);
\r
930 if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
\r
931 crText = RGB(128,128,128);
\r
933 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
934 pLVCD->clrTextBk = RGB(156,156,156);
\r
935 else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
936 pLVCD->clrTextBk = RGB(200,200,128);
\r
938 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
\r
940 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)
\r
942 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
943 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
946 if(data->m_CommitHash.ToString() == m_HeadHash)
\r
948 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
949 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
952 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
953 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
955 if (data->m_CommitHash.IsEmpty())
\r
957 //crText = GetSysColor(RGB(200,200,0));
\r
958 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
959 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
960 // tells the control to recalculate the extent of the text.
\r
961 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
965 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
967 if (m_bStrictStopped)
\r
968 crText = GetSysColor(COLOR_GRAYTEXT);
\r
970 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
971 pLVCD->clrText = crText;
\r
975 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
977 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
979 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
982 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
984 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
\r
987 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
988 if(pLVCD->iSubItem == 0)
\r
991 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem+1, LVIR_BOUNDS, second);
\r
992 rect.right=second.left;
\r
995 TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
\r
996 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
998 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
999 if( !data ->m_CommitHash.IsEmpty())
\r
1000 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
1002 *pResult = CDRF_SKIPDEFAULT;
\r
1008 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
1010 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1012 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
1013 //if(!data->m_IsFull)
\r
1015 //if(data->SafeFetchFullInfo(&g_Git))
\r
1016 // this->Invalidate();
\r
1017 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
1020 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
1024 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
1026 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
1027 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
1029 *pResult = CDRF_SKIPDEFAULT;
\r
1037 if (pLVCD->iSubItem == 1)
\r
1039 if(this->m_IsIDReplaceAction)
\r
1041 *pResult = CDRF_DODEFAULT;
\r
1044 *pResult = CDRF_DODEFAULT;
\r
1046 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
1050 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
1051 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
1053 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
1055 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
1056 TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
\r
1057 // Get the selected state of the
\r
1058 // item being drawn.
\r
1060 // Fill the background
\r
1061 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
1063 // Draw the icon(s) into the compatible DC
\r
1064 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
1065 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1068 if (pLogEntry->m_Action & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
\r
1069 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1072 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
1073 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1076 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
1077 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
1079 *pResult = CDRF_SKIPDEFAULT;
\r
1085 *pResult = CDRF_DODEFAULT;
\r
1089 // CGitLogListBase message handlers
\r
1091 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1093 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
1095 // Create a pointer to the item
\r
1096 LV_ITEM* pItem = &(pDispInfo)->item;
\r
1098 // Do the list need text information?
\r
1099 if (!(pItem->mask & LVIF_TEXT))
\r
1102 // By default, clear text buffer.
\r
1103 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
1105 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
1108 if (m_bNoDispUpdates || bOutOfRange)
\r
1111 // Which item number?
\r
1112 int itemid = pItem->iItem;
\r
1113 GitRev * pLogEntry = NULL;
\r
1114 if (itemid < m_arShownList.GetCount())
\r
1115 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
1120 temp.Format(_T("%d"),pItem->iItem+1);
\r
1124 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
1128 switch (pItem->iSubItem)
\r
1130 case this->LOGLIST_GRAPH: //Graphic
\r
1133 if(this->m_IsRebaseReplaceGraph)
\r
1136 path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
\r
1138 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
\r
1142 case this->LOGLIST_ACTION: //action -- no text in the column
\r
1143 if(this->m_IsIDReplaceAction)
\r
1144 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
1146 case this->LOGLIST_MESSAGE: //Message
\r
1148 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
1150 case this->LOGLIST_AUTHOR: //Author
\r
1152 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
1154 case this->LOGLIST_DATE: //Date
\r
1155 if (!pLogEntry && pLogEntry->m_CommitHash.IsEmpty())
\r
1156 lstrcpyn(pItem->pszText,
\r
1157 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1158 pItem->cchTextMax);
\r
1169 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
1172 int selIndex = GetSelectionMark();
\r
1174 return; // nothing selected, nothing to do with a context menu
\r
1176 // if the user selected the info text telling about not all revisions shown due to
\r
1177 // the "stop on copy/rename" option, we also don't show the context menu
\r
1178 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
1181 // if the context menu is invoked through the keyboard, we have to use
\r
1182 // a calculated position on where to anchor the menu on
\r
1183 if ((point.x == -1) && (point.y == -1))
\r
1186 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
1187 ClientToScreen(&rect);
\r
1188 point = rect.CenterPoint();
\r
1190 m_nSearchIndex = selIndex;
\r
1191 m_bCancelled = FALSE;
\r
1193 // calculate some information the context menu commands can use
\r
1194 // CString pathURL = GetURLFromPath(m_path);
\r
1196 POSITION pos = GetFirstSelectedItemPosition();
\r
1197 int indexNext = GetNextSelectedItem(pos);
\r
1198 if (indexNext < 0)
\r
1201 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
1203 GitRev revSelected = pSelLogEntry->Rev;
\r
1204 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
1205 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
1207 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
1209 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
1210 if (changedpath->lCopyFromRev)
\r
1211 revPrevious = changedpath->lCopyFromRev;
\r
1214 GitRev revSelected2;
\r
1217 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1218 revSelected2 = pLogEntry->Rev;
\r
1220 bool bAllFromTheSameAuthor = true;
\r
1221 CString firstAuthor;
\r
1222 CLogDataVector selEntries;
\r
1223 GitRev revLowest, revHighest;
\r
1224 GitRevRangeArray revisionRanges;
\r
1226 POSITION pos = GetFirstSelectedItemPosition();
\r
1227 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1228 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1229 selEntries.push_back(pLogEntry);
\r
1230 firstAuthor = pLogEntry->sAuthor;
\r
1231 revLowest = pLogEntry->Rev;
\r
1232 revHighest = pLogEntry->Rev;
\r
1235 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1236 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1237 selEntries.push_back(pLogEntry);
\r
1238 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
1239 bAllFromTheSameAuthor = false;
\r
1240 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
1241 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
1247 int FirstSelect=-1, LastSelect=-1;
\r
1248 pos = GetFirstSelectedItemPosition();
\r
1249 FirstSelect = GetNextSelectedItem(pos);
\r
1252 LastSelect = GetNextSelectedItem(pos);
\r
1254 //entry is selected, now show the popup menu
\r
1256 CIconMenu submenu;
\r
1257 if (popup.CreatePopupMenu())
\r
1260 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
\r
1261 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_PICK, IDI_PICK);
\r
1263 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
\r
1264 popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH);
\r
1266 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
\r
1267 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
\r
1269 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
\r
1270 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
\r
1272 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
\r
1273 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
\r
1274 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1276 if (GetSelectedCount() == 1)
\r
1280 if( !pSelLogEntry->m_CommitHash.IsEmpty())
\r
1282 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))
\r
1283 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1285 // TortoiseMerge could be improved to take a /blame switch
\r
1286 // and then not 'cat' the files from a unified diff but
\r
1288 // But until that's implemented, the context menu entry for
\r
1289 // this feature is commented out.
\r
1290 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1293 if(m_ContextMenuMask&GetContextMenuBit(ID_COMMIT))
\r
1294 popup.AppendMenuIcon(ID_COMMIT, IDS_LOG_POPUP_COMMIT, IDI_COMMIT);
\r
1296 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))
\r
1297 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1299 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
\r
1300 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1301 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1302 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1305 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1307 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1309 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1311 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1313 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1314 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1316 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1320 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1322 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1324 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1326 CString str,format;
\r
1327 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
\r
1328 str.Format(format,g_Git.GetCurrentBranch());
\r
1330 if(!pSelLogEntry->m_CommitHash.IsEmpty())
\r
1332 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))
\r
1333 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1335 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))
\r
1336 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
\r
1338 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
\r
1339 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
\r
1341 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
\r
1342 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);
\r
1344 format.LoadString(IDS_REBASE_THIS_FORMAT);
\r
1345 str.Format(format,g_Git.GetCurrentBranch());
\r
1347 if(pSelLogEntry->m_CommitHash != m_HeadHash)
\r
1348 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
\r
1349 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
\r
1351 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
\r
1352 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
\r
1355 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1360 if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1)
\r
1362 popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE);
\r
1363 popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE);
\r
1364 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1367 if (GetSelectedCount() >= 2)
\r
1369 bool bAddSeparator = false;
\r
1370 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1372 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO))
\r
1373 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1376 if (GetSelectedCount() == 2)
\r
1378 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1379 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2))
\r
1380 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1381 bAddSeparator = true;
\r
1386 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1388 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1389 bAddSeparator = true;
\r
1391 if (bAddSeparator)
\r
1392 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1395 if ( GetSelectedCount() >0 && (!pSelLogEntry->m_CommitHash.IsEmpty()))
\r
1397 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
\r
1399 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT))
\r
1403 headindex = this->GetHeadIndex();
\r
1406 head.Format(_T("HEAD~%d"),LastSelect-headindex);
\r
1407 CString hash=g_Git.GetHash(head);
\r
1408 hash=hash.Left(40);
\r
1409 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1410 if(pLastEntry->m_CommitHash.ToString() == hash)
\r
1411 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
\r
1415 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))
\r
1416 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
\r
1418 if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))
\r
1419 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH))
\r
1420 popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH);
\r
1422 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1428 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1430 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1432 // if (GetSelectedCount() == 1)
\r
1434 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1435 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1436 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1441 if (GetSelectedCount() == 1)
\r
1443 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
\r
1444 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH);
\r
1446 if (GetSelectedCount() != 0)
\r
1448 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
\r
1449 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1452 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
\r
1453 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1456 if (GetSelectedCount() == 1)
\r
1458 if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE))
\r
1460 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() )
\r
1463 str.LoadString(IDS_DELETE_BRANCHTAG);
\r
1464 if( m_HashMap[pSelLogEntry->m_CommitHash].size() == 1 )
\r
1467 str+=m_HashMap[pSelLogEntry->m_CommitHash].at(0);
\r
1468 popup.AppendMenuIcon(ID_DELETE,str+_T("..."),IDI_DELETE);
\r
1470 else if( m_HashMap[pSelLogEntry->m_CommitHash].size() > 1 )
\r
1473 submenu.CreatePopupMenu();
\r
1474 for(int i=0;i<m_HashMap[pSelLogEntry->m_CommitHash].size();i++)
\r
1476 submenu.AppendMenuIcon(ID_DELETE+(i<<16),m_HashMap[pSelLogEntry->m_CommitHash][i]+_T("..."));
\r
1479 popup.AppendMenu(MF_BYPOSITION|MF_POPUP|MF_STRING,(UINT) submenu.m_hMenu,str);
\r
1487 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1488 // DialogEnableWindow(IDOK, FALSE);
\r
1489 // SetPromptApp(&theApp);
\r
1491 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1493 // EnableOKButton();
\r
1494 } // if (popup.CreatePopupMenu())
\r
1498 bool CGitLogListBase::IsSelectionContinuous()
\r
1500 if ( GetSelectedCount()==1 )
\r
1502 // if only one revision is selected, the selection is of course
\r
1507 POSITION pos = GetFirstSelectedItemPosition();
\r
1508 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1511 int itemindex = GetNextSelectedItem(pos);
\r
1514 int nextindex = GetNextSelectedItem(pos);
\r
1515 if (nextindex - itemindex > 1)
\r
1517 bContinuous = false;
\r
1520 itemindex = nextindex;
\r
1523 return bContinuous;
\r
1526 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1529 CString sClipdata;
\r
1530 POSITION pos = GetFirstSelectedItemPosition();
\r
1534 sRev.LoadString(IDS_LOG_REVISION);
\r
1536 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1538 sDate.LoadString(IDS_LOG_DATE);
\r
1540 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1543 CString sLogCopyText;
\r
1545 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1549 //pLogEntry->m_Files
\r
1550 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1552 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1554 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1555 sPaths += _T("\r\n");
\r
1558 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
1559 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1560 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1562 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1563 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1565 sClipdata += sLogCopyText;
\r
1568 sClipdata += pLogEntry->m_CommitHash;
\r
1573 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1578 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1580 if (m_bThreadRunning)
\r
1583 int FirstSelect=-1, LastSelect=-1;
\r
1584 POSITION pos = GetFirstSelectedItemPosition();
\r
1585 FirstSelect = GetNextSelectedItem(pos);
\r
1588 LastSelect = GetNextSelectedItem(pos);
\r
1591 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect);
\r
1594 UpdateLogInfoLabel();
\r
1595 int selIndex = m_LogList.GetSelectionMark();
\r
1598 int selCount = m_LogList.GetSelectedCount();
\r
1599 if (selCount != 1)
\r
1602 // Find selected entry in the log list
\r
1603 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1604 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1605 long rev1 = pLogEntry->Rev;
\r
1606 long rev2 = rev1-1;
\r
1607 CTGitPath path = m_path;
\r
1609 // See how many files under the relative root were changed in selected revision
\r
1611 LogChangedPath * changed = NULL;
\r
1612 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1614 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1615 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1622 if (m_path.IsDirectory() && nChanged == 1)
\r
1624 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1625 // Do diff on that file instead of whole directory
\r
1626 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1629 m_bCancelled = FALSE;
\r
1630 DialogEnableWindow(IDOK, FALSE);
\r
1631 SetPromptApp(&theApp);
\r
1632 theApp.DoWaitCursor(1);
\r
1634 if (PromptShown())
\r
1636 GitDiff diff(this, m_hWnd, true);
\r
1637 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1638 diff.SetHEADPeg(m_LogRevision);
\r
1639 diff.ShowCompare(path, rev2, path, rev1);
\r
1643 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1646 theApp.DoWaitCursor(-1);
\r
1651 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1653 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1656 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1658 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1660 if (pFindInfo->lvfi.psz == 0)
\r
1663 CString sCmp = pFindInfo->lvfi.psz;
\r
1665 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1667 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1668 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1669 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1671 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1679 if (sCmp.Compare(sRev)==0)
\r
1686 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1688 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1690 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1691 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1692 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1694 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1702 if (sCmp.Compare(sRev)==0)
\r
1714 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
\r
1718 this->m_logEntries.ClearAll();
\r
1719 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
\r
1721 //this->m_logEntries.ParserFromLog();
\r
1722 SetItemCountEx(this->m_logEntries.size());
\r
1724 this->m_arShownList.RemoveAll();
\r
1726 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1730 m_logEntries.GetGitRevAt(m_logEntries.size()-i-1).m_IsFull=TRUE;
\r
1731 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
1735 m_logEntries.GetGitRevAt(i).m_IsFull=TRUE;
\r
1736 this->m_arShownList.Add(&m_logEntries[i]);
\r
1746 int CGitLogListBase::BeginFetchLog()
\r
1750 this->m_logEntries.ClearAll();
\r
1753 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1756 if(this->m_Path.IsEmpty())
\r
1759 path=&this->m_Path;
\r
1763 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1764 // if(this->m_bAllBranch)
\r
1765 mask |= m_ShowMask;
\r
1767 this->m_arShownList.RemoveAll();
\r
1771 this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev.m_CommitHash);
\r
1772 this->m_LogCache.m_HashMap[m_wcRev.m_CommitHash]=m_wcRev;
\r
1775 CString cmd=g_Git.GetLogCmd(m_StartRef,path,-1,mask,NULL,NULL,true);
\r
1777 //this->m_logEntries.ParserFromLog();
\r
1778 if(IsInWorkingThread())
\r
1780 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
\r
1784 SetItemCountEx(this->m_logEntries.size());
\r
1787 if(git_open_log(&m_DllGitLog,CUnicodeUtils::GetMulti(cmd,CP_ACP).GetBuffer()))
\r
1795 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1797 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1798 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1799 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1801 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1803 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1805 DiffSelectedRevWithPrevious();
\r
1810 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1812 DiffSelectedFile();
\r
1819 if (m_hAccel && !bSkipAccelerator)
\r
1821 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1827 //m_tooltips.RelayEvent(pMsg);
\r
1828 return __super::PreTranslateMessage(pMsg);
\r
1831 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1833 // a double click on an entry in the revision list has happened
\r
1836 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1837 DiffSelectedRevWithPrevious();
\r
1840 int CGitLogListBase::FetchLogAsync(void * data)
\r
1843 m_bExitThread=FALSE;
\r
1844 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1845 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1846 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1847 if (m_LoadingThread ==NULL)
\r
1849 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1850 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1851 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1857 //this is the thread function which calls the subversion function
\r
1858 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1860 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1863 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1866 oldest=CTime::GetCurrentTime();
\r
1867 latest=CTime(1971,1,2,0,0,0);
\r
1868 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1870 if(m_logEntries[i].IsEmpty())
\r
1873 if(m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime() < oldest.GetTime())
\r
1874 oldest = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime();
\r
1876 if(m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime() > latest.GetTime())
\r
1877 latest = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime();
\r
1882 //Helper class for FetchFullLogInfo()
\r
1883 class CGitCall_FetchFullLogInfo : public CGitCall
\r
1886 CGitCall_FetchFullLogInfo(CGitLogListBase* ploglist):m_ploglist(ploglist),m_CollectedCount(0){}
\r
1887 virtual bool OnOutputData(const BYTE* data, size_t size)
\r
1890 return m_ploglist->m_bExitThread;
\r
1891 //Add received data to byte collector
\r
1892 m_ByteCollector.append(data,size);
\r
1894 //Find loginfo endmarker
\r
1895 static const BYTE dataToFind[]={0,0,'#','<'};
\r
1896 int found=m_ByteCollector.findData(dataToFind,4);
\r
1898 return m_ploglist->m_bExitThread;//Not found
\r
1899 found+=2;//Position after loginfo end-marker
\r
1901 //Prepare data for OnLogInfo and call it
\r
1902 BYTE_VECTOR logInfo;
\r
1903 logInfo.append(&*m_ByteCollector.begin(),found);
\r
1904 OnLogInfo(logInfo);
\r
1906 //Remove loginfo from bytecollector
\r
1907 m_ByteCollector.erase(m_ByteCollector.begin(),m_ByteCollector.begin()+found);
\r
1909 return m_ploglist->m_bExitThread;
\r
1911 virtual void OnEnd()
\r
1913 //Rest should be a complete log line.
\r
1914 if(!m_ByteCollector.empty())
\r
1915 OnLogInfo(m_ByteCollector);
\r
1919 void OnLogInfo(BYTE_VECTOR& logInfo)
\r
1922 fullRev.ParserFromLog(logInfo);
\r
1923 MAP_HASH_REV::iterator itRev=m_ploglist->m_logEntries.m_HashMap.find(fullRev.m_CommitHash);
\r
1924 if(itRev==m_ploglist->m_logEntries.m_HashMap.end())
\r
1926 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
\r
1930 int rev=itRev->second;
\r
1931 GitRev* revInVector=&m_ploglist->m_logEntries.GetGitRevAt(rev);
\r
1934 if(revInVector->m_IsFull)
\r
1937 GitRev *pRev= m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev]);
\r
1940 ++m_CollectedCount;
\r
1941 InterlockedExchange(&pRev->m_IsUpdateing,FALSE);
\r
1942 InterlockedExchange(&pRev->m_IsFull,TRUE);
\r
1943 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1947 // fullRev.m_IsUpdateing=TRUE;
\r
1948 // fullRev.m_IsFull=TRUE;
\r
1951 if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE))
\r
1952 return;//Cannot update this row now. Ignore.
\r
1953 TCHAR oldmark=revInVector->m_Mark;
\r
1954 GIT_REV_LIST oldlist=revInVector->m_ParentHash;
\r
1955 // CString oldhash=m_CommitHash;
\r
1957 //Parse new rev info
\r
1958 revInVector->ParserFromLog(logInfo);
\r
1961 revInVector->m_Mark=oldmark; //parser full log will cause old mark overwrited.
\r
1962 //So we need keep old bound mark.
\r
1963 revInVector->m_ParentHash=oldlist;
\r
1966 m_ploglist->m_LogCache.AddCacheEntry(*revInVector);
\r
1969 InterlockedExchange(&revInVector->m_IsFull,TRUE);
\r
1970 InterlockedExchange(&revInVector->m_IsUpdateing,FALSE);
\r
1972 //Notify listcontrol and update progress bar
\r
1973 ++m_CollectedCount;
\r
1975 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1977 DWORD percent=m_CollectedCount*68/m_ploglist->m_logEntries.size() + GITLOG_START+1+30;
\r
1978 if(percent == GITLOG_END)
\r
1979 percent = GITLOG_END -1;
\r
1981 ::PostMessage(m_ploglist->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1984 CGitLogListBase* m_ploglist;
\r
1985 BYTE_VECTOR m_ByteCollector;
\r
1986 int m_CollectedCount;
\r
1990 void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to)
\r
1992 CGitCall_FetchFullLogInfo fetcher(this);
\r
1994 CGit::LOG_INFO_FULL_DIFF|
\r
1995 CGit::LOG_INFO_STAT|
\r
1996 CGit::LOG_INFO_FILESTATE|
\r
1997 CGit::LOG_INFO_DETECT_COPYRENAME|
\r
1998 CGit::LOG_INFO_SHOW_MERGEDFILE |
\r
2002 if(this->m_Path.IsEmpty())
\r
2005 path=&this->m_Path;
\r
2007 g_Git.GetLog(&fetcher,CString(),path,-1,mask,&from,&to);
\r
2010 void CGitLogListBase::FetchLastLogInfo()
\r
2012 unsigned int updated=0;
\r
2016 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
2018 if(m_logEntries.GetGitRevAt(i).m_IsFull)
\r
2021 GitRev *pRev = m_LogCache.GetCacheData(m_logEntries[i]);
\r
2024 if(!m_logEntries.FetchFullInfo(i))
\r
2028 m_LogCache.AddCacheEntry(m_logEntries.GetGitRevAt(i));
\r
2033 InterlockedExchange(&pRev->m_IsUpdateing,FALSE);
\r
2034 InterlockedExchange(&pRev->m_IsFull,TRUE);
\r
2037 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
\r
2041 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2042 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2049 UINT CGitLogListBase::LogThread()
\r
2051 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
2053 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
2054 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2058 if(BeginFetchLog())
\r
2061 //Update work copy item;
\r
2062 if( m_logEntries.size() > 0)
\r
2064 GitRev *pRev = &m_logEntries.GetGitRevAt(0);
\r
2066 m_arShownList.Add(pRev);
\r
2068 if( pRev->m_CommitHash.IsEmpty() )
\r
2070 pRev->m_Files.Clear();
\r
2071 pRev->m_ParentHash.clear();
\r
2072 pRev->m_ParentHash.push_back(m_HeadHash);
\r
2073 g_Git.GetCommitDiffList(pRev->m_CommitHash.ToString(),this->m_HeadHash, pRev->m_Files);
\r
2074 pRev->m_Action =0;
\r
2076 for(int j=0;j< pRev->m_Files.GetCount();j++)
\r
2077 pRev->m_Action |= pRev->m_Files[j].m_Action;
\r
2079 pRev->m_Body.Format(_T("%d files changed"),m_logEntries.GetGitRevAt(0).m_Files.GetCount());
\r
2080 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0);
\r
2084 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2086 git_get_log_firstcommit(m_DllGitLog);
\r
2087 GIT_COMMIT commit;
\r
2088 t1=GetTickCount();
\r
2090 int oldsize=m_logEntries.size();
\r
2091 while( git_get_log_nextcommit(this->m_DllGitLog,&commit) == 0)
\r
2093 //printf("%s\r\n",commit.m_Subject);
\r
2097 CGitHash hash = (char*)commit.m_hash ;
\r
2099 m_logEntries.push_back(hash);
\r
2101 GitRev *pRev = m_LogCache.GetCacheData(hash);
\r
2103 if(pRev == NULL || !pRev->m_IsFull)
\r
2105 pRev->ParserFromCommit(&commit);
\r
2106 pRev->ParserParentFromCommit(&commit);
\r
2108 pRev->SafeFetchFullInfo(&g_Git);
\r
2109 git_free_commit(&commit);
\r
2113 ASSERT(pRev->m_CommitHash == hash);
\r
2114 pRev->ParserParentFromCommit(&commit);
\r
2117 m_arShownList.Add(pRev);
\r
2119 if(t2-t1>500 && m_logEntries.size()<(oldsize+100) )
\r
2122 oldsize = m_logEntries.size();
\r
2123 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL);
\r
2124 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
2129 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL);
\r
2130 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
2132 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2135 // if(m_ProcCallBack)
\r
2136 // m_ProcCallBack(m_ProcData,GITLOG_START);
\r
2137 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
2139 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
2140 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2142 //does the user force the cache to refresh (shift or control key down)?
\r
2143 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
2144 || (GetKeyState (VK_SHIFT) < 0);
\r
2146 //disable the "Get All" button while we're receiving
\r
2149 FillGitShortLog();
\r
2151 if(this->m_bExitThread)
\r
2153 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2154 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2157 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2158 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START_ALL, 0);
\r
2160 int start=0; CString firstcommit,lastcommit;
\r
2162 for(int i=0;i<m_logEntries.size();i++)
\r
2164 if( i==0 && m_logEntries.GetGitRevAt(i).m_CommitHash.IsEmpty() )
\r
2166 m_logEntries.GetGitRevAt(i).m_Files.Clear();
\r
2167 m_logEntries.GetGitRevAt(i).m_ParentHash.clear();
\r
2168 m_logEntries.GetGitRevAt(i).m_ParentHash.push_back(m_HeadHash);
\r
2169 g_Git.GetCommitDiffList(m_logEntries.GetGitRevAt(i).m_CommitHash.ToString(),this->m_HeadHash,m_logEntries.GetGitRevAt(i).m_Files);
\r
2170 m_logEntries.GetGitRevAt(i).m_Action =0;
\r
2171 for(int j=0;j< m_logEntries.GetGitRevAt(i).m_Files.GetCount();j++)
\r
2172 m_logEntries.GetGitRevAt(i).m_Action |= m_logEntries.GetGitRevAt(i).m_Files[j].m_Action;
\r
2174 m_logEntries.GetGitRevAt(i).m_Body.Format(_T("%d files changed"),m_logEntries.GetGitRevAt(i).m_Files.GetCount());
\r
2175 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0);
\r
2179 start=this->m_logEntries.GetGitRevAt(i).ParserFromLog(m_logEntries.m_RawlogData,start);
\r
2180 m_logEntries.m_HashMap[m_logEntries.GetGitRevAt(i).m_CommitHash.ToString()]=i;
\r
2182 if(m_LogCache.GetCacheData(m_logEntries.GetGitRevAt(i)))
\r
2184 if(firstcommit.IsEmpty())
\r
2185 firstcommit=m_logEntries.GetGitRevAt(i).m_CommitHash.ToString();
\r
2186 lastcommit=m_logEntries.GetGitRevAt(i).m_CommitHash.ToString();
\r
2190 InterlockedExchange(&m_logEntries.GetGitRevAt(i).m_IsUpdateing,FALSE);
\r
2191 InterlockedExchange(&m_logEntries.GetGitRevAt(i).m_IsFull,TRUE);
\r
2194 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0);
\r
2198 if(start>=m_logEntries.m_RawlogData.size())
\r
2201 int percent=i*30/m_logEntries.size() + GITLOG_START+1;
\r
2203 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0);
\r
2205 if(this->m_bExitThread)
\r
2207 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2208 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2212 if(!lastcommit.IsEmpty())
\r
2213 FetchFullLogInfo(lastcommit,firstcommit);
\r
2215 this->FetchLastLogInfo();
\r
2218 RedrawItems(0, m_arShownList.GetCount());
\r
2219 // SetRedraw(false);
\r
2220 // ResizeAllListCtrlCols();
\r
2221 // SetRedraw(true);
\r
2223 if ( m_pStoreSelection )
\r
2225 // Deleting the instance will restore the
\r
2226 // selection of the CLogDlg.
\r
2227 delete m_pStoreSelection;
\r
2228 m_pStoreSelection = NULL;
\r
2232 // If no selection has been set then this must be the first time
\r
2233 // the revisions are shown. Let's preselect the topmost revision.
\r
2234 if ( GetItemCount()>0 )
\r
2236 SetSelectionMark(0);
\r
2237 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
2244 //FetchFullLogInfo();
\r
2245 //FetchFullLogInfoOrig();
\r
2246 //RefreshCursor();
\r
2247 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
2248 // the log messages
\r
2250 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
2252 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2257 void CGitLogListBase::Refresh()
\r
2259 m_bExitThread=TRUE;
\r
2260 if(m_LoadingThread!=NULL)
\r
2262 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2263 if(ret == WAIT_TIMEOUT)
\r
2264 TerminateThread();
\r
2267 this->SetItemCountEx(0);
\r
2270 //Update branch and Tag info
\r
2272 //Assume Thread have exited
\r
2273 //if(!m_bThreadRunning)
\r
2276 m_logEntries.clear();
\r
2277 m_bExitThread=FALSE;
\r
2278 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
2279 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2280 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
2282 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
2283 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2284 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
2286 m_sFilterText.Empty();
\r
2287 m_From=CTime(1970,1,2,0,0,0);
\r
2288 m_To=CTime::GetCurrentTime();
\r
2291 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
2295 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
2297 type |= tr1::regex_constants::icase;
\r
2298 pat = tr1::wregex(regexp_str, type);
\r
2301 catch (exception) {}
\r
2305 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
2308 pShownlist->RemoveAll();
\r
2309 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
2310 bool bRegex = false;
\r
2311 if (m_bFilterWithRegex)
\r
2312 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
2314 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
2316 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2318 if ((bRegex)&&(m_bFilterWithRegex))
\r
2321 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2323 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
2324 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
2326 pShownlist->Add(m_logEntries[i]);
\r
2331 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2333 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).m_Subject);
\r
2334 if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
2336 pShownlist->Add(&m_logEntries[i]);
\r
2340 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).m_Body);
\r
2341 if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
2343 pShownlist->Add(&m_logEntries.GetGitRevAt(i));
\r
2348 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2350 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2352 bool bGoing = true;
\r
2353 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2355 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2356 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
2358 pShownlist->Add(m_logEntries[i]);
\r
2362 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
2364 pShownlist->Add(m_logEntries[i]);
\r
2368 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
2370 pShownlist->Add(m_logEntries[i]);
\r
2379 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2381 if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
2383 pShownlist->Add(&m_logEntries.GetGitRevAt(i));
\r
2387 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2389 sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash);
\r
2390 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
2392 pShownlist->Add(&m_logEntries.GetGitRevAt(i));
\r
2399 CString find = m_sFilterText;
\r
2402 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2404 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
2406 sBugIDs = sBugIDs.MakeLower();
\r
2407 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2409 pShownlist->Add(m_logEntries[i]);
\r
2414 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2416 CString msg = m_logEntries.GetGitRevAt(i).m_Subject;
\r
2418 msg = msg.MakeLower();
\r
2419 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2421 pShownlist->Add(&m_logEntries.GetGitRevAt(i));
\r
2424 msg = m_logEntries.GetGitRevAt(i).m_Body;
\r
2426 msg = msg.MakeLower();
\r
2427 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2429 pShownlist->Add(&m_logEntries[i]);
\r
2434 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2436 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2438 bool bGoing = true;
\r
2439 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2441 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2442 CString path = cpath->sCopyFromPath;
\r
2444 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2446 pShownlist->Add(m_logEntries[i]);
\r
2450 path = cpath->sPath;
\r
2452 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2454 pShownlist->Add(m_logEntries[i]);
\r
2458 path = cpath->GetAction();
\r
2460 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2462 pShownlist->Add(m_logEntries[i]);
\r
2469 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2471 CString msg = m_logEntries.GetGitRevAt(i).m_AuthorName;
\r
2472 msg = msg.MakeLower();
\r
2473 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2475 pShownlist->Add(&m_logEntries.GetGitRevAt(i));
\r
2479 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2481 sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash);
\r
2482 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2484 pShownlist->Add(&m_logEntries.GetGitRevAt(i));
\r
2488 } // else (from if (bRegex))
\r
2489 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2493 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
2495 __time64_t time = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime();
\r
2496 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2503 void CGitLogListBase::StartFilter()
\r
2505 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2506 RecalculateShownList(&m_arShownList);
\r
2507 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2511 SetItemCountEx(ShownCountWithStopped());
\r
2512 RedrawItems(0, ShownCountWithStopped());
\r
2514 //ResizeAllListCtrlCols();
\r
2519 void CGitLogListBase::RemoveFilter()
\r
2522 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2524 m_arShownList.RemoveAll();
\r
2526 // reset the time filter too
\r
2528 m_timFrom = (__time64_t(m_tFrom));
\r
2529 m_timTo = (__time64_t(m_tTo));
\r
2530 m_DateFrom.SetTime(&m_timFrom);
\r
2531 m_DateTo.SetTime(&m_timTo);
\r
2532 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2533 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2536 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2538 if(this->m_IsOldFirst)
\r
2540 m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
2543 m_arShownList.Add(&m_logEntries[i]);
\r
2546 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2548 SetItemCountEx(ShownCountWithStopped());
\r
2549 RedrawItems(0, ShownCountWithStopped());
\r
2550 // SetRedraw(false);
\r
2551 // ResizeAllListCtrlCols();
\r
2552 // SetRedraw(true);
\r
2554 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2557 void CGitLogListBase::Clear()
\r
2559 m_arShownList.RemoveAll();
\r
2562 m_logEntries.ClearAll();
\r
2566 void CGitLogListBase::OnDestroy()
\r
2568 // save the column widths to the registry
\r
2569 SaveColumnWidths();
\r
2571 if(this->m_bThreadRunning)
\r
2573 this->m_bExitThread=true;
\r
2574 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2575 if(ret == WAIT_TIMEOUT)
\r
2576 TerminateThread();
\r
2578 while(m_LogCache.SaveCache())
\r
2580 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
\r
2581 MB_YESNO) == IDNO)
\r
2584 CHintListCtrl::OnDestroy();
\r
2587 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
\r
2590 int i=(int)wParam;
\r
2591 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
2592 this->InvalidateRect(rect);
\r
2594 if(this->GetItemState(i,LVIF_STATE) & LVIS_SELECTED)
\r
2602 * Save column widths to the registry
\r
2604 void CGitLogListBase::SaveColumnWidths()
\r
2606 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
2609 int numcols = pHdrCtrl->GetItemCount();
\r
2610 for (int col = 0; col < numcols; col++)
\r
2612 int width = GetColumnWidth( col );
\r
2614 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
2615 CRegDWORD regwidth(regentry, 0);
\r
2616 regwidth = width; // this writes it to reg
\r
2621 int CGitLogListBase::GetHeadIndex()
\r
2623 if(m_HeadHash.IsEmpty())
\r
2626 for(int i=0;i<m_arShownList.GetCount();i++)
\r
2628 GitRev *pRev = (GitRev*)m_arShownList[i];
\r
2631 if(pRev->m_CommitHash.ToString() == m_HeadHash )
\r