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,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 mergeLane = 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
662 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
668 if (ln == Lanes::EMPTY)
\r
671 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
672 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
674 if (ln == Lanes::CROSS) {
\r
675 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
676 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
678 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
681 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
684 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
687 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
688 // Take the default processing unless we set this to something else below.
\r
689 *pResult = CDRF_DODEFAULT;
\r
691 if (m_bNoDispUpdates)
\r
696 switch (pLVCD->nmcd.dwDrawStage)
\r
698 case CDDS_PREPAINT:
\r
700 *pResult = CDRF_NOTIFYITEMDRAW;
\r
704 case CDDS_ITEMPREPAINT:
\r
706 // This is the prepaint stage for an item. Here's where we set the
\r
707 // item's text color.
\r
709 // Tell Windows to send draw notifications for each subitem.
\r
710 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
712 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
714 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
716 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
720 if (data->bCopiedSelf)
\r
722 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
723 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
724 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
728 crText = m_Colors.GetColor(CColors::Modified);
\r
730 if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
\r
731 crText = RGB(128,128,128);
\r
733 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
734 pLVCD->clrTextBk = RGB(156,156,156);
\r
735 else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
736 pLVCD->clrTextBk = RGB(200,200,128);
\r
738 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
\r
740 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)
\r
742 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
743 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
746 if(data->m_CommitHash == m_HeadHash)
\r
748 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
749 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
752 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
753 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
754 // if (data->Rev == m_wcRev)
\r
756 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
757 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
758 // tells the control to recalculate the extent of the text.
\r
759 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
763 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
765 if (m_bStrictStopped)
\r
766 crText = GetSysColor(COLOR_GRAYTEXT);
\r
768 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
769 pLVCD->clrText = crText;
\r
773 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
775 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
777 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
780 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
782 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
\r
785 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
787 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
788 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
790 *pResult = CDRF_SKIPDEFAULT;
\r
796 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
798 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
800 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
801 //if(!data->m_IsFull)
\r
803 //if(data->SafeFetchFullInfo(&g_Git))
\r
804 // this->Invalidate();
\r
805 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
808 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
812 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
814 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
815 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
817 *pResult = CDRF_SKIPDEFAULT;
\r
824 if (pLVCD->iSubItem == 1)
\r
826 if(this->m_IsIDReplaceAction)
\r
828 *pResult = CDRF_DODEFAULT;
\r
831 *pResult = CDRF_DODEFAULT;
\r
833 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
837 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
838 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
840 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
842 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
843 // Get the selected state of the
\r
844 // item being drawn.
\r
846 // Fill the background
\r
847 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
849 // Draw the icon(s) into the compatible DC
\r
850 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
851 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
854 if (pLogEntry->m_Action & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
\r
855 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
858 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
859 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
862 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
863 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
865 *pResult = CDRF_SKIPDEFAULT;
\r
871 *pResult = CDRF_DODEFAULT;
\r
875 // CGitLogListBase message handlers
\r
877 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
879 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
881 // Create a pointer to the item
\r
882 LV_ITEM* pItem = &(pDispInfo)->item;
\r
884 // Do the list need text information?
\r
885 if (!(pItem->mask & LVIF_TEXT))
\r
888 // By default, clear text buffer.
\r
889 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
891 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
894 if (m_bNoDispUpdates || bOutOfRange)
\r
897 // Which item number?
\r
898 int itemid = pItem->iItem;
\r
899 GitRev * pLogEntry = NULL;
\r
900 if (itemid < m_arShownList.GetCount())
\r
901 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
906 temp.Format(_T("%d"),pItem->iItem+1);
\r
910 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
914 switch (pItem->iSubItem)
\r
916 case this->LOGLIST_GRAPH: //Graphic
\r
919 if(this->m_IsRebaseReplaceGraph)
\r
922 path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
\r
924 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
\r
928 case this->LOGLIST_ACTION: //action -- no text in the column
\r
929 if(this->m_IsIDReplaceAction)
\r
930 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
932 case this->LOGLIST_MESSAGE: //Message
\r
934 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
936 case this->LOGLIST_AUTHOR: //Author
\r
938 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
940 case this->LOGLIST_DATE: //Date
\r
942 lstrcpyn(pItem->pszText,
\r
943 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
944 pItem->cchTextMax);
\r
955 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
958 int selIndex = GetSelectionMark();
\r
960 return; // nothing selected, nothing to do with a context menu
\r
962 // if the user selected the info text telling about not all revisions shown due to
\r
963 // the "stop on copy/rename" option, we also don't show the context menu
\r
964 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
967 // if the context menu is invoked through the keyboard, we have to use
\r
968 // a calculated position on where to anchor the menu on
\r
969 if ((point.x == -1) && (point.y == -1))
\r
972 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
973 ClientToScreen(&rect);
\r
974 point = rect.CenterPoint();
\r
976 m_nSearchIndex = selIndex;
\r
977 m_bCancelled = FALSE;
\r
979 // calculate some information the context menu commands can use
\r
980 // CString pathURL = GetURLFromPath(m_path);
\r
982 POSITION pos = GetFirstSelectedItemPosition();
\r
983 int indexNext = GetNextSelectedItem(pos);
\r
987 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
989 GitRev revSelected = pSelLogEntry->Rev;
\r
990 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
991 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
993 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
995 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
996 if (changedpath->lCopyFromRev)
\r
997 revPrevious = changedpath->lCopyFromRev;
\r
1000 GitRev revSelected2;
\r
1003 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1004 revSelected2 = pLogEntry->Rev;
\r
1006 bool bAllFromTheSameAuthor = true;
\r
1007 CString firstAuthor;
\r
1008 CLogDataVector selEntries;
\r
1009 GitRev revLowest, revHighest;
\r
1010 GitRevRangeArray revisionRanges;
\r
1012 POSITION pos = GetFirstSelectedItemPosition();
\r
1013 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1014 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1015 selEntries.push_back(pLogEntry);
\r
1016 firstAuthor = pLogEntry->sAuthor;
\r
1017 revLowest = pLogEntry->Rev;
\r
1018 revHighest = pLogEntry->Rev;
\r
1021 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1022 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1023 selEntries.push_back(pLogEntry);
\r
1024 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
1025 bAllFromTheSameAuthor = false;
\r
1026 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
1027 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
1033 int FirstSelect=-1, LastSelect=-1;
\r
1034 pos = GetFirstSelectedItemPosition();
\r
1035 FirstSelect = GetNextSelectedItem(pos);
\r
1038 LastSelect = GetNextSelectedItem(pos);
\r
1040 //entry is selected, now show the popup menu
\r
1042 CIconMenu submenu;
\r
1043 if (popup.CreatePopupMenu())
\r
1046 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
\r
1047 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_SKIP, IDI_PICK);
\r
1049 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
\r
1050 popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH);
\r
1052 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
\r
1053 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
\r
1055 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
\r
1056 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
\r
1058 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
\r
1059 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
\r
1060 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1062 if (GetSelectedCount() == 1)
\r
1067 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))
\r
1068 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1070 // TortoiseMerge could be improved to take a /blame switch
\r
1071 // and then not 'cat' the files from a unified diff but
\r
1073 // But until that's implemented, the context menu entry for
\r
1074 // this feature is commented out.
\r
1075 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1077 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))
\r
1078 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1080 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
\r
1081 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1082 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1083 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1086 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1088 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1090 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1092 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1094 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1095 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1097 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1101 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1103 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1105 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1107 CString str,format;
\r
1108 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
\r
1109 str.Format(format,g_Git.GetCurrentBranch());
\r
1111 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))
\r
1112 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1114 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))
\r
1115 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
\r
1117 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
\r
1118 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
\r
1120 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
\r
1121 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);
\r
1123 format.LoadString(IDS_REBASE_THIS_FORMAT);
\r
1124 str.Format(format,g_Git.GetCurrentBranch());
\r
1126 if(pSelLogEntry->m_CommitHash != m_HeadHash)
\r
1127 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
\r
1128 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
\r
1130 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
\r
1131 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
\r
1134 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1138 if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1)
\r
1140 popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE);
\r
1141 popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE);
\r
1142 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1145 if (GetSelectedCount() >= 2)
\r
1147 bool bAddSeparator = false;
\r
1148 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1150 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO))
\r
1151 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1154 if (GetSelectedCount() == 2)
\r
1156 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1157 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2))
\r
1158 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1159 bAddSeparator = true;
\r
1164 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1166 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1167 bAddSeparator = true;
\r
1169 if (bAddSeparator)
\r
1170 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1173 if ( GetSelectedCount() >0 )
\r
1175 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
\r
1177 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT))
\r
1181 headindex = this->GetHeadIndex();
\r
1184 head.Format(_T("HEAD~%d"),LastSelect-headindex);
\r
1185 CString hash=g_Git.GetHash(head);
\r
1186 hash=hash.Left(40);
\r
1187 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1188 if(pLastEntry->m_CommitHash == hash)
\r
1189 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
\r
1193 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))
\r
1194 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
\r
1196 if(GetSelectedCount()<=2)
\r
1197 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH))
\r
1198 popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH);
\r
1200 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1206 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1208 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1210 // if (GetSelectedCount() == 1)
\r
1212 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1213 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1214 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1219 if (GetSelectedCount() == 1)
\r
1221 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
\r
1222 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH);
\r
1224 if (GetSelectedCount() != 0)
\r
1226 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
\r
1227 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1230 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
\r
1231 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1234 if (GetSelectedCount() == 1)
\r
1236 if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE))
\r
1238 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() )
\r
1241 str.LoadString(IDS_DELETE_BRANCHTAG);
\r
1242 if( m_HashMap[pSelLogEntry->m_CommitHash].size() == 1 )
\r
1245 str+=m_HashMap[pSelLogEntry->m_CommitHash].at(0);
\r
1246 popup.AppendMenuIcon(ID_DELETE,str+_T("..."),IDI_DELETE);
\r
1248 else if( m_HashMap[pSelLogEntry->m_CommitHash].size() > 1 )
\r
1251 submenu.CreatePopupMenu();
\r
1252 for(int i=0;i<m_HashMap[pSelLogEntry->m_CommitHash].size();i++)
\r
1254 submenu.AppendMenuIcon(ID_DELETE+(i<<16),m_HashMap[pSelLogEntry->m_CommitHash][i]+_T("..."));
\r
1257 popup.AppendMenu(MF_BYPOSITION|MF_POPUP|MF_STRING,(UINT) submenu.m_hMenu,str);
\r
1265 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1266 // DialogEnableWindow(IDOK, FALSE);
\r
1267 // SetPromptApp(&theApp);
\r
1269 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1271 // EnableOKButton();
\r
1272 } // if (popup.CreatePopupMenu())
\r
1276 bool CGitLogListBase::IsSelectionContinuous()
\r
1278 if ( GetSelectedCount()==1 )
\r
1280 // if only one revision is selected, the selection is of course
\r
1285 POSITION pos = GetFirstSelectedItemPosition();
\r
1286 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1289 int itemindex = GetNextSelectedItem(pos);
\r
1292 int nextindex = GetNextSelectedItem(pos);
\r
1293 if (nextindex - itemindex > 1)
\r
1295 bContinuous = false;
\r
1298 itemindex = nextindex;
\r
1301 return bContinuous;
\r
1304 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1307 CString sClipdata;
\r
1308 POSITION pos = GetFirstSelectedItemPosition();
\r
1312 sRev.LoadString(IDS_LOG_REVISION);
\r
1314 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1316 sDate.LoadString(IDS_LOG_DATE);
\r
1318 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1321 CString sLogCopyText;
\r
1323 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1327 //pLogEntry->m_Files
\r
1328 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1330 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1332 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1333 sPaths += _T("\r\n");
\r
1336 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
1337 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1338 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1340 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1341 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1343 sClipdata += sLogCopyText;
\r
1346 sClipdata += pLogEntry->m_CommitHash;
\r
1351 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1356 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1358 if (m_bThreadRunning)
\r
1361 int FirstSelect=-1, LastSelect=-1;
\r
1362 POSITION pos = GetFirstSelectedItemPosition();
\r
1363 FirstSelect = GetNextSelectedItem(pos);
\r
1366 LastSelect = GetNextSelectedItem(pos);
\r
1369 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect);
\r
1372 UpdateLogInfoLabel();
\r
1373 int selIndex = m_LogList.GetSelectionMark();
\r
1376 int selCount = m_LogList.GetSelectedCount();
\r
1377 if (selCount != 1)
\r
1380 // Find selected entry in the log list
\r
1381 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1382 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1383 long rev1 = pLogEntry->Rev;
\r
1384 long rev2 = rev1-1;
\r
1385 CTGitPath path = m_path;
\r
1387 // See how many files under the relative root were changed in selected revision
\r
1389 LogChangedPath * changed = NULL;
\r
1390 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1392 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1393 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1400 if (m_path.IsDirectory() && nChanged == 1)
\r
1402 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1403 // Do diff on that file instead of whole directory
\r
1404 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1407 m_bCancelled = FALSE;
\r
1408 DialogEnableWindow(IDOK, FALSE);
\r
1409 SetPromptApp(&theApp);
\r
1410 theApp.DoWaitCursor(1);
\r
1412 if (PromptShown())
\r
1414 GitDiff diff(this, m_hWnd, true);
\r
1415 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1416 diff.SetHEADPeg(m_LogRevision);
\r
1417 diff.ShowCompare(path, rev2, path, rev1);
\r
1421 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1424 theApp.DoWaitCursor(-1);
\r
1429 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1431 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1434 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1436 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1438 if (pFindInfo->lvfi.psz == 0)
\r
1441 CString sCmp = pFindInfo->lvfi.psz;
\r
1443 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1445 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1446 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1447 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1449 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1457 if (sCmp.Compare(sRev)==0)
\r
1464 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1466 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1468 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1469 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1470 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1472 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1480 if (sCmp.Compare(sRev)==0)
\r
1492 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
\r
1496 this->m_logEntries.ClearAll();
\r
1497 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
\r
1499 //this->m_logEntries.ParserFromLog();
\r
1500 SetItemCountEx(this->m_logEntries.size());
\r
1502 this->m_arShownList.RemoveAll();
\r
1504 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1508 m_logEntries[m_logEntries.size()-i-1].m_IsFull=TRUE;
\r
1509 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
1513 m_logEntries[i].m_IsFull=TRUE;
\r
1514 this->m_arShownList.Add(&m_logEntries[i]);
\r
1524 int CGitLogListBase::FillGitShortLog()
\r
1528 this->m_logEntries.ClearAll();
\r
1530 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1533 if(this->m_Path.IsEmpty())
\r
1536 path=&this->m_Path;
\r
1540 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1541 // if(this->m_bAllBranch)
\r
1542 mask |= m_ShowMask;
\r
1544 this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask);
\r
1546 //this->m_logEntries.ParserFromLog();
\r
1547 if(IsInWorkingThread())
\r
1548 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
\r
1550 SetItemCountEx(this->m_logEntries.size());
\r
1552 this->m_arShownList.RemoveAll();
\r
1554 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1556 m_logEntries[i].m_Subject=_T("parser...");
\r
1557 if(this->m_IsOldFirst)
\r
1559 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);
\r
1563 this->m_arShownList.Add(&m_logEntries[i]);
\r
1569 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1571 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1572 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1573 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1575 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1577 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1579 DiffSelectedRevWithPrevious();
\r
1584 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1586 DiffSelectedFile();
\r
1593 if (m_hAccel && !bSkipAccelerator)
\r
1595 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1601 //m_tooltips.RelayEvent(pMsg);
\r
1602 return __super::PreTranslateMessage(pMsg);
\r
1605 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1607 // a double click on an entry in the revision list has happened
\r
1610 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1611 DiffSelectedRevWithPrevious();
\r
1614 int CGitLogListBase::FetchLogAsync(void * data)
\r
1617 m_bExitThread=FALSE;
\r
1618 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1619 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1620 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1621 if (m_LoadingThread ==NULL)
\r
1623 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1624 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1625 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1631 //this is the thread function which calls the subversion function
\r
1632 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1634 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1637 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1640 oldest=CTime::GetCurrentTime();
\r
1641 latest=CTime(1971,1,2,0,0,0);
\r
1642 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1644 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1645 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1647 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1648 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1653 //Helper class for FetchFullLogInfo()
\r
1654 class CGitCall_FetchFullLogInfo : public CGitCall
\r
1657 CGitCall_FetchFullLogInfo(CGitLogListBase* ploglist):m_ploglist(ploglist),m_CollectedCount(0){}
\r
1658 virtual bool OnOutputData(const BYTE* data, size_t size)
\r
1661 return m_ploglist->m_bExitThread;
\r
1662 //Add received data to byte collector
\r
1663 m_ByteCollector.append(data,size);
\r
1665 //Find loginfo endmarker
\r
1666 static const BYTE dataToFind[]={0,0,'#','<'};
\r
1667 int found=m_ByteCollector.findData(dataToFind,4);
\r
1669 return m_ploglist->m_bExitThread;//Not found
\r
1670 found+=2;//Position after loginfo end-marker
\r
1672 //Prepare data for OnLogInfo and call it
\r
1673 BYTE_VECTOR logInfo;
\r
1674 logInfo.append(&*m_ByteCollector.begin(),found);
\r
1675 OnLogInfo(logInfo);
\r
1677 //Remove loginfo from bytecollector
\r
1678 m_ByteCollector.erase(m_ByteCollector.begin(),m_ByteCollector.begin()+found);
\r
1680 return m_ploglist->m_bExitThread;
\r
1682 virtual void OnEnd()
\r
1684 //Rest should be a complete log line.
\r
1685 if(!m_ByteCollector.empty())
\r
1686 OnLogInfo(m_ByteCollector);
\r
1690 void OnLogInfo(BYTE_VECTOR& logInfo)
\r
1693 fullRev.ParserFromLog(logInfo);
\r
1694 MAP_HASH_REV::iterator itRev=m_ploglist->m_logEntries.m_HashMap.find(fullRev.m_CommitHash);
\r
1695 if(itRev==m_ploglist->m_logEntries.m_HashMap.end())
\r
1697 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
\r
1701 int rev=itRev->second;
\r
1702 GitRev* revInVector=&m_ploglist->m_logEntries[rev];
\r
1705 if(revInVector->m_IsFull)
\r
1708 if(!m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev]))
\r
1710 ++m_CollectedCount;
\r
1711 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsUpdateing,FALSE);
\r
1712 InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsFull,TRUE);
\r
1713 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1717 // fullRev.m_IsUpdateing=TRUE;
\r
1718 // fullRev.m_IsFull=TRUE;
\r
1721 if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE))
\r
1722 return;//Cannot update this row now. Ignore.
\r
1723 TCHAR oldmark=revInVector->m_Mark;
\r
1724 GIT_REV_LIST oldlist=revInVector->m_ParentHash;
\r
1725 // CString oldhash=m_CommitHash;
\r
1727 //Parse new rev info
\r
1728 revInVector->ParserFromLog(logInfo);
\r
1731 revInVector->m_Mark=oldmark; //parser full log will cause old mark overwrited.
\r
1732 //So we need keep old bound mark.
\r
1733 revInVector->m_ParentHash=oldlist;
\r
1736 m_ploglist->m_LogCache.AddCacheEntry(*revInVector);
\r
1739 InterlockedExchange(&revInVector->m_IsFull,TRUE);
\r
1740 InterlockedExchange(&revInVector->m_IsUpdateing,FALSE);
\r
1742 //Notify listcontrol and update progress bar
\r
1743 ++m_CollectedCount;
\r
1745 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1747 DWORD percent=m_CollectedCount*68/m_ploglist->m_logEntries.size() + GITLOG_START+1+30;
\r
1748 if(percent == GITLOG_END)
\r
1749 percent = GITLOG_END -1;
\r
1751 ::PostMessage(m_ploglist->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1754 CGitLogListBase* m_ploglist;
\r
1755 BYTE_VECTOR m_ByteCollector;
\r
1756 int m_CollectedCount;
\r
1760 void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to)
\r
1762 CGitCall_FetchFullLogInfo fetcher(this);
\r
1764 CGit::LOG_INFO_STAT|
\r
1765 CGit::LOG_INFO_FILESTATE|
\r
1766 CGit::LOG_INFO_DETECT_COPYRENAME|
\r
1767 CGit::LOG_INFO_SHOW_MERGEDFILE |
\r
1771 if(this->m_Path.IsEmpty())
\r
1774 path=&this->m_Path;
\r
1776 g_Git.GetLog(&fetcher,CString(),path,-1,mask,&from,&to);
\r
1779 void CGitLogListBase::FetchLastLogInfo()
\r
1781 unsigned int updated=0;
\r
1785 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1787 if(m_logEntries[i].m_IsFull)
\r
1790 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1792 if(!m_logEntries.FetchFullInfo(i))
\r
1796 m_LogCache.AddCacheEntry(m_logEntries[i]);
\r
1801 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1802 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1805 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
\r
1809 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1810 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1817 UINT CGitLogListBase::LogThread()
\r
1820 // if(m_ProcCallBack)
\r
1821 // m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1822 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
1824 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1825 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1827 //does the user force the cache to refresh (shift or control key down)?
\r
1828 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1829 || (GetKeyState (VK_SHIFT) < 0);
\r
1831 //disable the "Get All" button while we're receiving
\r
1834 FillGitShortLog();
\r
1836 if(this->m_bExitThread)
\r
1838 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1839 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1842 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1843 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START_ALL, 0);
\r
1845 int start=0; CString firstcommit,lastcommit;
\r
1847 for(int i=0;i<m_logEntries.size();i++)
\r
1849 start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start);
\r
1850 m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i;
\r
1852 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1854 if(firstcommit.IsEmpty())
\r
1855 firstcommit=m_logEntries[i].m_CommitHash;
\r
1856 lastcommit=m_logEntries[i].m_CommitHash;
\r
1860 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1861 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1866 if(start>=m_logEntries.m_RawlogData.size())
\r
1869 int percent=i*30/m_logEntries.size() + GITLOG_START+1;
\r
1871 ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0);
\r
1872 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0);
\r
1874 if(this->m_bExitThread)
\r
1876 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1877 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1881 if(!lastcommit.IsEmpty())
\r
1882 FetchFullLogInfo(lastcommit,firstcommit);
\r
1884 this->FetchLastLogInfo();
\r
1887 RedrawItems(0, m_arShownList.GetCount());
\r
1888 // SetRedraw(false);
\r
1889 // ResizeAllListCtrlCols();
\r
1890 // SetRedraw(true);
\r
1892 if ( m_pStoreSelection )
\r
1894 // Deleting the instance will restore the
\r
1895 // selection of the CLogDlg.
\r
1896 delete m_pStoreSelection;
\r
1897 m_pStoreSelection = NULL;
\r
1901 // If no selection has been set then this must be the first time
\r
1902 // the revisions are shown. Let's preselect the topmost revision.
\r
1903 if ( GetItemCount()>0 )
\r
1905 SetSelectionMark(0);
\r
1906 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1913 //FetchFullLogInfo();
\r
1914 //FetchFullLogInfoOrig();
\r
1915 //RefreshCursor();
\r
1916 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1917 // the log messages
\r
1919 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
1921 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1926 void CGitLogListBase::Refresh()
\r
1928 m_bExitThread=TRUE;
\r
1929 if(m_LoadingThread!=NULL)
\r
1931 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
1932 if(ret == WAIT_TIMEOUT)
\r
1933 TerminateThread();
\r
1938 //Update branch and Tag info
\r
1940 //Assume Thread have exited
\r
1941 //if(!m_bThreadRunning)
\r
1943 this->SetItemCountEx(0);
\r
1944 m_logEntries.clear();
\r
1945 m_bExitThread=FALSE;
\r
1946 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1947 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1948 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1950 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1951 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1952 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1954 m_sFilterText.Empty();
\r
1955 m_From=CTime(1970,1,2,0,0,0);
\r
1956 m_To=CTime::GetCurrentTime();
\r
1959 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1963 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1965 type |= tr1::regex_constants::icase;
\r
1966 pat = tr1::wregex(regexp_str, type);
\r
1969 catch (exception) {}
\r
1973 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1976 pShownlist->RemoveAll();
\r
1977 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1978 bool bRegex = false;
\r
1979 if (m_bFilterWithRegex)
\r
1980 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1982 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1984 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1986 if ((bRegex)&&(m_bFilterWithRegex))
\r
1989 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1991 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1992 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1994 pShownlist->Add(m_logEntries[i]);
\r
1999 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2001 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
2002 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
2004 pShownlist->Add(&m_logEntries[i]);
\r
2008 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
2009 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
2011 pShownlist->Add(&m_logEntries[i]);
\r
2016 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2018 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2020 bool bGoing = true;
\r
2021 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2023 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2024 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
2026 pShownlist->Add(m_logEntries[i]);
\r
2030 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
2032 pShownlist->Add(m_logEntries[i]);
\r
2036 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
2038 pShownlist->Add(m_logEntries[i]);
\r
2047 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2049 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
2051 pShownlist->Add(&m_logEntries[i]);
\r
2055 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2057 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2058 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
2060 pShownlist->Add(&m_logEntries[i]);
\r
2067 CString find = m_sFilterText;
\r
2070 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2072 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
2074 sBugIDs = sBugIDs.MakeLower();
\r
2075 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2077 pShownlist->Add(m_logEntries[i]);
\r
2082 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2084 CString msg = m_logEntries[i].m_Subject;
\r
2086 msg = msg.MakeLower();
\r
2087 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2089 pShownlist->Add(&m_logEntries[i]);
\r
2092 msg = m_logEntries[i].m_Body;
\r
2094 msg = msg.MakeLower();
\r
2095 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2097 pShownlist->Add(&m_logEntries[i]);
\r
2102 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2104 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2106 bool bGoing = true;
\r
2107 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2109 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2110 CString path = cpath->sCopyFromPath;
\r
2112 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2114 pShownlist->Add(m_logEntries[i]);
\r
2118 path = cpath->sPath;
\r
2120 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2122 pShownlist->Add(m_logEntries[i]);
\r
2126 path = cpath->GetAction();
\r
2128 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2130 pShownlist->Add(m_logEntries[i]);
\r
2137 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2139 CString msg = m_logEntries[i].m_AuthorName;
\r
2140 msg = msg.MakeLower();
\r
2141 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2143 pShownlist->Add(&m_logEntries[i]);
\r
2147 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2149 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2150 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2152 pShownlist->Add(&m_logEntries[i]);
\r
2156 } // else (from if (bRegex))
\r
2157 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2161 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
2163 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2164 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2171 void CGitLogListBase::StartFilter()
\r
2173 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2174 RecalculateShownList(&m_arShownList);
\r
2175 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2179 SetItemCountEx(ShownCountWithStopped());
\r
2180 RedrawItems(0, ShownCountWithStopped());
\r
2182 //ResizeAllListCtrlCols();
\r
2187 void CGitLogListBase::RemoveFilter()
\r
2190 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2192 m_arShownList.RemoveAll();
\r
2194 // reset the time filter too
\r
2196 m_timFrom = (__time64_t(m_tFrom));
\r
2197 m_timTo = (__time64_t(m_tTo));
\r
2198 m_DateFrom.SetTime(&m_timFrom);
\r
2199 m_DateTo.SetTime(&m_timTo);
\r
2200 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2201 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2204 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2206 if(this->m_IsOldFirst)
\r
2208 m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
2211 m_arShownList.Add(&m_logEntries[i]);
\r
2214 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2216 SetItemCountEx(ShownCountWithStopped());
\r
2217 RedrawItems(0, ShownCountWithStopped());
\r
2218 // SetRedraw(false);
\r
2219 // ResizeAllListCtrlCols();
\r
2220 // SetRedraw(true);
\r
2222 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2225 void CGitLogListBase::Clear()
\r
2227 m_arShownList.RemoveAll();
\r
2230 m_logEntries.ClearAll();
\r
2234 void CGitLogListBase::OnDestroy()
\r
2236 // save the column widths to the registry
\r
2237 SaveColumnWidths();
\r
2239 if(this->m_bThreadRunning)
\r
2241 this->m_bExitThread=true;
\r
2242 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2243 if(ret == WAIT_TIMEOUT)
\r
2244 TerminateThread();
\r
2246 while(m_LogCache.SaveCache())
\r
2248 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
\r
2249 MB_YESNO) == IDNO)
\r
2252 CHintListCtrl::OnDestroy();
\r
2255 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
\r
2258 int i=(int)wParam;
\r
2259 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
2260 this->InvalidateRect(rect);
\r
2265 * Save column widths to the registry
\r
2267 void CGitLogListBase::SaveColumnWidths()
\r
2269 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
2272 int numcols = pHdrCtrl->GetItemCount();
\r
2273 for (int col = 0; col < numcols; col++)
\r
2275 int width = GetColumnWidth( col );
\r
2277 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
\r
2278 CRegDWORD regwidth(regentry, 0);
\r
2279 regwidth = width; // this writes it to reg
\r
2284 int CGitLogListBase::GetHeadIndex()
\r
2286 if(m_HeadHash.IsEmpty())
\r
2289 for(int i=0;i<m_arShownList.GetCount();i++)
\r
2291 GitRev *pRev = (GitRev*)m_arShownList[i];
\r
2294 if(pRev->m_CommitHash == m_HeadHash )
\r