1 // GitLogList.cpp : implementation file
4 Description: qgit revision list view
6 Author: Marco Costalba (C) 2005-2007
8 Copyright: See COPYING file that comes with this distribution
12 #include "GitLogListBase.h"
14 //#include "VssStyle.h"
20 #include "SVNProgressDlg.h"
21 #include "ProgressDlg.h"
22 //#include "RepositoryBrowser.h"
23 //#include "CopyDlg.h"
24 //#include "StatGraphDlg.h"
26 #include "MessageBox.h"
29 #include "PathUtils.h"
30 #include "StringUtils.h"
31 #include "UnicodeUtils.h"
33 //#include "GitInfo.h"
34 //#include "GitDiff.h"
36 //#include "RevisionRangeDlg.h"
37 //#include "BrowseFolder.h"
38 //#include "BlameDlg.h"
40 //#include "GitHelpers.h"
41 #include "GitStatus.h"
42 //#include "LogDlgHelper.h"
43 //#include "CachedLogInfo.h"
44 //#include "RepositoryInfo.h"
45 //#include "EditPropertiesDlg.h"
46 #include "FileDiffDlg.h"
47 #include "..\\TortoiseShell\\Resource.h"
49 const UINT
CGitLogListBase::m_FindDialogMessage
= RegisterWindowMessage(FINDMSGSTRING
);
51 IMPLEMENT_DYNAMIC(CGitLogListBase
, CHintListCtrl
)
53 CGitLogListBase::CGitLogListBase():CHintListCtrl()
54 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
56 ,m_bNoDispUpdates(FALSE
)
57 , m_bThreadRunning(FALSE
)
58 , m_bStrictStopped(false)
59 , m_pStoreSelection(NULL
)
60 , m_nSelectedFilter(LOGFILTER_ALL
)
63 , m_logEntries(&m_LogCache
)
66 // use the default GUI font, create a copy of it and
67 // change the copy to BOLD (leave the rest of the font
69 HFONT hFont
= (HFONT
)GetStockObject(DEFAULT_GUI_FONT
);
71 GetObject(hFont
, sizeof(LOGFONT
), &lf
);
72 lf
.lfWeight
= FW_BOLD
;
73 m_boldFont
= CreateFontIndirect(&lf
);
75 m_bShowBugtraqColumn
=0;
77 m_IsIDReplaceAction
=FALSE
;
79 this->m_critSec
.Init();
80 m_wcRev
.m_CommitHash
.Empty();
81 m_wcRev
.m_Subject
=_T("Working dir changes");
82 m_wcRev
.m_ParentHash
.clear();
83 m_wcRev
.m_Mark
=_T('-');
84 m_wcRev
.m_IsUpdateing
=FALSE
;
85 m_wcRev
.m_IsFull
= TRUE
;
87 m_hModifiedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
88 m_hReplacedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
89 m_hAddedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
90 m_hDeletedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
92 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
94 g_Git
.GetMapHashToFriendName(m_HashMap
);
95 m_CurrentBranch
=g_Git
.GetCurrentBranch();
96 this->m_HeadHash
=g_Git
.GetHash(CString(_T("HEAD"))).Left(40);
98 m_From
=CTime(1970,1,2,0,0,0);
99 m_To
=CTime::GetCurrentTime();
101 m_LoadingThread
= NULL
;
103 InterlockedExchange(&m_bExitThread
,FALSE
);
104 m_IsOldFirst
= FALSE
;
105 m_IsRebaseReplaceGraph
= FALSE
;
108 for(int i
=0;i
<Lanes::COLORS_NUM
;i
++)
110 m_LineColors
[i
] = m_Colors
.GetColor((CColors::Colors
)(CColors::BranchLine1
+i
));
112 // get short/long datetime setting from registry
113 DWORD RegUseShortDateFormat
= CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE
);
114 if ( RegUseShortDateFormat
)
116 m_DateFormat
= DATE_SHORTDATE
;
120 m_DateFormat
= DATE_LONGDATE
;
122 // get relative time display setting from registry
123 DWORD regRelativeTimes
= CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE
);
124 m_bRelativeTimes
= (regRelativeTimes
!= 0);
125 m_ContextMenuMask
= 0xFFFFFFFFFFFFFFFF;
127 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_PICK
);
128 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SQUASH
);
129 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_EDIT
);
130 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SKIP
);
133 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
134 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
135 GetVersionEx((OSVERSIONINFO
*)&inf
);
136 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
137 m_bVista
= (fullver
>= 0x0600);
139 m_ColumnRegKey
=_T("log");
142 CGitLogListBase::~CGitLogListBase()
144 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
146 DestroyIcon(m_hModifiedIcon
);
147 DestroyIcon(m_hReplacedIcon
);
148 DestroyIcon(m_hAddedIcon
);
149 DestroyIcon(m_hDeletedIcon
);
150 m_logEntries
.ClearAll();
153 DeleteObject(m_boldFont
);
155 if ( m_pStoreSelection
)
157 delete m_pStoreSelection
;
158 m_pStoreSelection
= NULL
;
161 SafeTerminateThread();
165 BEGIN_MESSAGE_MAP(CGitLogListBase
, CHintListCtrl
)
166 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
167 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, OnNMCustomdrawLoglist
)
168 ON_NOTIFY_REFLECT(LVN_GETDISPINFO
, OnLvnGetdispinfoLoglist
)
170 ON_NOTIFY_REFLECT(NM_DBLCLK
, OnNMDblclkLoglist
)
171 ON_NOTIFY_REFLECT(LVN_ODFINDITEM
,OnLvnOdfinditemLoglist
)
174 ON_MESSAGE(MSG_LOADED
,OnLoad
)
176 ON_WM_MEASUREITEM_REFLECT()
179 void CGitLogListBase::OnMeasureItem(int nIDCtl
, LPMEASUREITEMSTRUCT lpMeasureItemStruct
)
181 // TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
183 CListCtrl::OnMeasureItem(nIDCtl
, lpMeasureItemStruct
);
186 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct
)
188 //if (m_nRowHeight>0)
190 lpMeasureItemStruct
->itemHeight
= 50;
194 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct
)
197 return CHintListCtrl::OnCreate(lpCreateStruct
);
200 void CGitLogListBase::PreSubclassWindow()
202 SetExtendedStyle(LVS_EX_FULLROWSELECT
| LVS_EX_SUBITEMIMAGES
);
203 // load the icons for the action columns
204 // m_Theme.Open(m_hWnd, L"ListView");
205 m_Theme
.Open(m_hWnd
, L
"Explorer::ListView;ListView");
206 m_Theme
.SetWindowTheme(m_hWnd
, L
"Explorer", NULL
);
207 CHintListCtrl::PreSubclassWindow();
210 void CGitLogListBase::InsertGitColumn()
214 int c
= GetHeaderCtrl()->GetItemCount()-1;
218 temp
.LoadString(IDS_LOG_GRAPH
);
220 if(m_IsRebaseReplaceGraph
)
226 temp
.LoadString(IDS_LOG_GRAPH
);
228 InsertColumn(this->LOGLIST_GRAPH
, temp
);
231 // make the revision column right aligned
233 Column
.mask
= LVCF_FMT
;
234 Column
.fmt
= LVCFMT_RIGHT
;
235 SetColumn(0, &Column
);
238 // g_Git.GetLog(log);
240 if(m_IsIDReplaceAction
)
242 temp
.LoadString(IDS_LOG_ID
);
243 InsertColumn(this->LOGLIST_ACTION
, temp
);
247 temp
.LoadString(IDS_LOG_ACTIONS
);
248 InsertColumn(this->LOGLIST_ACTION
, temp
);
250 temp
.LoadString(IDS_LOG_MESSAGE
);
251 InsertColumn(this->LOGLIST_MESSAGE
, temp
);
253 temp
.LoadString(IDS_LOG_AUTHOR
);
254 InsertColumn(this->LOGLIST_AUTHOR
, temp
);
256 temp
.LoadString(IDS_LOG_DATE
);
257 InsertColumn(this->LOGLIST_DATE
, temp
);
260 if (m_bShowBugtraqColumn
)
262 // temp = m_ProjectProperties.sLabel;
264 temp
.LoadString(IDS_LOG_BUGIDS
);
265 InsertColumn(this->LOGLIST_BUG
, temp
);
270 ResizeAllListCtrlCols();
276 * Resizes all columns in a list control to values in registry.
278 void CGitLogListBase::ResizeAllListCtrlCols()
280 // column max and min widths to allow
281 static const int nMinimumWidth
= 10;
282 static const int nMaximumWidth
= 1000;
283 CHeaderCtrl
* pHdrCtrl
= (CHeaderCtrl
*)(GetDlgItem(0));
286 int numcols
= pHdrCtrl
->GetItemCount();
287 for (int col
= 0; col
< numcols
; col
++)
289 // get width for this col last time from registry
291 regentry
.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey
, col
);
292 CRegDWORD
regwidth(regentry
, 0);
296 // no saved value, setup sensible defaults
297 if (col
== this->LOGLIST_MESSAGE
)
299 cx
= LOGLIST_MESSAGE_MIN
;
303 cx
= ICONITEMBORDER
+16*4;
306 if (cx
< nMinimumWidth
)
309 } else if (cx
> nMaximumWidth
)
314 SetColumnWidth(col
, cx
);
321 BOOL
CGitLogListBase::GetShortName(CString ref
, CString
&shortname
,CString prefix
)
323 //TRACE(_T("%s %s\r\n"),ref,prefix);
324 if(ref
.Left(prefix
.GetLength()) == prefix
)
326 shortname
= ref
.Right(ref
.GetLength()-prefix
.GetLength());
327 if(shortname
.Right(3)==_T("^{}"))
328 shortname
=shortname
.Left(shortname
.GetLength()-3);
334 void CGitLogListBase::FillBackGround(HDC hdc
, int Index
,CRect
&rect
)
338 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
339 rItem
.mask
= LVIF_STATE
;
341 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
344 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.GetAt(Index
);
348 if (m_Theme
.IsAppThemed() && m_bVista
)
350 int state
= LISS_NORMAL
;
351 if (rItem
.state
& LVIS_SELECTED
)
353 if (::GetFocus() == m_hWnd
)
354 state
|= LISS_SELECTED
;
356 state
|= LISS_SELECTEDNOTFOCUS
;
360 if(pLogEntry
->m_Action
&CTGitPath::LOGACTIONS_REBASE_SQUASH
)
361 brush
= ::CreateSolidBrush(RGB(156,156,156));
362 else if(pLogEntry
->m_Action
&CTGitPath::LOGACTIONS_REBASE_EDIT
)
363 brush
= ::CreateSolidBrush(RGB(200,200,128));
368 ::FillRect(hdc
, &rect
, brush
);
369 ::DeleteObject(brush
);
373 if (m_Theme
.IsBackgroundPartiallyTransparent(LVP_LISTITEM
, state
))
374 m_Theme
.DrawParentBackground(m_hWnd
, hdc
, &rect
);
376 CRect rectDraw
= rect
;
377 if(rItem
.state
& LVIS_SELECTED
)
378 rectDraw
.InflateRect(1,0);
380 rectDraw
.InflateRect(1,1);
382 m_Theme
.DrawBackground(hdc
, LVP_LISTITEM
, state
, rectDraw
, &rect
);
388 if (rItem
.state
& LVIS_SELECTED
)
390 if (::GetFocus() == m_hWnd
)
391 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT
));
393 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE
));
397 //if (pLogEntry->bCopiedSelf)
398 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
400 if(pLogEntry
->m_Action
&CTGitPath::LOGACTIONS_REBASE_SQUASH
)
401 brush
= ::CreateSolidBrush(RGB(156,156,156));
402 else if(pLogEntry
->m_Action
&CTGitPath::LOGACTIONS_REBASE_EDIT
)
403 brush
= ::CreateSolidBrush(RGB(200,200,128));
405 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW
));
410 ::FillRect(hdc
, &rect
, brush
);
411 ::DeleteObject(brush
);
416 void CGitLogListBase::DrawTagBranch(HDC hdc
,CRect
&rect
,INT_PTR index
)
418 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(index
);
421 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
422 rItem
.mask
= LVIF_STATE
;
424 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
427 for(unsigned int i
=0;i
<m_HashMap
[data
->m_CommitHash
].size();i
++)
430 str
=m_HashMap
[data
->m_CommitHash
][i
];
437 //Determine label color
438 if(GetShortName(str
,shortname
,_T("refs/heads/")))
440 if( shortname
== m_CurrentBranch
)
441 colRef
= m_Colors
.GetColor(CColors::CurrentBranch
);
443 colRef
= m_Colors
.GetColor(CColors::LocalBranch
);
445 }else if(GetShortName(str
,shortname
,_T("refs/remotes/")))
447 colRef
= m_Colors
.GetColor(CColors::RemoteBranch
);
449 else if(GetShortName(str
,shortname
,_T("refs/tags/")))
451 colRef
= m_Colors
.GetColor(CColors::Tag
);
453 else if(GetShortName(str
,shortname
,_T("refs/stash")))
455 colRef
= m_Colors
.GetColor(CColors::Stash
);
456 shortname
=_T("stash");
459 //When row selected, ajust label color
460 if (!(m_Theme
.IsAppThemed() && m_bVista
))
461 if (rItem
.state
& LVIS_SELECTED
)
462 colRef
= CColors::MixColors(colRef
, ::GetSysColor(COLOR_HIGHLIGHT
), 150);
464 brush
= ::CreateSolidBrush(colRef
);
467 if(!shortname
.IsEmpty())
470 memset(&size
,0,sizeof(SIZE
));
471 GetTextExtentPoint32(hdc
, shortname
,shortname
.GetLength(),&size
);
473 rt
.SetRect(rt
.left
,rt
.top
,rt
.left
+size
.cx
,rt
.bottom
);
476 //Fill interior of ref label
477 ::FillRect(hdc
, &rt
, brush
);
485 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
,100), m_Colors
.Darken(colRef
,100));
486 rectEdge
.DeflateRect(1,1);
487 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
,50), m_Colors
.Darken(colRef
,50));
491 //Draw text inside label
492 if (m_Theme
.IsAppThemed() && m_bVista
)
494 int txtState
= LISS_NORMAL
;
495 if (rItem
.state
& LVIS_SELECTED
)
496 txtState
= LISS_SELECTED
;
498 m_Theme
.DrawText(hdc
, LVP_LISTITEM
, txtState
, shortname
, -1, DT_CENTER
| DT_SINGLELINE
| DT_VCENTER
, 0, &rt
);
502 if (rItem
.state
& LVIS_SELECTED
)
504 COLORREF clrNew
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
505 COLORREF clrOld
= ::SetTextColor(hdc
,clrNew
);
506 ::DrawText(hdc
,shortname
,shortname
.GetLength(),&rt
,DT_CENTER
| DT_SINGLELINE
| DT_VCENTER
);
507 ::SetTextColor(hdc
,clrOld
);
510 ::DrawText(hdc
,shortname
,shortname
.GetLength(),&rt
,DT_CENTER
| DT_SINGLELINE
| DT_VCENTER
);
515 //::MoveToEx(hdc,rt.left,rt.top,NULL);
516 //::LineTo(hdc,rt.right,rt.top);
517 //::LineTo(hdc,rt.right,rt.bottom);
518 //::LineTo(hdc,rt.left,rt.bottom);
519 //::LineTo(hdc,rt.left,rt.top);
525 ::DeleteObject(brush
);
529 if (m_Theme
.IsAppThemed() && m_bVista
)
531 int txtState
= LISS_NORMAL
;
532 if (rItem
.state
& LVIS_SELECTED
)
533 txtState
= LISS_SELECTED
;
535 m_Theme
.DrawText(hdc
, LVP_LISTITEM
, txtState
, data
->m_Subject
, -1, DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
, 0, &rt
);
539 if (rItem
.state
& LVIS_SELECTED
)
541 COLORREF clrOld
= ::SetTextColor(hdc
,::GetSysColor(COLOR_HIGHLIGHTTEXT
));
542 ::DrawText(hdc
,data
->m_Subject
,data
->m_Subject
.GetLength(),&rt
,DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
);
543 ::SetTextColor(hdc
,clrOld
);
546 ::DrawText(hdc
,data
->m_Subject
,data
->m_Subject
.GetLength(),&rt
,DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
);
551 static COLORREF
blend(const COLORREF
& col1
, const COLORREF
& col2
, int amount
= 128) {
553 // Returns ((256 - amount)*col1 + amount*col2) / 256;
554 return RGB(((256 - amount
)*GetRValue(col1
) + amount
*GetRValue(col2
) ) / 256,
555 ((256 - amount
)*GetGValue(col1
) + amount
*GetGValue(col2
) ) / 256,
556 ((256 - amount
)*GetBValue(col1
) + amount
*GetBValue(col2
) ) / 256);
559 Gdiplus::Color
GetGdiColor(COLORREF col
)
561 return Gdiplus::Color(GetRValue(col
),GetGValue(col
),GetBValue(col
));
563 void CGitLogListBase::paintGraphLane(HDC hdc
, int laneHeight
,int type
, int x1
, int x2
,
564 const COLORREF
& col
,const COLORREF
& activeColor
, int top
567 int h
= laneHeight
/ 2;
568 int m
= (x1
+ x2
) / 2;
569 int r
= (x2
- x1
) / 3;
572 #define P_CENTER m , h+top
573 #define P_0 x2, h+top
574 #define P_90 m , 0+top
575 #define P_180 x1, h+top
576 #define P_270 m , 2 * h+top
577 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
580 #define DELTA_UR_B 2*(x1 - m), 2*h +top
581 #define DELTA_UR_E 0*16, 90*16 +top // -,
583 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
584 #define DELTA_DR_E 270*16, 90*16 +top // -'
586 #define DELTA_UL_B 2*(x2 - m), 2*h +top
587 #define DELTA_UL_E 90*16, 90*16 +top // ,-
589 #define DELTA_DL_B 2*(x2 - m),2*-h +top
590 #define DELTA_DL_E 180*16, 90*16 // '-
592 #define CENTER_UR x1, 2*h, 225
593 #define CENTER_DR x1, 0 , 135
594 #define CENTER_UL x2, 2*h, 315
595 #define CENTER_DL x2, 0 , 45
598 Gdiplus::Graphics
graphics( hdc
);
600 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias
);
609 Gdiplus::LinearGradientBrush
gradient(
610 Gdiplus::Point(x1
-2, h
+top
-2),
611 Gdiplus::Point(P_270
),
612 GetGdiColor(activeColor
),GetGdiColor(col
));
615 Gdiplus::Pen
mypen(&gradient
,2);
616 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
618 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
619 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
+h
-1, x2
-x1
,laneHeight
,270,90);
620 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
627 Gdiplus::Pen
mypen(Gdiplus::Color(0,0,0),2);
630 graphics
.DrawArc(&mypen
,x1
,top
+h
, x2
-x1
,laneHeight
,270,90);
638 Gdiplus::LinearGradientBrush
gradient(
639 Gdiplus::Point(x1
-2, h
+top
-2),
640 Gdiplus::Point(P_90
),
641 GetGdiColor(activeColor
),GetGdiColor(col
));
644 Gdiplus::Pen
mypen(&gradient
,2);
646 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
-h
-1, x2
-x1
,laneHeight
,0,90);
650 QConicalGradient
gradient(CENTER_DR
);
651 gradient
.setColorAt(0.375, activeCol
);
652 gradient
.setColorAt(0.625, col
);
653 myPen
.setBrush(gradient
);
655 p
->drawArc(P_CENTER
, DELTA_DR
);
664 //static QPen myPen(Qt::black, 2); // fast path here
666 pen
.CreatePen(PS_SOLID
,2,col
);
667 //myPen.setColor(col);
668 HPEN oldpen
=(HPEN
)::SelectObject(hdc
,(HPEN
)pen
);
670 Gdiplus::Pen
myPen(GetGdiColor(col
),2);
672 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
679 case Lanes::NOT_ACTIVE
:
680 case Lanes::MERGE_FORK
:
681 case Lanes::MERGE_FORK_R
:
682 case Lanes::MERGE_FORK_L
:
687 //DrawLine(hdc,P_90,P_270);
688 graphics
.DrawLine(&myPen
,P_90
,P_270
);
689 //p->drawLine(P_90, P_270);
693 //DrawLine(hdc,P_CENTER,P_270);
694 graphics
.DrawLine(&myPen
,P_CENTER
,P_270
);
695 //p->drawLine(P_CENTER, P_270);
699 case Lanes::BOUNDARY
:
700 case Lanes::BOUNDARY_C
:
701 case Lanes::BOUNDARY_R
:
702 case Lanes::BOUNDARY_L
:
703 //DrawLine(hdc,P_90, P_CENTER);
704 graphics
.DrawLine(&myPen
,P_90
,P_CENTER
);
705 //p->drawLine(P_90, P_CENTER);
711 myPen
.SetColor(GetGdiColor(activeColor
));
715 case Lanes::MERGE_FORK
:
720 case Lanes::CROSS_EMPTY
:
721 case Lanes::BOUNDARY_C
:
722 //DrawLine(hdc,P_180,P_0);
723 graphics
.DrawLine(&myPen
,P_180
,P_0
);
724 //p->drawLine(P_180, P_0);
726 case Lanes::MERGE_FORK_R
:
727 case Lanes::BOUNDARY_R
:
728 //DrawLine(hdc,P_180,P_CENTER);
729 graphics
.DrawLine(&myPen
,P_180
,P_CENTER
);
730 //p->drawLine(P_180, P_CENTER);
732 case Lanes::MERGE_FORK_L
:
735 case Lanes::BOUNDARY_L
:
736 //DrawLine(hdc,P_CENTER,P_0);
737 graphics
.DrawLine(&myPen
,P_CENTER
,P_0
);
738 //p->drawLine(P_CENTER, P_0);
744 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias
);
747 brush
.CreateSolidBrush(col
);
748 HBRUSH oldbrush
=(HBRUSH
)::SelectObject(hdc
,(HBRUSH
)brush
);
749 // center symbol, e.g. rect or ellipse
755 //p->setPen(Qt::NoPen);
757 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias
);
758 ::Ellipse(hdc
, R_CENTER
);
759 //p->drawEllipse(R_CENTER);
761 case Lanes::MERGE_FORK
:
762 case Lanes::MERGE_FORK_R
:
763 case Lanes::MERGE_FORK_L
:
764 //p->setPen(Qt::NoPen);
766 //p->drawRect(R_CENTER);
767 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
768 Rectangle(hdc
,R_CENTER
);
770 case Lanes::UNAPPLIED
:
772 //p->setPen(Qt::NoPen);
773 //p->setBrush(Qt::red);
774 //p->drawRect(m - r, h - 1, d, 2);
775 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
776 ::Rectangle(hdc
,m
-r
,h
-1,d
,2);
780 //p->setPen(Qt::NoPen);
781 //p->setBrush(DARK_GREEN);
782 //p->drawRect(m - r, h - 1, d, 2);
783 //p->drawRect(m - 1, h - r, 2, d);
784 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
785 ::Rectangle(hdc
,m
-r
,h
-1,d
,2);
786 ::Rectangle(hdc
,m
-1,h
-r
,2,d
);
788 case Lanes::BOUNDARY
:
790 //p->drawEllipse(R_CENTER);
791 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias
);
792 ::Ellipse(hdc
, R_CENTER
);
794 case Lanes::BOUNDARY_C
:
795 case Lanes::BOUNDARY_R
:
796 case Lanes::BOUNDARY_L
:
798 //p->drawRect(R_CENTER);
799 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
800 ::Rectangle(hdc
,R_CENTER
);
806 ::SelectObject(hdc
,oldpen
);
807 ::SelectObject(hdc
,oldbrush
);
816 void CGitLogListBase::DrawGraph(HDC hdc
,CRect
&rect
,INT_PTR index
)
820 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(index
);
821 if(data
->m_CommitHash
.IsEmpty())
826 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
827 rItem
.mask
= LVIF_STATE
;
829 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
833 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
837 if (data
->m_Lanes
.size() == 0)
838 m_logEntries
.setLane(data
->m_CommitHash
);
840 std::vector
<int>& lanes
=data
->m_Lanes
;
841 UINT laneNum
= lanes
.size();
843 for (UINT i
= 0; i
< laneNum
; i
++)
844 if (Lanes::isMerge(lanes
[i
])) {
850 int maxWidth
= rect
.Width();
851 int lw
= 3 * rect
.Height() / 4; //laneWidth()
853 COLORREF activeColor
= m_LineColors
[activeLane
% Lanes::COLORS_NUM
];
854 //if (opt.state & QStyle::State_Selected)
855 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
858 for (unsigned int i
= 0; i
< laneNum
&& x2
< maxWidth
; i
++)
865 if (ln
== Lanes::EMPTY
)
868 COLORREF color
= i
== activeLane
? activeColor
: m_LineColors
[i
% Lanes::COLORS_NUM
];
869 paintGraphLane(hdc
, rect
.Height(),ln
, x1
+rect
.left
, x2
+rect
.left
, color
,activeColor
, rect
.top
);
873 for (UINT i
= 0; i
< laneNum
&& x2
< maxWidth
; i
++) {
879 if (ln
== Lanes::EMPTY
)
882 UINT col
= ( Lanes:: isHead(ln
) ||Lanes:: isTail(ln
) || Lanes::isJoin(ln
)
883 || ln
==Lanes:: CROSS_EMPTY
) ? activeLane
: i
;
885 if (ln
== Lanes::CROSS
) {
886 paintGraphLane(hdc
, rect
.Height(),Lanes::NOT_ACTIVE
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
887 paintGraphLane(hdc
, rect
.Height(),Lanes::CROSS
, x1
, x2
, m_LineColors
[activeLane
% Lanes::COLORS_NUM
],rect
.top
);
889 paintGraphLane(hdc
, rect
.Height(),ln
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
895 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
898 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
899 // Take the default processing unless we set this to something else below.
900 *pResult
= CDRF_DODEFAULT
;
902 if (m_bNoDispUpdates
)
907 switch (pLVCD
->nmcd
.dwDrawStage
)
911 *pResult
= CDRF_NOTIFYITEMDRAW
;
915 case CDDS_ITEMPREPAINT
:
917 // This is the prepaint stage for an item. Here's where we set the
918 // item's text color.
920 // Tell Windows to send draw notifications for each subitem.
921 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
923 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
925 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
927 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
931 if (data
->bCopiedSelf
)
933 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
934 if (!m_Theme
.IsAppm_Themed() || !m_bVista
|| ((pLVCD
->nmcd
.uItemState
& CDIS_HOT
)==0))
935 pLVCD
->clrTextBk
= GetSysColor(COLOR_MENU
);
939 crText
= m_Colors
.GetColor(CColors::Modified
);
941 if (data
->m_Action
& (CTGitPath::LOGACTIONS_REBASE_DONE
| CTGitPath::LOGACTIONS_REBASE_SKIP
) )
942 crText
= RGB(128,128,128);
944 if(data
->m_Action
&CTGitPath::LOGACTIONS_REBASE_SQUASH
)
945 pLVCD
->clrTextBk
= RGB(156,156,156);
946 else if(data
->m_Action
&CTGitPath::LOGACTIONS_REBASE_EDIT
)
947 pLVCD
->clrTextBk
= RGB(200,200,128);
949 pLVCD
->clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
951 if(data
->m_Action
&CTGitPath::LOGACTIONS_REBASE_CURRENT
)
953 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
954 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
957 if(data
->m_CommitHash
.ToString() == m_HeadHash
)
959 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
960 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
963 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
964 // crText = GetSysColor(COLOR_GRAYTEXT);
966 if (data
->m_CommitHash
.IsEmpty())
968 //crText = GetSysColor(RGB(200,200,0));
969 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
970 // We changed the font, so we're returning CDRF_NEWFONT. This
971 // tells the control to recalculate the extent of the text.
972 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
976 if (m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
978 if (m_bStrictStopped
)
979 crText
= GetSysColor(COLOR_GRAYTEXT
);
981 // Store the color back in the NMLVCUSTOMDRAW struct.
982 pLVCD
->clrText
= crText
;
986 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
988 if ((m_bStrictStopped
)&&(m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
990 pLVCD
->nmcd
.uItemState
&= ~(CDIS_SELECTED
|CDIS_FOCUS
);
993 if (pLVCD
->iSubItem
== LOGLIST_GRAPH
)
995 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
&& (!this->m_IsRebaseReplaceGraph
) )
998 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
999 if(pLVCD
->iSubItem
== 0)
1002 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
+1, LVIR_BOUNDS
, second
);
1003 rect
.right
=second
.left
;
1006 //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
1007 FillBackGround(pLVCD
->nmcd
.hdc
, (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
,rect
);
1009 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
1010 if( !data
->m_CommitHash
.IsEmpty())
1011 DrawGraph(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1013 *pResult
= CDRF_SKIPDEFAULT
;
1019 if (pLVCD
->iSubItem
== LOGLIST_MESSAGE
)
1021 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1023 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
1024 //if(!data->m_IsFull)
1026 //if(data->SafeFetchFullInfo(&g_Git))
1027 // this->Invalidate();
1028 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
1031 if(m_HashMap
[data
->m_CommitHash
].size()!=0)
1035 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1037 FillBackGround(pLVCD
->nmcd
.hdc
, (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
,rect
);
1038 DrawTagBranch(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1040 *pResult
= CDRF_SKIPDEFAULT
;
1048 if (pLVCD
->iSubItem
== 1)
1050 if(this->m_IsIDReplaceAction
)
1052 *pResult
= CDRF_DODEFAULT
;
1055 *pResult
= CDRF_DODEFAULT
;
1057 if (m_arShownList
.GetCount() <= (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1061 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1062 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1064 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
));
1066 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1067 //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
1068 // Get the selected state of the
1069 // item being drawn.
1071 // Fill the background
1072 FillBackGround(pLVCD
->nmcd
.hdc
, (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
,rect
);
1074 // Draw the icon(s) into the compatible DC
1075 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_MODIFIED
)
1076 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1079 if (pLogEntry
->m_Action
& (CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
) )
1080 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1083 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
1084 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1087 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
1088 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1090 *pResult
= CDRF_SKIPDEFAULT
;
1096 *pResult
= CDRF_DODEFAULT
;
1100 // CGitLogListBase message handlers
1102 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1104 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1106 // Create a pointer to the item
1107 LV_ITEM
* pItem
= &(pDispInfo
)->item
;
1109 // Do the list need text information?
1110 if (!(pItem
->mask
& LVIF_TEXT
))
1113 // By default, clear text buffer.
1114 lstrcpyn(pItem
->pszText
, _T(""), pItem
->cchTextMax
);
1116 bool bOutOfRange
= pItem
->iItem
>= ShownCountWithStopped();
1119 if (m_bNoDispUpdates
|| bOutOfRange
)
1122 // Which item number?
1123 int itemid
= pItem
->iItem
;
1124 GitRev
* pLogEntry
= NULL
;
1125 if (itemid
< m_arShownList
.GetCount())
1126 pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(pItem
->iItem
));
1131 temp
.Format(_T("%d"),pItem
->iItem
+1);
1135 temp
.Format(_T("%d"),m_arShownList
.GetCount()-pItem
->iItem
);
1139 switch (pItem
->iSubItem
)
1141 case this->LOGLIST_GRAPH
: //Graphic
1144 if(this->m_IsRebaseReplaceGraph
)
1147 path
.m_Action
=pLogEntry
->m_Action
&CTGitPath::LOGACTIONS_REBASE_MODE_MASK
;
1149 lstrcpyn(pItem
->pszText
,path
.GetActionName(), pItem
->cchTextMax
);
1153 case this->LOGLIST_ACTION
: //action -- no text in the column
1154 if(this->m_IsIDReplaceAction
)
1155 lstrcpyn(pItem
->pszText
, temp
, pItem
->cchTextMax
);
1157 case this->LOGLIST_MESSAGE
: //Message
1159 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->m_Subject
, pItem
->cchTextMax
);
1161 case this->LOGLIST_AUTHOR
: //Author
1163 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->m_AuthorName
, pItem
->cchTextMax
);
1165 case this->LOGLIST_DATE
: //Date
1166 if ( pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()) )
1167 lstrcpyn(pItem
->pszText
,
1168 CAppUtils::FormatDateAndTime( pLogEntry
->m_AuthorDate
, m_DateFormat
, true, m_bRelativeTimes
),
1180 void CGitLogListBase::OnContextMenu(CWnd
* pWnd
, CPoint point
)
1183 int selIndex
= GetSelectionMark();
1185 return; // nothing selected, nothing to do with a context menu
1187 // if the user selected the info text telling about not all revisions shown due to
1188 // the "stop on copy/rename" option, we also don't show the context menu
1189 if ((m_bStrictStopped
)&&(selIndex
== m_arShownList
.GetCount()))
1192 // if the context menu is invoked through the keyboard, we have to use
1193 // a calculated position on where to anchor the menu on
1194 if ((point
.x
== -1) && (point
.y
== -1))
1197 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1198 ClientToScreen(&rect
);
1199 point
= rect
.CenterPoint();
1201 m_nSearchIndex
= selIndex
;
1202 m_bCancelled
= FALSE
;
1204 // calculate some information the context menu commands can use
1205 // CString pathURL = GetURLFromPath(m_path);
1207 POSITION pos
= GetFirstSelectedItemPosition();
1208 int indexNext
= GetNextSelectedItem(pos
);
1212 GitRev
* pSelLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(indexNext
));
1214 GitRev revSelected
= pSelLogEntry
->Rev
;
1215 GitRev revPrevious
= git_revnum_t(revSelected
)-1;
1216 if ((pSelLogEntry
->pArChangedPaths
)&&(pSelLogEntry
->pArChangedPaths
->GetCount() <= 2))
1218 for (int i
=0; i
<pSelLogEntry
->pArChangedPaths
->GetCount(); ++i
)
1220 LogChangedPath
* changedpath
= (LogChangedPath
*)pSelLogEntry
->pArChangedPaths
->GetAt(i
);
1221 if (changedpath
->lCopyFromRev
)
1222 revPrevious
= changedpath
->lCopyFromRev
;
1225 GitRev revSelected2
;
1228 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1229 revSelected2
= pLogEntry
->Rev
;
1231 bool bAllFromTheSameAuthor
= true;
1232 CString firstAuthor
;
1233 CLogDataVector selEntries
;
1234 GitRev revLowest
, revHighest
;
1235 GitRevRangeArray revisionRanges
;
1237 POSITION pos
= GetFirstSelectedItemPosition();
1238 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1239 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1240 selEntries
.push_back(pLogEntry
);
1241 firstAuthor
= pLogEntry
->sAuthor
;
1242 revLowest
= pLogEntry
->Rev
;
1243 revHighest
= pLogEntry
->Rev
;
1246 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1247 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1248 selEntries
.push_back(pLogEntry
);
1249 if (firstAuthor
.Compare(pLogEntry
->sAuthor
))
1250 bAllFromTheSameAuthor
= false;
1251 revLowest
= (git_revnum_t(pLogEntry
->Rev
) > git_revnum_t(revLowest
) ? revLowest
: pLogEntry
->Rev
);
1252 revHighest
= (git_revnum_t(pLogEntry
->Rev
) < git_revnum_t(revHighest
) ? revHighest
: pLogEntry
->Rev
);
1258 int FirstSelect
=-1, LastSelect
=-1;
1259 pos
= GetFirstSelectedItemPosition();
1260 FirstSelect
= GetNextSelectedItem(pos
);
1263 LastSelect
= GetNextSelectedItem(pos
);
1265 //entry is selected, now show the popup menu
1268 if (popup
.CreatePopupMenu())
1271 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_PICK
))
1272 popup
.AppendMenuIcon(ID_REBASE_PICK
, IDS_REBASE_PICK
, IDI_PICK
);
1274 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_SQUASH
))
1275 popup
.AppendMenuIcon(ID_REBASE_SQUASH
,IDS_REBASE_SQUASH
, IDI_SQUASH
);
1277 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_EDIT
))
1278 popup
.AppendMenuIcon(ID_REBASE_EDIT
, IDS_REBASE_EDIT
, IDI_EDIT
);
1280 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_SKIP
))
1281 popup
.AppendMenuIcon(ID_REBASE_SKIP
, IDS_REBASE_SKIP
, IDI_SKIP
);
1283 if(m_ContextMenuMask
&(GetContextMenuBit(ID_REBASE_SKIP
)|GetContextMenuBit(ID_REBASE_EDIT
)|
1284 GetContextMenuBit(ID_REBASE_SQUASH
)|GetContextMenuBit(ID_REBASE_PICK
)))
1285 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1287 if (GetSelectedCount() == 1)
1291 if( !pSelLogEntry
->m_CommitHash
.IsEmpty())
1293 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARE
))
1294 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1296 // TortoiseMerge could be improved to take a /blame switch
1297 // and then not 'cat' the files from a unified diff but
1299 // But until that's implemented, the context menu entry for
1300 // this feature is commented out.
1301 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
1304 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMMIT
))
1305 popup
.AppendMenuIcon(ID_COMMIT
, IDS_LOG_POPUP_COMMIT
, IDI_COMMIT
);
1307 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF1
))
1308 popup
.AppendMenuIcon(ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
1310 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPAREWITHPREVIOUS
))
1311 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
);
1312 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
1313 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1316 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1318 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1320 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1322 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1324 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1325 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1327 // popup.AppendMenu(MF_SEPARATOR, NULL);
1332 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1333 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
))
1334 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
1336 format
.LoadString(IDS_LOG_POPUP_MERGEREV
);
1337 str
.Format(format
,g_Git
.GetCurrentBranch());
1339 if (m_ContextMenuMask
&GetContextMenuBit(ID_MERGEREV
))
1340 popup
.AppendMenuIcon(ID_MERGEREV
, str
, IDI_MERGE
);
1343 format
.LoadString(IDS_RESET_TO_THIS_FORMAT
);
1344 str
.Format(format
,g_Git
.GetCurrentBranch());
1346 if(!pSelLogEntry
->m_CommitHash
.IsEmpty())
1348 if(m_ContextMenuMask
&GetContextMenuBit(ID_RESET
))
1349 popup
.AppendMenuIcon(ID_RESET
,str
,IDI_REVERT
);
1351 if(m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHTOREV
))
1352 popup
.AppendMenuIcon(ID_SWITCHTOREV
, IDS_SWITCH_TO_THIS
, IDI_SWITCH
);
1354 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_BRANCH
))
1355 popup
.AppendMenuIcon(ID_CREATE_BRANCH
, IDS_CREATE_BRANCH_AT_THIS
, IDI_COPY
);
1357 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_TAG
))
1358 popup
.AppendMenuIcon(ID_CREATE_TAG
,IDS_CREATE_TAG_AT_THIS
, IDI_COPY
);
1360 format
.LoadString(IDS_REBASE_THIS_FORMAT
);
1361 str
.Format(format
,g_Git
.GetCurrentBranch());
1363 if(pSelLogEntry
->m_CommitHash
!= m_HeadHash
)
1364 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_TO_VERSION
))
1365 popup
.AppendMenuIcon(ID_REBASE_TO_VERSION
, str
, IDI_REBASE
);
1367 if(m_ContextMenuMask
&GetContextMenuBit(ID_EXPORT
))
1368 popup
.AppendMenuIcon(ID_EXPORT
,IDS_EXPORT_TO_THIS
, IDI_EXPORT
);
1371 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1376 if(!pSelLogEntry
->m_Ref
.IsEmpty() && GetSelectedCount() == 1)
1378 popup
.AppendMenuIcon(ID_REFLOG_DEL
, IDS_REFLOG_DEL
, IDI_DELETE
);
1379 popup
.AppendMenuIcon(ID_STASH_APPLY
,IDS_MENUSTASHAPPLY
, IDI_RELOCATE
);
1380 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1383 if (GetSelectedCount() >= 2)
1385 bool bAddSeparator
= false;
1386 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
1388 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARETWO
))
1389 popup
.AppendMenuIcon(ID_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
1392 if (GetSelectedCount() == 2)
1394 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
1395 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF2
))
1396 popup
.AppendMenuIcon(ID_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
1397 bAddSeparator
= true;
1402 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
1404 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
1405 bAddSeparator
= true;
1408 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1411 if ( GetSelectedCount() >0 && (!pSelLogEntry
->m_CommitHash
.IsEmpty()))
1413 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
1415 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMBINE_COMMIT
))
1419 headindex
= this->GetHeadIndex();
1422 head
.Format(_T("HEAD~%d"),LastSelect
-headindex
);
1423 CString hash
=g_Git
.GetHash(head
);
1425 GitRev
* pLastEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(LastSelect
));
1426 if(pLastEntry
->m_CommitHash
.ToString() == hash
)
1427 popup
.AppendMenuIcon(ID_COMBINE_COMMIT
,IDS_COMBINE_TO_ONE
,IDI_COMBINE
);
1431 if(m_ContextMenuMask
&GetContextMenuBit(ID_CHERRY_PICK
))
1432 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSION
, IDI_EXPORT
);
1434 if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))
1435 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_PATCH
))
1436 popup
.AppendMenuIcon(ID_CREATE_PATCH
, IDS_CREATE_PATCH
, IDI_PATCH
);
1438 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1444 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
1446 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
1448 // if (GetSelectedCount() == 1)
1450 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
1451 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
1452 // popup.AppendMenu(MF_SEPARATOR, NULL);
1457 if (GetSelectedCount() == 1)
1459 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYHASH
))
1460 popup
.AppendMenuIcon(ID_COPYHASH
, IDS_COPY_COMMIT_HASH
);
1462 if (GetSelectedCount() != 0)
1464 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARD
))
1465 popup
.AppendMenuIcon(ID_COPYCLIPBOARD
, IDS_LOG_POPUP_COPYTOCLIPBOARD
);
1468 if(m_ContextMenuMask
&GetContextMenuBit(ID_FINDENTRY
))
1469 popup
.AppendMenuIcon(ID_FINDENTRY
, IDS_LOG_POPUP_FIND
);
1472 if (GetSelectedCount() == 1)
1474 if(m_ContextMenuMask
&GetContextMenuBit(ID_DELETE
))
1476 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end() )
1479 str
.LoadString(IDS_DELETE_BRANCHTAG
);
1480 if( m_HashMap
[pSelLogEntry
->m_CommitHash
].size() == 1 )
1483 str
+=m_HashMap
[pSelLogEntry
->m_CommitHash
].at(0);
1484 popup
.AppendMenuIcon(ID_DELETE
,str
+_T("..."),IDI_DELETE
);
1486 else if( m_HashMap
[pSelLogEntry
->m_CommitHash
].size() > 1 )
1489 submenu
.CreatePopupMenu();
1490 for(int i
=0;i
<m_HashMap
[pSelLogEntry
->m_CommitHash
].size();i
++)
1492 submenu
.AppendMenuIcon(ID_DELETE
+(i
<<16),m_HashMap
[pSelLogEntry
->m_CommitHash
][i
]+_T("..."));
1495 popup
.AppendMenu(MF_BYPOSITION
|MF_POPUP
|MF_STRING
,(UINT
) submenu
.m_hMenu
,str
);
1503 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1504 // DialogEnableWindow(IDOK, FALSE);
1505 // SetPromptApp(&theApp);
1507 this->ContextMenuAction(cmd
, FirstSelect
, LastSelect
);
1509 // EnableOKButton();
1510 } // if (popup.CreatePopupMenu())
1514 bool CGitLogListBase::IsSelectionContinuous()
1516 if ( GetSelectedCount()==1 )
1518 // if only one revision is selected, the selection is of course
1523 POSITION pos
= GetFirstSelectedItemPosition();
1524 bool bContinuous
= (m_arShownList
.GetCount() == (INT_PTR
)m_logEntries
.size());
1527 int itemindex
= GetNextSelectedItem(pos
);
1530 int nextindex
= GetNextSelectedItem(pos
);
1531 if (nextindex
- itemindex
> 1)
1533 bContinuous
= false;
1536 itemindex
= nextindex
;
1542 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly
)
1546 POSITION pos
= GetFirstSelectedItemPosition();
1550 sRev
.LoadString(IDS_LOG_REVISION
);
1552 sAuthor
.LoadString(IDS_LOG_AUTHOR
);
1554 sDate
.LoadString(IDS_LOG_DATE
);
1556 sMessage
.LoadString(IDS_LOG_MESSAGE
);
1559 CString sLogCopyText
;
1561 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1565 //pLogEntry->m_Files
1566 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
1568 for (int cpPathIndex
= 0; cpPathIndex
<pLogEntry
->m_Files
.GetCount(); ++cpPathIndex
)
1570 sPaths
+= ((CTGitPath
&)pLogEntry
->m_Files
[cpPathIndex
]).GetActionName() + _T(" : ") + pLogEntry
->m_Files
[cpPathIndex
].GetGitPathString();
1571 sPaths
+= _T("\r\n");
1574 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"),
1575 (LPCTSTR
)sRev
, pLogEntry
->m_CommitHash
.ToString(),
1576 (LPCTSTR
)sAuthor
, (LPCTSTR
)pLogEntry
->m_AuthorName
,
1578 (LPCTSTR
)CAppUtils::FormatDateAndTime( pLogEntry
->m_AuthorDate
, m_DateFormat
, true, m_bRelativeTimes
),
1579 (LPCTSTR
)sMessage
, pLogEntry
->m_Subject
+_T("\r\n")+pLogEntry
->m_Body
,
1581 sClipdata
+= sLogCopyText
;
1584 sClipdata
+= pLogEntry
->m_CommitHash
;
1589 CStringUtils::WriteAsciiStringToClipboard(sClipdata
, GetSafeHwnd());
1594 void CGitLogListBase::DiffSelectedRevWithPrevious()
1596 if (m_bThreadRunning
)
1599 int FirstSelect
=-1, LastSelect
=-1;
1600 POSITION pos
= GetFirstSelectedItemPosition();
1601 FirstSelect
= GetNextSelectedItem(pos
);
1604 LastSelect
= GetNextSelectedItem(pos
);
1607 ContextMenuAction(ID_COMPAREWITHPREVIOUS
,FirstSelect
,LastSelect
);
1610 UpdateLogInfoLabel();
1611 int selIndex
= m_LogList
.GetSelectionMark();
1614 int selCount
= m_LogList
.GetSelectedCount();
1618 // Find selected entry in the log list
1619 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1620 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1621 long rev1
= pLogEntry
->Rev
;
1623 CTGitPath path
= m_path
;
1625 // See how many files under the relative root were changed in selected revision
1627 LogChangedPath
* changed
= NULL
;
1628 for (INT_PTR c
= 0; c
< pLogEntry
->pArChangedPaths
->GetCount(); ++c
)
1630 LogChangedPath
* cpath
= pLogEntry
->pArChangedPaths
->GetAt(c
);
1631 if (cpath
&& cpath
-> sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
1638 if (m_path
.IsDirectory() && nChanged
== 1)
1640 // We're looking at the log for a directory and only one file under dir was changed in the revision
1641 // Do diff on that file instead of whole directory
1642 path
.AppendPathString(changed
->sPath
.Mid(m_sRelativeRoot
.GetLength()));
1645 m_bCancelled
= FALSE
;
1646 DialogEnableWindow(IDOK
, FALSE
);
1647 SetPromptApp(&theApp
);
1648 theApp
.DoWaitCursor(1);
1652 GitDiff
diff(this, m_hWnd
, true);
1653 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1654 diff
.SetHEADPeg(m_LogRevision
);
1655 diff
.ShowCompare(path
, rev2
, path
, rev1
);
1659 CAppUtils::StartShowCompare(m_hWnd
, path
, rev2
, path
, rev1
, GitRev(), m_LogRevision
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1662 theApp
.DoWaitCursor(-1);
1667 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1669 LPNMLVFINDITEM pFindInfo
= reinterpret_cast<LPNMLVFINDITEM
>(pNMHDR
);
1672 if (pFindInfo
->lvfi
.flags
& LVFI_PARAM
)
1674 if ((pFindInfo
->iStart
< 0)||(pFindInfo
->iStart
>= m_arShownList
.GetCount()))
1676 if (pFindInfo
->lvfi
.psz
== 0)
1679 CString sCmp
= pFindInfo
->lvfi
.psz
;
1681 for (int i
=pFindInfo
->iStart
; i
<m_arShownList
.GetCount(); ++i
)
1683 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(i
));
1684 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
1685 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
1687 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
1695 if (sCmp
.Compare(sRev
)==0)
1702 if (pFindInfo
->lvfi
.flags
& LVFI_WRAP
)
1704 for (int i
=0; i
<pFindInfo
->iStart
; ++i
)
1706 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1707 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
1708 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
1710 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
1718 if (sCmp
.Compare(sRev
)==0)
1730 int CGitLogListBase::FillGitLog(CTGitPath
*path
,int info
,CString
*from
,CString
*to
)
1734 this->m_logEntries
.ClearAll();
1735 this->m_logEntries
.ParserFromLog(path
,-1,info
,from
,to
);
1737 //this->m_logEntries.ParserFromLog();
1738 SetItemCountEx(this->m_logEntries
.size());
1740 this->m_arShownList
.RemoveAll();
1742 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
1746 m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1).m_IsFull
=TRUE
;
1747 this->m_arShownList
.Add(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
1751 m_logEntries
.GetGitRevAt(i
).m_IsFull
=TRUE
;
1752 this->m_arShownList
.Add(&m_logEntries
.GetGitRevAt(i
));
1762 int CGitLogListBase::BeginFetchLog()
1766 this->m_logEntries
.ClearAll();
1769 this->m_LogCache
.ClearAllParent();
1771 m_LogCache
.FetchCacheIndex(g_Git
.m_CurrentDir
);
1774 if(this->m_Path
.IsEmpty())
1781 mask
= CGit::LOG_INFO_ONLY_HASH
| CGit::LOG_INFO_BOUNDARY
;
1782 // if(this->m_bAllBranch)
1783 mask
|= m_ShowMask
;
1785 this->m_arShownList
.RemoveAll();
1789 this->m_logEntries
.insert(m_logEntries
.begin(),this->m_wcRev
.m_CommitHash
);
1790 this->m_LogCache
.m_HashMap
[m_wcRev
.m_CommitHash
]=m_wcRev
;
1793 CString cmd
=g_Git
.GetLogCmd(m_StartRef
,path
,-1,mask
,NULL
,NULL
,true);
1795 //this->m_logEntries.ParserFromLog();
1796 if(IsInWorkingThread())
1798 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
);
1802 SetItemCountEx(this->m_logEntries
.size());
1807 if(g_Git
.IsInitRepos())
1810 if(git_open_log(&m_DllGitLog
,CUnicodeUtils::GetMulti(cmd
,CP_ACP
).GetBuffer()))
1818 BOOL
CGitLogListBase::PreTranslateMessage(MSG
* pMsg
)
1820 // Skip Ctrl-C when copying text out of the log message or search filter
1821 BOOL bSkipAccelerator
= ( pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW
) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT
) ) && GetKeyState(VK_CONTROL
)&0x8000 );
1822 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
1824 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
1826 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1828 DiffSelectedRevWithPrevious();
1833 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
1842 if (m_hAccel
&& !bSkipAccelerator
)
1844 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
1850 //m_tooltips.RelayEvent(pMsg);
1851 return __super::PreTranslateMessage(pMsg
);
1854 void CGitLogListBase::OnNMDblclkLoglist(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
1856 // a double click on an entry in the revision list has happened
1859 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1860 DiffSelectedRevWithPrevious();
1863 int CGitLogListBase::FetchLogAsync(void * data
)
1866 m_bExitThread
=FALSE
;
1867 InterlockedExchange(&m_bThreadRunning
, TRUE
);
1868 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
1869 m_LoadingThread
= AfxBeginThread(LogThreadEntry
, this);
1870 if (m_LoadingThread
==NULL
)
1872 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1873 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
1874 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
1880 //this is the thread function which calls the subversion function
1881 UINT
CGitLogListBase::LogThreadEntry(LPVOID pVoid
)
1883 return ((CGitLogListBase
*)pVoid
)->LogThread();
1886 void CGitLogListBase::GetTimeRange(CTime
&oldest
, CTime
&latest
)
1889 oldest
=CTime::GetCurrentTime();
1890 latest
=CTime(1971,1,2,0,0,0);
1891 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
1893 if(m_logEntries
[i
].IsEmpty())
1896 if(m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime() < oldest
.GetTime())
1897 oldest
= m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime();
1899 if(m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime() > latest
.GetTime())
1900 latest
= m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime();
1908 //Helper class for FetchFullLogInfo()
1909 class CGitCall_FetchFullLogInfo
: public CGitCall
1912 CGitCall_FetchFullLogInfo(CGitLogListBase
* ploglist
):m_ploglist(ploglist
),m_CollectedCount(0){}
1913 virtual bool OnOutputData(const BYTE
* data
, size_t size
)
1916 return m_ploglist
->m_bExitThread
;
1917 //Add received data to byte collector
1918 m_ByteCollector
.append(data
,size
);
1920 //Find loginfo endmarker
1921 static const BYTE dataToFind
[]={0,0,'#','<'};
1922 int found
=m_ByteCollector
.findData(dataToFind
,4);
1924 return m_ploglist
->m_bExitThread
;//Not found
1925 found
+=2;//Position after loginfo end-marker
1927 //Prepare data for OnLogInfo and call it
1928 BYTE_VECTOR logInfo
;
1929 logInfo
.append(&*m_ByteCollector
.begin(),found
);
1932 //Remove loginfo from bytecollector
1933 m_ByteCollector
.erase(m_ByteCollector
.begin(),m_ByteCollector
.begin()+found
);
1935 return m_ploglist
->m_bExitThread
;
1937 virtual void OnEnd()
1939 //Rest should be a complete log line.
1940 if(!m_ByteCollector
.empty())
1941 OnLogInfo(m_ByteCollector
);
1945 void OnLogInfo(BYTE_VECTOR
& logInfo
)
1948 fullRev
.ParserFromLog(logInfo
);
1949 MAP_HASH_REV::iterator itRev
=m_ploglist
->m_logEntries
.m_HashMap
.find(fullRev
.m_CommitHash
);
1950 if(itRev
==m_ploglist
->m_logEntries
.m_HashMap
.end())
1952 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
1956 int rev
=itRev
->second
;
1957 GitRev
* revInVector
=&m_ploglist
->m_logEntries
.GetGitRevAt(rev
);
1960 if(revInVector
->m_IsFull
)
1963 GitRev
*pRev
= m_ploglist
->m_LogCache
.GetCacheData(m_ploglist
->m_logEntries
[rev
]);
1967 InterlockedExchange(&pRev
->m_IsUpdateing
,FALSE
);
1968 InterlockedExchange(&pRev
->m_IsFull
,TRUE
);
1969 ::PostMessage(m_ploglist
->m_hWnd
,MSG_LOADED
,(WPARAM
)rev
,0);
1973 // fullRev.m_IsUpdateing=TRUE;
1974 // fullRev.m_IsFull=TRUE;
1977 if(InterlockedExchange(&revInVector
->m_IsUpdateing
,TRUE
))
1978 return;//Cannot update this row now. Ignore.
1979 TCHAR oldmark
=revInVector
->m_Mark
;
1980 GIT_REV_LIST oldlist
=revInVector
->m_ParentHash
;
1981 // CString oldhash=m_CommitHash;
1983 //Parse new rev info
1984 revInVector
->ParserFromLog(logInfo
);
1987 revInVector
->m_Mark
=oldmark
; //parser full log will cause old mark overwrited.
1988 //So we need keep old bound mark.
1989 revInVector
->m_ParentHash
=oldlist
;
1992 m_ploglist
->m_LogCache
.AddCacheEntry(*revInVector
);
1995 InterlockedExchange(&revInVector
->m_IsFull
,TRUE
);
1996 InterlockedExchange(&revInVector
->m_IsUpdateing
,FALSE
);
1998 //Notify listcontrol and update progress bar
2001 ::PostMessage(m_ploglist
->m_hWnd
,MSG_LOADED
,(WPARAM
)rev
,0);
2003 DWORD percent
=m_CollectedCount
*68/m_ploglist
->m_logEntries
.size() + GITLOG_START
+1+30;
2004 if(percent
== GITLOG_END
)
2005 percent
= GITLOG_END
-1;
2007 ::PostMessage(m_ploglist
->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
2010 CGitLogListBase
* m_ploglist
;
2011 BYTE_VECTOR m_ByteCollector
;
2012 int m_CollectedCount
;
2016 void CGitLogListBase::FetchFullLogInfo(CString
&from
, CString
&to
)
2018 CGitCall_FetchFullLogInfo
fetcher(this);
2020 CGit::LOG_INFO_FULL_DIFF
|
2021 CGit::LOG_INFO_STAT
|
2022 CGit::LOG_INFO_FILESTATE
|
2023 CGit::LOG_INFO_DETECT_COPYRENAME
|
2024 CGit::LOG_INFO_SHOW_MERGEDFILE
|
2028 if(this->m_Path
.IsEmpty())
2033 g_Git
.GetLog(&fetcher
,CString(),path
,-1,mask
,&from
,&to
);
2036 void CGitLogListBase::FetchLastLogInfo()
2038 unsigned int updated
=0;
2042 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
2044 if(m_logEntries
.GetGitRevAt(i
).m_IsFull
)
2047 GitRev
*pRev
= m_LogCache
.GetCacheData(m_logEntries
[i
]);
2050 if(!m_logEntries
.FetchFullInfo(i
))
2054 m_LogCache
.AddCacheEntry(m_logEntries
.GetGitRevAt(i
));
2059 InterlockedExchange(&pRev
->m_IsUpdateing
,FALSE
);
2060 InterlockedExchange(&pRev
->m_IsFull
,TRUE
);
2063 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)i
,0);
2067 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2068 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2075 UINT
CGitLogListBase::LogThread()
2077 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2079 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2080 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2087 TRACE(_T("\n===Begin===\n"));
2088 //Update work copy item;
2089 if( m_logEntries
.size() > 0)
2091 GitRev
*pRev
= &m_logEntries
.GetGitRevAt(0);
2093 m_arShownList
.Add(pRev
);
2095 if( pRev
->m_CommitHash
.IsEmpty() )
2097 pRev
->m_Files
.Clear();
2098 pRev
->m_ParentHash
.clear();
2099 pRev
->m_ParentHash
.push_back(m_HeadHash
);
2100 if(g_Git
.IsInitRepos())
2102 g_Git
.GetInitAddList(pRev
->m_Files
);
2106 g_Git
.GetCommitDiffList(pRev
->m_CommitHash
.ToString(),this->m_HeadHash
.ToString(), pRev
->m_Files
);
2110 for(int j
=0;j
< pRev
->m_Files
.GetCount();j
++)
2111 pRev
->m_Action
|= pRev
->m_Files
[j
].m_Action
;
2113 pRev
->m_Body
.Format(_T("%d files changed"),m_logEntries
.GetGitRevAt(0).m_Files
.GetCount());
2114 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
2118 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2120 if(!g_Git
.IsInitRepos())
2122 git_get_log_firstcommit(m_DllGitLog
);
2123 int total
= git_get_log_estimate_commit_count(m_DllGitLog
);
2125 t2
=t1
=GetTickCount();
2126 int oldprecentage
= 0;
2127 int oldsize
=m_logEntries
.size();
2128 while( git_get_log_nextcommit(this->m_DllGitLog
,&commit
) == 0)
2130 //printf("%s\r\n",commit.m_Subject);
2134 CGitHash hash
= (char*)commit
.m_hash
;
2136 GitRev
*pRev
= m_LogCache
.GetCacheData(hash
);
2138 if(pRev
== NULL
|| !pRev
->m_IsFull
)
2140 pRev
->ParserFromCommit(&commit
);
2141 pRev
->ParserParentFromCommit(&commit
);
2142 pRev
->SafeFetchFullInfo(&g_Git
);
2146 ASSERT(pRev
->m_CommitHash
== hash
);
2147 pRev
->ParserParentFromCommit(&commit
);
2153 git_free_commit(&commit
);
2155 this->m_critSec
.Lock();
2156 m_logEntries
.push_back(hash
);
2157 m_arShownList
.Add(pRev
);
2158 this->m_critSec
.Unlock();
2162 if(t2
-t1
>500 || (m_logEntries
.size()-oldsize
>100))
2165 int percent
=m_logEntries
.size()*100/total
+ GITLOG_START
+1;
2168 if(percent
< GITLOG_START
)
2169 percent
= GITLOG_START
+1;
2171 oldsize
= m_logEntries
.size();
2172 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2174 //if( percent > oldprecentage )
2176 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
2177 oldprecentage
= percent
;
2185 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2186 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
2188 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2191 // if(m_ProcCallBack)
2192 // m_ProcCallBack(m_ProcData,GITLOG_START);
2193 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2195 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2196 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2198 //does the user force the cache to refresh (shift or control key down)?
2199 bool refresh
= (GetKeyState (VK_CONTROL
) < 0)
2200 || (GetKeyState (VK_SHIFT
) < 0);
2202 //disable the "Get All" button while we're receiving
2207 if(this->m_bExitThread
)
2209 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2210 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2213 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2214 ::PostMessage(GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START_ALL
, 0);
2216 int start
=0; CString firstcommit
,lastcommit
;
2218 for(int i
=0;i
<m_logEntries
.size();i
++)
2220 if( i
==0 && m_logEntries
.GetGitRevAt(i
).m_CommitHash
.IsEmpty() )
2222 m_logEntries
.GetGitRevAt(i
).m_Files
.Clear();
2223 m_logEntries
.GetGitRevAt(i
).m_ParentHash
.clear();
2224 m_logEntries
.GetGitRevAt(i
).m_ParentHash
.push_back(m_HeadHash
);
2225 g_Git
.GetCommitDiffList(m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString(),this->m_HeadHash
,m_logEntries
.GetGitRevAt(i
).m_Files
);
2226 m_logEntries
.GetGitRevAt(i
).m_Action
=0;
2227 for(int j
=0;j
< m_logEntries
.GetGitRevAt(i
).m_Files
.GetCount();j
++)
2228 m_logEntries
.GetGitRevAt(i
).m_Action
|= m_logEntries
.GetGitRevAt(i
).m_Files
[j
].m_Action
;
2230 m_logEntries
.GetGitRevAt(i
).m_Body
.Format(_T("%d files changed"),m_logEntries
.GetGitRevAt(i
).m_Files
.GetCount());
2231 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
2235 start
=this->m_logEntries
.GetGitRevAt(i
).ParserFromLog(m_logEntries
.m_RawlogData
,start
);
2236 m_logEntries
.m_HashMap
[m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString()]=i
;
2238 if(m_LogCache
.GetCacheData(m_logEntries
.GetGitRevAt(i
)))
2240 if(firstcommit
.IsEmpty())
2241 firstcommit
=m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString();
2242 lastcommit
=m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString();
2246 InterlockedExchange(&m_logEntries
.GetGitRevAt(i
).m_IsUpdateing
,FALSE
);
2247 InterlockedExchange(&m_logEntries
.GetGitRevAt(i
).m_IsFull
,TRUE
);
2250 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
) i
, 0);
2254 if(start
>=m_logEntries
.m_RawlogData
.size())
2257 int percent
=i
*30/m_logEntries
.size() + GITLOG_START
+1;
2259 ::PostMessage(GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
, 0);
2261 if(this->m_bExitThread
)
2263 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2264 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2268 if(!lastcommit
.IsEmpty())
2269 FetchFullLogInfo(lastcommit
,firstcommit
);
2271 this->FetchLastLogInfo();
2274 RedrawItems(0, m_arShownList
.GetCount());
2275 // SetRedraw(false);
2276 // ResizeAllListCtrlCols();
2279 if ( m_pStoreSelection
)
2281 // Deleting the instance will restore the
2282 // selection of the CLogDlg.
2283 delete m_pStoreSelection
;
2284 m_pStoreSelection
= NULL
;
2288 // If no selection has been set then this must be the first time
2289 // the revisions are shown. Let's preselect the topmost revision.
2290 if ( GetItemCount()>0 )
2292 SetSelectionMark(0);
2293 SetItemState(0, LVIS_SELECTED
, LVIS_SELECTED
);
2300 //FetchFullLogInfo();
2301 //FetchFullLogInfoOrig();
2303 // make sure the filter is applied (if any) now, after we refreshed/fetched
2306 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
2308 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2313 void CGitLogListBase::Refresh()
2315 SafeTerminateThread();
2317 this->SetItemCountEx(0);
2320 //Update branch and Tag info
2322 //Assume Thread have exited
2323 //if(!m_bThreadRunning)
2326 m_logEntries
.clear();
2327 InterlockedExchange(&m_bExitThread
,FALSE
);
2329 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2330 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2331 if ( (m_LoadingThread
=AfxBeginThread(LogThreadEntry
, this)) ==NULL
)
2333 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2334 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2335 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
2337 m_sFilterText
.Empty();
2338 m_From
=CTime(1970,1,2,0,0,0);
2339 m_To
=CTime::GetCurrentTime();
2342 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str
, tr1::wregex
& pat
, bool bMatchCase
/* = false */)
2346 tr1::regex_constants::syntax_option_type type
= tr1::regex_constants::ECMAScript
;
2348 type
|= tr1::regex_constants::icase
;
2349 pat
= tr1::wregex(regexp_str
, type
);
2352 catch (exception
) {}
2356 void CGitLogListBase::RecalculateShownList(CPtrArray
* pShownlist
)
2359 pShownlist
->RemoveAll();
2360 tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
2361 bool bRegex
= false;
2362 if (m_bFilterWithRegex
)
2363 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
2365 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_any
;
2367 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
2369 if ((bRegex
)&&(m_bFilterWithRegex
))
2372 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
2374 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR
)m_logEntries
[i
]->sBugIDs
);
2375 if (regex_search(wstring((LPCTSTR
)m_logEntries
[i
]->sBugIDs
), pat
, flags
)&&IsEntryInDateRange(i
))
2377 pShownlist
->Add(m_logEntries
[i
]);
2382 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_MESSAGES
))
2384 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).m_Subject
);
2385 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).m_Subject
), pat
, flags
)&&IsEntryInDateRange(i
))
2387 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2391 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).m_Body
);
2392 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).m_Body
), pat
, flags
)&&IsEntryInDateRange(i
))
2394 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2399 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_PATHS
))
2401 LogChangedPathArray
* cpatharray
= m_logEntries
[i
]->pArChangedPaths
;
2404 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount() && bGoing
; ++cpPathIndex
)
2406 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
2407 if (regex_search(wstring((LPCTSTR
)cpath
->sCopyFromPath
), pat
, flags
)&&IsEntryInDateRange(i
))
2409 pShownlist
->Add(m_logEntries
[i
]);
2413 if (regex_search(wstring((LPCTSTR
)cpath
->sPath
), pat
, flags
)&&IsEntryInDateRange(i
))
2415 pShownlist
->Add(m_logEntries
[i
]);
2419 if (regex_search(wstring((LPCTSTR
)cpath
->GetAction()), pat
, flags
)&&IsEntryInDateRange(i
))
2421 pShownlist
->Add(m_logEntries
[i
]);
2430 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_AUTHORS
))
2432 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).m_AuthorName
), pat
, flags
)&&IsEntryInDateRange(i
))
2434 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2438 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_REVS
))
2440 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
2441 if (regex_search(wstring((LPCTSTR
)sRev
), pat
, flags
)&&IsEntryInDateRange(i
))
2443 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2450 CString find
= m_sFilterText
;
2453 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
2455 CString sBugIDs
= m_logEntries
[i
]->sBugIDs
;
2457 sBugIDs
= sBugIDs
.MakeLower();
2458 if ((sBugIDs
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2460 pShownlist
->Add(m_logEntries
[i
]);
2465 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_MESSAGES
))
2467 CString msg
= m_logEntries
.GetGitRevAt(i
).m_Subject
;
2469 msg
= msg
.MakeLower();
2470 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2472 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2475 msg
= m_logEntries
.GetGitRevAt(i
).m_Body
;
2477 msg
= msg
.MakeLower();
2478 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2480 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2485 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_PATHS
))
2487 LogChangedPathArray
* cpatharray
= m_logEntries
[i
]->pArChangedPaths
;
2490 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount() && bGoing
; ++cpPathIndex
)
2492 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
2493 CString path
= cpath
->sCopyFromPath
;
2495 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
2497 pShownlist
->Add(m_logEntries
[i
]);
2501 path
= cpath
->sPath
;
2503 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
2505 pShownlist
->Add(m_logEntries
[i
]);
2509 path
= cpath
->GetAction();
2511 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
2513 pShownlist
->Add(m_logEntries
[i
]);
2520 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_AUTHORS
))
2522 CString msg
= m_logEntries
.GetGitRevAt(i
).m_AuthorName
;
2523 msg
= msg
.MakeLower();
2524 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2526 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2530 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_REVS
))
2532 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
2533 if ((sRev
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2535 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2539 } // else (from if (bRegex))
2540 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
2544 BOOL
CGitLogListBase::IsEntryInDateRange(int i
)
2546 __time64_t time
= m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime();
2547 if ((time
>= m_From
.GetTime())&&(time
<= m_To
.GetTime()))
2554 void CGitLogListBase::StartFilter()
2556 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2557 RecalculateShownList(&m_arShownList
);
2558 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2562 SetItemCountEx(ShownCountWithStopped());
2563 RedrawItems(0, ShownCountWithStopped());
2565 //ResizeAllListCtrlCols();
2570 void CGitLogListBase::RemoveFilter()
2573 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2575 m_arShownList
.RemoveAll();
2577 // reset the time filter too
2579 m_timFrom
= (__time64_t(m_tFrom
));
2580 m_timTo
= (__time64_t(m_tTo
));
2581 m_DateFrom
.SetTime(&m_timFrom
);
2582 m_DateTo
.SetTime(&m_timTo
);
2583 m_DateFrom
.SetRange(&m_timFrom
, &m_timTo
);
2584 m_DateTo
.SetRange(&m_timFrom
, &m_timTo
);
2587 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
2589 if(this->m_IsOldFirst
)
2591 m_arShownList
.Add(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
2594 m_arShownList
.Add(&m_logEntries
.GetGitRevAt(i
));
2597 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
2599 SetItemCountEx(ShownCountWithStopped());
2600 RedrawItems(0, ShownCountWithStopped());
2601 // SetRedraw(false);
2602 // ResizeAllListCtrlCols();
2605 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2608 void CGitLogListBase::Clear()
2610 m_arShownList
.RemoveAll();
2613 m_logEntries
.ClearAll();
2617 void CGitLogListBase::OnDestroy()
2619 // save the column widths to the registry
2622 SafeTerminateThread();
2624 while(m_LogCache
.SaveCache())
2626 if(CMessageBox::Show(NULL
,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
2630 CHintListCtrl::OnDestroy();
2633 LRESULT
CGitLogListBase::OnLoad(WPARAM wParam
,LPARAM lParam
)
2637 this->GetItemRect(i
,&rect
,LVIR_BOUNDS
);
2638 this->InvalidateRect(rect
);
2640 if(this->GetItemState(i
,LVIF_STATE
) & LVIS_SELECTED
)
2648 * Save column widths to the registry
2650 void CGitLogListBase::SaveColumnWidths()
2652 CHeaderCtrl
* pHdrCtrl
= (CHeaderCtrl
*)(GetDlgItem(0));
2655 int numcols
= pHdrCtrl
->GetItemCount();
2656 for (int col
= 0; col
< numcols
; col
++)
2658 int width
= GetColumnWidth( col
);
2660 regentry
.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey
, col
);
2661 CRegDWORD
regwidth(regentry
, 0);
2662 regwidth
= width
; // this writes it to reg
2667 int CGitLogListBase::GetHeadIndex()
2669 if(m_HeadHash
.IsEmpty())
2672 for(int i
=0;i
<m_arShownList
.GetCount();i
++)
2674 GitRev
*pRev
= (GitRev
*)m_arShownList
[i
];
2677 if(pRev
->m_CommitHash
.ToString() == m_HeadHash
)
2683 void CGitLogListBase::OnFind()
2687 m_pFindDialog
= new CFindReplaceDialog();
2688 m_pFindDialog
->Create(TRUE
, NULL
, NULL
, FR_HIDEUPDOWN
| FR_HIDEWHOLEWORD
, this);
2692 LRESULT
CGitLogListBase::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2695 ASSERT(m_pFindDialog
!= NULL
);
2697 if (m_pFindDialog
->IsTerminating())
2699 // invalidate the handle identifying the dialog box.
2700 m_pFindDialog
= NULL
;
2704 if(m_pFindDialog
->FindNext())
2706 //read data from dialog
2707 CString FindText
= m_pFindDialog
->GetFindString();
2708 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
2709 bool bFound
= false;
2711 bool bRegex
= ValidateRegexp(FindText
, pat
, bMatchCase
);
2713 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_not_null
;
2716 for (i
= this->m_nSearchIndex
; i
<m_arShownList
.GetCount()&&!bFound
; i
++)
2718 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.GetAt(i
);
2721 str
+=pLogEntry
->m_CommitHash
.ToString();
2723 str
+=pLogEntry
->m_AuthorEmail
;
2725 str
+=pLogEntry
->m_AuthorName
;
2727 str
+=pLogEntry
->m_Body
;
2729 str
+=pLogEntry
->m_CommitterEmail
;
2731 str
+=pLogEntry
->m_CommitterName
;
2733 str
+=pLogEntry
->m_Subject
;
2736 for(int i
=0;i
<pLogEntry
->m_Files
.GetCount();i
++)
2738 str
+=pLogEntry
->m_Files
[i
].GetWinPath();
2740 str
+=pLogEntry
->m_Files
[i
].GetGitOldPathString();
2747 if (regex_search(wstring(str
), pat
, flags
))
2757 if (str
.Find(FindText
) >= 0)
2767 msg
= msg
.MakeLower();
2768 CString find
= FindText
.MakeLower();
2769 if (msg
.Find(find
) >= 0)
2776 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
2779 this->m_nSearchIndex
= (i
+1);
2780 EnsureVisible(i
, FALSE
);
2781 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED
);
2782 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2783 SetSelectionMark(i
);
2784 //FillLogMessageCtrl();
2787 if (m_nSearchIndex
>= m_arShownList
.GetCount())
2788 m_nSearchIndex
= (int)m_arShownList
.GetCount()-1;
2790 } // if(m_pFindDialog->FindNext())
2791 //UpdateLogInfoLabel();