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
172 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
174 PreSubclassWindow();
\r
175 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
178 void CGitLogListBase::PreSubclassWindow()
\r
180 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
181 // load the icons for the action columns
\r
182 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
183 CHintListCtrl::PreSubclassWindow();
\r
186 void CGitLogListBase::InsertGitColumn()
\r
190 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
194 temp.LoadString(IDS_LOG_GRAPH);
\r
196 if(m_IsRebaseReplaceGraph)
\r
202 temp.LoadString(IDS_LOG_GRAPH);
\r
204 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
207 // make the revision column right aligned
\r
209 Column.mask = LVCF_FMT;
\r
210 Column.fmt = LVCFMT_RIGHT;
\r
211 SetColumn(0, &Column);
\r
214 // g_Git.GetLog(log);
\r
216 if(m_IsIDReplaceAction)
\r
218 temp.LoadString(IDS_LOG_ID);
\r
219 InsertColumn(this->LOGLIST_ACTION, temp);
\r
223 temp.LoadString(IDS_LOG_ACTIONS);
\r
224 InsertColumn(this->LOGLIST_ACTION, temp);
\r
226 temp.LoadString(IDS_LOG_MESSAGE);
\r
227 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
229 temp.LoadString(IDS_LOG_AUTHOR);
\r
230 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
232 temp.LoadString(IDS_LOG_DATE);
\r
233 InsertColumn(this->LOGLIST_DATE, temp);
\r
236 if (m_bShowBugtraqColumn)
\r
238 // temp = m_ProjectProperties.sLabel;
\r
239 if (temp.IsEmpty())
\r
240 temp.LoadString(IDS_LOG_BUGIDS);
\r
241 InsertColumn(this->LOGLIST_BUG, temp);
\r
246 ResizeAllListCtrlCols();
\r
252 * Resizes all columns in a list control to values in registry.
\r
254 void CGitLogListBase::ResizeAllListCtrlCols()
\r
256 // column max and min widths to allow
\r
257 static const int nMinimumWidth = 10;
\r
258 static const int nMaximumWidth = 1000;
\r
259 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
262 int numcols = pHdrCtrl->GetItemCount();
\r
263 for (int col = 0; col < numcols; col++)
\r
265 // get width for this col last time from registry
\r
267 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
268 CRegDWORD regwidth(regentry, 0);
\r
272 // no saved value, setup sensible defaults
\r
273 if (col == this->LOGLIST_MESSAGE)
\r
275 cx = LOGLIST_MESSAGE_MIN;
\r
279 cx = ICONITEMBORDER+16*4;
\r
282 if (cx < nMinimumWidth)
\r
284 cx = nMinimumWidth;
\r
285 } else if (cx > nMaximumWidth)
\r
287 cx = nMaximumWidth;
\r
290 SetColumnWidth(col, cx);
\r
297 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
299 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
300 if(ref.Left(prefix.GetLength()) == prefix)
\r
302 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
303 if(shortname.Right(3)==_T("^{}"))
\r
304 shortname=shortname.Left(shortname.GetLength()-3);
\r
309 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
313 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
314 rItem.mask = LVIF_STATE;
\r
315 rItem.iItem = Index;
\r
316 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
319 GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index);
\r
323 if (m_Theme.IsAppThemed() && m_bVista)
\r
325 m_Theme.Open(m_hWnd, L"Explorer");
\r
326 int state = LISS_NORMAL;
\r
327 if (rItem.state & LVIS_SELECTED)
\r
329 if (::GetFocus() == m_hWnd)
\r
330 state |= LISS_SELECTED;
\r
332 state |= LISS_SELECTEDNOTFOCUS;
\r
336 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
337 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
338 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
339 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
344 ::FillRect(hdc, &rect, brush);
\r
345 ::DeleteObject(brush);
\r
349 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
350 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
352 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
357 if (rItem.state & LVIS_SELECTED)
\r
359 if (::GetFocus() == m_hWnd)
\r
360 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
362 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
366 //if (pLogEntry->bCopiedSelf)
\r
367 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
369 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
370 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
371 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
372 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
374 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
379 ::FillRect(hdc, &rect, brush);
\r
380 ::DeleteObject(brush);
\r
385 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
387 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
390 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
391 rItem.mask = LVIF_STATE;
\r
392 rItem.iItem = index;
\r
393 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
396 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
399 str=m_HashMap[data->m_CommitHash][i];
\r
404 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
406 if( shortname == m_CurrentBranch )
\r
407 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch));
\r
409 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch));
\r
411 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
413 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch));
\r
415 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
417 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag));
\r
419 else if(GetShortName(str,shortname,_T("refs/stash")))
\r
421 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Stash));
\r
422 shortname=_T("stash");
\r
426 if(!shortname.IsEmpty())
\r
429 memset(&size,0,sizeof(SIZE));
\r
430 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
432 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
434 ::FillRect(hdc, &rt, brush);
\r
435 if (rItem.state & LVIS_SELECTED)
\r
437 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
438 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
439 ::SetTextColor(hdc,clrOld);
\r
442 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
446 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
447 ::LineTo(hdc,rt.right,rt.top);
\r
448 ::LineTo(hdc,rt.right,rt.bottom);
\r
449 ::LineTo(hdc,rt.left,rt.bottom);
\r
450 ::LineTo(hdc,rt.left,rt.top);
\r
452 rt.left=rt.right+3;
\r
455 ::DeleteObject(brush);
\r
457 rt.right=rect.right;
\r
459 if (rItem.state & LVIS_SELECTED)
\r
461 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
462 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
463 ::SetTextColor(hdc,clrOld);
\r
466 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
471 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
472 const COLORREF& col,const COLORREF& activeColor, int top
\r
475 int h = laneHeight / 2;
\r
476 int m = (x1 + x2) / 2;
\r
477 int r = (x2 - x1) / 3;
\r
480 #define P_CENTER m , h+top
\r
481 #define P_0 x2, h+top
\r
482 #define P_90 m , 0+top
\r
483 #define P_180 x1, h+top
\r
484 #define P_270 m , 2 * h+top
\r
485 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
487 //static QPen myPen(Qt::black, 2); // fast path here
\r
489 pen.CreatePen(PS_SOLID,2,col);
\r
490 //myPen.setColor(col);
\r
491 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
493 //p->setPen(myPen);
\r
497 case Lanes::ACTIVE:
\r
498 case Lanes::NOT_ACTIVE:
\r
499 case Lanes::MERGE_FORK:
\r
500 case Lanes::MERGE_FORK_R:
\r
501 case Lanes::MERGE_FORK_L:
\r
503 case Lanes::JOIN_R:
\r
504 case Lanes::JOIN_L:
\r
505 DrawLine(hdc,P_90,P_270);
\r
506 //p->drawLine(P_90, P_270);
\r
509 case Lanes::HEAD_R:
\r
510 case Lanes::HEAD_L:
\r
511 case Lanes::BRANCH:
\r
512 DrawLine(hdc,P_CENTER,P_270);
\r
513 //p->drawLine(P_CENTER, P_270);
\r
516 case Lanes::TAIL_R:
\r
517 case Lanes::TAIL_L:
\r
518 case Lanes::INITIAL:
\r
519 case Lanes::BOUNDARY:
\r
520 case Lanes::BOUNDARY_C:
\r
521 case Lanes::BOUNDARY_R:
\r
522 case Lanes::BOUNDARY_L:
\r
523 DrawLine(hdc,P_90, P_CENTER);
\r
524 //p->drawLine(P_90, P_CENTER);
\r
532 case Lanes::MERGE_FORK:
\r
537 case Lanes::CROSS_EMPTY:
\r
538 case Lanes::BOUNDARY_C:
\r
539 DrawLine(hdc,P_180,P_0);
\r
540 //p->drawLine(P_180, P_0);
\r
542 case Lanes::MERGE_FORK_R:
\r
543 case Lanes::JOIN_R:
\r
544 case Lanes::HEAD_R:
\r
545 case Lanes::TAIL_R:
\r
546 case Lanes::BOUNDARY_R:
\r
547 DrawLine(hdc,P_180,P_CENTER);
\r
548 //p->drawLine(P_180, P_CENTER);
\r
550 case Lanes::MERGE_FORK_L:
\r
551 case Lanes::JOIN_L:
\r
552 case Lanes::HEAD_L:
\r
553 case Lanes::TAIL_L:
\r
554 case Lanes::BOUNDARY_L:
\r
555 DrawLine(hdc,P_CENTER,P_0);
\r
556 //p->drawLine(P_CENTER, P_0);
\r
563 brush.CreateSolidBrush(col);
\r
564 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
565 // center symbol, e.g. rect or ellipse
\r
567 case Lanes::ACTIVE:
\r
568 case Lanes::INITIAL:
\r
569 case Lanes::BRANCH:
\r
571 //p->setPen(Qt::NoPen);
\r
572 //p->setBrush(col);
\r
573 ::Ellipse(hdc, R_CENTER);
\r
574 //p->drawEllipse(R_CENTER);
\r
576 case Lanes::MERGE_FORK:
\r
577 case Lanes::MERGE_FORK_R:
\r
578 case Lanes::MERGE_FORK_L:
\r
579 //p->setPen(Qt::NoPen);
\r
580 //p->setBrush(col);
\r
581 //p->drawRect(R_CENTER);
\r
582 Rectangle(hdc,R_CENTER);
\r
584 case Lanes::UNAPPLIED:
\r
586 //p->setPen(Qt::NoPen);
\r
587 //p->setBrush(Qt::red);
\r
588 //p->drawRect(m - r, h - 1, d, 2);
\r
589 ::Rectangle(hdc,m-r,h-1,d,2);
\r
591 case Lanes::APPLIED:
\r
593 //p->setPen(Qt::NoPen);
\r
594 //p->setBrush(DARK_GREEN);
\r
595 //p->drawRect(m - r, h - 1, d, 2);
\r
596 //p->drawRect(m - 1, h - r, 2, d);
\r
597 ::Rectangle(hdc,m-r,h-1,d,2);
\r
598 ::Rectangle(hdc,m-1,h-r,2,d);
\r
600 case Lanes::BOUNDARY:
\r
601 //p->setBrush(back);
\r
602 //p->drawEllipse(R_CENTER);
\r
603 ::Ellipse(hdc, R_CENTER);
\r
605 case Lanes::BOUNDARY_C:
\r
606 case Lanes::BOUNDARY_R:
\r
607 case Lanes::BOUNDARY_L:
\r
608 //p->setBrush(back);
\r
609 //p->drawRect(R_CENTER);
\r
610 ::Rectangle(hdc,R_CENTER);
\r
616 ::SelectObject(hdc,oldpen);
\r
617 ::SelectObject(hdc,oldbrush);
\r
626 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
630 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
631 if(data->m_CommitHash.IsEmpty())
\r
636 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
637 rItem.mask = LVIF_STATE;
\r
638 rItem.iItem = index;
\r
639 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
643 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
647 if (data->m_Lanes.size() == 0)
\r
648 m_logEntries.setLane(data->m_CommitHash);
\r
650 std::vector<int>& lanes=data->m_Lanes;
\r
651 UINT laneNum = lanes.size();
\r
652 UINT activeLane = 0;
\r
653 for (UINT i = 0; i < laneNum; i++)
\r
654 if (Lanes::isMerge(lanes[i])) {
\r
659 int x1 = 0, x2 = 0;
\r
660 int maxWidth = rect.Width();
\r
661 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
663 COLORREF activeColor = m_LineColors[activeLane % Lanes::COLORS_NUM];
\r
664 //if (opt.state & QStyle::State_Selected)
\r
665 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
\r
668 for (unsigned int i = 0; i < laneNum && x2 < maxWidth; i++)
\r
675 if (ln == Lanes::EMPTY)
\r
678 COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM];
\r
679 paintGraphLane(hdc, rect.Height(),ln, x1, x2, color,activeColor, rect.top);
\r
683 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
689 if (ln == Lanes::EMPTY)
\r
692 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
693 || ln ==Lanes:: CROSS_EMPTY) ? activeLane : i;
\r
695 if (ln == Lanes::CROSS) {
\r
696 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
697 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[activeLane % Lanes::COLORS_NUM],rect.top);
\r
699 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
703 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
706 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
709 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
710 // Take the default processing unless we set this to something else below.
\r
711 *pResult = CDRF_DODEFAULT;
\r
713 if (m_bNoDispUpdates)
\r
718 switch (pLVCD->nmcd.dwDrawStage)
\r
720 case CDDS_PREPAINT:
\r
722 *pResult = CDRF_NOTIFYITEMDRAW;
\r
726 case CDDS_ITEMPREPAINT:
\r
728 // This is the prepaint stage for an item. Here's where we set the
\r
729 // item's text color.
\r
731 // Tell Windows to send draw notifications for each subitem.
\r
732 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
734 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
736 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
738 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
742 if (data->bCopiedSelf)
\r
744 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
745 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
746 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
750 crText = m_Colors.GetColor(CColors::Modified);
\r
752 if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
\r
753 crText = RGB(128,128,128);
\r
755 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
756 pLVCD->clrTextBk = RGB(156,156,156);
\r
757 else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
758 pLVCD->clrTextBk = RGB(200,200,128);
\r
760 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
\r
762 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)
\r
764 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
765 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
768 if(data->m_CommitHash == m_HeadHash)
\r
770 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
771 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
774 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
775 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
776 // if (data->Rev == m_wcRev)
\r
778 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
779 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
780 // tells the control to recalculate the extent of the text.
\r
781 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
785 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
787 if (m_bStrictStopped)
\r
788 crText = GetSysColor(COLOR_GRAYTEXT);
\r
790 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
791 pLVCD->clrText = crText;
\r
795 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
797 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
799 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
802 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
804 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
\r
807 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
809 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
810 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
812 *pResult = CDRF_SKIPDEFAULT;
\r
818 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
820 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
822 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
823 //if(!data->m_IsFull)
\r
825 //if(data->SafeFetchFullInfo(&g_Git))
\r
826 // this->Invalidate();
\r
827 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
830 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
834 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
836 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
837 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
839 *pResult = CDRF_SKIPDEFAULT;
\r
846 if (pLVCD->iSubItem == 1)
\r
848 if(this->m_IsIDReplaceAction)
\r
850 *pResult = CDRF_DODEFAULT;
\r
853 *pResult = CDRF_DODEFAULT;
\r
855 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
859 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
860 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
862 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
864 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
865 // Get the selected state of the
\r
866 // item being drawn.
\r
868 // Fill the background
\r
869 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
871 // Draw the icon(s) into the compatible DC
\r
872 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
873 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
876 if (pLogEntry->m_Action & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
\r
877 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
880 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
881 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
884 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
885 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
887 *pResult = CDRF_SKIPDEFAULT;
\r
893 *pResult = CDRF_DODEFAULT;
\r
897 // CGitLogListBase message handlers
\r
899 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
901 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
903 // Create a pointer to the item
\r
904 LV_ITEM* pItem = &(pDispInfo)->item;
\r
906 // Do the list need text information?
\r
907 if (!(pItem->mask & LVIF_TEXT))
\r
910 // By default, clear text buffer.
\r
911 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
913 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
916 if (m_bNoDispUpdates || bOutOfRange)
\r
919 // Which item number?
\r
920 int itemid = pItem->iItem;
\r
921 GitRev * pLogEntry = NULL;
\r
922 if (itemid < m_arShownList.GetCount())
\r
923 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
928 temp.Format(_T("%d"),pItem->iItem+1);
\r
932 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
936 switch (pItem->iSubItem)
\r
938 case this->LOGLIST_GRAPH: //Graphic
\r
941 if(this->m_IsRebaseReplaceGraph)
\r
944 path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
\r
946 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
\r
950 case this->LOGLIST_ACTION: //action -- no text in the column
\r
951 if(this->m_IsIDReplaceAction)
\r
952 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
954 case this->LOGLIST_MESSAGE: //Message
\r
956 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
958 case this->LOGLIST_AUTHOR: //Author
\r
960 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
962 case this->LOGLIST_DATE: //Date
\r
964 lstrcpyn(pItem->pszText,
\r
965 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
966 pItem->cchTextMax);
\r
977 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
980 int selIndex = GetSelectionMark();
\r
982 return; // nothing selected, nothing to do with a context menu
\r
984 // if the user selected the info text telling about not all revisions shown due to
\r
985 // the "stop on copy/rename" option, we also don't show the context menu
\r
986 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
989 // if the context menu is invoked through the keyboard, we have to use
\r
990 // a calculated position on where to anchor the menu on
\r
991 if ((point.x == -1) && (point.y == -1))
\r
994 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
995 ClientToScreen(&rect);
\r
996 point = rect.CenterPoint();
\r
998 m_nSearchIndex = selIndex;
\r
999 m_bCancelled = FALSE;
\r
1001 // calculate some information the context menu commands can use
\r
1002 // CString pathURL = GetURLFromPath(m_path);
\r
1004 POSITION pos = GetFirstSelectedItemPosition();
\r
1005 int indexNext = GetNextSelectedItem(pos);
\r
1006 if (indexNext < 0)
\r
1009 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
1011 GitRev revSelected = pSelLogEntry->Rev;
\r
1012 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
1013 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
1015 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
1017 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
1018 if (changedpath->lCopyFromRev)
\r
1019 revPrevious = changedpath->lCopyFromRev;
\r
1022 GitRev revSelected2;
\r
1025 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1026 revSelected2 = pLogEntry->Rev;
\r
1028 bool bAllFromTheSameAuthor = true;
\r
1029 CString firstAuthor;
\r
1030 CLogDataVector selEntries;
\r
1031 GitRev revLowest, revHighest;
\r
1032 GitRevRangeArray revisionRanges;
\r
1034 POSITION pos = GetFirstSelectedItemPosition();
\r
1035 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1036 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1037 selEntries.push_back(pLogEntry);
\r
1038 firstAuthor = pLogEntry->sAuthor;
\r
1039 revLowest = pLogEntry->Rev;
\r
1040 revHighest = pLogEntry->Rev;
\r
1043 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1044 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1045 selEntries.push_back(pLogEntry);
\r
1046 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
1047 bAllFromTheSameAuthor = false;
\r
1048 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
1049 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
1055 int FirstSelect=-1, LastSelect=-1;
\r
1056 pos = GetFirstSelectedItemPosition();
\r
1057 FirstSelect = GetNextSelectedItem(pos);
\r
1060 LastSelect = GetNextSelectedItem(pos);
\r
1062 //entry is selected, now show the popup menu
\r
1064 CIconMenu submenu;
\r
1065 if (popup.CreatePopupMenu())
\r
1068 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
\r
1069 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_SKIP, IDI_PICK);
\r
1071 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
\r
1072 popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH);
\r
1074 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
\r
1075 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
\r
1077 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
\r
1078 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
\r
1080 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
\r
1081 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
\r
1082 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1084 if (GetSelectedCount() == 1)
\r
1089 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))
\r
1090 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1092 // TortoiseMerge could be improved to take a /blame switch
\r
1093 // and then not 'cat' the files from a unified diff but
\r
1095 // But until that's implemented, the context menu entry for
\r
1096 // this feature is commented out.
\r
1097 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1099 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))
\r
1100 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1102 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
\r
1103 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1104 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1105 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1108 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1110 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1112 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1114 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1116 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1117 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1119 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1123 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1125 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1127 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1129 CString str,format;
\r
1130 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
\r
1131 str.Format(format,g_Git.GetCurrentBranch());
\r
1133 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))
\r
1134 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1136 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))
\r
1137 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
\r
1139 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
\r
1140 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
\r
1142 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
\r
1143 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);
\r
1145 format.LoadString(IDS_REBASE_THIS_FORMAT);
\r
1146 str.Format(format,g_Git.GetCurrentBranch());
\r
1148 if(pSelLogEntry->m_CommitHash != m_HeadHash)
\r
1149 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
\r
1150 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
\r
1152 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
\r
1153 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
\r
1156 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1160 if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1)
\r
1162 popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE);
\r
1163 popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE);
\r
1164 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1167 if (GetSelectedCount() >= 2)
\r
1169 bool bAddSeparator = false;
\r
1170 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1172 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO))
\r
1173 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1176 if (GetSelectedCount() == 2)
\r
1178 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1179 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2))
\r
1180 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1181 bAddSeparator = true;
\r
1186 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1188 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1189 bAddSeparator = true;
\r
1191 if (bAddSeparator)
\r
1192 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1195 if ( GetSelectedCount() >0 )
\r
1197 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
\r
1199 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT))
\r
1203 headindex = this->GetHeadIndex();
\r
1206 head.Format(_T("HEAD~%d"),LastSelect-headindex);
\r
1207 CString hash=g_Git.GetHash(head);
\r
1208 hash=hash.Left(40);
\r
1209 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1210 if(pLastEntry->m_CommitHash == hash)
\r
1211 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
\r
1215 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))
\r
1216 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
\r
1218 if(GetSelectedCount()<=2)
\r
1219 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH))
\r
1220 popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH);
\r
1222 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1228 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1230 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1232 // if (GetSelectedCount() == 1)
\r
1234 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1235 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1236 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1241 if (GetSelectedCount() == 1)
\r
1243 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
\r
1244 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH);
\r
1246 if (GetSelectedCount() != 0)
\r
1248 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
\r
1249 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1252 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
\r
1253 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1256 if (GetSelectedCount() == 1)
\r
1258 if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE))
\r
1260 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() )
\r
1263 str.LoadString(IDS_DELETE_BRANCHTAG);
\r
1264 if( m_HashMap[pSelLogEntry->m_CommitHash].size() == 1 )
\r
1267 str+=m_HashMap[pSelLogEntry->m_CommitHash].at(0);
\r
1268 popup.AppendMenuIcon(ID_DELETE,str+_T("..."),IDI_DELETE);
\r
1270 else if( m_HashMap[pSelLogEntry->m_CommitHash].size() > 1 )
\r
1273 submenu.CreatePopupMenu();
\r
1274 for(int i=0;i<m_HashMap[pSelLogEntry->m_CommitHash].size();i++)
\r
1276 submenu.AppendMenuIcon(ID_DELETE+(i<<16),m_HashMap[pSelLogEntry->m_CommitHash][i]+_T("..."));
\r
1279 popup.AppendMenu(MF_BYPOSITION|MF_POPUP|MF_STRING,(UINT) submenu.m_hMenu,str);
\r
1287 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1288 // DialogEnableWindow(IDOK, FALSE);
\r
1289 // SetPromptApp(&theApp);
\r
1291 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1293 // EnableOKButton();
\r
1294 } // if (popup.CreatePopupMenu())
\r
1298 bool CGitLogListBase::IsSelectionContinuous()
\r
1300 if ( GetSelectedCount()==1 )
\r
1302 // if only one revision is selected, the selection is of course
\r
1307 POSITION pos = GetFirstSelectedItemPosition();
\r
1308 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1311 int itemindex = GetNextSelectedItem(pos);
\r
1314 int nextindex = GetNextSelectedItem(pos);
\r
1315 if (nextindex - itemindex > 1)
\r
1317 bContinuous = false;
\r
1320 itemindex = nextindex;
\r
1323 return bContinuous;
\r
1326 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1329 CString sClipdata;
\r
1330 POSITION pos = GetFirstSelectedItemPosition();
\r
1334 sRev.LoadString(IDS_LOG_REVISION);
\r
1336 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1338 sDate.LoadString(IDS_LOG_DATE);
\r
1340 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1343 CString sLogCopyText;
\r
1345 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1349 //pLogEntry->m_Files
\r
1350 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1352 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1354 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1355 sPaths += _T("\r\n");
\r
1358 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
1359 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1360 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1362 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1363 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1365 sClipdata += sLogCopyText;
\r
1368 sClipdata += pLogEntry->m_CommitHash;
\r
1373 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1378 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1380 if (m_bThreadRunning)
\r
1383 int FirstSelect=-1, LastSelect=-1;
\r
1384 POSITION pos = GetFirstSelectedItemPosition();
\r
1385 FirstSelect = GetNextSelectedItem(pos);
\r
1388 LastSelect = GetNextSelectedItem(pos);
\r
1391 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect);
\r
1394 UpdateLogInfoLabel();
\r
1395 int selIndex = m_LogList.GetSelectionMark();
\r
1398 int selCount = m_LogList.GetSelectedCount();
\r
1399 if (selCount != 1)
\r
1402 // Find selected entry in the log list
\r
1403 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1404 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1405 long rev1 = pLogEntry->Rev;
\r
1406 long rev2 = rev1-1;
\r
1407 CTGitPath path = m_path;
\r
1409 // See how many files under the relative root were changed in selected revision
\r
1411 LogChangedPath * changed = NULL;
\r
1412 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1414 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1415 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1422 if (m_path.IsDirectory() && nChanged == 1)
\r
1424 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1425 // Do diff on that file instead of whole directory
\r
1426 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1429 m_bCancelled = FALSE;
\r
1430 DialogEnableWindow(IDOK, FALSE);
\r
1431 SetPromptApp(&theApp);
\r
1432 theApp.DoWaitCursor(1);
\r
1434 if (PromptShown())
\r
1436 GitDiff diff(this, m_hWnd, true);
\r
1437 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1438 diff.SetHEADPeg(m_LogRevision);
\r
1439 diff.ShowCompare(path, rev2, path, rev1);
\r
1443 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1446 theApp.DoWaitCursor(-1);
\r
1451 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1453 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1456 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1458 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1460 if (pFindInfo->lvfi.psz == 0)
\r
1463 CString sCmp = pFindInfo->lvfi.psz;
\r
1465 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1467 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1468 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1469 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1471 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1479 if (sCmp.Compare(sRev)==0)
\r
1486 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1488 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1490 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1491 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1492 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1494 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1502 if (sCmp.Compare(sRev)==0)
\r
1514 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
\r
1518 this->m_logEntries.ClearAll();
\r
1519 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
\r
1521 //this->m_logEntries.ParserFromLog();
\r
1522 SetItemCountEx(this->m_logEntries.size());
\r
1524 this->m_arShownList.RemoveAll();
\r
1526 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1530 m_logEntries[m_logEntries.size()-i-1].m_IsFull=TRUE;
\r
1531 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
1535 m_logEntries[i].m_IsFull=TRUE;
\r
1536 this->m_arShownList.Add(&m_logEntries[i]);
\r
1546 int CGitLogListBase::FillGitShortLog()
\r
1550 this->m_logEntries.ClearAll();
\r
1552 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1555 if(this->m_Path.IsEmpty())
\r
1558 path=&this->m_Path;
\r
1562 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1563 // if(this->m_bAllBranch)
\r
1564 mask |= m_ShowMask;
\r
1566 this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask);
\r
1568 //this->m_logEntries.ParserFromLog();
\r
1569 if(IsInWorkingThread())
\r
1570 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
\r
1572 SetItemCountEx(this->m_logEntries.size());
\r
1574 this->m_arShownList.RemoveAll();
\r
1576 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1578 m_logEntries[i].m_Subject=_T("parser...");
\r
1579 if(this->m_IsOldFirst)
\r
1581 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);
\r
1585 this->m_arShownList.Add(&m_logEntries[i]);
\r
1591 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1593 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1594 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1595 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1597 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1599 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1601 DiffSelectedRevWithPrevious();
\r
1606 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1608 DiffSelectedFile();
\r
1615 if (m_hAccel && !bSkipAccelerator)
\r
1617 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1623 //m_tooltips.RelayEvent(pMsg);
\r
1624 return __super::PreTranslateMessage(pMsg);
\r
1627 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1629 // a double click on an entry in the revision list has happened
\r
1632 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1633 DiffSelectedRevWithPrevious();
\r
1636 int CGitLogListBase::FetchLogAsync(void * data)
\r
1639 m_bExitThread=FALSE;
\r
1640 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1641 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1642 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1643 if (m_LoadingThread ==NULL)
\r
1645 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1646 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1647 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1653 //this is the thread function which calls the subversion function
\r
1654 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1656 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1659 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1662 oldest=CTime::GetCurrentTime();
\r
1663 latest=CTime(1971,1,2,0,0,0);
\r
1664 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1666 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1667 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1669 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1670 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1675 //Helper class for FetchFullLogInfo()
\r
1676 class CGitCall_FetchFullLogInfo : public CGitCall
\r
1679 CGitCall_FetchFullLogInfo(CGitLogListBase* ploglist):m_ploglist(ploglist),m_CollectedCount(0){}
\r
1680 virtual bool OnOutputData(const BYTE* data, size_t size)
\r
1683 return m_ploglist->m_bExitThread;
\r
1684 //Add received data to byte collector
\r
1685 m_ByteCollector.append(data,size);
\r
1687 //Find loginfo endmarker
\r
1688 static const BYTE dataToFind[]={0,0,'#','<'};
\r
1689 int found=m_ByteCollector.findData(dataToFind,4);
\r
1691 return m_ploglist->m_bExitThread;//Not found
\r
1692 found+=2;//Position after loginfo end-marker
\r
1694 //Prepare data for OnLogInfo and call it
\r
1695 BYTE_VECTOR logInfo;
\r
1696 logInfo.append(&*m_ByteCollector.begin(),found);
\r
1697 OnLogInfo(logInfo);
\r
1699 //Remove loginfo from bytecollector
\r
1700 m_ByteCollector.erase(m_ByteCollector.begin(),m_ByteCollector.begin()+found);
\r
1702 return m_ploglist->m_bExitThread;
\r
1704 virtual void OnEnd()
\r
1706 //Rest should be a complete log line.
\r
1707 if(!m_ByteCollector.empty())
\r
1708 OnLogInfo(m_ByteCollector);
\r
1712 void OnLogInfo(BYTE_VECTOR& logInfo)
\r
1715 fullRev.ParserFromLog(logInfo);
\r
1716 MAP_HASH_REV::iterator itRev=m_ploglist->m_logEntries.m_HashMap.find(fullRev.m_CommitHash);
\r
1717 if(itRev==m_ploglist->m_logEntries.m_HashMap.end())
\r
1719 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
\r
1723 int rev=itRev->second;
\r
1724 GitRev* revInVector=&m_ploglist->m_logEntries[rev];
\r
1727 if(revInVector->m_IsFull)
\r
1730 if(!m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev]))
\r
1732 ++m_CollectedCount;
\r
1733 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsUpdateing,FALSE);
\r
1734 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsFull,TRUE);
\r
1735 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1739 // fullRev.m_IsUpdateing=TRUE;
\r
1740 // fullRev.m_IsFull=TRUE;
\r
1743 if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE))
\r
1744 return;//Cannot update this row now. Ignore.
\r
1745 TCHAR oldmark=revInVector->m_Mark;
\r
1746 GIT_REV_LIST oldlist=revInVector->m_ParentHash;
\r
1747 // CString oldhash=m_CommitHash;
\r
1749 //Parse new rev info
\r
1750 revInVector->ParserFromLog(logInfo);
\r
1753 revInVector->m_Mark=oldmark; //parser full log will cause old mark overwrited.
\r
1754 //So we need keep old bound mark.
\r
1755 revInVector->m_ParentHash=oldlist;
\r
1758 m_ploglist->m_LogCache.AddCacheEntry(*revInVector);
\r
1761 InterlockedExchange(&revInVector->m_IsFull,TRUE);
\r
1762 InterlockedExchange(&revInVector->m_IsUpdateing,FALSE);
\r
1764 //Notify listcontrol and update progress bar
\r
1765 ++m_CollectedCount;
\r
1767 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1769 DWORD percent=m_CollectedCount*68/m_ploglist->m_logEntries.size() + GITLOG_START+1+30;
\r
1770 if(percent == GITLOG_END)
\r
1771 percent = GITLOG_END -1;
\r
1773 ::PostMessage(m_ploglist->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1776 CGitLogListBase* m_ploglist;
\r
1777 BYTE_VECTOR m_ByteCollector;
\r
1778 int m_CollectedCount;
\r
1782 void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to)
\r
1784 CGitCall_FetchFullLogInfo fetcher(this);
\r
1786 CGit::LOG_INFO_STAT|
\r
1787 CGit::LOG_INFO_FILESTATE|
\r
1788 CGit::LOG_INFO_DETECT_COPYRENAME|
\r
1789 CGit::LOG_INFO_SHOW_MERGEDFILE |
\r
1793 if(this->m_Path.IsEmpty())
\r
1796 path=&this->m_Path;
\r
1798 g_Git.GetLog(&fetcher,CString(),path,-1,mask,&from,&to);
\r
1801 void CGitLogListBase::FetchLastLogInfo()
\r
1803 unsigned int updated=0;
\r
1807 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1809 if(m_logEntries[i].m_IsFull)
\r
1812 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1814 if(!m_logEntries.FetchFullInfo(i))
\r
1818 m_LogCache.AddCacheEntry(m_logEntries[i]);
\r
1823 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1824 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1827 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
\r
1831 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1832 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1839 UINT CGitLogListBase::LogThread()
\r
1842 // if(m_ProcCallBack)
\r
1843 // m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1844 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
1846 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1847 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1849 //does the user force the cache to refresh (shift or control key down)?
\r
1850 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1851 || (GetKeyState (VK_SHIFT) < 0);
\r
1853 //disable the "Get All" button while we're receiving
\r
1856 FillGitShortLog();
\r
1858 if(this->m_bExitThread)
\r
1860 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1861 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1864 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1865 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START_ALL, 0);
\r
1867 int start=0; CString firstcommit,lastcommit;
\r
1869 for(int i=0;i<m_logEntries.size();i++)
\r
1871 start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start);
\r
1872 m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i;
\r
1874 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1876 if(firstcommit.IsEmpty())
\r
1877 firstcommit=m_logEntries[i].m_CommitHash;
\r
1878 lastcommit=m_logEntries[i].m_CommitHash;
\r
1882 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1883 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1888 if(start>=m_logEntries.m_RawlogData.size())
\r
1891 int percent=i*30/m_logEntries.size() + GITLOG_START+1;
\r
1893 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0);
\r
1894 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0);
\r
1896 if(this->m_bExitThread)
\r
1898 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1899 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1903 if(!lastcommit.IsEmpty())
\r
1904 FetchFullLogInfo(lastcommit,firstcommit);
\r
1906 this->FetchLastLogInfo();
\r
1909 RedrawItems(0, m_arShownList.GetCount());
\r
1910 // SetRedraw(false);
\r
1911 // ResizeAllListCtrlCols();
\r
1912 // SetRedraw(true);
\r
1914 if ( m_pStoreSelection )
\r
1916 // Deleting the instance will restore the
\r
1917 // selection of the CLogDlg.
\r
1918 delete m_pStoreSelection;
\r
1919 m_pStoreSelection = NULL;
\r
1923 // If no selection has been set then this must be the first time
\r
1924 // the revisions are shown. Let's preselect the topmost revision.
\r
1925 if ( GetItemCount()>0 )
\r
1927 SetSelectionMark(0);
\r
1928 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1935 //FetchFullLogInfo();
\r
1936 //FetchFullLogInfoOrig();
\r
1937 //RefreshCursor();
\r
1938 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1939 // the log messages
\r
1941 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
1943 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1948 void CGitLogListBase::Refresh()
\r
1950 m_bExitThread=TRUE;
\r
1951 if(m_LoadingThread!=NULL)
\r
1953 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
1954 if(ret == WAIT_TIMEOUT)
\r
1955 TerminateThread();
\r
1960 //Update branch and Tag info
\r
1962 //Assume Thread have exited
\r
1963 //if(!m_bThreadRunning)
\r
1965 this->SetItemCountEx(0);
\r
1966 m_logEntries.clear();
\r
1967 m_bExitThread=FALSE;
\r
1968 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1969 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1970 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1972 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1973 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1974 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1976 m_sFilterText.Empty();
\r
1977 m_From=CTime(1970,1,2,0,0,0);
\r
1978 m_To=CTime::GetCurrentTime();
\r
1981 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1985 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1987 type |= tr1::regex_constants::icase;
\r
1988 pat = tr1::wregex(regexp_str, type);
\r
1991 catch (exception) {}
\r
1995 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1998 pShownlist->RemoveAll();
\r
1999 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
2000 bool bRegex = false;
\r
2001 if (m_bFilterWithRegex)
\r
2002 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
2004 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
2006 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2008 if ((bRegex)&&(m_bFilterWithRegex))
\r
2011 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2013 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
2014 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
2016 pShownlist->Add(m_logEntries[i]);
\r
2021 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2023 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
2024 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
2026 pShownlist->Add(&m_logEntries[i]);
\r
2030 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
2031 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
2033 pShownlist->Add(&m_logEntries[i]);
\r
2038 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2040 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2042 bool bGoing = true;
\r
2043 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2045 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2046 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
2048 pShownlist->Add(m_logEntries[i]);
\r
2052 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
2054 pShownlist->Add(m_logEntries[i]);
\r
2058 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
2060 pShownlist->Add(m_logEntries[i]);
\r
2069 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2071 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
2073 pShownlist->Add(&m_logEntries[i]);
\r
2077 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2079 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2080 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
2082 pShownlist->Add(&m_logEntries[i]);
\r
2089 CString find = m_sFilterText;
\r
2092 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2094 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
2096 sBugIDs = sBugIDs.MakeLower();
\r
2097 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2099 pShownlist->Add(m_logEntries[i]);
\r
2104 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2106 CString msg = m_logEntries[i].m_Subject;
\r
2108 msg = msg.MakeLower();
\r
2109 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2111 pShownlist->Add(&m_logEntries[i]);
\r
2114 msg = m_logEntries[i].m_Body;
\r
2116 msg = msg.MakeLower();
\r
2117 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2119 pShownlist->Add(&m_logEntries[i]);
\r
2124 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2126 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2128 bool bGoing = true;
\r
2129 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2131 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2132 CString path = cpath->sCopyFromPath;
\r
2134 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2136 pShownlist->Add(m_logEntries[i]);
\r
2140 path = cpath->sPath;
\r
2142 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2144 pShownlist->Add(m_logEntries[i]);
\r
2148 path = cpath->GetAction();
\r
2150 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2152 pShownlist->Add(m_logEntries[i]);
\r
2159 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2161 CString msg = m_logEntries[i].m_AuthorName;
\r
2162 msg = msg.MakeLower();
\r
2163 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2165 pShownlist->Add(&m_logEntries[i]);
\r
2169 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2171 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2172 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2174 pShownlist->Add(&m_logEntries[i]);
\r
2178 } // else (from if (bRegex))
\r
2179 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2183 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
2185 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2186 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2193 void CGitLogListBase::StartFilter()
\r
2195 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2196 RecalculateShownList(&m_arShownList);
\r
2197 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2201 SetItemCountEx(ShownCountWithStopped());
\r
2202 RedrawItems(0, ShownCountWithStopped());
\r
2204 //ResizeAllListCtrlCols();
\r
2209 void CGitLogListBase::RemoveFilter()
\r
2212 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2214 m_arShownList.RemoveAll();
\r
2216 // reset the time filter too
\r
2218 m_timFrom = (__time64_t(m_tFrom));
\r
2219 m_timTo = (__time64_t(m_tTo));
\r
2220 m_DateFrom.SetTime(&m_timFrom);
\r
2221 m_DateTo.SetTime(&m_timTo);
\r
2222 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2223 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2226 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2228 if(this->m_IsOldFirst)
\r
2230 m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
2233 m_arShownList.Add(&m_logEntries[i]);
\r
2236 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2238 SetItemCountEx(ShownCountWithStopped());
\r
2239 RedrawItems(0, ShownCountWithStopped());
\r
2240 // SetRedraw(false);
\r
2241 // ResizeAllListCtrlCols();
\r
2242 // SetRedraw(true);
\r
2244 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2247 void CGitLogListBase::Clear()
\r
2249 m_arShownList.RemoveAll();
\r
2252 m_logEntries.ClearAll();
\r
2256 void CGitLogListBase::OnDestroy()
\r
2258 // save the column widths to the registry
\r
2259 SaveColumnWidths();
\r
2261 if(this->m_bThreadRunning)
\r
2263 this->m_bExitThread=true;
\r
2264 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2265 if(ret == WAIT_TIMEOUT)
\r
2266 TerminateThread();
\r
2268 while(m_LogCache.SaveCache())
\r
2270 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
\r
2271 MB_YESNO) == IDNO)
\r
2274 CHintListCtrl::OnDestroy();
\r
2277 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
\r
2280 int i=(int)wParam;
\r
2281 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
2282 this->InvalidateRect(rect);
\r
2287 * Save column widths to the registry
\r
2289 void CGitLogListBase::SaveColumnWidths()
\r
2291 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
2294 int numcols = pHdrCtrl->GetItemCount();
\r
2295 for (int col = 0; col < numcols; col++)
\r
2297 int width = GetColumnWidth( col );
\r
2299 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
2300 CRegDWORD regwidth(regentry, 0);
\r
2301 regwidth = width; // this writes it to reg
\r
2306 int CGitLogListBase::GetHeadIndex()
\r
2308 if(m_HeadHash.IsEmpty())
\r
2311 for(int i=0;i<m_arShownList.GetCount();i++)
\r
2313 GitRev *pRev = (GitRev*)m_arShownList[i];
\r
2316 if(pRev->m_CommitHash == m_HeadHash )
\r