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
51 IMPLEMENT_DYNAMIC(CGitLogListBase, CHintListCtrl)
\r
53 CGitLogListBase::CGitLogListBase():CHintListCtrl()
\r
54 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
56 ,m_bNoDispUpdates(FALSE)
\r
57 , m_bThreadRunning(FALSE)
\r
58 , m_bStrictStopped(false)
\r
59 , m_pStoreSelection(NULL)
\r
60 , 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
87 m_From=CTime(1970,1,2,0,0,0);
\r
88 m_To=CTime::GetCurrentTime();
\r
89 m_bAllBranch = FALSE;
\r
90 m_LoadingThread = NULL;
\r
92 m_bExitThread=FALSE;
\r
95 CGitLogListBase::~CGitLogListBase()
\r
97 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
99 DestroyIcon(m_hModifiedIcon);
\r
100 DestroyIcon(m_hReplacedIcon);
\r
101 DestroyIcon(m_hAddedIcon);
\r
102 DestroyIcon(m_hDeletedIcon);
\r
103 m_logEntries.ClearAll();
\r
106 DeleteObject(m_boldFont);
\r
108 if ( m_pStoreSelection )
\r
110 delete m_pStoreSelection;
\r
111 m_pStoreSelection = NULL;
\r
116 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
117 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
118 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
119 ON_WM_CONTEXTMENU()
\r
120 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
121 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
125 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
127 PreSubclassWindow();
\r
128 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
131 void CGitLogListBase::PreSubclassWindow()
\r
133 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
134 // load the icons for the action columns
\r
135 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
136 CHintListCtrl::PreSubclassWindow();
\r
139 void CGitLogListBase::InsertGitColumn()
\r
143 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
147 temp.LoadString(IDS_LOG_GRAPH);
\r
149 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
152 // make the revision column right aligned
\r
154 Column.mask = LVCF_FMT;
\r
155 Column.fmt = LVCFMT_RIGHT;
\r
156 SetColumn(0, &Column);
\r
159 // g_Git.GetLog(log);
\r
161 if(m_IsIDReplaceAction)
\r
163 temp.LoadString(IDS_LOG_ID);
\r
164 InsertColumn(this->LOGLIST_ACTION, temp);
\r
168 temp.LoadString(IDS_LOG_ACTIONS);
\r
169 InsertColumn(this->LOGLIST_ACTION, temp);
\r
171 temp.LoadString(IDS_LOG_MESSAGE);
\r
172 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
174 temp.LoadString(IDS_LOG_AUTHOR);
\r
175 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
177 temp.LoadString(IDS_LOG_DATE);
\r
178 InsertColumn(this->LOGLIST_DATE, temp);
\r
181 if (m_bShowBugtraqColumn)
\r
183 // temp = m_ProjectProperties.sLabel;
\r
184 if (temp.IsEmpty())
\r
185 temp.LoadString(IDS_LOG_BUGIDS);
\r
186 InsertColumn(this->LOGLIST_BUG, temp);
\r
191 ResizeAllListCtrlCols();
\r
196 void CGitLogListBase::ResizeAllListCtrlCols()
\r
199 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
200 int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
201 int nItemCount = GetItemCount();
\r
202 TCHAR textbuf[MAX_PATH];
\r
203 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
206 for (int col = 0; col <= maxcol; col++)
\r
209 hdi.mask = HDI_TEXT;
\r
210 hdi.pszText = textbuf;
\r
211 hdi.cchTextMax = sizeof(textbuf);
\r
212 pHdrCtrl->GetItem(col, &hdi);
\r
213 int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
214 for (int index = 0; index<nItemCount; ++index)
\r
216 // get the width of the string and add 14 pixels for the column separator and margins
\r
217 int linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
218 if (index < m_arShownList.GetCount())
\r
220 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
221 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
223 // set the bold font and ask for the string width again
\r
224 SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
225 linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
226 // restore the system font
\r
227 SendMessage(WM_SETFONT, NULL, NULL);
\r
232 // add the image size
\r
233 CImageList * pImgList = GetImageList(LVSIL_SMALL);
\r
234 if ((pImgList)&&(pImgList->GetImageCount()))
\r
237 pImgList->GetImageInfo(0, &imginfo);
\r
238 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
239 linewidth += 3; // 3 pixels between icon and text
\r
242 if (cx < linewidth)
\r
245 // Adjust columns "Actions" containing icons
\r
246 if (col == this->LOGLIST_ACTION)
\r
248 if (cx < nMinimumWidth)
\r
250 cx = nMinimumWidth;
\r
254 if (col == this->LOGLIST_MESSAGE)
\r
256 if (cx > LOGLIST_MESSAGE_MAX)
\r
258 cx = LOGLIST_MESSAGE_MAX;
\r
260 if (cx < LOGLIST_MESSAGE_MIN)
\r
262 cx = LOGLIST_MESSAGE_MIN;
\r
266 // keep the bug id column small
\r
267 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
269 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
271 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
275 SetColumnWidth(col, cx);
\r
282 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
284 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
285 if(ref.Left(prefix.GetLength()) == prefix)
\r
287 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
288 if(shortname.Right(3)==_T("^{}"))
\r
289 shortname=shortname.Left(shortname.GetLength()-3);
\r
294 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
298 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
299 rItem.mask = LVIF_STATE;
\r
300 rItem.iItem = Index;
\r
301 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
304 if (m_Theme.IsAppThemed() && m_bVista)
\r
306 m_Theme.Open(m_hWnd, L"Explorer");
\r
307 int state = LISS_NORMAL;
\r
308 if (rItem.state & LVIS_SELECTED)
\r
310 if (::GetFocus() == m_hWnd)
\r
311 state |= LISS_SELECTED;
\r
313 state |= LISS_SELECTEDNOTFOCUS;
\r
318 if (pLogEntry->bCopiedSelf)
\r
320 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
321 // information at this drawing stage. But we can check the whether the
\r
322 // previous stage changed the background color of the item
\r
323 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
326 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
329 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
330 ::DeleteObject(brush);
\r
337 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
338 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
340 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
345 if (rItem.state & LVIS_SELECTED)
\r
347 if (::GetFocus() == m_hWnd)
\r
348 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
350 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
354 //if (pLogEntry->bCopiedSelf)
\r
355 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
357 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
362 ::FillRect(hdc, &rect, brush);
\r
363 ::DeleteObject(brush);
\r
368 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
370 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
373 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
374 rItem.mask = LVIF_STATE;
\r
375 rItem.iItem = index;
\r
376 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
379 for(int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
382 str=m_HashMap[data->m_CommitHash][i];
\r
387 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
389 brush = ::CreateSolidBrush(RGB(0xff, 0, 0));
\r
390 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
392 brush = ::CreateSolidBrush(RGB(0xff, 0xff, 0));
\r
394 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
396 brush = ::CreateSolidBrush(RGB(0, 0, 0xff));
\r
399 if(!shortname.IsEmpty())
\r
402 memset(&size,0,sizeof(SIZE));
\r
403 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
405 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
407 ::FillRect(hdc, &rt, brush);
\r
408 if (rItem.state & LVIS_SELECTED)
\r
410 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
411 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
412 ::SetTextColor(hdc,clrOld);
\r
415 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
419 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
420 ::LineTo(hdc,rt.right,rt.top);
\r
421 ::LineTo(hdc,rt.right,rt.bottom);
\r
422 ::LineTo(hdc,rt.left,rt.bottom);
\r
423 ::LineTo(hdc,rt.left,rt.top);
\r
425 rt.left=rt.right+3;
\r
428 ::DeleteObject(brush);
\r
430 rt.right=rect.right;
\r
432 if (rItem.state & LVIS_SELECTED)
\r
434 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
435 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
436 ::SetTextColor(hdc,clrOld);
\r
439 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
444 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
445 const COLORREF& col,int top
\r
448 int h = laneHeight / 2;
\r
449 int m = (x1 + x2) / 2;
\r
450 int r = (x2 - x1) / 3;
\r
453 #define P_CENTER m , h+top
\r
454 #define P_0 x2, h+top
\r
455 #define P_90 m , 0+top
\r
456 #define P_180 x1, h+top
\r
457 #define P_270 m , 2 * h+top
\r
458 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
460 //static QPen myPen(Qt::black, 2); // fast path here
\r
462 pen.CreatePen(PS_SOLID,2,col);
\r
463 //myPen.setColor(col);
\r
464 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
466 //p->setPen(myPen);
\r
470 case Lanes::ACTIVE:
\r
471 case Lanes::NOT_ACTIVE:
\r
472 case Lanes::MERGE_FORK:
\r
473 case Lanes::MERGE_FORK_R:
\r
474 case Lanes::MERGE_FORK_L:
\r
476 case Lanes::JOIN_R:
\r
477 case Lanes::JOIN_L:
\r
478 DrawLine(hdc,P_90,P_270);
\r
479 //p->drawLine(P_90, P_270);
\r
482 case Lanes::HEAD_R:
\r
483 case Lanes::HEAD_L:
\r
484 case Lanes::BRANCH:
\r
485 DrawLine(hdc,P_CENTER,P_270);
\r
486 //p->drawLine(P_CENTER, P_270);
\r
489 case Lanes::TAIL_R:
\r
490 case Lanes::TAIL_L:
\r
491 case Lanes::INITIAL:
\r
492 case Lanes::BOUNDARY:
\r
493 case Lanes::BOUNDARY_C:
\r
494 case Lanes::BOUNDARY_R:
\r
495 case Lanes::BOUNDARY_L:
\r
496 DrawLine(hdc,P_90, P_CENTER);
\r
497 //p->drawLine(P_90, P_CENTER);
\r
505 case Lanes::MERGE_FORK:
\r
510 case Lanes::CROSS_EMPTY:
\r
511 case Lanes::BOUNDARY_C:
\r
512 DrawLine(hdc,P_180,P_0);
\r
513 //p->drawLine(P_180, P_0);
\r
515 case Lanes::MERGE_FORK_R:
\r
516 case Lanes::JOIN_R:
\r
517 case Lanes::HEAD_R:
\r
518 case Lanes::TAIL_R:
\r
519 case Lanes::BOUNDARY_R:
\r
520 DrawLine(hdc,P_180,P_CENTER);
\r
521 //p->drawLine(P_180, P_CENTER);
\r
523 case Lanes::MERGE_FORK_L:
\r
524 case Lanes::JOIN_L:
\r
525 case Lanes::HEAD_L:
\r
526 case Lanes::TAIL_L:
\r
527 case Lanes::BOUNDARY_L:
\r
528 DrawLine(hdc,P_CENTER,P_0);
\r
529 //p->drawLine(P_CENTER, P_0);
\r
536 brush.CreateSolidBrush(col);
\r
537 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
538 // center symbol, e.g. rect or ellipse
\r
540 case Lanes::ACTIVE:
\r
541 case Lanes::INITIAL:
\r
542 case Lanes::BRANCH:
\r
544 //p->setPen(Qt::NoPen);
\r
545 //p->setBrush(col);
\r
546 ::Ellipse(hdc, R_CENTER);
\r
547 //p->drawEllipse(R_CENTER);
\r
549 case Lanes::MERGE_FORK:
\r
550 case Lanes::MERGE_FORK_R:
\r
551 case Lanes::MERGE_FORK_L:
\r
552 //p->setPen(Qt::NoPen);
\r
553 //p->setBrush(col);
\r
554 //p->drawRect(R_CENTER);
\r
555 Rectangle(hdc,R_CENTER);
\r
557 case Lanes::UNAPPLIED:
\r
559 //p->setPen(Qt::NoPen);
\r
560 //p->setBrush(Qt::red);
\r
561 //p->drawRect(m - r, h - 1, d, 2);
\r
562 ::Rectangle(hdc,m-r,h-1,d,2);
\r
564 case Lanes::APPLIED:
\r
566 //p->setPen(Qt::NoPen);
\r
567 //p->setBrush(DARK_GREEN);
\r
568 //p->drawRect(m - r, h - 1, d, 2);
\r
569 //p->drawRect(m - 1, h - r, 2, d);
\r
570 ::Rectangle(hdc,m-r,h-1,d,2);
\r
571 ::Rectangle(hdc,m-1,h-r,2,d);
\r
573 case Lanes::BOUNDARY:
\r
574 //p->setBrush(back);
\r
575 //p->drawEllipse(R_CENTER);
\r
576 ::Ellipse(hdc, R_CENTER);
\r
578 case Lanes::BOUNDARY_C:
\r
579 case Lanes::BOUNDARY_R:
\r
580 case Lanes::BOUNDARY_L:
\r
581 //p->setBrush(back);
\r
582 //p->drawRect(R_CENTER);
\r
583 ::Rectangle(hdc,R_CENTER);
\r
589 ::SelectObject(hdc,oldpen);
\r
590 ::SelectObject(hdc,oldbrush);
\r
599 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
603 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
606 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
607 rItem.mask = LVIF_STATE;
\r
608 rItem.iItem = index;
\r
609 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
612 static const COLORREF colors[Lanes::COLORS_NUM] = { RGB(0,0,0), RGB(0xFF,0,0), RGB(0,0xFF,0),
\r
613 RGB(0,0,0xFF), RGB(128,128,128), RGB(128,128,0),
\r
614 RGB(0,128,128), RGB(128,0,128) };
\r
617 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
621 if (data->m_Lanes.size() == 0)
\r
622 m_logEntries.setLane(data->m_CommitHash);
\r
624 std::vector<int>& lanes=data->m_Lanes;
\r
625 UINT laneNum = lanes.size();
\r
626 UINT mergeLane = 0;
\r
627 for (UINT i = 0; i < laneNum; i++)
\r
628 if (Lanes::isMerge(lanes[i])) {
\r
633 int x1 = 0, x2 = 0;
\r
634 int maxWidth = rect.Width();
\r
635 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
636 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
642 if (ln == Lanes::EMPTY)
\r
645 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
646 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
648 if (ln == Lanes::CROSS) {
\r
649 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
650 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, colors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
652 paintGraphLane(hdc, rect.Height(),ln, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
655 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
658 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
661 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
662 // Take the default processing unless we set this to something else below.
\r
663 *pResult = CDRF_DODEFAULT;
\r
665 if (m_bNoDispUpdates)
\r
670 switch (pLVCD->nmcd.dwDrawStage)
\r
672 case CDDS_PREPAINT:
\r
674 *pResult = CDRF_NOTIFYITEMDRAW;
\r
678 case CDDS_ITEMPREPAINT:
\r
680 // This is the prepaint stage for an item. Here's where we set the
\r
681 // item's text color.
\r
683 // Tell Windows to send draw notifications for each subitem.
\r
684 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
686 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
688 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
690 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
694 if (data->bCopiedSelf)
\r
696 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
697 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
698 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
702 crText = m_Colors.GetColor(CColors::Modified);
\r
704 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
705 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
706 // if (data->Rev == m_wcRev)
\r
708 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
709 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
710 // tells the control to recalculate the extent of the text.
\r
711 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
715 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
717 if (m_bStrictStopped)
\r
718 crText = GetSysColor(COLOR_GRAYTEXT);
\r
720 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
721 pLVCD->clrText = crText;
\r
725 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
727 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
729 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
732 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
734 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
737 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
739 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
740 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
742 *pResult = CDRF_SKIPDEFAULT;
\r
748 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
750 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
752 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
753 if(!data->m_IsFull)
\r
755 if(data->SafeFetchFullInfo(&g_Git))
\r
756 this->Invalidate();
\r
757 TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
760 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
764 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
766 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
767 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
769 *pResult = CDRF_SKIPDEFAULT;
\r
776 if (pLVCD->iSubItem == 1)
\r
778 if(this->m_IsIDReplaceAction)
\r
780 *pResult = CDRF_DODEFAULT;
\r
783 *pResult = CDRF_DODEFAULT;
\r
785 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
789 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
790 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
792 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
794 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
795 // Get the selected state of the
\r
796 // item being drawn.
\r
798 // Fill the background
\r
799 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
801 // Draw the icon(s) into the compatible DC
\r
802 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
803 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
806 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
807 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
810 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
811 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
814 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
815 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
817 *pResult = CDRF_SKIPDEFAULT;
\r
823 *pResult = CDRF_DODEFAULT;
\r
827 // CGitLogListBase message handlers
\r
829 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
831 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
833 // Create a pointer to the item
\r
834 LV_ITEM* pItem = &(pDispInfo)->item;
\r
836 // Do the list need text information?
\r
837 if (!(pItem->mask & LVIF_TEXT))
\r
840 // By default, clear text buffer.
\r
841 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
843 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
846 if (m_bNoDispUpdates || bOutOfRange)
\r
849 // Which item number?
\r
850 int itemid = pItem->iItem;
\r
851 GitRev * pLogEntry = NULL;
\r
852 if (itemid < m_arShownList.GetCount())
\r
853 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
856 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
859 switch (pItem->iSubItem)
\r
861 case this->LOGLIST_GRAPH: //Graphic
\r
866 case this->LOGLIST_ACTION: //action -- no text in the column
\r
867 if(this->m_IsIDReplaceAction)
\r
868 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
870 case this->LOGLIST_MESSAGE: //Message
\r
872 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
874 case this->LOGLIST_AUTHOR: //Author
\r
876 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
878 case this->LOGLIST_DATE: //Date
\r
880 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
891 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
894 int selIndex = GetSelectionMark();
\r
896 return; // nothing selected, nothing to do with a context menu
\r
898 // if the user selected the info text telling about not all revisions shown due to
\r
899 // the "stop on copy/rename" option, we also don't show the context menu
\r
900 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
903 // if the context menu is invoked through the keyboard, we have to use
\r
904 // a calculated position on where to anchor the menu on
\r
905 if ((point.x == -1) && (point.y == -1))
\r
908 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
909 ClientToScreen(&rect);
\r
910 point = rect.CenterPoint();
\r
912 m_nSearchIndex = selIndex;
\r
913 m_bCancelled = FALSE;
\r
915 // calculate some information the context menu commands can use
\r
916 // CString pathURL = GetURLFromPath(m_path);
\r
918 POSITION pos = GetFirstSelectedItemPosition();
\r
919 int indexNext = GetNextSelectedItem(pos);
\r
923 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
925 GitRev revSelected = pSelLogEntry->Rev;
\r
926 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
927 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
929 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
931 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
932 if (changedpath->lCopyFromRev)
\r
933 revPrevious = changedpath->lCopyFromRev;
\r
936 GitRev revSelected2;
\r
939 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
940 revSelected2 = pLogEntry->Rev;
\r
942 bool bAllFromTheSameAuthor = true;
\r
943 CString firstAuthor;
\r
944 CLogDataVector selEntries;
\r
945 GitRev revLowest, revHighest;
\r
946 GitRevRangeArray revisionRanges;
\r
948 POSITION pos = GetFirstSelectedItemPosition();
\r
949 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
950 revisionRanges.AddRevision(pLogEntry->Rev);
\r
951 selEntries.push_back(pLogEntry);
\r
952 firstAuthor = pLogEntry->sAuthor;
\r
953 revLowest = pLogEntry->Rev;
\r
954 revHighest = pLogEntry->Rev;
\r
957 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
958 revisionRanges.AddRevision(pLogEntry->Rev);
\r
959 selEntries.push_back(pLogEntry);
\r
960 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
961 bAllFromTheSameAuthor = false;
\r
962 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
963 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
969 int FirstSelect=-1, LastSelect=-1;
\r
970 pos = GetFirstSelectedItemPosition();
\r
971 FirstSelect = GetNextSelectedItem(pos);
\r
974 LastSelect = GetNextSelectedItem(pos);
\r
976 //entry is selected, now show the popup menu
\r
978 if (popup.CreatePopupMenu())
\r
980 if (GetSelectedCount() == 1)
\r
983 if (!m_path.IsDirectory())
\r
987 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
988 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
990 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
991 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
992 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
993 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
994 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
995 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
996 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
997 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1004 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1006 // TortoiseMerge could be improved to take a /blame switch
\r
1007 // and then not 'cat' the files from a unified diff but
\r
1009 // But until that's implemented, the context menu entry for
\r
1010 // this feature is commented out.
\r
1011 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1013 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1014 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1015 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1016 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1019 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1021 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1023 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1025 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1027 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1028 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1030 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1034 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1036 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1038 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1040 popup.AppendMenuIcon(ID_SWITCHTOREV, _T("Switch/Checkout to this") , IDI_SWITCH);
\r
1041 popup.AppendMenuIcon(ID_CREATE_BRANCH, _T("Create Branch at this version") , IDI_COPY);
\r
1042 popup.AppendMenuIcon(ID_CREATE_TAG, _T("Create Tag at this version"), IDI_COPY);
\r
1043 popup.AppendMenuIcon(ID_CHERRY_PICK, _T("Cherry Pick this version"), IDI_EXPORT);
\r
1044 popup.AppendMenuIcon(ID_EXPORT, _T("Export this version"), IDI_EXPORT);
\r
1047 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1049 else if (GetSelectedCount() >= 2)
\r
1051 bool bAddSeparator = false;
\r
1052 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1054 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1056 if (GetSelectedCount() == 2)
\r
1058 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1059 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1060 bAddSeparator = true;
\r
1064 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1066 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1067 bAddSeparator = true;
\r
1069 if (bAddSeparator)
\r
1070 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1073 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1075 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1077 // if (GetSelectedCount() == 1)
\r
1079 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1080 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1081 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1086 if (GetSelectedCount() == 1)
\r
1088 popup.AppendMenuIcon(ID_COPYHASH, _T("Copy Commit Hash"));
\r
1090 if (GetSelectedCount() != 0)
\r
1092 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1094 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1096 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1097 // DialogEnableWindow(IDOK, FALSE);
\r
1098 // SetPromptApp(&theApp);
\r
1100 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1102 // EnableOKButton();
\r
1103 } // if (popup.CreatePopupMenu())
\r
1107 bool CGitLogListBase::IsSelectionContinuous()
\r
1109 if ( GetSelectedCount()==1 )
\r
1111 // if only one revision is selected, the selection is of course
\r
1116 POSITION pos = GetFirstSelectedItemPosition();
\r
1117 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1120 int itemindex = GetNextSelectedItem(pos);
\r
1123 int nextindex = GetNextSelectedItem(pos);
\r
1124 if (nextindex - itemindex > 1)
\r
1126 bContinuous = false;
\r
1129 itemindex = nextindex;
\r
1132 return bContinuous;
\r
1135 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1138 CString sClipdata;
\r
1139 POSITION pos = GetFirstSelectedItemPosition();
\r
1143 sRev.LoadString(IDS_LOG_REVISION);
\r
1145 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1147 sDate.LoadString(IDS_LOG_DATE);
\r
1149 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1152 CString sLogCopyText;
\r
1154 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1158 //pLogEntry->m_Files
\r
1159 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1161 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1163 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1164 sPaths += _T("\r\n");
\r
1167 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
1168 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1169 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1170 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),
\r
1171 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1173 sClipdata += sLogCopyText;
\r
1176 sClipdata += pLogEntry->m_CommitHash;
\r
1181 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1186 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1189 if (m_bThreadRunning)
\r
1191 UpdateLogInfoLabel();
\r
1192 int selIndex = m_LogList.GetSelectionMark();
\r
1195 int selCount = m_LogList.GetSelectedCount();
\r
1196 if (selCount != 1)
\r
1199 // Find selected entry in the log list
\r
1200 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1201 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1202 long rev1 = pLogEntry->Rev;
\r
1203 long rev2 = rev1-1;
\r
1204 CTGitPath path = m_path;
\r
1206 // See how many files under the relative root were changed in selected revision
\r
1208 LogChangedPath * changed = NULL;
\r
1209 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1211 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1212 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1219 if (m_path.IsDirectory() && nChanged == 1)
\r
1221 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1222 // Do diff on that file instead of whole directory
\r
1223 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1226 m_bCancelled = FALSE;
\r
1227 DialogEnableWindow(IDOK, FALSE);
\r
1228 SetPromptApp(&theApp);
\r
1229 theApp.DoWaitCursor(1);
\r
1231 if (PromptShown())
\r
1233 GitDiff diff(this, m_hWnd, true);
\r
1234 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1235 diff.SetHEADPeg(m_LogRevision);
\r
1236 diff.ShowCompare(path, rev2, path, rev1);
\r
1240 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1243 theApp.DoWaitCursor(-1);
\r
1248 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1250 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1253 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1255 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1257 if (pFindInfo->lvfi.psz == 0)
\r
1260 CString sCmp = pFindInfo->lvfi.psz;
\r
1262 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1264 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1265 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1266 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1268 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1276 if (sCmp.Compare(sRev)==0)
\r
1283 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1285 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1287 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1288 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1289 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1291 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1299 if (sCmp.Compare(sRev)==0)
\r
1311 int CGitLogListBase::FillGitLog(CTGitPath *path,int info)
\r
1315 this->m_logEntries.ClearAll();
\r
1316 this->m_logEntries.ParserFromLog(path,-1,info);
\r
1318 //this->m_logEntries.ParserFromLog();
\r
1319 SetItemCountEx(this->m_logEntries.size());
\r
1321 this->m_arShownList.RemoveAll();
\r
1323 for(int i=0;i<m_logEntries.size();i++)
\r
1325 m_logEntries[i].m_IsFull=TRUE;
\r
1326 this->m_arShownList.Add(&m_logEntries[i]);
\r
1335 int CGitLogListBase::FillGitShortLog()
\r
1339 this->m_logEntries.ClearAll();
\r
1341 if(this->m_Path.IsEmpty())
\r
1344 path=&this->m_Path;
\r
1348 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1349 if(this->m_bAllBranch)
\r
1350 mask |= CGit::LOG_INFO_ALL_BRANCH;
\r
1352 this->m_logEntries.ParserShortLog(path,hash,-1,mask);
\r
1355 //this->m_logEntries.ParserFromLog();
\r
1356 SetItemCountEx(this->m_logEntries.size());
\r
1358 this->m_arShownList.RemoveAll();
\r
1360 for(int i=0;i<m_logEntries.size();i++)
\r
1361 this->m_arShownList.Add(&m_logEntries[i]);
\r
1366 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1368 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1369 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1370 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1372 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1374 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1376 DiffSelectedRevWithPrevious();
\r
1381 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1383 DiffSelectedFile();
\r
1390 if (m_hAccel && !bSkipAccelerator)
\r
1392 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1398 //m_tooltips.RelayEvent(pMsg);
\r
1399 return __super::PreTranslateMessage(pMsg);
\r
1402 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1404 // a double click on an entry in the revision list has happened
\r
1407 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1408 DiffSelectedRevWithPrevious();
\r
1411 int CGitLogListBase::FetchLogAsync(CALLBACK_PROCESS *proc,void * data)
\r
1413 m_ProcCallBack=proc;
\r
1415 m_bExitThread=FALSE;
\r
1416 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1417 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1418 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1419 if (m_LoadingThread ==NULL)
\r
1421 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1422 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1423 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1429 //this is the thread function which calls the subversion function
\r
1430 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1432 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1435 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1438 oldest=CTime::GetCurrentTime();
\r
1439 latest=CTime(1971,1,2,0,0,0);
\r
1440 for(int i=0;i<m_logEntries.size();i++)
\r
1442 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1443 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1445 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1446 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1451 UINT CGitLogListBase::LogThread()
\r
1454 if(m_ProcCallBack)
\r
1455 m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1457 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1458 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1460 //does the user force the cache to refresh (shift or control key down)?
\r
1461 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1462 || (GetKeyState (VK_SHIFT) < 0);
\r
1464 //disable the "Get All" button while we're receiving
\r
1468 temp.LoadString(IDS_PROGRESSWAIT);
\r
1469 ShowText(temp, true);
\r
1471 FillGitShortLog();
\r
1475 RedrawItems(0, m_arShownList.GetCount());
\r
1477 ResizeAllListCtrlCols();
\r
1480 if ( m_pStoreSelection )
\r
1482 // Deleting the instance will restore the
\r
1483 // selection of the CLogDlg.
\r
1484 delete m_pStoreSelection;
\r
1485 m_pStoreSelection = NULL;
\r
1489 // If no selection has been set then this must be the first time
\r
1490 // the revisions are shown. Let's preselect the topmost revision.
\r
1491 if ( GetItemCount()>0 )
\r
1493 SetSelectionMark(0);
\r
1494 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1497 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1504 for(int i=0;i<m_logEntries.size();i++)
\r
1506 if(!m_logEntries.FetchFullInfo(i))
\r
1511 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1512 if(percent == GITLOG_END)
\r
1513 percent == GITLOG_END -1;
\r
1515 if(m_ProcCallBack)
\r
1516 m_ProcCallBack(m_ProcData,percent);
\r
1521 if(updated==m_logEntries.size())
\r
1525 //RefreshCursor();
\r
1526 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1527 // the log messages
\r
1531 if(m_ProcCallBack)
\r
1532 m_ProcCallBack(m_ProcData,GITLOG_END);
\r
1534 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1539 void CGitLogListBase::Refresh()
\r
1541 if(!m_bThreadRunning)
\r
1543 this->SetItemCountEx(0);
\r
1544 m_logEntries.clear();
\r
1545 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1546 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1547 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1549 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1550 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1551 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1553 m_sFilterText.Empty();
\r
1554 m_From=CTime(1970,1,2,0,0,0);
\r
1555 m_To=CTime::GetCurrentTime();
\r
1558 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1562 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1564 type |= tr1::regex_constants::icase;
\r
1565 pat = tr1::wregex(regexp_str, type);
\r
1568 catch (exception) {}
\r
1572 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1575 pShownlist->RemoveAll();
\r
1576 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1577 bool bRegex = false;
\r
1578 if (m_bFilterWithRegex)
\r
1579 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1581 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1583 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1585 if ((bRegex)&&(m_bFilterWithRegex))
\r
1588 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1590 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1591 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1593 pShownlist->Add(m_logEntries[i]);
\r
1598 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1600 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1601 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1603 pShownlist->Add(&m_logEntries[i]);
\r
1607 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1608 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1610 pShownlist->Add(&m_logEntries[i]);
\r
1615 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1617 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1619 bool bGoing = true;
\r
1620 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1622 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1623 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1625 pShownlist->Add(m_logEntries[i]);
\r
1629 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
1631 pShownlist->Add(m_logEntries[i]);
\r
1635 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
1637 pShownlist->Add(m_logEntries[i]);
\r
1646 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1648 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
1650 pShownlist->Add(&m_logEntries[i]);
\r
1654 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1656 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1657 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
1659 pShownlist->Add(&m_logEntries[i]);
\r
1666 CString find = m_sFilterText;
\r
1669 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1671 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
1673 sBugIDs = sBugIDs.MakeLower();
\r
1674 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1676 pShownlist->Add(m_logEntries[i]);
\r
1681 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1683 CString msg = m_logEntries[i].m_Subject;
\r
1685 msg = msg.MakeLower();
\r
1686 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1688 pShownlist->Add(&m_logEntries[i]);
\r
1691 msg = m_logEntries[i].m_Body;
\r
1693 msg = msg.MakeLower();
\r
1694 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1696 pShownlist->Add(&m_logEntries[i]);
\r
1701 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1703 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1705 bool bGoing = true;
\r
1706 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1708 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1709 CString path = cpath->sCopyFromPath;
\r
1711 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1713 pShownlist->Add(m_logEntries[i]);
\r
1717 path = cpath->sPath;
\r
1719 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1721 pShownlist->Add(m_logEntries[i]);
\r
1725 path = cpath->GetAction();
\r
1727 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1729 pShownlist->Add(m_logEntries[i]);
\r
1736 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1738 CString msg = m_logEntries[i].m_AuthorName;
\r
1739 msg = msg.MakeLower();
\r
1740 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1742 pShownlist->Add(&m_logEntries[i]);
\r
1746 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1748 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1749 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1751 pShownlist->Add(&m_logEntries[i]);
\r
1755 } // else (from if (bRegex))
\r
1756 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1760 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
1762 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
1763 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
1770 void CGitLogListBase::StartFilter()
\r
1772 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1773 RecalculateShownList(&m_arShownList);
\r
1774 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1778 SetItemCountEx(ShownCountWithStopped());
\r
1779 RedrawItems(0, ShownCountWithStopped());
\r
1781 //ResizeAllListCtrlCols();
\r
1785 void CGitLogListBase::RemoveFilter()
\r
1788 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1790 m_arShownList.RemoveAll();
\r
1792 // reset the time filter too
\r
1794 m_timFrom = (__time64_t(m_tFrom));
\r
1795 m_timTo = (__time64_t(m_tTo));
\r
1796 m_DateFrom.SetTime(&m_timFrom);
\r
1797 m_DateTo.SetTime(&m_timTo);
\r
1798 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
1799 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
1802 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1804 m_arShownList.Add(&m_logEntries[i]);
\r
1806 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1808 SetItemCountEx(ShownCountWithStopped());
\r
1809 RedrawItems(0, ShownCountWithStopped());
\r
1811 ResizeAllListCtrlCols();
\r
1814 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1817 void CGitLogListBase::Clear()
\r
1819 m_arShownList.RemoveAll();
\r
1820 m_logEntries.clear();
\r
1821 m_logEntries.m_HashMap.clear();
\r
1823 m_logEntries.m_Lns.clear();
\r
1825 m_logEntries.m_FirstFreeLane=0;
\r
1826 m_logEntries.m_Lns.clear();
\r