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 "TortoiseProc.h"
\r
13 #include "GitLogList.h"
\r
15 //#include "VssStyle.h"
\r
16 #include "IconMenu.h"
\r
19 #include "InputDlg.h"
\r
20 #include "PropDlg.h"
\r
21 #include "SVNProgressDlg.h"
\r
22 #include "ProgressDlg.h"
\r
23 //#include "RepositoryBrowser.h"
\r
24 //#include "CopyDlg.h"
\r
25 //#include "StatGraphDlg.h"
\r
27 #include "MessageBox.h"
\r
28 #include "Registry.h"
\r
29 #include "AppUtils.h"
\r
30 #include "PathUtils.h"
\r
31 #include "StringUtils.h"
\r
32 #include "UnicodeUtils.h"
\r
33 #include "TempFile.h"
\r
34 //#include "GitInfo.h"
\r
35 //#include "GitDiff.h"
\r
36 #include "IconMenu.h"
\r
37 //#include "RevisionRangeDlg.h"
\r
38 //#include "BrowseFolder.h"
\r
39 //#include "BlameDlg.h"
\r
40 //#include "Blame.h"
\r
41 //#include "GitHelpers.h"
\r
42 #include "GitStatus.h"
\r
43 //#include "LogDlgHelper.h"
\r
44 //#include "CachedLogInfo.h"
\r
45 //#include "RepositoryInfo.h"
\r
46 //#include "EditPropertiesDlg.h"
\r
47 #include "FileDiffDlg.h"
\r
52 IMPLEMENT_DYNAMIC(CGitLogList, CHintListCtrl)
\r
54 CGitLogList::CGitLogList():CHintListCtrl()
\r
55 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
57 ,m_bNoDispUpdates(FALSE)
\r
58 , m_bThreadRunning(FALSE)
\r
59 , m_bStrictStopped(false)
\r
60 , m_pStoreSelection(NULL)
\r
61 , m_nSelectedFilter(LOGFILTER_ALL)
\r
63 // use the default GUI font, create a copy of it and
\r
64 // change the copy to BOLD (leave the rest of the font
\r
66 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
68 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
69 lf.lfWeight = FW_BOLD;
\r
70 m_boldFont = CreateFontIndirect(&lf);
\r
72 m_wcRev.m_CommitHash=GIT_REV_ZERO;
\r
73 m_wcRev.m_Subject=_T("Working Copy");
\r
75 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
76 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
77 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
78 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
80 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
82 g_Git.GetMapHashToFriendName(m_HashMap);
\r
84 m_From=CTime(1970,1,2,0,0,0);
\r
85 m_To=CTime::GetCurrentTime();
\r
88 CGitLogList::~CGitLogList()
\r
90 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
92 DestroyIcon(m_hModifiedIcon);
\r
93 DestroyIcon(m_hReplacedIcon);
\r
94 DestroyIcon(m_hAddedIcon);
\r
95 DestroyIcon(m_hDeletedIcon);
\r
96 m_logEntries.ClearAll();
\r
99 DeleteObject(m_boldFont);
\r
101 if ( m_pStoreSelection )
\r
103 delete m_pStoreSelection;
\r
104 m_pStoreSelection = NULL;
\r
109 BEGIN_MESSAGE_MAP(CGitLogList, CHintListCtrl)
\r
110 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
111 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
112 ON_WM_CONTEXTMENU()
\r
113 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
114 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
118 int CGitLogList:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
120 PreSubclassWindow();
\r
121 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
124 void CGitLogList::PreSubclassWindow()
\r
126 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);
\r
127 // load the icons for the action columns
\r
128 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
129 CHintListCtrl::PreSubclassWindow();
\r
132 void CGitLogList::InsertGitColumn()
\r
136 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
140 temp.LoadString(IDS_LOG_GRAPH);
\r
142 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
145 // make the revision column right aligned
\r
147 Column.mask = LVCF_FMT;
\r
148 Column.fmt = LVCFMT_RIGHT;
\r
149 SetColumn(0, &Column);
\r
152 // g_Git.GetLog(log);
\r
154 temp.LoadString(IDS_LOG_ACTIONS);
\r
155 InsertColumn(this->LOGLIST_ACTION, temp);
\r
157 temp.LoadString(IDS_LOG_MESSAGE);
\r
158 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
160 temp.LoadString(IDS_LOG_AUTHOR);
\r
161 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
163 temp.LoadString(IDS_LOG_DATE);
\r
164 InsertColumn(this->LOGLIST_DATE, temp);
\r
167 if (m_bShowBugtraqColumn)
\r
169 // temp = m_ProjectProperties.sLabel;
\r
170 if (temp.IsEmpty())
\r
171 temp.LoadString(IDS_LOG_BUGIDS);
\r
172 InsertColumn(this->LOGLIST_BUG, temp);
\r
177 ResizeAllListCtrlCols();
\r
182 void CGitLogList::ResizeAllListCtrlCols()
\r
185 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
186 int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
187 int nItemCount = GetItemCount();
\r
188 TCHAR textbuf[MAX_PATH];
\r
189 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
192 for (int col = 0; col <= maxcol; col++)
\r
195 hdi.mask = HDI_TEXT;
\r
196 hdi.pszText = textbuf;
\r
197 hdi.cchTextMax = sizeof(textbuf);
\r
198 pHdrCtrl->GetItem(col, &hdi);
\r
199 int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
200 for (int index = 0; index<nItemCount; ++index)
\r
202 // get the width of the string and add 14 pixels for the column separator and margins
\r
203 int linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
204 if (index < m_arShownList.GetCount())
\r
206 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
207 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
209 // set the bold font and ask for the string width again
\r
210 SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
211 linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
212 // restore the system font
\r
213 SendMessage(WM_SETFONT, NULL, NULL);
\r
218 // add the image size
\r
219 CImageList * pImgList = GetImageList(LVSIL_SMALL);
\r
220 if ((pImgList)&&(pImgList->GetImageCount()))
\r
223 pImgList->GetImageInfo(0, &imginfo);
\r
224 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
225 linewidth += 3; // 3 pixels between icon and text
\r
228 if (cx < linewidth)
\r
231 // Adjust columns "Actions" containing icons
\r
232 if (col == this->LOGLIST_ACTION)
\r
234 if (cx < nMinimumWidth)
\r
236 cx = nMinimumWidth;
\r
240 if (col == this->LOGLIST_MESSAGE)
\r
242 if (cx > LOGLIST_MESSAGE_MAX)
\r
244 cx = LOGLIST_MESSAGE_MAX;
\r
246 if (cx < LOGLIST_MESSAGE_MIN)
\r
248 cx = LOGLIST_MESSAGE_MIN;
\r
252 // keep the bug id column small
\r
253 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
255 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
257 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
261 SetColumnWidth(col, cx);
\r
268 BOOL CGitLogList::GetShortName(CString ref, CString &shortname,CString prefix)
\r
270 if(ref.Left(prefix.GetLength()) == prefix)
\r
272 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
277 void CGitLogList::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
281 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
282 rItem.mask = LVIF_STATE;
\r
283 rItem.iItem = Index;
\r
284 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
287 if (m_Theme.IsAppThemed() && m_bVista)
\r
289 m_Theme.Open(m_hWnd, L"Explorer");
\r
290 int state = LISS_NORMAL;
\r
291 if (rItem.state & LVIS_SELECTED)
\r
293 if (::GetFocus() == m_hWnd)
\r
294 state |= LISS_SELECTED;
\r
296 state |= LISS_SELECTEDNOTFOCUS;
\r
301 if (pLogEntry->bCopiedSelf)
\r
303 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
304 // information at this drawing stage. But we can check the whether the
\r
305 // previous stage changed the background color of the item
\r
306 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
309 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
312 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
313 ::DeleteObject(brush);
\r
320 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
321 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
323 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
328 if (rItem.state & LVIS_SELECTED)
\r
330 if (::GetFocus() == m_hWnd)
\r
331 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
333 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
337 //if (pLogEntry->bCopiedSelf)
\r
338 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
340 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
345 ::FillRect(hdc, &rect, brush);
\r
346 ::DeleteObject(brush);
\r
351 void CGitLogList::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
353 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
356 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
357 rItem.mask = LVIF_STATE;
\r
358 rItem.iItem = index;
\r
359 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
362 for(int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
365 str=m_HashMap[data->m_CommitHash][i];
\r
370 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
372 brush = ::CreateSolidBrush(RGB(0xff, 0, 0));
\r
373 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
375 brush = ::CreateSolidBrush(RGB(0xff, 0xff, 0));
\r
377 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
379 brush = ::CreateSolidBrush(RGB(0, 0, 0xff));
\r
382 if(!shortname.IsEmpty())
\r
385 memset(&size,0,sizeof(SIZE));
\r
386 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
388 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
390 ::FillRect(hdc, &rt, brush);
\r
391 if (rItem.state & LVIS_SELECTED)
\r
393 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
394 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
395 ::SetTextColor(hdc,clrOld);
\r
398 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
402 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
403 ::LineTo(hdc,rt.right,rt.top);
\r
404 ::LineTo(hdc,rt.right,rt.bottom);
\r
405 ::LineTo(hdc,rt.left,rt.bottom);
\r
406 ::LineTo(hdc,rt.left,rt.top);
\r
408 rt.left=rt.right+3;
\r
411 ::DeleteObject(brush);
\r
413 rt.right=rect.right;
\r
415 if (rItem.state & LVIS_SELECTED)
\r
417 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
418 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
419 ::SetTextColor(hdc,clrOld);
\r
422 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
427 void CGitLogList::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
428 const COLORREF& col,int top
\r
431 int h = laneHeight / 2;
\r
432 int m = (x1 + x2) / 2;
\r
433 int r = (x2 - x1) / 3;
\r
436 #define P_CENTER m , h+top
\r
437 #define P_0 x2, h+top
\r
438 #define P_90 m , 0+top
\r
439 #define P_180 x1, h+top
\r
440 #define P_270 m , 2 * h+top
\r
441 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
443 //static QPen myPen(Qt::black, 2); // fast path here
\r
445 pen.CreatePen(PS_SOLID,2,col);
\r
446 //myPen.setColor(col);
\r
447 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
449 //p->setPen(myPen);
\r
453 case Lanes::ACTIVE:
\r
454 case Lanes::NOT_ACTIVE:
\r
455 case Lanes::MERGE_FORK:
\r
456 case Lanes::MERGE_FORK_R:
\r
457 case Lanes::MERGE_FORK_L:
\r
459 case Lanes::JOIN_R:
\r
460 case Lanes::JOIN_L:
\r
461 DrawLine(hdc,P_90,P_270);
\r
462 //p->drawLine(P_90, P_270);
\r
465 case Lanes::HEAD_R:
\r
466 case Lanes::HEAD_L:
\r
467 case Lanes::BRANCH:
\r
468 DrawLine(hdc,P_CENTER,P_270);
\r
469 //p->drawLine(P_CENTER, P_270);
\r
472 case Lanes::TAIL_R:
\r
473 case Lanes::TAIL_L:
\r
474 case Lanes::INITIAL:
\r
475 case Lanes::BOUNDARY:
\r
476 case Lanes::BOUNDARY_C:
\r
477 case Lanes::BOUNDARY_R:
\r
478 case Lanes::BOUNDARY_L:
\r
479 DrawLine(hdc,P_90, P_CENTER);
\r
480 //p->drawLine(P_90, P_CENTER);
\r
488 case Lanes::MERGE_FORK:
\r
493 case Lanes::CROSS_EMPTY:
\r
494 case Lanes::BOUNDARY_C:
\r
495 DrawLine(hdc,P_180,P_0);
\r
496 //p->drawLine(P_180, P_0);
\r
498 case Lanes::MERGE_FORK_R:
\r
499 case Lanes::JOIN_R:
\r
500 case Lanes::HEAD_R:
\r
501 case Lanes::TAIL_R:
\r
502 case Lanes::BOUNDARY_R:
\r
503 DrawLine(hdc,P_180,P_CENTER);
\r
504 //p->drawLine(P_180, P_CENTER);
\r
506 case Lanes::MERGE_FORK_L:
\r
507 case Lanes::JOIN_L:
\r
508 case Lanes::HEAD_L:
\r
509 case Lanes::TAIL_L:
\r
510 case Lanes::BOUNDARY_L:
\r
511 DrawLine(hdc,P_CENTER,P_0);
\r
512 //p->drawLine(P_CENTER, P_0);
\r
519 brush.CreateSolidBrush(col);
\r
520 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
521 // center symbol, e.g. rect or ellipse
\r
523 case Lanes::ACTIVE:
\r
524 case Lanes::INITIAL:
\r
525 case Lanes::BRANCH:
\r
527 //p->setPen(Qt::NoPen);
\r
528 //p->setBrush(col);
\r
529 ::Ellipse(hdc, R_CENTER);
\r
530 //p->drawEllipse(R_CENTER);
\r
532 case Lanes::MERGE_FORK:
\r
533 case Lanes::MERGE_FORK_R:
\r
534 case Lanes::MERGE_FORK_L:
\r
535 //p->setPen(Qt::NoPen);
\r
536 //p->setBrush(col);
\r
537 //p->drawRect(R_CENTER);
\r
538 Rectangle(hdc,R_CENTER);
\r
540 case Lanes::UNAPPLIED:
\r
542 //p->setPen(Qt::NoPen);
\r
543 //p->setBrush(Qt::red);
\r
544 //p->drawRect(m - r, h - 1, d, 2);
\r
545 ::Rectangle(hdc,m-r,h-1,d,2);
\r
547 case Lanes::APPLIED:
\r
549 //p->setPen(Qt::NoPen);
\r
550 //p->setBrush(DARK_GREEN);
\r
551 //p->drawRect(m - r, h - 1, d, 2);
\r
552 //p->drawRect(m - 1, h - r, 2, d);
\r
553 ::Rectangle(hdc,m-r,h-1,d,2);
\r
554 ::Rectangle(hdc,m-1,h-r,2,d);
\r
556 case Lanes::BOUNDARY:
\r
557 //p->setBrush(back);
\r
558 //p->drawEllipse(R_CENTER);
\r
559 ::Ellipse(hdc, R_CENTER);
\r
561 case Lanes::BOUNDARY_C:
\r
562 case Lanes::BOUNDARY_R:
\r
563 case Lanes::BOUNDARY_L:
\r
564 //p->setBrush(back);
\r
565 //p->drawRect(R_CENTER);
\r
566 ::Rectangle(hdc,R_CENTER);
\r
572 ::SelectObject(hdc,oldpen);
\r
573 ::SelectObject(hdc,oldbrush);
\r
582 void CGitLogList::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
586 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
589 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
590 rItem.mask = LVIF_STATE;
\r
591 rItem.iItem = index;
\r
592 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
595 static const COLORREF colors[Lanes::COLORS_NUM] = { RGB(0,0,0), RGB(0xFF,0,0), RGB(0,0x1F,0),
\r
596 RGB(0,0,0xFF), RGB(128,128,128), RGB(128,128,0),
\r
597 RGB(0,128,128), RGB(128,0,128) };
\r
600 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
604 if (data->m_Lanes.size() == 0)
\r
605 m_logEntries.setLane(data->m_CommitHash);
\r
607 std::vector<int>& lanes=data->m_Lanes;
\r
608 UINT laneNum = lanes.size();
\r
609 UINT mergeLane = 0;
\r
610 for (UINT i = 0; i < laneNum; i++)
\r
611 if (Lanes::isMerge(lanes[i])) {
\r
616 int x1 = 0, x2 = 0;
\r
617 int maxWidth = rect.Width();
\r
618 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
619 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
625 if (ln == Lanes::EMPTY)
\r
628 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
629 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
631 if (ln == Lanes::CROSS) {
\r
632 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
633 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, colors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
635 paintGraphLane(hdc, rect.Height(),ln, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
638 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
641 void CGitLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
644 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
645 // Take the default processing unless we set this to something else below.
\r
646 *pResult = CDRF_DODEFAULT;
\r
648 if (m_bNoDispUpdates)
\r
653 switch (pLVCD->nmcd.dwDrawStage)
\r
655 case CDDS_PREPAINT:
\r
657 *pResult = CDRF_NOTIFYITEMDRAW;
\r
661 case CDDS_ITEMPREPAINT:
\r
663 // This is the prepaint stage for an item. Here's where we set the
\r
664 // item's text color.
\r
666 // Tell Windows to send draw notifications for each subitem.
\r
667 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
669 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
671 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
673 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
677 if (data->bCopiedSelf)
\r
679 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
680 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
681 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
685 crText = m_Colors.GetColor(CColors::Modified);
\r
687 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
688 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
689 // if (data->Rev == m_wcRev)
\r
691 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
692 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
693 // tells the control to recalculate the extent of the text.
\r
694 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
698 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
700 if (m_bStrictStopped)
\r
701 crText = GetSysColor(COLOR_GRAYTEXT);
\r
703 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
704 pLVCD->clrText = crText;
\r
708 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
710 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
712 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
715 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
717 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
720 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
722 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
723 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
725 *pResult = CDRF_SKIPDEFAULT;
\r
731 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
733 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
735 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
736 if(!data->m_IsFull)
\r
738 if(data->SafeFetchFullInfo(&g_Git))
\r
739 this->Invalidate();
\r
740 TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
743 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
747 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
749 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
750 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
752 *pResult = CDRF_SKIPDEFAULT;
\r
759 if (pLVCD->iSubItem == 1)
\r
761 *pResult = CDRF_DODEFAULT;
\r
763 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
767 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
768 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
770 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
772 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
773 // Get the selected state of the
\r
774 // item being drawn.
\r
776 // Fill the background
\r
777 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
779 // Draw the icon(s) into the compatible DC
\r
780 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
781 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
784 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
785 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
788 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
789 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
792 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
793 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
795 *pResult = CDRF_SKIPDEFAULT;
\r
801 *pResult = CDRF_DODEFAULT;
\r
805 // CGitLogList message handlers
\r
807 void CGitLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
809 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
811 // Create a pointer to the item
\r
812 LV_ITEM* pItem = &(pDispInfo)->item;
\r
814 // Do the list need text information?
\r
815 if (!(pItem->mask & LVIF_TEXT))
\r
818 // By default, clear text buffer.
\r
819 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
821 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
824 if (m_bNoDispUpdates || bOutOfRange)
\r
827 // Which item number?
\r
828 int itemid = pItem->iItem;
\r
829 GitRev * pLogEntry = NULL;
\r
830 if (itemid < m_arShownList.GetCount())
\r
831 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
835 switch (pItem->iSubItem)
\r
837 case this->LOGLIST_GRAPH: //Graphic
\r
842 case this->LOGLIST_ACTION: //action -- no text in the column
\r
844 case this->LOGLIST_MESSAGE: //Message
\r
846 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
848 case this->LOGLIST_AUTHOR: //Author
\r
850 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
852 case this->LOGLIST_DATE: //Date
\r
854 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
865 void CGitLogList::OnContextMenu(CWnd* pWnd, CPoint point)
\r
868 int selIndex = GetSelectionMark();
\r
870 return; // nothing selected, nothing to do with a context menu
\r
872 // if the user selected the info text telling about not all revisions shown due to
\r
873 // the "stop on copy/rename" option, we also don't show the context menu
\r
874 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
877 // if the context menu is invoked through the keyboard, we have to use
\r
878 // a calculated position on where to anchor the menu on
\r
879 if ((point.x == -1) && (point.y == -1))
\r
882 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
883 ClientToScreen(&rect);
\r
884 point = rect.CenterPoint();
\r
886 m_nSearchIndex = selIndex;
\r
887 m_bCancelled = FALSE;
\r
889 // calculate some information the context menu commands can use
\r
890 // CString pathURL = GetURLFromPath(m_path);
\r
892 POSITION pos = GetFirstSelectedItemPosition();
\r
893 int indexNext = GetNextSelectedItem(pos);
\r
897 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
899 GitRev revSelected = pSelLogEntry->Rev;
\r
900 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
901 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
903 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
905 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
906 if (changedpath->lCopyFromRev)
\r
907 revPrevious = changedpath->lCopyFromRev;
\r
910 GitRev revSelected2;
\r
913 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
914 revSelected2 = pLogEntry->Rev;
\r
916 bool bAllFromTheSameAuthor = true;
\r
917 CString firstAuthor;
\r
918 CLogDataVector selEntries;
\r
919 GitRev revLowest, revHighest;
\r
920 GitRevRangeArray revisionRanges;
\r
922 POSITION pos = GetFirstSelectedItemPosition();
\r
923 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
924 revisionRanges.AddRevision(pLogEntry->Rev);
\r
925 selEntries.push_back(pLogEntry);
\r
926 firstAuthor = pLogEntry->sAuthor;
\r
927 revLowest = pLogEntry->Rev;
\r
928 revHighest = pLogEntry->Rev;
\r
931 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
932 revisionRanges.AddRevision(pLogEntry->Rev);
\r
933 selEntries.push_back(pLogEntry);
\r
934 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
935 bAllFromTheSameAuthor = false;
\r
936 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
937 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
943 int FirstSelect=-1, LastSelect=-1;
\r
944 pos = GetFirstSelectedItemPosition();
\r
945 FirstSelect = GetNextSelectedItem(pos);
\r
948 LastSelect = GetNextSelectedItem(pos);
\r
950 //entry is selected, now show the popup menu
\r
952 if (popup.CreatePopupMenu())
\r
954 if (GetSelectedCount() == 1)
\r
957 if (!m_path.IsDirectory())
\r
961 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
962 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
964 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
965 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
966 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
967 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
968 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
969 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
970 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
971 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
978 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
980 // TortoiseMerge could be improved to take a /blame switch
\r
981 // and then not 'cat' the files from a unified diff but
\r
983 // But until that's implemented, the context menu entry for
\r
984 // this feature is commented out.
\r
985 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
987 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
988 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
989 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
990 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
993 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
995 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
997 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
999 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1001 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1002 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1004 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1008 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1010 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1012 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1014 popup.AppendMenuIcon(ID_SWITCHTOREV, _T("Switch/Checkout to this") , IDI_SWITCH);
\r
1015 popup.AppendMenuIcon(ID_CREATE_BRANCH, _T("Create Branch at this version") , IDI_COPY);
\r
1016 popup.AppendMenuIcon(ID_CREATE_TAG, _T("Create Tag at this version"), IDI_COPY);
\r
1017 popup.AppendMenuIcon(ID_CHERRY_PICK, _T("Cherry Pick this version"), IDI_EXPORT);
\r
1018 popup.AppendMenuIcon(ID_EXPORT, _T("Export this version"), IDI_EXPORT);
\r
1021 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1023 else if (GetSelectedCount() >= 2)
\r
1025 bool bAddSeparator = false;
\r
1026 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1028 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1030 if (GetSelectedCount() == 2)
\r
1032 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1033 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1034 bAddSeparator = true;
\r
1038 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1040 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1041 bAddSeparator = true;
\r
1043 if (bAddSeparator)
\r
1044 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1047 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1049 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1051 // if (GetSelectedCount() == 1)
\r
1053 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1054 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1055 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1060 if (GetSelectedCount() == 1)
\r
1062 popup.AppendMenuIcon(ID_COPYHASH, _T("Copy Commit Hash"));
\r
1064 if (GetSelectedCount() != 0)
\r
1066 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1068 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1070 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1071 // DialogEnableWindow(IDOK, FALSE);
\r
1072 // SetPromptApp(&theApp);
\r
1073 theApp.DoWaitCursor(1);
\r
1074 bool bOpenWith = false;
\r
1080 CString tempfile=GetTempFile();
\r
1082 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
1083 cmd.Format(_T("git.exe diff-tree -r -p --stat %s"),r1->m_CommitHash);
\r
1084 g_Git.RunLogFile(cmd,tempfile);
\r
1085 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r1->m_Subject);
\r
1091 CString tempfile=GetTempFile();
\r
1093 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
1094 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1095 cmd.Format(_T("git.exe diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash);
\r
1096 g_Git.RunLogFile(cmd,tempfile);
\r
1097 CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r2->m_CommitHash.Left(6));
\r
1102 case ID_COMPARETWO:
\r
1104 GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));
\r
1105 GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1107 dlg.SetDiff(NULL,*r1,*r2);
\r
1116 GitRev * r1 = &m_wcRev;
\r
1117 GitRev * r2 = pSelLogEntry;
\r
1119 dlg.SetDiff(NULL,*r1,*r2);
\r
1122 //user clicked on the menu item "compare with working copy"
\r
1123 //if (PromptShown())
\r
1125 // GitDiff diff(this, m_hWnd, true);
\r
1126 // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1127 // diff.SetHEADPeg(m_LogRevision);
\r
1128 // diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected);
\r
1131 // CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1135 case ID_COMPAREWITHPREVIOUS:
\r
1140 if(pSelLogEntry->m_ParentHash.size()>0)
\r
1141 //if(m_logEntries.m_HashMap[pSelLogEntry->m_ParentHash[0]]>=0)
\r
1143 dlg.SetDiff(NULL,pSelLogEntry->m_CommitHash,pSelLogEntry->m_ParentHash[0]);
\r
1147 CMessageBox::Show(NULL,_T("No previous version"),_T("TortoiseGit"),MB_OK);
\r
1149 //if (PromptShown())
\r
1151 // GitDiff diff(this, m_hWnd, true);
\r
1152 // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1153 // diff.SetHEADPeg(m_LogRevision);
\r
1154 // diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected);
\r
1157 // CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1160 case ID_COPYCLIPBOARD:
\r
1162 CopySelectionToClipBoard();
\r
1167 CopySelectionToClipBoard(TRUE);
\r
1171 CAppUtils::Export(&pSelLogEntry->m_CommitHash);
\r
1173 case ID_CREATE_BRANCH:
\r
1174 CAppUtils::CreateBranchTag(FALSE,&pSelLogEntry->m_CommitHash);
\r
1175 m_HashMap.clear();
\r
1176 g_Git.GetMapHashToFriendName(m_HashMap);
\r
1179 case ID_CREATE_TAG:
\r
1180 CAppUtils::CreateBranchTag(TRUE,&pSelLogEntry->m_CommitHash);
\r
1181 m_HashMap.clear();
\r
1182 g_Git.GetMapHashToFriendName(m_HashMap);
\r
1185 case ID_SWITCHTOREV:
\r
1186 CAppUtils::Switch(&pSelLogEntry->m_CommitHash);
\r
1187 m_HashMap.clear();
\r
1188 g_Git.GetMapHashToFriendName(m_HashMap);
\r
1193 //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);
\r
1197 case ID_REVERTREV:
\r
1199 // we need an URL to complete this command, so error out if we can't get an URL
\r
1200 if (pathURL.IsEmpty())
\r
1202 CString strMessage;
\r
1203 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
1204 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
1205 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
1209 msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath());
\r
1210 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
1212 CGitProgressDlg dlg;
\r
1213 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
1214 dlg.SetPathList(CTGitPathList(m_path));
\r
1215 dlg.SetUrl(pathURL);
\r
1216 dlg.SetSecondUrl(pathURL);
\r
1217 revisionRanges.AdjustForMerge(true);
\r
1218 dlg.SetRevisionRanges(revisionRanges);
\r
1219 dlg.SetPegRevision(m_LogRevision);
\r
1226 // we need an URL to complete this command, so error out if we can't get an URL
\r
1227 if (pathURL.IsEmpty())
\r
1229 CString strMessage;
\r
1230 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
1231 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
1232 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
1236 CString path = m_path.GetWinPathString();
\r
1237 bool bGotSavePath = false;
\r
1238 if ((GetSelectedCount() == 1)&&(!m_path.IsDirectory()))
\r
1240 bGotSavePath = CAppUtils::FileOpenSave(path, NULL, IDS_LOG_MERGETO, IDS_COMMONFILEFILTER, true, GetSafeHwnd());
\r
1244 CBrowseFolder folderBrowser;
\r
1245 folderBrowser.SetInfo(CString(MAKEINTRESOURCE(IDS_LOG_MERGETO)));
\r
1246 bGotSavePath = (folderBrowser.Show(GetSafeHwnd(), path, path) == CBrowseFolder::OK);
\r
1250 CGitProgressDlg dlg;
\r
1251 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
1252 dlg.SetPathList(CTGitPathList(CTGitPath(path)));
\r
1253 dlg.SetUrl(pathURL);
\r
1254 dlg.SetSecondUrl(pathURL);
\r
1255 revisionRanges.AdjustForMerge(false);
\r
1256 dlg.SetRevisionRanges(revisionRanges);
\r
1257 dlg.SetPegRevision(m_LogRevision);
\r
1262 case ID_REVERTTOREV:
\r
1264 // we need an URL to complete this command, so error out if we can't get an URL
\r
1265 if (pathURL.IsEmpty())
\r
1267 CString strMessage;
\r
1268 strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString()));
\r
1269 CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR);
\r
1270 TRACE(_T("could not retrieve the URL of the folder!\n"));
\r
1275 msg.Format(IDS_LOG_REVERTTOREV_CONFIRM, m_path.GetWinPath());
\r
1276 if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
\r
1278 CGitProgressDlg dlg;
\r
1279 dlg.SetCommand(CGitProgressDlg::GitProgress_Merge);
\r
1280 dlg.SetPathList(CTGitPathList(m_path));
\r
1281 dlg.SetUrl(pathURL);
\r
1282 dlg.SetSecondUrl(pathURL);
\r
1283 GitRevRangeArray revarray;
\r
1284 revarray.AddRevRange(GitRev::REV_HEAD, revSelected);
\r
1285 dlg.SetRevisionRanges(revarray);
\r
1286 dlg.SetPegRevision(m_LogRevision);
\r
1294 case ID_BLAMECOMPARE:
\r
1296 //user clicked on the menu item "compare with working copy"
\r
1297 //now first get the revision which is selected
\r
1298 if (PromptShown())
\r
1300 GitDiff diff(this, this->m_hWnd, true);
\r
1301 diff.SetHEADPeg(m_LogRevision);
\r
1302 diff.ShowCompare(m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), false, true);
\r
1305 CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_BASE, m_path, revSelected, GitRev(), m_LogRevision, false, false, true);
\r
1310 //user clicked on the menu item "compare and blame revisions"
\r
1311 if (PromptShown())
\r
1313 GitDiff diff(this, this->m_hWnd, true);
\r
1314 diff.SetHEADPeg(m_LogRevision);
\r
1315 diff.ShowCompare(CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
1318 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revSelected2, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
1321 case ID_BLAMEWITHPREVIOUS:
\r
1323 //user clicked on the menu item "Compare and Blame with previous revision"
\r
1324 if (PromptShown())
\r
1326 GitDiff diff(this, this->m_hWnd, true);
\r
1327 diff.SetHEADPeg(m_LogRevision);
\r
1328 diff.ShowCompare(CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), false, true);
\r
1331 CAppUtils::StartShowCompare(m_hWnd, CTGitPath(pathURL), revPrevious, CTGitPath(pathURL), revSelected, GitRev(), m_LogRevision, false, false, true);
\r
1339 CProgressDlg progDlg;
\r
1340 progDlg.SetTitle(IDS_APPNAME);
\r
1341 progDlg.SetAnimation(IDR_DOWNLOAD);
\r
1342 CString sInfoLine;
\r
1343 sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, m_path.GetWinPath(), (LPCTSTR)revSelected.ToString());
\r
1344 progDlg.SetLine(1, sInfoLine, true);
\r
1345 SetAndClearProgressInfo(&progDlg);
\r
1346 progDlg.ShowModeless(m_hWnd);
\r
1347 CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, m_path, revSelected);
\r
1348 bool bSuccess = true;
\r
1349 if (!Cat(m_path, GitRev(GitRev::REV_HEAD), revSelected, tempfile))
\r
1352 // try again, but with the selected revision as the peg revision
\r
1353 if (!Cat(m_path, revSelected, revSelected, tempfile))
\r
1356 SetAndClearProgressInfo((HWND)NULL);
\r
1357 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1366 SetAndClearProgressInfo((HWND)NULL);
\r
1367 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1370 ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1371 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
1373 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1374 cmd += tempfile.GetWinPathString() + _T(" ");
\r
1375 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1383 dlg.EndRev = revSelected;
\r
1384 if (dlg.DoModal() == IDOK)
\r
1389 tempfile = blame.BlameToTempFile(m_path, dlg.StartRev, dlg.EndRev, dlg.EndRev, logfile, _T(""), dlg.m_bIncludeMerge, TRUE, TRUE);
\r
1390 if (!tempfile.IsEmpty())
\r
1392 if (dlg.m_bTextView)
\r
1394 //open the default text editor for the result file
\r
1395 CAppUtils::StartTextViewer(tempfile);
\r
1399 CString sParams = _T("/path:\"") + m_path.GetGitPathString() + _T("\" ");
\r
1400 if(!CAppUtils::LaunchTortoiseBlame(tempfile, logfile, CPathUtils::GetFileNameFromPath(m_path.GetFileOrDirectoryName()),sParams))
\r
1408 CMessageBox::Show(this->m_hWnd, blame.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
1416 CString url = _T("tgit:")+pathURL;
\r
1417 sCmd.Format(_T("%s /command:update /path:\"%s\" /rev:%ld"),
\r
1418 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1419 (LPCTSTR)m_path.GetWinPath(), (LONG)revSelected);
\r
1420 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1423 case ID_FINDENTRY:
\r
1425 m_nSearchIndex = GetSelectionMark();
\r
1426 if (m_nSearchIndex < 0)
\r
1427 m_nSearchIndex = 0;
\r
1428 if (m_pFindDialog)
\r
1434 m_pFindDialog = new CFindReplaceDialog();
\r
1435 m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this);
\r
1439 case ID_REPOBROWSE:
\r
1442 sCmd.Format(_T("%s /command:repobrowser /path:\"%s\" /rev:%s"),
\r
1443 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1444 (LPCTSTR)pathURL, (LPCTSTR)revSelected.ToString());
\r
1446 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1451 EditLogMessage(selIndex);
\r
1454 case ID_EDITAUTHOR:
\r
1456 EditAuthor(selEntries);
\r
1461 CEditPropertiesDlg dlg;
\r
1462 dlg.SetProjectProperties(&m_ProjectProperties);
\r
1463 CTGitPathList escapedlist;
\r
1464 dlg.SetPathList(CTGitPathList(CTGitPath(pathURL)));
\r
1465 dlg.SetRevision(revSelected);
\r
1466 dlg.RevProps(true);
\r
1474 sCmd.Format(_T("%s /command:export /path:\"%s\" /revision:%ld"),
\r
1475 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1476 (LPCTSTR)pathURL, (LONG)revSelected);
\r
1477 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1483 CString url = _T("tgit:")+pathURL;
\r
1484 sCmd.Format(_T("%s /command:checkout /url:\"%s\" /revision:%ld"),
\r
1485 (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")),
\r
1486 (LPCTSTR)url, (LONG)revSelected);
\r
1487 CAppUtils::LaunchApplication(sCmd, NULL, false);
\r
1492 CString url = m_ProjectProperties.sWebViewerRev;
\r
1493 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1494 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1495 if (!url.IsEmpty())
\r
1496 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1499 case ID_VIEWPATHREV:
\r
1501 CString relurl = pathURL;
\r
1502 CString sRoot = GetRepositoryRoot(CTGitPath(relurl));
\r
1503 relurl = relurl.Mid(sRoot.GetLength());
\r
1504 CString url = m_ProjectProperties.sWebViewerPathRev;
\r
1505 url = GetAbsoluteUrlFromRelativeUrl(url);
\r
1506 url.Replace(_T("%REVISION%"), revSelected.ToString());
\r
1507 url.Replace(_T("%PATH%"), relurl);
\r
1508 if (!url.IsEmpty())
\r
1509 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
\r
1515 theApp.DoWaitCursor(-1);
\r
1516 // EnableOKButton();
\r
1517 } // if (popup.CreatePopupMenu())
\r
1521 bool CGitLogList::IsSelectionContinuous()
\r
1523 if ( GetSelectedCount()==1 )
\r
1525 // if only one revision is selected, the selection is of course
\r
1530 POSITION pos = GetFirstSelectedItemPosition();
\r
1531 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1534 int itemindex = GetNextSelectedItem(pos);
\r
1537 int nextindex = GetNextSelectedItem(pos);
\r
1538 if (nextindex - itemindex > 1)
\r
1540 bContinuous = false;
\r
1543 itemindex = nextindex;
\r
1546 return bContinuous;
\r
1549 void CGitLogList::CopySelectionToClipBoard(bool HashOnly)
\r
1552 CString sClipdata;
\r
1553 POSITION pos = GetFirstSelectedItemPosition();
\r
1557 sRev.LoadString(IDS_LOG_REVISION);
\r
1559 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1561 sDate.LoadString(IDS_LOG_DATE);
\r
1563 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1566 CString sLogCopyText;
\r
1568 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1572 //pLogEntry->m_Files
\r
1573 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1575 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1577 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1578 sPaths += _T("\r\n");
\r
1581 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
1582 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1583 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1584 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),
\r
1585 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1587 sClipdata += sLogCopyText;
\r
1590 sClipdata += pLogEntry->m_CommitHash;
\r
1595 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1600 void CGitLogList::DiffSelectedRevWithPrevious()
\r
1603 if (m_bThreadRunning)
\r
1605 UpdateLogInfoLabel();
\r
1606 int selIndex = m_LogList.GetSelectionMark();
\r
1609 int selCount = m_LogList.GetSelectedCount();
\r
1610 if (selCount != 1)
\r
1613 // Find selected entry in the log list
\r
1614 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1615 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1616 long rev1 = pLogEntry->Rev;
\r
1617 long rev2 = rev1-1;
\r
1618 CTGitPath path = m_path;
\r
1620 // See how many files under the relative root were changed in selected revision
\r
1622 LogChangedPath * changed = NULL;
\r
1623 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1625 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1626 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1633 if (m_path.IsDirectory() && nChanged == 1)
\r
1635 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1636 // Do diff on that file instead of whole directory
\r
1637 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1640 m_bCancelled = FALSE;
\r
1641 DialogEnableWindow(IDOK, FALSE);
\r
1642 SetPromptApp(&theApp);
\r
1643 theApp.DoWaitCursor(1);
\r
1645 if (PromptShown())
\r
1647 GitDiff diff(this, m_hWnd, true);
\r
1648 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1649 diff.SetHEADPeg(m_LogRevision);
\r
1650 diff.ShowCompare(path, rev2, path, rev1);
\r
1654 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1657 theApp.DoWaitCursor(-1);
\r
1662 void CGitLogList::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1664 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1667 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1669 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1671 if (pFindInfo->lvfi.psz == 0)
\r
1674 CString sCmp = pFindInfo->lvfi.psz;
\r
1676 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1678 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1679 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1680 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1682 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1690 if (sCmp.Compare(sRev)==0)
\r
1697 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1699 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1701 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1702 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1703 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1705 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1713 if (sCmp.Compare(sRev)==0)
\r
1725 int CGitLogList::FillGitShortLog()
\r
1729 this->m_logEntries.ClearAll();
\r
1730 this->m_logEntries.ParserShortLog();
\r
1732 //this->m_logEntries.ParserFromLog();
\r
1733 SetItemCountEx(this->m_logEntries.size());
\r
1735 this->m_arShownList.RemoveAll();
\r
1737 for(int i=0;i<m_logEntries.size();i++)
\r
1738 this->m_arShownList.Add(&m_logEntries[i]);
\r
1743 BOOL CGitLogList::PreTranslateMessage(MSG* pMsg)
\r
1745 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1746 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1747 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1749 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1751 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1753 DiffSelectedRevWithPrevious();
\r
1758 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1760 DiffSelectedFile();
\r
1767 if (m_hAccel && !bSkipAccelerator)
\r
1769 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1775 //m_tooltips.RelayEvent(pMsg);
\r
1776 return __super::PreTranslateMessage(pMsg);
\r
1779 void CGitLogList::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1781 // a double click on an entry in the revision list has happened
\r
1784 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1785 DiffSelectedRevWithPrevious();
\r
1788 int CGitLogList::FetchLogAsync(CALLBACK_PROCESS *proc,void * data)
\r
1790 m_ProcCallBack=proc;
\r
1793 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1794 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1795 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1797 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1798 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1799 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1805 //this is the thread function which calls the subversion function
\r
1806 UINT CGitLogList::LogThreadEntry(LPVOID pVoid)
\r
1808 return ((CGitLogList*)pVoid)->LogThread();
\r
1811 void CGitLogList::GetTimeRange(CTime &oldest, CTime &latest)
\r
1814 oldest=CTime::GetCurrentTime();
\r
1815 latest=CTime(1971,1,2,0,0,0);
\r
1816 for(int i=0;i<m_logEntries.size();i++)
\r
1818 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1819 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1821 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1822 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1827 UINT CGitLogList::LogThread()
\r
1830 if(m_ProcCallBack)
\r
1831 m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1833 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1834 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1836 //does the user force the cache to refresh (shift or control key down)?
\r
1837 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1838 || (GetKeyState (VK_SHIFT) < 0);
\r
1840 //disable the "Get All" button while we're receiving
\r
1844 temp.LoadString(IDS_PROGRESSWAIT);
\r
1845 ShowText(temp, true);
\r
1847 FillGitShortLog();
\r
1851 RedrawItems(0, m_arShownList.GetCount());
\r
1853 ResizeAllListCtrlCols();
\r
1856 if ( m_pStoreSelection )
\r
1858 // Deleting the instance will restore the
\r
1859 // selection of the CLogDlg.
\r
1860 delete m_pStoreSelection;
\r
1861 m_pStoreSelection = NULL;
\r
1865 // If no selection has been set then this must be the first time
\r
1866 // the revisions are shown. Let's preselect the topmost revision.
\r
1867 if ( GetItemCount()>0 )
\r
1869 SetSelectionMark(0);
\r
1870 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1873 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1880 for(int i=0;i<m_logEntries.size();i++)
\r
1882 if(!m_logEntries.FetchFullInfo(i))
\r
1887 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1888 if(percent == GITLOG_END)
\r
1889 percent == GITLOG_END -1;
\r
1891 if(m_ProcCallBack)
\r
1892 m_ProcCallBack(m_ProcData,percent);
\r
1894 if(updated==m_logEntries.size())
\r
1898 //RefreshCursor();
\r
1899 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1900 // the log messages
\r
1904 if(m_ProcCallBack)
\r
1905 m_ProcCallBack(m_ProcData,GITLOG_END);
\r
1907 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1912 void CGitLogList::Refresh()
\r
1914 if(!m_bThreadRunning)
\r
1916 this->SetItemCountEx(0);
\r
1917 m_logEntries.clear();
\r
1918 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1919 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1920 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1922 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1923 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1924 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1926 m_sFilterText.Empty();
\r
1927 m_From=CTime(1970,1,2,0,0,0);
\r
1928 m_To=CTime::GetCurrentTime();
\r
1931 bool CGitLogList::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1935 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1937 type |= tr1::regex_constants::icase;
\r
1938 pat = tr1::wregex(regexp_str, type);
\r
1941 catch (exception) {}
\r
1945 void CGitLogList::RecalculateShownList(CPtrArray * pShownlist)
\r
1948 pShownlist->RemoveAll();
\r
1949 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1950 bool bRegex = false;
\r
1951 if (m_bFilterWithRegex)
\r
1952 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1954 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1956 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1958 if ((bRegex)&&(m_bFilterWithRegex))
\r
1961 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1963 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1964 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1966 pShownlist->Add(m_logEntries[i]);
\r
1971 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1973 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1974 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1976 pShownlist->Add(&m_logEntries[i]);
\r
1980 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1981 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1983 pShownlist->Add(&m_logEntries[i]);
\r
1988 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1990 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1992 bool bGoing = true;
\r
1993 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1995 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1996 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1998 pShownlist->Add(m_logEntries[i]);
\r
2002 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
2004 pShownlist->Add(m_logEntries[i]);
\r
2008 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
2010 pShownlist->Add(m_logEntries[i]);
\r
2019 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2021 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
2023 pShownlist->Add(&m_logEntries[i]);
\r
2027 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2029 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
2030 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
2032 pShownlist->Add(&m_logEntries[i]);
\r
2039 CString find = m_sFilterText;
\r
2042 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
2044 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
2046 sBugIDs = sBugIDs.MakeLower();
\r
2047 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2049 pShownlist->Add(m_logEntries[i]);
\r
2054 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
2056 CString msg = m_logEntries[i].m_Subject;
\r
2058 msg = msg.MakeLower();
\r
2059 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2061 pShownlist->Add(&m_logEntries[i]);
\r
2064 msg = m_logEntries[i].m_Body;
\r
2066 msg = msg.MakeLower();
\r
2067 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2069 pShownlist->Add(&m_logEntries[i]);
\r
2074 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
2076 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
2078 bool bGoing = true;
\r
2079 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
2081 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
2082 CString path = cpath->sCopyFromPath;
\r
2084 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2086 pShownlist->Add(m_logEntries[i]);
\r
2090 path = cpath->sPath;
\r
2092 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2094 pShownlist->Add(m_logEntries[i]);
\r
2098 path = cpath->GetAction();
\r
2100 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2102 pShownlist->Add(m_logEntries[i]);
\r
2109 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2111 CString msg = m_logEntries[i].m_AuthorName;
\r
2112 msg = msg.MakeLower();
\r
2113 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2115 pShownlist->Add(&m_logEntries[i]);
\r
2119 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2121 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
2122 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2124 pShownlist->Add(&m_logEntries[i]);
\r
2128 } // else (from if (bRegex))
\r
2129 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2133 BOOL CGitLogList::IsEntryInDateRange(int i)
\r
2135 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2136 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2143 void CGitLogList::StartFilter()
\r
2145 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2146 RecalculateShownList(&m_arShownList);
\r
2147 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2151 SetItemCountEx(ShownCountWithStopped());
\r
2152 RedrawItems(0, ShownCountWithStopped());
\r
2154 //ResizeAllListCtrlCols();
\r
2158 void CGitLogList::RemoveFilter()
\r
2161 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2163 m_arShownList.RemoveAll();
\r
2165 // reset the time filter too
\r
2167 m_timFrom = (__time64_t(m_tFrom));
\r
2168 m_timTo = (__time64_t(m_tTo));
\r
2169 m_DateFrom.SetTime(&m_timFrom);
\r
2170 m_DateTo.SetTime(&m_timTo);
\r
2171 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2172 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2175 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2177 m_arShownList.Add(&m_logEntries[i]);
\r
2179 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2181 SetItemCountEx(ShownCountWithStopped());
\r
2182 RedrawItems(0, ShownCountWithStopped());
\r
2184 ResizeAllListCtrlCols();
\r
2187 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r