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
61 // use the default GUI font, create a copy of it and
\r
62 // change the copy to BOLD (leave the rest of the font
\r
64 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
66 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
67 lf.lfWeight = FW_BOLD;
\r
68 m_boldFont = CreateFontIndirect(&lf);
\r
70 m_bShowBugtraqColumn=0;
\r
72 m_IsIDReplaceAction=FALSE;
\r
74 m_wcRev.m_CommitHash=GIT_REV_ZERO;
\r
75 m_wcRev.m_Subject=_T("Working Copy");
\r
77 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
78 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
79 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
80 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
82 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
84 g_Git.GetMapHashToFriendName(m_HashMap);
\r
85 m_CurrentBranch=g_Git.GetCurrentBranch();
\r
86 this->m_HeadHash=g_Git.GetHash(CString(_T("HEAD"))).Left(40);
\r
88 m_From=CTime(1970,1,2,0,0,0);
\r
89 m_To=CTime::GetCurrentTime();
\r
91 m_LoadingThread = NULL;
\r
93 m_bExitThread=FALSE;
\r
94 m_IsOldFirst = FALSE;
\r
95 m_IsRebaseReplaceGraph = FALSE;
\r
98 for(int i=0;i<Lanes::COLORS_NUM;i++)
\r
100 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
\r
102 // get short/long datetime setting from registry
\r
103 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
\r
104 if ( RegUseShortDateFormat )
\r
106 m_DateFormat = DATE_SHORTDATE;
\r
110 m_DateFormat = DATE_LONGDATE;
\r
112 // get relative time display setting from registry
\r
113 DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);
\r
114 m_bRelativeTimes = (regRelativeTimes != 0);
\r
115 m_ContextMenuMask = 0xFFFFFFFFFFFFFFFF;
\r
117 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_PICK);
\r
118 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SQUASH);
\r
119 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT);
\r
120 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP);
\r
122 m_ColumnRegKey=_T("log");
\r
125 CGitLogListBase::~CGitLogListBase()
\r
127 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
129 DestroyIcon(m_hModifiedIcon);
\r
130 DestroyIcon(m_hReplacedIcon);
\r
131 DestroyIcon(m_hAddedIcon);
\r
132 DestroyIcon(m_hDeletedIcon);
\r
133 m_logEntries.ClearAll();
\r
136 DeleteObject(m_boldFont);
\r
138 if ( m_pStoreSelection )
\r
140 delete m_pStoreSelection;
\r
141 m_pStoreSelection = NULL;
\r
144 if(this->m_bThreadRunning)
\r
146 m_bExitThread=true;
\r
147 WaitForSingleObject(m_LoadingThread->m_hThread,1000);
\r
153 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
154 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
155 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
156 ON_WM_CONTEXTMENU()
\r
157 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
158 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
161 ON_MESSAGE(MSG_LOADED,OnLoad)
\r
164 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
166 PreSubclassWindow();
\r
167 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
170 void CGitLogListBase::PreSubclassWindow()
\r
172 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
173 // load the icons for the action columns
\r
174 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
175 CHintListCtrl::PreSubclassWindow();
\r
178 void CGitLogListBase::InsertGitColumn()
\r
182 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
186 temp.LoadString(IDS_LOG_GRAPH);
\r
188 if(m_IsRebaseReplaceGraph)
\r
194 temp.LoadString(IDS_LOG_GRAPH);
\r
196 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
199 // make the revision column right aligned
\r
201 Column.mask = LVCF_FMT;
\r
202 Column.fmt = LVCFMT_RIGHT;
\r
203 SetColumn(0, &Column);
\r
206 // g_Git.GetLog(log);
\r
208 if(m_IsIDReplaceAction)
\r
210 temp.LoadString(IDS_LOG_ID);
\r
211 InsertColumn(this->LOGLIST_ACTION, temp);
\r
215 temp.LoadString(IDS_LOG_ACTIONS);
\r
216 InsertColumn(this->LOGLIST_ACTION, temp);
\r
218 temp.LoadString(IDS_LOG_MESSAGE);
\r
219 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
221 temp.LoadString(IDS_LOG_AUTHOR);
\r
222 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
224 temp.LoadString(IDS_LOG_DATE);
\r
225 InsertColumn(this->LOGLIST_DATE, temp);
\r
228 if (m_bShowBugtraqColumn)
\r
230 // temp = m_ProjectProperties.sLabel;
\r
231 if (temp.IsEmpty())
\r
232 temp.LoadString(IDS_LOG_BUGIDS);
\r
233 InsertColumn(this->LOGLIST_BUG, temp);
\r
238 ResizeAllListCtrlCols();
\r
244 * Resizes all columns in a list control to values in registry.
\r
246 void CGitLogListBase::ResizeAllListCtrlCols()
\r
248 // column max and min widths to allow
\r
249 static const int nMinimumWidth = 10;
\r
250 static const int nMaximumWidth = 1000;
\r
251 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
254 int numcols = pHdrCtrl->GetItemCount();
\r
255 for (int col = 0; col < numcols; col++)
\r
257 // get width for this col last time from registry
\r
259 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
260 CRegDWORD regwidth(regentry, 0);
\r
264 // no saved value, setup sensible defaults
\r
265 if (col == this->LOGLIST_MESSAGE)
\r
267 cx = LOGLIST_MESSAGE_MIN;
\r
271 cx = ICONITEMBORDER+16*4;
\r
274 if (cx < nMinimumWidth)
\r
276 cx = nMinimumWidth;
\r
277 } else if (cx > nMaximumWidth)
\r
279 cx = nMaximumWidth;
\r
282 SetColumnWidth(col, cx);
\r
289 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
291 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
292 if(ref.Left(prefix.GetLength()) == prefix)
\r
294 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
295 if(shortname.Right(3)==_T("^{}"))
\r
296 shortname=shortname.Left(shortname.GetLength()-3);
\r
301 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
305 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
306 rItem.mask = LVIF_STATE;
\r
307 rItem.iItem = Index;
\r
308 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
311 GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index);
\r
313 if (m_Theme.IsAppThemed() && m_bVista)
\r
315 m_Theme.Open(m_hWnd, L"Explorer");
\r
316 int state = LISS_NORMAL;
\r
317 if (rItem.state & LVIS_SELECTED)
\r
319 if (::GetFocus() == m_hWnd)
\r
320 state |= LISS_SELECTED;
\r
322 state |= LISS_SELECTEDNOTFOCUS;
\r
327 if (pLogEntry->bCopiedSelf)
\r
329 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
330 // information at this drawing stage. But we can check the whether the
\r
331 // previous stage changed the background color of the item
\r
332 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
335 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
338 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
339 ::DeleteObject(brush);
\r
346 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
347 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
349 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
354 if (rItem.state & LVIS_SELECTED)
\r
356 if (::GetFocus() == m_hWnd)
\r
357 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
359 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
363 //if (pLogEntry->bCopiedSelf)
\r
364 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
366 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
367 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
368 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
369 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
371 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
376 ::FillRect(hdc, &rect, brush);
\r
377 ::DeleteObject(brush);
\r
382 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
384 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
387 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
388 rItem.mask = LVIF_STATE;
\r
389 rItem.iItem = index;
\r
390 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
393 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
396 str=m_HashMap[data->m_CommitHash][i];
\r
401 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
403 if( shortname == m_CurrentBranch )
\r
404 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch));
\r
406 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch));
\r
408 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
410 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch));
\r
412 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
414 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag));
\r
416 else if(GetShortName(str,shortname,_T("refs/stash")))
\r
418 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Stash));
\r
419 shortname=_T("stash");
\r
423 if(!shortname.IsEmpty())
\r
426 memset(&size,0,sizeof(SIZE));
\r
427 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
429 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
431 ::FillRect(hdc, &rt, brush);
\r
432 if (rItem.state & LVIS_SELECTED)
\r
434 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
435 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
436 ::SetTextColor(hdc,clrOld);
\r
439 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
443 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
444 ::LineTo(hdc,rt.right,rt.top);
\r
445 ::LineTo(hdc,rt.right,rt.bottom);
\r
446 ::LineTo(hdc,rt.left,rt.bottom);
\r
447 ::LineTo(hdc,rt.left,rt.top);
\r
449 rt.left=rt.right+3;
\r
452 ::DeleteObject(brush);
\r
454 rt.right=rect.right;
\r
456 if (rItem.state & LVIS_SELECTED)
\r
458 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
459 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
460 ::SetTextColor(hdc,clrOld);
\r
463 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
468 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
469 const COLORREF& col,int top
\r
472 int h = laneHeight / 2;
\r
473 int m = (x1 + x2) / 2;
\r
474 int r = (x2 - x1) / 3;
\r
477 #define P_CENTER m , h+top
\r
478 #define P_0 x2, h+top
\r
479 #define P_90 m , 0+top
\r
480 #define P_180 x1, h+top
\r
481 #define P_270 m , 2 * h+top
\r
482 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
484 //static QPen myPen(Qt::black, 2); // fast path here
\r
486 pen.CreatePen(PS_SOLID,2,col);
\r
487 //myPen.setColor(col);
\r
488 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
490 //p->setPen(myPen);
\r
494 case Lanes::ACTIVE:
\r
495 case Lanes::NOT_ACTIVE:
\r
496 case Lanes::MERGE_FORK:
\r
497 case Lanes::MERGE_FORK_R:
\r
498 case Lanes::MERGE_FORK_L:
\r
500 case Lanes::JOIN_R:
\r
501 case Lanes::JOIN_L:
\r
502 DrawLine(hdc,P_90,P_270);
\r
503 //p->drawLine(P_90, P_270);
\r
506 case Lanes::HEAD_R:
\r
507 case Lanes::HEAD_L:
\r
508 case Lanes::BRANCH:
\r
509 DrawLine(hdc,P_CENTER,P_270);
\r
510 //p->drawLine(P_CENTER, P_270);
\r
513 case Lanes::TAIL_R:
\r
514 case Lanes::TAIL_L:
\r
515 case Lanes::INITIAL:
\r
516 case Lanes::BOUNDARY:
\r
517 case Lanes::BOUNDARY_C:
\r
518 case Lanes::BOUNDARY_R:
\r
519 case Lanes::BOUNDARY_L:
\r
520 DrawLine(hdc,P_90, P_CENTER);
\r
521 //p->drawLine(P_90, P_CENTER);
\r
529 case Lanes::MERGE_FORK:
\r
534 case Lanes::CROSS_EMPTY:
\r
535 case Lanes::BOUNDARY_C:
\r
536 DrawLine(hdc,P_180,P_0);
\r
537 //p->drawLine(P_180, P_0);
\r
539 case Lanes::MERGE_FORK_R:
\r
540 case Lanes::JOIN_R:
\r
541 case Lanes::HEAD_R:
\r
542 case Lanes::TAIL_R:
\r
543 case Lanes::BOUNDARY_R:
\r
544 DrawLine(hdc,P_180,P_CENTER);
\r
545 //p->drawLine(P_180, P_CENTER);
\r
547 case Lanes::MERGE_FORK_L:
\r
548 case Lanes::JOIN_L:
\r
549 case Lanes::HEAD_L:
\r
550 case Lanes::TAIL_L:
\r
551 case Lanes::BOUNDARY_L:
\r
552 DrawLine(hdc,P_CENTER,P_0);
\r
553 //p->drawLine(P_CENTER, P_0);
\r
560 brush.CreateSolidBrush(col);
\r
561 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
562 // center symbol, e.g. rect or ellipse
\r
564 case Lanes::ACTIVE:
\r
565 case Lanes::INITIAL:
\r
566 case Lanes::BRANCH:
\r
568 //p->setPen(Qt::NoPen);
\r
569 //p->setBrush(col);
\r
570 ::Ellipse(hdc, R_CENTER);
\r
571 //p->drawEllipse(R_CENTER);
\r
573 case Lanes::MERGE_FORK:
\r
574 case Lanes::MERGE_FORK_R:
\r
575 case Lanes::MERGE_FORK_L:
\r
576 //p->setPen(Qt::NoPen);
\r
577 //p->setBrush(col);
\r
578 //p->drawRect(R_CENTER);
\r
579 Rectangle(hdc,R_CENTER);
\r
581 case Lanes::UNAPPLIED:
\r
583 //p->setPen(Qt::NoPen);
\r
584 //p->setBrush(Qt::red);
\r
585 //p->drawRect(m - r, h - 1, d, 2);
\r
586 ::Rectangle(hdc,m-r,h-1,d,2);
\r
588 case Lanes::APPLIED:
\r
590 //p->setPen(Qt::NoPen);
\r
591 //p->setBrush(DARK_GREEN);
\r
592 //p->drawRect(m - r, h - 1, d, 2);
\r
593 //p->drawRect(m - 1, h - r, 2, d);
\r
594 ::Rectangle(hdc,m-r,h-1,d,2);
\r
595 ::Rectangle(hdc,m-1,h-r,2,d);
\r
597 case Lanes::BOUNDARY:
\r
598 //p->setBrush(back);
\r
599 //p->drawEllipse(R_CENTER);
\r
600 ::Ellipse(hdc, R_CENTER);
\r
602 case Lanes::BOUNDARY_C:
\r
603 case Lanes::BOUNDARY_R:
\r
604 case Lanes::BOUNDARY_L:
\r
605 //p->setBrush(back);
\r
606 //p->drawRect(R_CENTER);
\r
607 ::Rectangle(hdc,R_CENTER);
\r
613 ::SelectObject(hdc,oldpen);
\r
614 ::SelectObject(hdc,oldbrush);
\r
623 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
627 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
628 if(data->m_CommitHash.IsEmpty())
\r
633 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
634 rItem.mask = LVIF_STATE;
\r
635 rItem.iItem = index;
\r
636 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
640 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
644 if (data->m_Lanes.size() == 0)
\r
645 m_logEntries.setLane(data->m_CommitHash);
\r
647 std::vector<int>& lanes=data->m_Lanes;
\r
648 UINT laneNum = lanes.size();
\r
649 UINT mergeLane = 0;
\r
650 for (UINT i = 0; i < laneNum; i++)
\r
651 if (Lanes::isMerge(lanes[i])) {
\r
656 int x1 = 0, x2 = 0;
\r
657 int maxWidth = rect.Width();
\r
658 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
659 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
665 if (ln == Lanes::EMPTY)
\r
668 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
669 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
671 if (ln == Lanes::CROSS) {
\r
672 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
673 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
675 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
678 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
681 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
684 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
685 // Take the default processing unless we set this to something else below.
\r
686 *pResult = CDRF_DODEFAULT;
\r
688 if (m_bNoDispUpdates)
\r
693 switch (pLVCD->nmcd.dwDrawStage)
\r
695 case CDDS_PREPAINT:
\r
697 *pResult = CDRF_NOTIFYITEMDRAW;
\r
701 case CDDS_ITEMPREPAINT:
\r
703 // This is the prepaint stage for an item. Here's where we set the
\r
704 // item's text color.
\r
706 // Tell Windows to send draw notifications for each subitem.
\r
707 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
709 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
711 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
713 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
717 if (data->bCopiedSelf)
\r
719 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
720 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
721 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
725 crText = m_Colors.GetColor(CColors::Modified);
\r
727 if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
\r
728 crText = RGB(128,128,128);
\r
730 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
731 pLVCD->clrTextBk = RGB(156,156,156);
\r
732 else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
733 pLVCD->clrTextBk = RGB(200,200,128);
\r
735 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
\r
737 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)
\r
739 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
740 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
743 if(data->m_CommitHash == m_HeadHash)
\r
745 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
746 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
749 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
750 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
751 // if (data->Rev == m_wcRev)
\r
753 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
754 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
755 // tells the control to recalculate the extent of the text.
\r
756 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
760 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
762 if (m_bStrictStopped)
\r
763 crText = GetSysColor(COLOR_GRAYTEXT);
\r
765 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
766 pLVCD->clrText = crText;
\r
770 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
772 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
774 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
777 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
779 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
\r
782 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
784 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
785 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
787 *pResult = CDRF_SKIPDEFAULT;
\r
793 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
795 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
797 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
798 //if(!data->m_IsFull)
\r
800 //if(data->SafeFetchFullInfo(&g_Git))
\r
801 // this->Invalidate();
\r
802 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
805 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
809 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
811 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
812 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
814 *pResult = CDRF_SKIPDEFAULT;
\r
821 if (pLVCD->iSubItem == 1)
\r
823 if(this->m_IsIDReplaceAction)
\r
825 *pResult = CDRF_DODEFAULT;
\r
828 *pResult = CDRF_DODEFAULT;
\r
830 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
834 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
835 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
837 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
839 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
840 // Get the selected state of the
\r
841 // item being drawn.
\r
843 // Fill the background
\r
844 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
846 // Draw the icon(s) into the compatible DC
\r
847 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
848 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
851 if (pLogEntry->m_Action & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
\r
852 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
855 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
856 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
859 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
860 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
862 *pResult = CDRF_SKIPDEFAULT;
\r
868 *pResult = CDRF_DODEFAULT;
\r
872 // CGitLogListBase message handlers
\r
874 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
876 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
878 // Create a pointer to the item
\r
879 LV_ITEM* pItem = &(pDispInfo)->item;
\r
881 // Do the list need text information?
\r
882 if (!(pItem->mask & LVIF_TEXT))
\r
885 // By default, clear text buffer.
\r
886 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
888 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
891 if (m_bNoDispUpdates || bOutOfRange)
\r
894 // Which item number?
\r
895 int itemid = pItem->iItem;
\r
896 GitRev * pLogEntry = NULL;
\r
897 if (itemid < m_arShownList.GetCount())
\r
898 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
903 temp.Format(_T("%d"),pItem->iItem+1);
\r
907 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
911 switch (pItem->iSubItem)
\r
913 case this->LOGLIST_GRAPH: //Graphic
\r
916 if(this->m_IsRebaseReplaceGraph)
\r
919 path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
\r
921 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
\r
925 case this->LOGLIST_ACTION: //action -- no text in the column
\r
926 if(this->m_IsIDReplaceAction)
\r
927 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
929 case this->LOGLIST_MESSAGE: //Message
\r
931 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
933 case this->LOGLIST_AUTHOR: //Author
\r
935 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
937 case this->LOGLIST_DATE: //Date
\r
939 lstrcpyn(pItem->pszText,
\r
940 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
941 pItem->cchTextMax);
\r
952 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
955 int selIndex = GetSelectionMark();
\r
957 return; // nothing selected, nothing to do with a context menu
\r
959 // if the user selected the info text telling about not all revisions shown due to
\r
960 // the "stop on copy/rename" option, we also don't show the context menu
\r
961 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
964 // if the context menu is invoked through the keyboard, we have to use
\r
965 // a calculated position on where to anchor the menu on
\r
966 if ((point.x == -1) && (point.y == -1))
\r
969 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
970 ClientToScreen(&rect);
\r
971 point = rect.CenterPoint();
\r
973 m_nSearchIndex = selIndex;
\r
974 m_bCancelled = FALSE;
\r
976 // calculate some information the context menu commands can use
\r
977 // CString pathURL = GetURLFromPath(m_path);
\r
979 POSITION pos = GetFirstSelectedItemPosition();
\r
980 int indexNext = GetNextSelectedItem(pos);
\r
984 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
986 GitRev revSelected = pSelLogEntry->Rev;
\r
987 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
988 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
990 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
992 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
993 if (changedpath->lCopyFromRev)
\r
994 revPrevious = changedpath->lCopyFromRev;
\r
997 GitRev revSelected2;
\r
1000 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1001 revSelected2 = pLogEntry->Rev;
\r
1003 bool bAllFromTheSameAuthor = true;
\r
1004 CString firstAuthor;
\r
1005 CLogDataVector selEntries;
\r
1006 GitRev revLowest, revHighest;
\r
1007 GitRevRangeArray revisionRanges;
\r
1009 POSITION pos = GetFirstSelectedItemPosition();
\r
1010 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1011 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1012 selEntries.push_back(pLogEntry);
\r
1013 firstAuthor = pLogEntry->sAuthor;
\r
1014 revLowest = pLogEntry->Rev;
\r
1015 revHighest = pLogEntry->Rev;
\r
1018 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1019 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1020 selEntries.push_back(pLogEntry);
\r
1021 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
1022 bAllFromTheSameAuthor = false;
\r
1023 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
1024 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
1030 int FirstSelect=-1, LastSelect=-1;
\r
1031 pos = GetFirstSelectedItemPosition();
\r
1032 FirstSelect = GetNextSelectedItem(pos);
\r
1035 LastSelect = GetNextSelectedItem(pos);
\r
1037 //entry is selected, now show the popup menu
\r
1039 if (popup.CreatePopupMenu())
\r
1042 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
\r
1043 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_SKIP, IDI_PICK);
\r
1045 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
\r
1046 popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH);
\r
1048 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
\r
1049 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
\r
1051 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
\r
1052 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
\r
1054 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
\r
1055 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
\r
1056 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1058 if (GetSelectedCount() == 1)
\r
1063 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))
\r
1064 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1066 // TortoiseMerge could be improved to take a /blame switch
\r
1067 // and then not 'cat' the files from a unified diff but
\r
1069 // But until that's implemented, the context menu entry for
\r
1070 // this feature is commented out.
\r
1071 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1073 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))
\r
1074 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1076 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
\r
1077 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1078 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1079 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1082 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1084 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1086 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1088 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1090 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1091 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1093 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1097 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1099 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1101 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1103 CString str,format;
\r
1104 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
\r
1105 str.Format(format,g_Git.GetCurrentBranch());
\r
1107 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))
\r
1108 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1110 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))
\r
1111 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
\r
1113 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
\r
1114 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
\r
1116 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
\r
1117 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);
\r
1119 format.LoadString(IDS_REBASE_THIS_FORMAT);
\r
1120 str.Format(format,g_Git.GetCurrentBranch());
\r
1122 if(pSelLogEntry->m_CommitHash != m_HeadHash)
\r
1123 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
\r
1124 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
\r
1126 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
\r
1127 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
\r
1130 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1134 if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1)
\r
1136 popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE);
\r
1137 popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE);
\r
1138 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1141 if (GetSelectedCount() >= 2)
\r
1143 bool bAddSeparator = false;
\r
1144 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1146 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO))
\r
1147 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1150 if (GetSelectedCount() == 2)
\r
1152 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1153 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2))
\r
1154 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1155 bAddSeparator = true;
\r
1160 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1162 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1163 bAddSeparator = true;
\r
1165 if (bAddSeparator)
\r
1166 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1169 if ( GetSelectedCount() >0 )
\r
1171 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
\r
1173 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT))
\r
1177 headindex = this->GetHeadIndex();
\r
1180 head.Format(_T("HEAD~%d"),LastSelect-headindex);
\r
1181 CString hash=g_Git.GetHash(head);
\r
1182 hash=hash.Left(40);
\r
1183 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1184 if(pLastEntry->m_CommitHash == hash)
\r
1185 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
\r
1189 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))
\r
1190 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
\r
1191 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1197 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1199 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1201 // if (GetSelectedCount() == 1)
\r
1203 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1204 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1205 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1210 if (GetSelectedCount() == 1)
\r
1212 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
\r
1213 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH);
\r
1215 if (GetSelectedCount() != 0)
\r
1217 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
\r
1218 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1221 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
\r
1222 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1224 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1225 // DialogEnableWindow(IDOK, FALSE);
\r
1226 // SetPromptApp(&theApp);
\r
1228 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1230 // EnableOKButton();
\r
1231 } // if (popup.CreatePopupMenu())
\r
1235 bool CGitLogListBase::IsSelectionContinuous()
\r
1237 if ( GetSelectedCount()==1 )
\r
1239 // if only one revision is selected, the selection is of course
\r
1244 POSITION pos = GetFirstSelectedItemPosition();
\r
1245 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1248 int itemindex = GetNextSelectedItem(pos);
\r
1251 int nextindex = GetNextSelectedItem(pos);
\r
1252 if (nextindex - itemindex > 1)
\r
1254 bContinuous = false;
\r
1257 itemindex = nextindex;
\r
1260 return bContinuous;
\r
1263 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1266 CString sClipdata;
\r
1267 POSITION pos = GetFirstSelectedItemPosition();
\r
1271 sRev.LoadString(IDS_LOG_REVISION);
\r
1273 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1275 sDate.LoadString(IDS_LOG_DATE);
\r
1277 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1280 CString sLogCopyText;
\r
1282 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1286 //pLogEntry->m_Files
\r
1287 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1289 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1291 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1292 sPaths += _T("\r\n");
\r
1295 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
1296 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1297 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1299 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1300 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1302 sClipdata += sLogCopyText;
\r
1305 sClipdata += pLogEntry->m_CommitHash;
\r
1310 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1315 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1317 if (m_bThreadRunning)
\r
1320 int FirstSelect=-1, LastSelect=-1;
\r
1321 POSITION pos = GetFirstSelectedItemPosition();
\r
1322 FirstSelect = GetNextSelectedItem(pos);
\r
1325 LastSelect = GetNextSelectedItem(pos);
\r
1328 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect);
\r
1331 UpdateLogInfoLabel();
\r
1332 int selIndex = m_LogList.GetSelectionMark();
\r
1335 int selCount = m_LogList.GetSelectedCount();
\r
1336 if (selCount != 1)
\r
1339 // Find selected entry in the log list
\r
1340 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1341 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1342 long rev1 = pLogEntry->Rev;
\r
1343 long rev2 = rev1-1;
\r
1344 CTGitPath path = m_path;
\r
1346 // See how many files under the relative root were changed in selected revision
\r
1348 LogChangedPath * changed = NULL;
\r
1349 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1351 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1352 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1359 if (m_path.IsDirectory() && nChanged == 1)
\r
1361 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1362 // Do diff on that file instead of whole directory
\r
1363 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1366 m_bCancelled = FALSE;
\r
1367 DialogEnableWindow(IDOK, FALSE);
\r
1368 SetPromptApp(&theApp);
\r
1369 theApp.DoWaitCursor(1);
\r
1371 if (PromptShown())
\r
1373 GitDiff diff(this, m_hWnd, true);
\r
1374 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1375 diff.SetHEADPeg(m_LogRevision);
\r
1376 diff.ShowCompare(path, rev2, path, rev1);
\r
1380 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1383 theApp.DoWaitCursor(-1);
\r
1388 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1390 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1393 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1395 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1397 if (pFindInfo->lvfi.psz == 0)
\r
1400 CString sCmp = pFindInfo->lvfi.psz;
\r
1402 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1404 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1405 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1406 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1408 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1416 if (sCmp.Compare(sRev)==0)
\r
1423 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1425 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1427 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1428 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1429 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1431 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1439 if (sCmp.Compare(sRev)==0)
\r
1451 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
\r
1455 this->m_logEntries.ClearAll();
\r
1456 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
\r
1458 //this->m_logEntries.ParserFromLog();
\r
1459 SetItemCountEx(this->m_logEntries.size());
\r
1461 this->m_arShownList.RemoveAll();
\r
1463 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1467 m_logEntries[m_logEntries.size()-i-1].m_IsFull=TRUE;
\r
1468 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
1472 m_logEntries[i].m_IsFull=TRUE;
\r
1473 this->m_arShownList.Add(&m_logEntries[i]);
\r
1483 int CGitLogListBase::FillGitShortLog()
\r
1487 this->m_logEntries.ClearAll();
\r
1489 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1492 if(this->m_Path.IsEmpty())
\r
1495 path=&this->m_Path;
\r
1499 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1500 // if(this->m_bAllBranch)
\r
1501 mask |= m_ShowMask;
\r
1503 this->m_logEntries.FetchShortLog(path,hash,-1,mask);
\r
1505 //this->m_logEntries.ParserFromLog();
\r
1506 if(IsInWorkingThread())
\r
1507 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
\r
1509 SetItemCountEx(this->m_logEntries.size());
\r
1511 this->m_arShownList.RemoveAll();
\r
1513 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1515 m_logEntries[i].m_Subject=_T("parser...");
\r
1516 if(this->m_IsOldFirst)
\r
1518 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);
\r
1522 this->m_arShownList.Add(&m_logEntries[i]);
\r
1528 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1530 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1531 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1532 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1534 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1536 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1538 DiffSelectedRevWithPrevious();
\r
1543 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1545 DiffSelectedFile();
\r
1552 if (m_hAccel && !bSkipAccelerator)
\r
1554 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1560 //m_tooltips.RelayEvent(pMsg);
\r
1561 return __super::PreTranslateMessage(pMsg);
\r
1564 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1566 // a double click on an entry in the revision list has happened
\r
1569 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1570 DiffSelectedRevWithPrevious();
\r
1573 int CGitLogListBase::FetchLogAsync(void * data)
\r
1576 m_bExitThread=FALSE;
\r
1577 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1578 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1579 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1580 if (m_LoadingThread ==NULL)
\r
1582 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1583 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1584 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1590 //this is the thread function which calls the subversion function
\r
1591 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1593 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1596 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1599 oldest=CTime::GetCurrentTime();
\r
1600 latest=CTime(1971,1,2,0,0,0);
\r
1601 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1603 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1604 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1606 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1607 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1612 //Helper class for FetchFullLogInfo()
\r
1613 class CGitCall_FetchFullLogInfo : public CGitCall
\r
1616 CGitCall_FetchFullLogInfo(CGitLogListBase* ploglist):m_ploglist(ploglist),m_CollectedCount(0){}
\r
1617 virtual bool OnOutputData(const BYTE* data, size_t size)
\r
1620 return m_ploglist->m_bExitThread;
\r
1621 //Add received data to byte collector
\r
1622 m_ByteCollector.append(data,size);
\r
1624 //Find loginfo endmarker
\r
1625 static const BYTE dataToFind[]={0,0};
\r
1626 int found=m_ByteCollector.findData(dataToFind,2);
\r
1628 return m_ploglist->m_bExitThread;//Not found
\r
1629 found+=2;//Position after loginfo end-marker
\r
1631 //Prepare data for OnLogInfo and call it
\r
1632 BYTE_VECTOR logInfo;
\r
1633 logInfo.append(&*m_ByteCollector.begin(),found);
\r
1634 OnLogInfo(logInfo);
\r
1636 //Remove loginfo from bytecollector
\r
1637 m_ByteCollector.erase(m_ByteCollector.begin(),m_ByteCollector.begin()+found);
\r
1639 return m_ploglist->m_bExitThread;
\r
1641 virtual void OnEnd()
\r
1643 //Rest should be a complete log line.
\r
1644 if(!m_ByteCollector.empty())
\r
1645 OnLogInfo(m_ByteCollector);
\r
1649 void OnLogInfo(BYTE_VECTOR& logInfo)
\r
1652 fullRev.ParserFromLog(logInfo);
\r
1653 MAP_HASH_REV::iterator itRev=m_ploglist->m_logEntries.m_HashMap.find(fullRev.m_CommitHash);
\r
1654 if(itRev==m_ploglist->m_logEntries.m_HashMap.end())
\r
1656 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
\r
1660 int rev=itRev->second;
\r
1661 GitRev* revInVector=&m_ploglist->m_logEntries[rev];
\r
1664 if(revInVector->m_IsFull)
\r
1667 if(!m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev]))
\r
1669 ++m_CollectedCount;
\r
1670 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsUpdateing,FALSE);
\r
1671 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsFull,TRUE);
\r
1672 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1676 // fullRev.m_IsUpdateing=TRUE;
\r
1677 // fullRev.m_IsFull=TRUE;
\r
1680 if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE))
\r
1681 return;//Cannot update this row now. Ignore.
\r
1682 TCHAR oldmark=revInVector->m_Mark;
\r
1683 GIT_REV_LIST oldlist=revInVector->m_ParentHash;
\r
1684 // CString oldhash=m_CommitHash;
\r
1686 //Parse new rev info
\r
1687 revInVector->ParserFromLog(logInfo);
\r
1690 revInVector->m_Mark=oldmark; //parser full log will cause old mark overwrited.
\r
1691 //So we need keep old bound mark.
\r
1692 revInVector->m_ParentHash=oldlist;
\r
1695 m_ploglist->m_LogCache.AddCacheEntry(*revInVector);
\r
1698 InterlockedExchange(&revInVector->m_IsFull,TRUE);
\r
1699 InterlockedExchange(&revInVector->m_IsUpdateing,FALSE);
\r
1701 //Notify listcontrol and update progress bar
\r
1702 ++m_CollectedCount;
\r
1704 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1706 DWORD percent=m_CollectedCount*68/m_ploglist->m_logEntries.size() + GITLOG_START+1+30;
\r
1707 if(percent == GITLOG_END)
\r
1708 percent = GITLOG_END -1;
\r
1710 ::PostMessage(m_ploglist->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1713 CGitLogListBase* m_ploglist;
\r
1714 BYTE_VECTOR m_ByteCollector;
\r
1715 int m_CollectedCount;
\r
1719 void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to)
\r
1721 CGitCall_FetchFullLogInfo fetcher(this);
\r
1723 CGit::LOG_INFO_STAT|
\r
1724 CGit::LOG_INFO_FILESTATE|
\r
1725 CGit::LOG_INFO_DETECT_COPYRENAME|
\r
1729 if(this->m_Path.IsEmpty())
\r
1732 path=&this->m_Path;
\r
1734 g_Git.GetLog(&fetcher,CString(),path,-1,mask,&from,&to);
\r
1737 void CGitLogListBase::FetchLastLogInfo()
\r
1739 unsigned int updated=0;
\r
1743 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1745 if(m_logEntries[i].m_IsFull)
\r
1748 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1750 if(!m_logEntries.FetchFullInfo(i))
\r
1754 m_LogCache.AddCacheEntry(m_logEntries[i]);
\r
1759 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1760 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1763 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
\r
1767 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1768 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1775 UINT CGitLogListBase::LogThread()
\r
1778 // if(m_ProcCallBack)
\r
1779 // m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1780 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
1782 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1783 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1785 //does the user force the cache to refresh (shift or control key down)?
\r
1786 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1787 || (GetKeyState (VK_SHIFT) < 0);
\r
1789 //disable the "Get All" button while we're receiving
\r
1792 FillGitShortLog();
\r
1794 if(this->m_bExitThread)
\r
1796 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1797 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1800 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1801 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START_ALL, 0);
\r
1803 int start=0; CString firstcommit,lastcommit;
\r
1805 for(int i=0;i<this->GetItemCount();i++)
\r
1807 start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start);
\r
1808 m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i;
\r
1810 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1812 if(firstcommit.IsEmpty())
\r
1813 firstcommit=m_logEntries[i].m_CommitHash;
\r
1814 lastcommit=m_logEntries[i].m_CommitHash;
\r
1818 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1819 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1824 if(start>=m_logEntries.m_RawlogData.size())
\r
1827 int percent=i*30/m_logEntries.size() + GITLOG_START+1;
\r
1829 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0);
\r
1830 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0);
\r
1832 if(this->m_bExitThread)
\r
1834 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1835 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1839 if(!lastcommit.IsEmpty())
\r
1840 FetchFullLogInfo(lastcommit,firstcommit);
\r
1842 this->FetchLastLogInfo();
\r
1845 RedrawItems(0, m_arShownList.GetCount());
\r
1846 // SetRedraw(false);
\r
1847 // ResizeAllListCtrlCols();
\r
1848 // SetRedraw(true);
\r
1850 if ( m_pStoreSelection )
\r
1852 // Deleting the instance will restore the
\r
1853 // selection of the CLogDlg.
\r
1854 delete m_pStoreSelection;
\r
1855 m_pStoreSelection = NULL;
\r
1859 // If no selection has been set then this must be the first time
\r
1860 // the revisions are shown. Let's preselect the topmost revision.
\r
1861 if ( GetItemCount()>0 )
\r
1863 SetSelectionMark(0);
\r
1864 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1871 //FetchFullLogInfo();
\r
1872 //FetchFullLogInfoOrig();
\r
1873 //RefreshCursor();
\r
1874 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1875 // the log messages
\r
1877 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
1879 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1884 void CGitLogListBase::Refresh()
\r
1886 m_bExitThread=TRUE;
\r
1887 if(m_LoadingThread!=NULL)
\r
1889 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
1890 if(ret == WAIT_TIMEOUT)
\r
1891 TerminateThread();
\r
1896 //Update branch and Tag info
\r
1898 //Assume Thread have exited
\r
1899 //if(!m_bThreadRunning)
\r
1901 this->SetItemCountEx(0);
\r
1902 m_logEntries.clear();
\r
1903 m_bExitThread=FALSE;
\r
1904 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1905 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1906 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1908 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1909 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1910 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1912 m_sFilterText.Empty();
\r
1913 m_From=CTime(1970,1,2,0,0,0);
\r
1914 m_To=CTime::GetCurrentTime();
\r
1917 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1921 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1923 type |= tr1::regex_constants::icase;
\r
1924 pat = tr1::wregex(regexp_str, type);
\r
1927 catch (exception) {}
\r
1931 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1934 pShownlist->RemoveAll();
\r
1935 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1936 bool bRegex = false;
\r
1937 if (m_bFilterWithRegex)
\r
1938 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1940 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1942 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1944 if ((bRegex)&&(m_bFilterWithRegex))
\r
1947 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1949 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1950 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1952 pShownlist->Add(m_logEntries[i]);
\r
1957 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1959 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1960 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1962 pShownlist->Add(&m_logEntries[i]);
\r
1966 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1967 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1969 pShownlist->Add(&m_logEntries[i]);
\r
1974 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1976 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1978 bool bGoing = true;
\r
1979 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1981 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1982 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1984 pShownlist->Add(m_logEntries[i]);
\r
1988 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
1990 pShownlist->Add(m_logEntries[i]);
\r
1994 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
1996 pShownlist->Add(m_logEntries[i]);
\r
2005 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2007 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
2009 pShownlist->Add(&m_logEntries[i]);
\r
2013 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2015 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2016 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
2018 pShownlist->Add(&m_logEntries[i]);
\r
2025 CString find = m_sFilterText;
\r
2028 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2030 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
2032 sBugIDs = sBugIDs.MakeLower();
\r
2033 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2035 pShownlist->Add(m_logEntries[i]);
\r
2040 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2042 CString msg = m_logEntries[i].m_Subject;
\r
2044 msg = msg.MakeLower();
\r
2045 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2047 pShownlist->Add(&m_logEntries[i]);
\r
2050 msg = m_logEntries[i].m_Body;
\r
2052 msg = msg.MakeLower();
\r
2053 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2055 pShownlist->Add(&m_logEntries[i]);
\r
2060 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2062 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2064 bool bGoing = true;
\r
2065 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2067 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2068 CString path = cpath->sCopyFromPath;
\r
2070 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2072 pShownlist->Add(m_logEntries[i]);
\r
2076 path = cpath->sPath;
\r
2078 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2080 pShownlist->Add(m_logEntries[i]);
\r
2084 path = cpath->GetAction();
\r
2086 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2088 pShownlist->Add(m_logEntries[i]);
\r
2095 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2097 CString msg = m_logEntries[i].m_AuthorName;
\r
2098 msg = msg.MakeLower();
\r
2099 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2101 pShownlist->Add(&m_logEntries[i]);
\r
2105 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2107 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2108 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2110 pShownlist->Add(&m_logEntries[i]);
\r
2114 } // else (from if (bRegex))
\r
2115 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2119 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
2121 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2122 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2129 void CGitLogListBase::StartFilter()
\r
2131 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2132 RecalculateShownList(&m_arShownList);
\r
2133 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2137 SetItemCountEx(ShownCountWithStopped());
\r
2138 RedrawItems(0, ShownCountWithStopped());
\r
2140 //ResizeAllListCtrlCols();
\r
2145 void CGitLogListBase::RemoveFilter()
\r
2148 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2150 m_arShownList.RemoveAll();
\r
2152 // reset the time filter too
\r
2154 m_timFrom = (__time64_t(m_tFrom));
\r
2155 m_timTo = (__time64_t(m_tTo));
\r
2156 m_DateFrom.SetTime(&m_timFrom);
\r
2157 m_DateTo.SetTime(&m_timTo);
\r
2158 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2159 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2162 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2164 if(this->m_IsOldFirst)
\r
2166 m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
2169 m_arShownList.Add(&m_logEntries[i]);
\r
2172 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2174 SetItemCountEx(ShownCountWithStopped());
\r
2175 RedrawItems(0, ShownCountWithStopped());
\r
2176 // SetRedraw(false);
\r
2177 // ResizeAllListCtrlCols();
\r
2178 // SetRedraw(true);
\r
2180 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2183 void CGitLogListBase::Clear()
\r
2185 m_arShownList.RemoveAll();
\r
2188 m_logEntries.ClearAll();
\r
2192 void CGitLogListBase::OnDestroy()
\r
2194 // save the column widths to the registry
\r
2195 SaveColumnWidths();
\r
2197 if(this->m_bThreadRunning)
\r
2199 this->m_bExitThread=true;
\r
2200 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2201 if(ret == WAIT_TIMEOUT)
\r
2202 TerminateThread();
\r
2204 while(m_LogCache.SaveCache())
\r
2206 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
\r
2207 MB_YESNO) == IDNO)
\r
2210 CHintListCtrl::OnDestroy();
\r
2213 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
\r
2216 int i=(int)wParam;
\r
2217 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
2218 this->InvalidateRect(rect);
\r
2223 * Save column widths to the registry
\r
2225 void CGitLogListBase::SaveColumnWidths()
\r
2227 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
2230 int numcols = pHdrCtrl->GetItemCount();
\r
2231 for (int col = 0; col < numcols; col++)
\r
2233 int width = GetColumnWidth( col );
\r
2235 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
2236 CRegDWORD regwidth(regentry, 0);
\r
2237 regwidth = width; // this writes it to reg
\r
2242 int CGitLogListBase::GetHeadIndex()
\r
2244 if(m_HeadHash.IsEmpty())
\r
2247 for(int i=0;i<m_arShownList.GetCount();i++)
\r
2249 GitRev *pRev = (GitRev*)m_arShownList[i];
\r
2252 if(pRev->m_CommitHash == m_HeadHash )
\r