1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseSVN
4 // Copyright (C) 2008-2016 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "GitLogCache.h"
27 * \ingroup TortoiseProc
28 * Instances of CStoreSelection save the selection of the CLogDlg. When the instance
29 * is deleted the destructor restores the selection.
31 typedef std::map
<CGitHash
, int> MAP_HASH_REV
;
34 * \ingroup TortoiseProc
35 * Helper class for the log dialog, handles all the log entries, including
38 class CLogDataVector
: public std::vector
<CGitHash
>
41 CLogCache
*m_pLogCache
;
42 /// De-allocates log items.
43 CLogDataVector(CLogCache
*pLogCache
)
45 m_pLogCache
=pLogCache
;
47 // Default to value set in Registry
48 m_logOrderBy
= CRegDWORD(L
"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER
);
52 m_pLogCache
= nullptr;
54 // Default to value set in Registry
55 m_logOrderBy
= CRegDWORD(L
"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER
);
57 void SetLogCache(CLogCache
*pLogCache
)
59 m_pLogCache
= pLogCache
;
61 GitRevLoglist
& GetGitRevAt(size_t i
)
64 return m_pLogCache
->m_HashMap
[(*this)[i
]];
67 int ParserFromLog(CTGitPath
* path
= nullptr, DWORD count
= 0, DWORD infomask
= CGit::LOG_INFO_STAT
| CGit::LOG_INFO_FILESTATE
| CGit::LOG_INFO_SHOW_MERGEDFILE
, CString
* range
= nullptr);
68 int Fill(std::set
<CGitHash
>& hashes
);
70 int FetchFullInfo(int i
);
74 // Log order: LOG_ORDER_CHRONOLOGIALREVERSED, LOG_ORDER_TOPOORDER, LOG_ORDER_DATEORDER
76 MAP_HASH_REV m_HashMap
;
77 void updateLanes(GitRevLoglist
& c
, Lanes
& lns
, CGitHash
& sha
);
78 void setLane(CGitHash
& sha
) ;
79 void append(CGitHash
& sha
, bool storeInVector
);
82 /// Ascending date sorting.
85 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
87 return pStart
->tmDate
< pEnd
->tmDate
;
90 /// Descending date sorting.
93 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
95 return pStart
->tmDate
> pEnd
->tmDate
;
98 /// Ascending revision sorting.
101 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
103 return pStart
->Rev
< pEnd
->Rev
;
106 /// Descending revision sorting.
109 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
111 return pStart
->Rev
> pEnd
->Rev
;
114 /// Ascending author sorting.
117 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
119 int ret
= pStart
->sAuthor
.CompareNoCase(pEnd
->sAuthor
);
121 return pStart
->Rev
< pEnd
->Rev
;
125 /// Descending author sorting.
126 struct DescAuthorSort
128 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
130 int ret
= pStart
->sAuthor
.CompareNoCase(pEnd
->sAuthor
);
132 return pStart
->Rev
> pEnd
->Rev
;
136 /// Ascending bugID sorting.
139 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
141 int ret
= pStart
->sBugIDs
.CompareNoCase(pEnd
->sBugIDs
);
143 return pStart
->Rev
< pEnd
->Rev
;
147 /// Descending bugID sorting.
150 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
152 int ret
= pStart
->sBugIDs
.CompareNoCase(pEnd
->sBugIDs
);
154 return pStart
->Rev
> pEnd
->Rev
;
158 /// Ascending message sorting.
159 struct AscMessageSort
161 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
163 return pStart
->sShortMessage
.CompareNoCase(pEnd
->sShortMessage
)<0;
166 /// Descending message sorting.
167 struct DescMessageSort
169 bool operator()(GitRev
& pStart
, GitRev
& pEnd
)
171 return pStart
->sShortMessage
.CompareNoCase(pEnd
->sShortMessage
)>0;
174 /// Ascending action sorting
177 bool operator() (GitRev
& pStart
, GitRev
& pEnd
)
179 if (pStart
->actions
== pEnd
->actions
)
180 return pStart
->Rev
< pEnd
->Rev
;
181 return pStart
->actions
< pEnd
->actions
;
184 /// Descending action sorting
185 struct DescActionSort
187 bool operator() (GitRev
& pStart
, GitRev
& pEnd
)
189 if (pStart
->actions
== pEnd
->actions
)
190 return pStart
->Rev
> pEnd
->Rev
;
191 return pStart
->actions
> pEnd
->actions
;