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-1
575 #define P_180 x1, h+top
576 #define P_270 m , 2 * h+top +1
577 #define R_CENTER m - r, h - r+top, d, 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
);
750 Gdiplus::SolidBrush
myBrush(GetGdiColor(col
));
751 // center symbol, e.g. rect or ellipse
757 //p->setPen(Qt::NoPen);
759 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias
);
760 graphics
.FillEllipse(&myBrush
, R_CENTER
);
761 //p->drawEllipse(R_CENTER);
763 case Lanes::MERGE_FORK
:
764 case Lanes::MERGE_FORK_R
:
765 case Lanes::MERGE_FORK_L
:
766 //p->setPen(Qt::NoPen);
768 //p->drawRect(R_CENTER);
769 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
770 graphics
.FillRectangle(&myBrush
, R_CENTER
);
772 case Lanes::UNAPPLIED
:
774 //p->setPen(Qt::NoPen);
775 //p->setBrush(Qt::red);
776 //p->drawRect(m - r, h - 1, d, 2);
777 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
778 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
782 //p->setPen(Qt::NoPen);
783 //p->setBrush(DARK_GREEN);
784 //p->drawRect(m - r, h - 1, d, 2);
785 //p->drawRect(m - 1, h - r, 2, d);
786 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
787 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
788 graphics
.FillRectangle(&myBrush
,m
-1,h
-r
,2,d
);
790 case Lanes::BOUNDARY
:
792 //p->drawEllipse(R_CENTER);
793 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias
);
794 graphics
.DrawEllipse(&myPen
, R_CENTER
);
796 case Lanes::BOUNDARY_C
:
797 case Lanes::BOUNDARY_R
:
798 case Lanes::BOUNDARY_L
:
800 //p->drawRect(R_CENTER);
801 graphics
.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeNone
);
802 graphics
.FillRectangle(&myBrush
,R_CENTER
);
808 ::SelectObject(hdc
,oldpen
);
809 ::SelectObject(hdc
,oldbrush
);
818 void CGitLogListBase::DrawGraph(HDC hdc
,CRect
&rect
,INT_PTR index
)
822 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(index
);
823 if(data
->m_CommitHash
.IsEmpty())
828 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
829 rItem
.mask
= LVIF_STATE
;
831 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
835 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
839 if (data
->m_Lanes
.size() == 0)
840 m_logEntries
.setLane(data
->m_CommitHash
);
842 std::vector
<int>& lanes
=data
->m_Lanes
;
843 UINT laneNum
= lanes
.size();
845 for (UINT i
= 0; i
< laneNum
; i
++)
846 if (Lanes::isMerge(lanes
[i
])) {
852 int maxWidth
= rect
.Width();
853 int lw
= 3 * rect
.Height() / 4; //laneWidth()
855 COLORREF activeColor
= m_LineColors
[activeLane
% Lanes::COLORS_NUM
];
856 //if (opt.state & QStyle::State_Selected)
857 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
860 for (unsigned int i
= 0; i
< laneNum
&& x2
< maxWidth
; i
++)
867 if (ln
== Lanes::EMPTY
)
870 COLORREF color
= i
== activeLane
? activeColor
: m_LineColors
[i
% Lanes::COLORS_NUM
];
871 paintGraphLane(hdc
, rect
.Height(),ln
, x1
+rect
.left
, x2
+rect
.left
, color
,activeColor
, rect
.top
);
875 for (UINT i
= 0; i
< laneNum
&& x2
< maxWidth
; i
++) {
881 if (ln
== Lanes::EMPTY
)
884 UINT col
= ( Lanes:: isHead(ln
) ||Lanes:: isTail(ln
) || Lanes::isJoin(ln
)
885 || ln
==Lanes:: CROSS_EMPTY
) ? activeLane
: i
;
887 if (ln
== Lanes::CROSS
) {
888 paintGraphLane(hdc
, rect
.Height(),Lanes::NOT_ACTIVE
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
889 paintGraphLane(hdc
, rect
.Height(),Lanes::CROSS
, x1
, x2
, m_LineColors
[activeLane
% Lanes::COLORS_NUM
],rect
.top
);
891 paintGraphLane(hdc
, rect
.Height(),ln
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
897 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
900 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
901 // Take the default processing unless we set this to something else below.
902 *pResult
= CDRF_DODEFAULT
;
904 if (m_bNoDispUpdates
)
909 switch (pLVCD
->nmcd
.dwDrawStage
)
913 *pResult
= CDRF_NOTIFYITEMDRAW
;
917 case CDDS_ITEMPREPAINT
:
919 // This is the prepaint stage for an item. Here's where we set the
920 // item's text color.
922 // Tell Windows to send draw notifications for each subitem.
923 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
925 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
927 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
929 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
933 if (data
->bCopiedSelf
)
935 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
936 if (!m_Theme
.IsAppm_Themed() || !m_bVista
|| ((pLVCD
->nmcd
.uItemState
& CDIS_HOT
)==0))
937 pLVCD
->clrTextBk
= GetSysColor(COLOR_MENU
);
941 crText
= m_Colors
.GetColor(CColors::Modified
);
943 if (data
->m_Action
& (CTGitPath::LOGACTIONS_REBASE_DONE
| CTGitPath::LOGACTIONS_REBASE_SKIP
) )
944 crText
= RGB(128,128,128);
946 if(data
->m_Action
&CTGitPath::LOGACTIONS_REBASE_SQUASH
)
947 pLVCD
->clrTextBk
= RGB(156,156,156);
948 else if(data
->m_Action
&CTGitPath::LOGACTIONS_REBASE_EDIT
)
949 pLVCD
->clrTextBk
= RGB(200,200,128);
951 pLVCD
->clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
953 if(data
->m_Action
&CTGitPath::LOGACTIONS_REBASE_CURRENT
)
955 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
956 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
959 if(data
->m_CommitHash
.ToString() == m_HeadHash
)
961 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
962 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
965 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
966 // crText = GetSysColor(COLOR_GRAYTEXT);
968 if (data
->m_CommitHash
.IsEmpty())
970 //crText = GetSysColor(RGB(200,200,0));
971 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
972 // We changed the font, so we're returning CDRF_NEWFONT. This
973 // tells the control to recalculate the extent of the text.
974 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
978 if (m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
980 if (m_bStrictStopped
)
981 crText
= GetSysColor(COLOR_GRAYTEXT
);
983 // Store the color back in the NMLVCUSTOMDRAW struct.
984 pLVCD
->clrText
= crText
;
988 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
990 if ((m_bStrictStopped
)&&(m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
992 pLVCD
->nmcd
.uItemState
&= ~(CDIS_SELECTED
|CDIS_FOCUS
);
995 if (pLVCD
->iSubItem
== LOGLIST_GRAPH
)
997 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
&& (!this->m_IsRebaseReplaceGraph
) )
1000 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1001 if(pLVCD
->iSubItem
== 0)
1004 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
+1, LVIR_BOUNDS
, second
);
1005 rect
.right
=second
.left
;
1008 //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
1009 FillBackGround(pLVCD
->nmcd
.hdc
, (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
,rect
);
1011 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
1012 if( !data
->m_CommitHash
.IsEmpty())
1013 DrawGraph(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1015 *pResult
= CDRF_SKIPDEFAULT
;
1021 if (pLVCD
->iSubItem
== LOGLIST_MESSAGE
)
1023 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1025 GitRev
* data
= (GitRev
*)m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
);
1026 //if(!data->m_IsFull)
1028 //if(data->SafeFetchFullInfo(&g_Git))
1029 // this->Invalidate();
1030 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
1033 if(m_HashMap
[data
->m_CommitHash
].size()!=0)
1037 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1039 FillBackGround(pLVCD
->nmcd
.hdc
, (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
,rect
);
1040 DrawTagBranch(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1042 *pResult
= CDRF_SKIPDEFAULT
;
1050 if (pLVCD
->iSubItem
== 1)
1052 if(this->m_IsIDReplaceAction
)
1054 *pResult
= CDRF_DODEFAULT
;
1057 *pResult
= CDRF_DODEFAULT
;
1059 if (m_arShownList
.GetCount() <= (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1063 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1064 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1066 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(pLVCD
->nmcd
.dwItemSpec
));
1068 GetSubItemRect(pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1069 //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
1070 // Get the selected state of the
1071 // item being drawn.
1073 // Fill the background
1074 FillBackGround(pLVCD
->nmcd
.hdc
, (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
,rect
);
1076 // Draw the icon(s) into the compatible DC
1077 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_MODIFIED
)
1078 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1081 if (pLogEntry
->m_Action
& (CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
) )
1082 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1085 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
1086 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1089 if (pLogEntry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
1090 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1092 *pResult
= CDRF_SKIPDEFAULT
;
1098 *pResult
= CDRF_DODEFAULT
;
1102 // CGitLogListBase message handlers
1104 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1106 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1108 // Create a pointer to the item
1109 LV_ITEM
* pItem
= &(pDispInfo
)->item
;
1111 // Do the list need text information?
1112 if (!(pItem
->mask
& LVIF_TEXT
))
1115 // By default, clear text buffer.
1116 lstrcpyn(pItem
->pszText
, _T(""), pItem
->cchTextMax
);
1118 bool bOutOfRange
= pItem
->iItem
>= ShownCountWithStopped();
1121 if (m_bNoDispUpdates
|| bOutOfRange
)
1124 // Which item number?
1125 int itemid
= pItem
->iItem
;
1126 GitRev
* pLogEntry
= NULL
;
1127 if (itemid
< m_arShownList
.GetCount())
1128 pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(pItem
->iItem
));
1133 temp
.Format(_T("%d"),pItem
->iItem
+1);
1137 temp
.Format(_T("%d"),m_arShownList
.GetCount()-pItem
->iItem
);
1141 switch (pItem
->iSubItem
)
1143 case this->LOGLIST_GRAPH
: //Graphic
1146 if(this->m_IsRebaseReplaceGraph
)
1149 path
.m_Action
=pLogEntry
->m_Action
&CTGitPath::LOGACTIONS_REBASE_MODE_MASK
;
1151 lstrcpyn(pItem
->pszText
,path
.GetActionName(), pItem
->cchTextMax
);
1155 case this->LOGLIST_ACTION
: //action -- no text in the column
1156 if(this->m_IsIDReplaceAction
)
1157 lstrcpyn(pItem
->pszText
, temp
, pItem
->cchTextMax
);
1159 case this->LOGLIST_MESSAGE
: //Message
1161 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->m_Subject
, pItem
->cchTextMax
);
1163 case this->LOGLIST_AUTHOR
: //Author
1165 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->m_AuthorName
, pItem
->cchTextMax
);
1167 case this->LOGLIST_DATE
: //Date
1168 if ( pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()) )
1169 lstrcpyn(pItem
->pszText
,
1170 CAppUtils::FormatDateAndTime( pLogEntry
->m_AuthorDate
, m_DateFormat
, true, m_bRelativeTimes
),
1182 void CGitLogListBase::OnContextMenu(CWnd
* pWnd
, CPoint point
)
1185 int selIndex
= GetSelectionMark();
1187 return; // nothing selected, nothing to do with a context menu
1189 // if the user selected the info text telling about not all revisions shown due to
1190 // the "stop on copy/rename" option, we also don't show the context menu
1191 if ((m_bStrictStopped
)&&(selIndex
== m_arShownList
.GetCount()))
1194 // if the context menu is invoked through the keyboard, we have to use
1195 // a calculated position on where to anchor the menu on
1196 if ((point
.x
== -1) && (point
.y
== -1))
1199 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1200 ClientToScreen(&rect
);
1201 point
= rect
.CenterPoint();
1203 m_nSearchIndex
= selIndex
;
1204 m_bCancelled
= FALSE
;
1206 // calculate some information the context menu commands can use
1207 // CString pathURL = GetURLFromPath(m_path);
1209 POSITION pos
= GetFirstSelectedItemPosition();
1210 int indexNext
= GetNextSelectedItem(pos
);
1214 GitRev
* pSelLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(indexNext
));
1216 GitRev revSelected
= pSelLogEntry
->Rev
;
1217 GitRev revPrevious
= git_revnum_t(revSelected
)-1;
1218 if ((pSelLogEntry
->pArChangedPaths
)&&(pSelLogEntry
->pArChangedPaths
->GetCount() <= 2))
1220 for (int i
=0; i
<pSelLogEntry
->pArChangedPaths
->GetCount(); ++i
)
1222 LogChangedPath
* changedpath
= (LogChangedPath
*)pSelLogEntry
->pArChangedPaths
->GetAt(i
);
1223 if (changedpath
->lCopyFromRev
)
1224 revPrevious
= changedpath
->lCopyFromRev
;
1227 GitRev revSelected2
;
1230 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1231 revSelected2
= pLogEntry
->Rev
;
1233 bool bAllFromTheSameAuthor
= true;
1234 CString firstAuthor
;
1235 CLogDataVector selEntries
;
1236 GitRev revLowest
, revHighest
;
1237 GitRevRangeArray revisionRanges
;
1239 POSITION pos
= GetFirstSelectedItemPosition();
1240 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1241 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1242 selEntries
.push_back(pLogEntry
);
1243 firstAuthor
= pLogEntry
->sAuthor
;
1244 revLowest
= pLogEntry
->Rev
;
1245 revHighest
= pLogEntry
->Rev
;
1248 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1249 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1250 selEntries
.push_back(pLogEntry
);
1251 if (firstAuthor
.Compare(pLogEntry
->sAuthor
))
1252 bAllFromTheSameAuthor
= false;
1253 revLowest
= (git_revnum_t(pLogEntry
->Rev
) > git_revnum_t(revLowest
) ? revLowest
: pLogEntry
->Rev
);
1254 revHighest
= (git_revnum_t(pLogEntry
->Rev
) < git_revnum_t(revHighest
) ? revHighest
: pLogEntry
->Rev
);
1260 int FirstSelect
=-1, LastSelect
=-1;
1261 pos
= GetFirstSelectedItemPosition();
1262 FirstSelect
= GetNextSelectedItem(pos
);
1265 LastSelect
= GetNextSelectedItem(pos
);
1267 //entry is selected, now show the popup menu
1270 if (popup
.CreatePopupMenu())
1273 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_PICK
))
1274 popup
.AppendMenuIcon(ID_REBASE_PICK
, IDS_REBASE_PICK
, IDI_PICK
);
1276 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_SQUASH
))
1277 popup
.AppendMenuIcon(ID_REBASE_SQUASH
,IDS_REBASE_SQUASH
, IDI_SQUASH
);
1279 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_EDIT
))
1280 popup
.AppendMenuIcon(ID_REBASE_EDIT
, IDS_REBASE_EDIT
, IDI_EDIT
);
1282 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_SKIP
))
1283 popup
.AppendMenuIcon(ID_REBASE_SKIP
, IDS_REBASE_SKIP
, IDI_SKIP
);
1285 if(m_ContextMenuMask
&(GetContextMenuBit(ID_REBASE_SKIP
)|GetContextMenuBit(ID_REBASE_EDIT
)|
1286 GetContextMenuBit(ID_REBASE_SQUASH
)|GetContextMenuBit(ID_REBASE_PICK
)))
1287 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1289 if (GetSelectedCount() == 1)
1293 if( !pSelLogEntry
->m_CommitHash
.IsEmpty())
1295 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARE
))
1296 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1298 // TortoiseMerge could be improved to take a /blame switch
1299 // and then not 'cat' the files from a unified diff but
1301 // But until that's implemented, the context menu entry for
1302 // this feature is commented out.
1303 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
1306 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMMIT
))
1307 popup
.AppendMenuIcon(ID_COMMIT
, IDS_LOG_POPUP_COMMIT
, IDI_COMMIT
);
1309 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF1
))
1310 popup
.AppendMenuIcon(ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
1312 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPAREWITHPREVIOUS
))
1313 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
);
1314 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
1315 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1318 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1320 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1322 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1324 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1326 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1327 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1329 // popup.AppendMenu(MF_SEPARATOR, NULL);
1334 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1336 if(!pSelLogEntry
->m_CommitHash
.IsEmpty())
1338 format
.LoadString(IDS_LOG_POPUP_MERGEREV
);
1339 str
.Format(format
,g_Git
.GetCurrentBranch());
1341 if (m_ContextMenuMask
&GetContextMenuBit(ID_MERGEREV
))
1342 popup
.AppendMenuIcon(ID_MERGEREV
, str
, IDI_MERGE
);
1344 format
.LoadString(IDS_RESET_TO_THIS_FORMAT
);
1345 str
.Format(format
,g_Git
.GetCurrentBranch());
1347 if(m_ContextMenuMask
&GetContextMenuBit(ID_RESET
))
1348 popup
.AppendMenuIcon(ID_RESET
,str
,IDI_REVERT
);
1350 if(m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHTOREV
))
1351 popup
.AppendMenuIcon(ID_SWITCHTOREV
, IDS_SWITCH_TO_THIS
, IDI_SWITCH
);
1353 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_BRANCH
))
1354 popup
.AppendMenuIcon(ID_CREATE_BRANCH
, IDS_CREATE_BRANCH_AT_THIS
, IDI_COPY
);
1356 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_TAG
))
1357 popup
.AppendMenuIcon(ID_CREATE_TAG
,IDS_CREATE_TAG_AT_THIS
, IDI_COPY
);
1359 format
.LoadString(IDS_REBASE_THIS_FORMAT
);
1360 str
.Format(format
,g_Git
.GetCurrentBranch());
1362 if(pSelLogEntry
->m_CommitHash
!= m_HeadHash
)
1363 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_TO_VERSION
))
1364 popup
.AppendMenuIcon(ID_REBASE_TO_VERSION
, str
, IDI_REBASE
);
1366 if(m_ContextMenuMask
&GetContextMenuBit(ID_EXPORT
))
1367 popup
.AppendMenuIcon(ID_EXPORT
,IDS_EXPORT_TO_THIS
, IDI_EXPORT
);
1369 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
))
1370 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
1372 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1377 if(!pSelLogEntry
->m_Ref
.IsEmpty() && GetSelectedCount() == 1)
1379 popup
.AppendMenuIcon(ID_REFLOG_DEL
, IDS_REFLOG_DEL
, IDI_DELETE
);
1380 popup
.AppendMenuIcon(ID_STASH_APPLY
,IDS_MENUSTASHAPPLY
, IDI_RELOCATE
);
1381 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1384 if (GetSelectedCount() >= 2)
1386 bool bAddSeparator
= false;
1387 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
1389 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARETWO
))
1390 popup
.AppendMenuIcon(ID_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
1393 if (GetSelectedCount() == 2)
1395 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
1396 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF2
))
1397 popup
.AppendMenuIcon(ID_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
1398 bAddSeparator
= true;
1403 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
1405 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
1406 bAddSeparator
= true;
1409 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
))
1410 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREVS
, IDI_REVERT
);
1414 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1417 if ( GetSelectedCount() >0 && (!pSelLogEntry
->m_CommitHash
.IsEmpty()))
1419 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
1421 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMBINE_COMMIT
))
1425 headindex
= this->GetHeadIndex();
1428 head
.Format(_T("HEAD~%d"),LastSelect
-headindex
);
1429 CString hash
=g_Git
.GetHash(head
);
1431 GitRev
* pLastEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(LastSelect
));
1432 if(pLastEntry
->m_CommitHash
.ToString() == hash
)
1433 popup
.AppendMenuIcon(ID_COMBINE_COMMIT
,IDS_COMBINE_TO_ONE
,IDI_COMBINE
);
1437 if(m_ContextMenuMask
&GetContextMenuBit(ID_CHERRY_PICK
))
1438 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSION
, IDI_EXPORT
);
1440 if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))
1441 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_PATCH
))
1442 popup
.AppendMenuIcon(ID_CREATE_PATCH
, IDS_CREATE_PATCH
, IDI_PATCH
);
1444 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1450 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
1452 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
1454 // if (GetSelectedCount() == 1)
1456 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
1457 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
1458 // popup.AppendMenu(MF_SEPARATOR, NULL);
1463 if (GetSelectedCount() == 1)
1465 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYHASH
))
1466 popup
.AppendMenuIcon(ID_COPYHASH
, IDS_COPY_COMMIT_HASH
);
1468 if (GetSelectedCount() != 0)
1470 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARD
))
1471 popup
.AppendMenuIcon(ID_COPYCLIPBOARD
, IDS_LOG_POPUP_COPYTOCLIPBOARD
);
1474 if(m_ContextMenuMask
&GetContextMenuBit(ID_FINDENTRY
))
1475 popup
.AppendMenuIcon(ID_FINDENTRY
, IDS_LOG_POPUP_FIND
);
1478 if (GetSelectedCount() == 1)
1480 if(m_ContextMenuMask
&GetContextMenuBit(ID_DELETE
))
1482 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end() )
1485 str
.LoadString(IDS_DELETE_BRANCHTAG
);
1486 if( m_HashMap
[pSelLogEntry
->m_CommitHash
].size() == 1 )
1489 str
+=m_HashMap
[pSelLogEntry
->m_CommitHash
].at(0);
1490 popup
.AppendMenuIcon(ID_DELETE
,str
+_T("..."),IDI_DELETE
);
1492 else if( m_HashMap
[pSelLogEntry
->m_CommitHash
].size() > 1 )
1495 submenu
.CreatePopupMenu();
1496 for(int i
=0;i
<m_HashMap
[pSelLogEntry
->m_CommitHash
].size();i
++)
1498 submenu
.AppendMenuIcon(ID_DELETE
+(i
<<16),m_HashMap
[pSelLogEntry
->m_CommitHash
][i
]+_T("..."));
1501 popup
.AppendMenu(MF_BYPOSITION
|MF_POPUP
|MF_STRING
,(UINT
) submenu
.m_hMenu
,str
);
1509 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1510 // DialogEnableWindow(IDOK, FALSE);
1511 // SetPromptApp(&theApp);
1513 this->ContextMenuAction(cmd
, FirstSelect
, LastSelect
);
1515 // EnableOKButton();
1516 } // if (popup.CreatePopupMenu())
1520 bool CGitLogListBase::IsSelectionContinuous()
1522 if ( GetSelectedCount()==1 )
1524 // if only one revision is selected, the selection is of course
1529 POSITION pos
= GetFirstSelectedItemPosition();
1530 bool bContinuous
= (m_arShownList
.GetCount() == (INT_PTR
)m_logEntries
.size());
1533 int itemindex
= GetNextSelectedItem(pos
);
1536 int nextindex
= GetNextSelectedItem(pos
);
1537 if (nextindex
- itemindex
> 1)
1539 bContinuous
= false;
1542 itemindex
= nextindex
;
1548 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly
)
1552 POSITION pos
= GetFirstSelectedItemPosition();
1556 sRev
.LoadString(IDS_LOG_REVISION
);
1558 sAuthor
.LoadString(IDS_LOG_AUTHOR
);
1560 sDate
.LoadString(IDS_LOG_DATE
);
1562 sMessage
.LoadString(IDS_LOG_MESSAGE
);
1565 CString sLogCopyText
;
1567 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(GetNextSelectedItem(pos
)));
1571 //pLogEntry->m_Files
1572 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
1574 for (int cpPathIndex
= 0; cpPathIndex
<pLogEntry
->m_Files
.GetCount(); ++cpPathIndex
)
1576 sPaths
+= ((CTGitPath
&)pLogEntry
->m_Files
[cpPathIndex
]).GetActionName() + _T(" : ") + pLogEntry
->m_Files
[cpPathIndex
].GetGitPathString();
1577 sPaths
+= _T("\r\n");
1580 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"),
1581 (LPCTSTR
)sRev
, pLogEntry
->m_CommitHash
.ToString(),
1582 (LPCTSTR
)sAuthor
, (LPCTSTR
)pLogEntry
->m_AuthorName
,
1584 (LPCTSTR
)CAppUtils::FormatDateAndTime( pLogEntry
->m_AuthorDate
, m_DateFormat
, true, m_bRelativeTimes
),
1585 (LPCTSTR
)sMessage
, pLogEntry
->m_Subject
+_T("\r\n")+pLogEntry
->m_Body
,
1587 sClipdata
+= sLogCopyText
;
1590 sClipdata
+= pLogEntry
->m_CommitHash
;
1595 CStringUtils::WriteAsciiStringToClipboard(sClipdata
, GetSafeHwnd());
1600 void CGitLogListBase::DiffSelectedRevWithPrevious()
1602 if (m_bThreadRunning
)
1605 int FirstSelect
=-1, LastSelect
=-1;
1606 POSITION pos
= GetFirstSelectedItemPosition();
1607 FirstSelect
= GetNextSelectedItem(pos
);
1610 LastSelect
= GetNextSelectedItem(pos
);
1613 ContextMenuAction(ID_COMPAREWITHPREVIOUS
,FirstSelect
,LastSelect
);
1616 UpdateLogInfoLabel();
1617 int selIndex
= m_LogList
.GetSelectionMark();
1620 int selCount
= m_LogList
.GetSelectedCount();
1624 // Find selected entry in the log list
1625 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1626 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(m_LogList
.GetNextSelectedItem(pos
)));
1627 long rev1
= pLogEntry
->Rev
;
1629 CTGitPath path
= m_path
;
1631 // See how many files under the relative root were changed in selected revision
1633 LogChangedPath
* changed
= NULL
;
1634 for (INT_PTR c
= 0; c
< pLogEntry
->pArChangedPaths
->GetCount(); ++c
)
1636 LogChangedPath
* cpath
= pLogEntry
->pArChangedPaths
->GetAt(c
);
1637 if (cpath
&& cpath
-> sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
1644 if (m_path
.IsDirectory() && nChanged
== 1)
1646 // We're looking at the log for a directory and only one file under dir was changed in the revision
1647 // Do diff on that file instead of whole directory
1648 path
.AppendPathString(changed
->sPath
.Mid(m_sRelativeRoot
.GetLength()));
1651 m_bCancelled
= FALSE
;
1652 DialogEnableWindow(IDOK
, FALSE
);
1653 SetPromptApp(&theApp
);
1654 theApp
.DoWaitCursor(1);
1658 GitDiff
diff(this, m_hWnd
, true);
1659 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1660 diff
.SetHEADPeg(m_LogRevision
);
1661 diff
.ShowCompare(path
, rev2
, path
, rev1
);
1665 CAppUtils::StartShowCompare(m_hWnd
, path
, rev2
, path
, rev1
, GitRev(), m_LogRevision
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1668 theApp
.DoWaitCursor(-1);
1673 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1675 LPNMLVFINDITEM pFindInfo
= reinterpret_cast<LPNMLVFINDITEM
>(pNMHDR
);
1678 if (pFindInfo
->lvfi
.flags
& LVFI_PARAM
)
1680 if ((pFindInfo
->iStart
< 0)||(pFindInfo
->iStart
>= m_arShownList
.GetCount()))
1682 if (pFindInfo
->lvfi
.psz
== 0)
1685 CString sCmp
= pFindInfo
->lvfi
.psz
;
1687 for (int i
=pFindInfo
->iStart
; i
<m_arShownList
.GetCount(); ++i
)
1689 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.GetAt(i
));
1690 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
1691 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
1693 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
1701 if (sCmp
.Compare(sRev
)==0)
1708 if (pFindInfo
->lvfi
.flags
& LVFI_WRAP
)
1710 for (int i
=0; i
<pFindInfo
->iStart
; ++i
)
1712 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.GetAt(i
));
1713 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
1714 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
1716 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
1724 if (sCmp
.Compare(sRev
)==0)
1736 int CGitLogListBase::FillGitLog(CTGitPath
*path
,int info
,CString
*from
,CString
*to
)
1740 this->m_logEntries
.ClearAll();
1741 this->m_logEntries
.ParserFromLog(path
,-1,info
,from
,to
);
1743 //this->m_logEntries.ParserFromLog();
1744 SetItemCountEx(this->m_logEntries
.size());
1746 this->m_arShownList
.RemoveAll();
1748 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
1752 m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1).m_IsFull
=TRUE
;
1753 this->m_arShownList
.Add(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
1757 m_logEntries
.GetGitRevAt(i
).m_IsFull
=TRUE
;
1758 this->m_arShownList
.Add(&m_logEntries
.GetGitRevAt(i
));
1768 int CGitLogListBase::BeginFetchLog()
1772 this->m_logEntries
.ClearAll();
1775 this->m_LogCache
.ClearAllParent();
1777 m_LogCache
.FetchCacheIndex(g_Git
.m_CurrentDir
);
1780 if(this->m_Path
.IsEmpty())
1787 mask
= CGit::LOG_INFO_ONLY_HASH
| CGit::LOG_INFO_BOUNDARY
;
1788 // if(this->m_bAllBranch)
1789 mask
|= m_ShowMask
;
1791 this->m_arShownList
.RemoveAll();
1795 this->m_logEntries
.insert(m_logEntries
.begin(),this->m_wcRev
.m_CommitHash
);
1796 this->m_LogCache
.m_HashMap
[m_wcRev
.m_CommitHash
]=m_wcRev
;
1799 CString cmd
=g_Git
.GetLogCmd(m_StartRef
,path
,-1,mask
,NULL
,NULL
,true);
1801 //this->m_logEntries.ParserFromLog();
1802 if(IsInWorkingThread())
1804 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
);
1808 SetItemCountEx(this->m_logEntries
.size());
1813 if(g_Git
.IsInitRepos())
1816 if(git_open_log(&m_DllGitLog
,CUnicodeUtils::GetMulti(cmd
,CP_ACP
).GetBuffer()))
1824 BOOL
CGitLogListBase::PreTranslateMessage(MSG
* pMsg
)
1826 // Skip Ctrl-C when copying text out of the log message or search filter
1827 BOOL bSkipAccelerator
= ( pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW
) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT
) ) && GetKeyState(VK_CONTROL
)&0x8000 );
1828 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
1830 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
1832 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1834 DiffSelectedRevWithPrevious();
1839 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
1848 if (m_hAccel
&& !bSkipAccelerator
)
1850 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
1856 //m_tooltips.RelayEvent(pMsg);
1857 return __super::PreTranslateMessage(pMsg
);
1860 void CGitLogListBase::OnNMDblclkLoglist(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
1862 // a double click on an entry in the revision list has happened
1865 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1866 DiffSelectedRevWithPrevious();
1869 int CGitLogListBase::FetchLogAsync(void * data
)
1872 m_bExitThread
=FALSE
;
1873 InterlockedExchange(&m_bThreadRunning
, TRUE
);
1874 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
1875 m_LoadingThread
= AfxBeginThread(LogThreadEntry
, this);
1876 if (m_LoadingThread
==NULL
)
1878 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1879 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
1880 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
1886 //this is the thread function which calls the subversion function
1887 UINT
CGitLogListBase::LogThreadEntry(LPVOID pVoid
)
1889 return ((CGitLogListBase
*)pVoid
)->LogThread();
1892 void CGitLogListBase::GetTimeRange(CTime
&oldest
, CTime
&latest
)
1895 oldest
=CTime::GetCurrentTime();
1896 latest
=CTime(1971,1,2,0,0,0);
1897 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
1899 if(m_logEntries
[i
].IsEmpty())
1902 if(m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime() < oldest
.GetTime())
1903 oldest
= m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime();
1905 if(m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime() > latest
.GetTime())
1906 latest
= m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime();
1914 //Helper class for FetchFullLogInfo()
1915 class CGitCall_FetchFullLogInfo
: public CGitCall
1918 CGitCall_FetchFullLogInfo(CGitLogListBase
* ploglist
):m_ploglist(ploglist
),m_CollectedCount(0){}
1919 virtual bool OnOutputData(const BYTE
* data
, size_t size
)
1922 return m_ploglist
->m_bExitThread
;
1923 //Add received data to byte collector
1924 m_ByteCollector
.append(data
,size
);
1926 //Find loginfo endmarker
1927 static const BYTE dataToFind
[]={0,0,'#','<'};
1928 int found
=m_ByteCollector
.findData(dataToFind
,4);
1930 return m_ploglist
->m_bExitThread
;//Not found
1931 found
+=2;//Position after loginfo end-marker
1933 //Prepare data for OnLogInfo and call it
1934 BYTE_VECTOR logInfo
;
1935 logInfo
.append(&*m_ByteCollector
.begin(),found
);
1938 //Remove loginfo from bytecollector
1939 m_ByteCollector
.erase(m_ByteCollector
.begin(),m_ByteCollector
.begin()+found
);
1941 return m_ploglist
->m_bExitThread
;
1943 virtual void OnEnd()
1945 //Rest should be a complete log line.
1946 if(!m_ByteCollector
.empty())
1947 OnLogInfo(m_ByteCollector
);
1951 void OnLogInfo(BYTE_VECTOR
& logInfo
)
1954 fullRev
.ParserFromLog(logInfo
);
1955 MAP_HASH_REV::iterator itRev
=m_ploglist
->m_logEntries
.m_HashMap
.find(fullRev
.m_CommitHash
);
1956 if(itRev
==m_ploglist
->m_logEntries
.m_HashMap
.end())
1958 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
1962 int rev
=itRev
->second
;
1963 GitRev
* revInVector
=&m_ploglist
->m_logEntries
.GetGitRevAt(rev
);
1966 if(revInVector
->m_IsFull
)
1969 GitRev
*pRev
= m_ploglist
->m_LogCache
.GetCacheData(m_ploglist
->m_logEntries
[rev
]);
1973 InterlockedExchange(&pRev
->m_IsUpdateing
,FALSE
);
1974 InterlockedExchange(&pRev
->m_IsFull
,TRUE
);
1975 ::PostMessage(m_ploglist
->m_hWnd
,MSG_LOADED
,(WPARAM
)rev
,0);
1979 // fullRev.m_IsUpdateing=TRUE;
1980 // fullRev.m_IsFull=TRUE;
1983 if(InterlockedExchange(&revInVector
->m_IsUpdateing
,TRUE
))
1984 return;//Cannot update this row now. Ignore.
1985 TCHAR oldmark
=revInVector
->m_Mark
;
1986 GIT_REV_LIST oldlist
=revInVector
->m_ParentHash
;
1987 // CString oldhash=m_CommitHash;
1989 //Parse new rev info
1990 revInVector
->ParserFromLog(logInfo
);
1993 revInVector
->m_Mark
=oldmark
; //parser full log will cause old mark overwrited.
1994 //So we need keep old bound mark.
1995 revInVector
->m_ParentHash
=oldlist
;
1998 m_ploglist
->m_LogCache
.AddCacheEntry(*revInVector
);
2001 InterlockedExchange(&revInVector
->m_IsFull
,TRUE
);
2002 InterlockedExchange(&revInVector
->m_IsUpdateing
,FALSE
);
2004 //Notify listcontrol and update progress bar
2007 ::PostMessage(m_ploglist
->m_hWnd
,MSG_LOADED
,(WPARAM
)rev
,0);
2009 DWORD percent
=m_CollectedCount
*68/m_ploglist
->m_logEntries
.size() + GITLOG_START
+1+30;
2010 if(percent
== GITLOG_END
)
2011 percent
= GITLOG_END
-1;
2013 ::PostMessage(m_ploglist
->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
2016 CGitLogListBase
* m_ploglist
;
2017 BYTE_VECTOR m_ByteCollector
;
2018 int m_CollectedCount
;
2022 void CGitLogListBase::FetchFullLogInfo(CString
&from
, CString
&to
)
2024 CGitCall_FetchFullLogInfo
fetcher(this);
2026 CGit::LOG_INFO_FULL_DIFF
|
2027 CGit::LOG_INFO_STAT
|
2028 CGit::LOG_INFO_FILESTATE
|
2029 CGit::LOG_INFO_DETECT_COPYRENAME
|
2030 CGit::LOG_INFO_SHOW_MERGEDFILE
|
2034 if(this->m_Path
.IsEmpty())
2039 g_Git
.GetLog(&fetcher
,CString(),path
,-1,mask
,&from
,&to
);
2042 void CGitLogListBase::FetchLastLogInfo()
2044 unsigned int updated
=0;
2048 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
2050 if(m_logEntries
.GetGitRevAt(i
).m_IsFull
)
2053 GitRev
*pRev
= m_LogCache
.GetCacheData(m_logEntries
[i
]);
2056 if(!m_logEntries
.FetchFullInfo(i
))
2060 m_LogCache
.AddCacheEntry(m_logEntries
.GetGitRevAt(i
));
2065 InterlockedExchange(&pRev
->m_IsUpdateing
,FALSE
);
2066 InterlockedExchange(&pRev
->m_IsFull
,TRUE
);
2069 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)i
,0);
2073 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2074 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2081 UINT
CGitLogListBase::LogThread()
2083 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2085 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2086 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2093 TRACE(_T("\n===Begin===\n"));
2094 //Update work copy item;
2095 if( m_logEntries
.size() > 0)
2097 GitRev
*pRev
= &m_logEntries
.GetGitRevAt(0);
2099 m_arShownList
.Add(pRev
);
2101 if( pRev
->m_CommitHash
.IsEmpty() )
2103 pRev
->m_Files
.Clear();
2104 pRev
->m_ParentHash
.clear();
2105 pRev
->m_ParentHash
.push_back(m_HeadHash
);
2106 if(g_Git
.IsInitRepos())
2108 g_Git
.GetInitAddList(pRev
->m_Files
);
2112 g_Git
.GetCommitDiffList(pRev
->m_CommitHash
.ToString(),this->m_HeadHash
.ToString(), pRev
->m_Files
);
2116 for(int j
=0;j
< pRev
->m_Files
.GetCount();j
++)
2117 pRev
->m_Action
|= pRev
->m_Files
[j
].m_Action
;
2119 pRev
->m_Body
.Format(_T("%d files changed"),m_logEntries
.GetGitRevAt(0).m_Files
.GetCount());
2120 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
2124 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2126 if(!g_Git
.IsInitRepos())
2128 git_get_log_firstcommit(m_DllGitLog
);
2129 int total
= git_get_log_estimate_commit_count(m_DllGitLog
);
2131 t2
=t1
=GetTickCount();
2132 int oldprecentage
= 0;
2133 int oldsize
=m_logEntries
.size();
2134 while( git_get_log_nextcommit(this->m_DllGitLog
,&commit
) == 0)
2136 //printf("%s\r\n",commit.m_Subject);
2140 CGitHash hash
= (char*)commit
.m_hash
;
2142 GitRev
*pRev
= m_LogCache
.GetCacheData(hash
);
2144 if(pRev
== NULL
|| !pRev
->m_IsFull
)
2146 pRev
->ParserFromCommit(&commit
);
2147 pRev
->ParserParentFromCommit(&commit
);
2148 pRev
->SafeFetchFullInfo(&g_Git
);
2152 ASSERT(pRev
->m_CommitHash
== hash
);
2153 pRev
->ParserParentFromCommit(&commit
);
2159 git_free_commit(&commit
);
2161 this->m_critSec
.Lock();
2162 m_logEntries
.push_back(hash
);
2163 m_arShownList
.Add(pRev
);
2164 this->m_critSec
.Unlock();
2168 if(t2
-t1
>500 || (m_logEntries
.size()-oldsize
>100))
2171 int percent
=m_logEntries
.size()*100/total
+ GITLOG_START
+1;
2174 if(percent
< GITLOG_START
)
2175 percent
= GITLOG_START
+1;
2177 oldsize
= m_logEntries
.size();
2178 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2180 //if( percent > oldprecentage )
2182 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
2183 oldprecentage
= percent
;
2191 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2192 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
2194 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2197 // if(m_ProcCallBack)
2198 // m_ProcCallBack(m_ProcData,GITLOG_START);
2199 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2201 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2202 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2204 //does the user force the cache to refresh (shift or control key down)?
2205 bool refresh
= (GetKeyState (VK_CONTROL
) < 0)
2206 || (GetKeyState (VK_SHIFT
) < 0);
2208 //disable the "Get All" button while we're receiving
2213 if(this->m_bExitThread
)
2215 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2216 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2219 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2220 ::PostMessage(GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START_ALL
, 0);
2222 int start
=0; CString firstcommit
,lastcommit
;
2224 for(int i
=0;i
<m_logEntries
.size();i
++)
2226 if( i
==0 && m_logEntries
.GetGitRevAt(i
).m_CommitHash
.IsEmpty() )
2228 m_logEntries
.GetGitRevAt(i
).m_Files
.Clear();
2229 m_logEntries
.GetGitRevAt(i
).m_ParentHash
.clear();
2230 m_logEntries
.GetGitRevAt(i
).m_ParentHash
.push_back(m_HeadHash
);
2231 g_Git
.GetCommitDiffList(m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString(),this->m_HeadHash
,m_logEntries
.GetGitRevAt(i
).m_Files
);
2232 m_logEntries
.GetGitRevAt(i
).m_Action
=0;
2233 for(int j
=0;j
< m_logEntries
.GetGitRevAt(i
).m_Files
.GetCount();j
++)
2234 m_logEntries
.GetGitRevAt(i
).m_Action
|= m_logEntries
.GetGitRevAt(i
).m_Files
[j
].m_Action
;
2236 m_logEntries
.GetGitRevAt(i
).m_Body
.Format(_T("%d files changed"),m_logEntries
.GetGitRevAt(i
).m_Files
.GetCount());
2237 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
2241 start
=this->m_logEntries
.GetGitRevAt(i
).ParserFromLog(m_logEntries
.m_RawlogData
,start
);
2242 m_logEntries
.m_HashMap
[m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString()]=i
;
2244 if(m_LogCache
.GetCacheData(m_logEntries
.GetGitRevAt(i
)))
2246 if(firstcommit
.IsEmpty())
2247 firstcommit
=m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString();
2248 lastcommit
=m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString();
2252 InterlockedExchange(&m_logEntries
.GetGitRevAt(i
).m_IsUpdateing
,FALSE
);
2253 InterlockedExchange(&m_logEntries
.GetGitRevAt(i
).m_IsFull
,TRUE
);
2256 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
) i
, 0);
2260 if(start
>=m_logEntries
.m_RawlogData
.size())
2263 int percent
=i
*30/m_logEntries
.size() + GITLOG_START
+1;
2265 ::PostMessage(GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
, 0);
2267 if(this->m_bExitThread
)
2269 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2270 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2274 if(!lastcommit
.IsEmpty())
2275 FetchFullLogInfo(lastcommit
,firstcommit
);
2277 this->FetchLastLogInfo();
2280 RedrawItems(0, m_arShownList
.GetCount());
2281 // SetRedraw(false);
2282 // ResizeAllListCtrlCols();
2285 if ( m_pStoreSelection
)
2287 // Deleting the instance will restore the
2288 // selection of the CLogDlg.
2289 delete m_pStoreSelection
;
2290 m_pStoreSelection
= NULL
;
2294 // If no selection has been set then this must be the first time
2295 // the revisions are shown. Let's preselect the topmost revision.
2296 if ( GetItemCount()>0 )
2298 SetSelectionMark(0);
2299 SetItemState(0, LVIS_SELECTED
, LVIS_SELECTED
);
2306 //FetchFullLogInfo();
2307 //FetchFullLogInfoOrig();
2309 // make sure the filter is applied (if any) now, after we refreshed/fetched
2312 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
2314 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2319 void CGitLogListBase::Refresh()
2321 SafeTerminateThread();
2323 this->SetItemCountEx(0);
2326 //Update branch and Tag info
2328 //Assume Thread have exited
2329 //if(!m_bThreadRunning)
2332 m_logEntries
.clear();
2333 InterlockedExchange(&m_bExitThread
,FALSE
);
2335 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2336 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2337 if ( (m_LoadingThread
=AfxBeginThread(LogThreadEntry
, this)) ==NULL
)
2339 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2340 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2341 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
2343 m_sFilterText
.Empty();
2344 m_From
=CTime(1970,1,2,0,0,0);
2345 m_To
=CTime::GetCurrentTime();
2348 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str
, tr1::wregex
& pat
, bool bMatchCase
/* = false */)
2352 tr1::regex_constants::syntax_option_type type
= tr1::regex_constants::ECMAScript
;
2354 type
|= tr1::regex_constants::icase
;
2355 pat
= tr1::wregex(regexp_str
, type
);
2358 catch (exception
) {}
2362 void CGitLogListBase::RecalculateShownList(CPtrArray
* pShownlist
)
2365 pShownlist
->RemoveAll();
2366 tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
2367 bool bRegex
= false;
2368 if (m_bFilterWithRegex
)
2369 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
2371 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_any
;
2373 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
2375 if ((bRegex
)&&(m_bFilterWithRegex
))
2378 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
2380 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR
)m_logEntries
[i
]->sBugIDs
);
2381 if (regex_search(wstring((LPCTSTR
)m_logEntries
[i
]->sBugIDs
), pat
, flags
)&&IsEntryInDateRange(i
))
2383 pShownlist
->Add(m_logEntries
[i
]);
2388 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_MESSAGES
))
2390 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).m_Subject
);
2391 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).m_Subject
), pat
, flags
)&&IsEntryInDateRange(i
))
2393 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2397 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).m_Body
);
2398 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).m_Body
), pat
, flags
)&&IsEntryInDateRange(i
))
2400 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2405 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_PATHS
))
2407 LogChangedPathArray
* cpatharray
= m_logEntries
[i
]->pArChangedPaths
;
2410 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount() && bGoing
; ++cpPathIndex
)
2412 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
2413 if (regex_search(wstring((LPCTSTR
)cpath
->sCopyFromPath
), pat
, flags
)&&IsEntryInDateRange(i
))
2415 pShownlist
->Add(m_logEntries
[i
]);
2419 if (regex_search(wstring((LPCTSTR
)cpath
->sPath
), pat
, flags
)&&IsEntryInDateRange(i
))
2421 pShownlist
->Add(m_logEntries
[i
]);
2425 if (regex_search(wstring((LPCTSTR
)cpath
->GetAction()), pat
, flags
)&&IsEntryInDateRange(i
))
2427 pShownlist
->Add(m_logEntries
[i
]);
2436 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_AUTHORS
))
2438 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).m_AuthorName
), pat
, flags
)&&IsEntryInDateRange(i
))
2440 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2444 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_REVS
))
2446 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
2447 if (regex_search(wstring((LPCTSTR
)sRev
), pat
, flags
)&&IsEntryInDateRange(i
))
2449 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2456 CString find
= m_sFilterText
;
2459 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
2461 CString sBugIDs
= m_logEntries
[i
]->sBugIDs
;
2463 sBugIDs
= sBugIDs
.MakeLower();
2464 if ((sBugIDs
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2466 pShownlist
->Add(m_logEntries
[i
]);
2471 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_MESSAGES
))
2473 CString msg
= m_logEntries
.GetGitRevAt(i
).m_Subject
;
2475 msg
= msg
.MakeLower();
2476 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2478 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2481 msg
= m_logEntries
.GetGitRevAt(i
).m_Body
;
2483 msg
= msg
.MakeLower();
2484 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2486 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2491 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_PATHS
))
2493 LogChangedPathArray
* cpatharray
= m_logEntries
[i
]->pArChangedPaths
;
2496 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount() && bGoing
; ++cpPathIndex
)
2498 LogChangedPath
* cpath
= cpatharray
->GetAt(cpPathIndex
);
2499 CString path
= cpath
->sCopyFromPath
;
2501 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
2503 pShownlist
->Add(m_logEntries
[i
]);
2507 path
= cpath
->sPath
;
2509 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
2511 pShownlist
->Add(m_logEntries
[i
]);
2515 path
= cpath
->GetAction();
2517 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
2519 pShownlist
->Add(m_logEntries
[i
]);
2526 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_AUTHORS
))
2528 CString msg
= m_logEntries
.GetGitRevAt(i
).m_AuthorName
;
2529 msg
= msg
.MakeLower();
2530 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2532 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2536 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_REVS
))
2538 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
2539 if ((sRev
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2541 pShownlist
->Add(&m_logEntries
.GetGitRevAt(i
));
2545 } // else (from if (bRegex))
2546 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
2550 BOOL
CGitLogListBase::IsEntryInDateRange(int i
)
2552 __time64_t time
= m_logEntries
.GetGitRevAt(i
).m_AuthorDate
.GetTime();
2553 if ((time
>= m_From
.GetTime())&&(time
<= m_To
.GetTime()))
2560 void CGitLogListBase::StartFilter()
2562 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2563 RecalculateShownList(&m_arShownList
);
2564 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2568 SetItemCountEx(ShownCountWithStopped());
2569 RedrawItems(0, ShownCountWithStopped());
2571 //ResizeAllListCtrlCols();
2576 void CGitLogListBase::RemoveFilter()
2579 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2581 m_arShownList
.RemoveAll();
2583 // reset the time filter too
2585 m_timFrom
= (__time64_t(m_tFrom
));
2586 m_timTo
= (__time64_t(m_tTo
));
2587 m_DateFrom
.SetTime(&m_timFrom
);
2588 m_DateTo
.SetTime(&m_timTo
);
2589 m_DateFrom
.SetRange(&m_timFrom
, &m_timTo
);
2590 m_DateTo
.SetRange(&m_timFrom
, &m_timTo
);
2593 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
2595 if(this->m_IsOldFirst
)
2597 m_arShownList
.Add(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
2600 m_arShownList
.Add(&m_logEntries
.GetGitRevAt(i
));
2603 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
2605 SetItemCountEx(ShownCountWithStopped());
2606 RedrawItems(0, ShownCountWithStopped());
2607 // SetRedraw(false);
2608 // ResizeAllListCtrlCols();
2611 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2614 void CGitLogListBase::Clear()
2616 m_arShownList
.RemoveAll();
2619 m_logEntries
.ClearAll();
2623 void CGitLogListBase::OnDestroy()
2625 // save the column widths to the registry
2628 SafeTerminateThread();
2630 while(m_LogCache
.SaveCache())
2632 if(CMessageBox::Show(NULL
,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
2636 CHintListCtrl::OnDestroy();
2639 LRESULT
CGitLogListBase::OnLoad(WPARAM wParam
,LPARAM lParam
)
2643 this->GetItemRect(i
,&rect
,LVIR_BOUNDS
);
2644 this->InvalidateRect(rect
);
2646 if(this->GetItemState(i
,LVIF_STATE
) & LVIS_SELECTED
)
2654 * Save column widths to the registry
2656 void CGitLogListBase::SaveColumnWidths()
2658 CHeaderCtrl
* pHdrCtrl
= (CHeaderCtrl
*)(GetDlgItem(0));
2661 int numcols
= pHdrCtrl
->GetItemCount();
2662 for (int col
= 0; col
< numcols
; col
++)
2664 int width
= GetColumnWidth( col
);
2666 regentry
.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey
, col
);
2667 CRegDWORD
regwidth(regentry
, 0);
2668 regwidth
= width
; // this writes it to reg
2673 int CGitLogListBase::GetHeadIndex()
2675 if(m_HeadHash
.IsEmpty())
2678 for(int i
=0;i
<m_arShownList
.GetCount();i
++)
2680 GitRev
*pRev
= (GitRev
*)m_arShownList
[i
];
2683 if(pRev
->m_CommitHash
.ToString() == m_HeadHash
)
2689 void CGitLogListBase::OnFind()
2693 m_pFindDialog
= new CFindReplaceDialog();
2694 m_pFindDialog
->Create(TRUE
, NULL
, NULL
, FR_HIDEUPDOWN
| FR_HIDEWHOLEWORD
, this);
2698 LRESULT
CGitLogListBase::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2701 ASSERT(m_pFindDialog
!= NULL
);
2703 if (m_pFindDialog
->IsTerminating())
2705 // invalidate the handle identifying the dialog box.
2706 m_pFindDialog
= NULL
;
2710 if(m_pFindDialog
->FindNext())
2712 //read data from dialog
2713 CString FindText
= m_pFindDialog
->GetFindString();
2714 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
2715 bool bFound
= false;
2717 bool bRegex
= ValidateRegexp(FindText
, pat
, bMatchCase
);
2719 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_not_null
;
2722 for (i
= this->m_nSearchIndex
; i
<m_arShownList
.GetCount()&&!bFound
; i
++)
2724 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.GetAt(i
);
2727 str
+=pLogEntry
->m_CommitHash
.ToString();
2730 for(int j
=0;j
<this->m_HashMap
[pLogEntry
->m_CommitHash
].size();j
++)
2732 str
+=m_HashMap
[pLogEntry
->m_CommitHash
][j
];
2736 str
+=pLogEntry
->m_AuthorEmail
;
2738 str
+=pLogEntry
->m_AuthorName
;
2740 str
+=pLogEntry
->m_Body
;
2742 str
+=pLogEntry
->m_CommitterEmail
;
2744 str
+=pLogEntry
->m_CommitterName
;
2746 str
+=pLogEntry
->m_Subject
;
2749 for(int i
=0;i
<pLogEntry
->m_Files
.GetCount();i
++)
2751 str
+=pLogEntry
->m_Files
[i
].GetWinPath();
2753 str
+=pLogEntry
->m_Files
[i
].GetGitOldPathString();
2760 if (regex_search(wstring(str
), pat
, flags
))
2770 if (str
.Find(FindText
) >= 0)
2780 msg
= msg
.MakeLower();
2781 CString find
= FindText
.MakeLower();
2782 if (msg
.Find(find
) >= 0)
2789 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
2792 this->m_nSearchIndex
= i
;
2793 EnsureVisible(i
, FALSE
);
2794 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED
);
2795 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2796 SetSelectionMark(i
);
2797 //FillLogMessageCtrl();
2800 if (m_nSearchIndex
>= m_arShownList
.GetCount())
2801 m_nSearchIndex
= (int)m_arShownList
.GetCount()-1;
2803 } // if(m_pFindDialog->FindNext())
2804 //UpdateLogInfoLabel();