Improve log speed.
[TortoiseGit.git] / src / TortoiseProc / LogDlgHelper.h
blob945f8d48a09ed84a956a468da048062218cafc44
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include "Git.h"
21 #include "GitRev.h"
22 #include "GitStatus.h"
23 #include "ILogReceiver.h"
24 #include "lanes.h"
25 #include <set>
27 class CLogDlg;
29 /**
30 * \ingroup TortoiseProc
31 * Instances of CStoreSelection save the selection of the CLogDlg. When the instance
32 * is deleted the destructor restores the selection.
34 typedef std::map<CString, int> MAP_HASH_REV;
36 class CStoreSelection
38 public:
39 CStoreSelection(CLogDlg* dlg);
40 ~CStoreSelection();
41 protected:
42 CLogDlg* m_logdlg;
43 std::set<LONG> m_SetSelectedRevisions;
47 /**
48 * \ingroup TortoiseProc
49 * Helper class for the log dialog, handles all the log entries, including
50 * sorting.
52 class CLogDataVector : public std::vector<GitRev>
54 public:
55 /// De-allocates log items.
56 CLogDataVector()
58 m_FirstFreeLane=0;
60 void ClearAll();
61 int ParserFromLog(CTGitPath *path =NULL,int count = -1,int infomask=CGit::LOG_INFO_STAT|CGit::LOG_INFO_FILESTATE,
62 CString *from=NULL,CString *to=NULL);
64 int FetchShortLog(CTGitPath *path , CString &hash,int count=-1 ,int mask=CGit::LOG_INFO_ONLY_HASH );
65 int ParserShortLog(CTGitPath *path ,CString &hash,int count=-1 ,int mask=CGit::LOG_INFO_ONLY_HASH );
67 int ParserFromRefLog(CString ref);
69 int FetchFullInfo(int i);
70 // void AddFullInfo(
72 Lanes m_Lns;
73 int m_FirstFreeLane;
74 MAP_HASH_REV m_HashMap;
75 void updateLanes(GitRev& c, Lanes& lns, CString &sha) ;
76 void setLane(CString& sha) ;
78 BYTE_VECTOR m_RawlogData;
79 std::vector<int> m_RawLogStart;
81 #if 0
82 /// Ascending date sorting.
83 struct AscDateSort
85 bool operator()(GitRev& pStart, GitRev& pEnd)
87 return pStart->tmDate < pEnd->tmDate;
90 /// Descending date sorting.
91 struct DescDateSort
93 bool operator()(GitRev& pStart, GitRev& pEnd)
95 return pStart->tmDate > pEnd->tmDate;
98 /// Ascending revision sorting.
99 struct AscRevSort
101 bool operator()(GitRev& pStart, GitRev& pEnd)
103 return pStart->Rev < pEnd->Rev;
106 /// Descending revision sorting.
107 struct DescRevSort
109 bool operator()(GitRev& pStart, GitRev& pEnd)
111 return pStart->Rev > pEnd->Rev;
114 /// Ascending author sorting.
115 struct AscAuthorSort
117 bool operator()(GitRev& pStart, GitRev& pEnd)
119 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
120 if (ret == 0)
121 return pStart->Rev < pEnd->Rev;
122 return ret<0;
125 /// Descending author sorting.
126 struct DescAuthorSort
128 bool operator()(GitRev& pStart, GitRev& pEnd)
130 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
131 if (ret == 0)
132 return pStart->Rev > pEnd->Rev;
133 return ret>0;
136 /// Ascending bugID sorting.
137 struct AscBugIDSort
139 bool operator()(GitRev& pStart, GitRev& pEnd)
141 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
142 if (ret == 0)
143 return pStart->Rev < pEnd->Rev;
144 return ret<0;
147 /// Descending bugID sorting.
148 struct DescBugIDSort
150 bool operator()(GitRev& pStart, GitRev& pEnd)
152 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
153 if (ret == 0)
154 return pStart->Rev > pEnd->Rev;
155 return ret>0;
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
175 struct AscActionSort
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;
194 #endif