Add support for "project" config level
[TortoiseGit.git] / src / TortoiseProc / LogDlgHelper.h
blob315ecedfbdc92dece24462f70c9ae2ee9ec3603b
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseSVN
4 // Copyright (C) 2008-2013 - 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.
20 #pragma once
21 #include "Git.h"
22 #include "GitRev.h"
23 #include "GitStatus.h"
24 #include "ILogReceiver.h"
25 #include "lanes.h"
26 #include <set>
27 #include "GitHash.h"
28 #include "GitLogCache.h"
29 class CLogDlg;
31 /**
32 * \ingroup TortoiseProc
33 * Instances of CStoreSelection save the selection of the CLogDlg. When the instance
34 * is deleted the destructor restores the selection.
36 typedef std::map<CGitHash, int> MAP_HASH_REV;
38 class CStoreSelection
40 public:
41 CStoreSelection(CLogDlg* dlg);
42 ~CStoreSelection();
43 protected:
44 CLogDlg* m_logdlg;
45 std::set<LONG> m_SetSelectedRevisions;
49 /**
50 * \ingroup TortoiseProc
51 * Helper class for the log dialog, handles all the log entries, including
52 * sorting.
54 class CLogDataVector : public std::vector<CGitHash>
56 public:
57 CLogCache *m_pLogCache;
58 /// De-allocates log items.
59 CLogDataVector(CLogCache *pLogCache)
61 m_pLogCache=pLogCache;
62 m_FirstFreeLane=0;
64 CLogDataVector()
66 m_pLogCache=NULL;
67 m_FirstFreeLane=0;
69 void SetLogCache(CLogCache *pLogCache)
71 m_pLogCache = pLogCache;
73 GitRev & GetGitRevAt(size_t i)
75 ASSERT(i<size());
76 return m_pLogCache->m_HashMap[(*this)[i]];
78 void ClearAll();
79 int ParserFromLog(CTGitPath *path =NULL, int count = -1, int infomask = CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, CString *range = NULL);
81 int FetchShortLog(CTGitPath *path , CString &hash,int count=-1 ,int mask=CGit::LOG_INFO_ONLY_HASH, int showWC=0 );
82 int ParserShortLog(CTGitPath *path ,CString &hash,int count=-1 ,int mask=CGit::LOG_INFO_ONLY_HASH );
84 int ParserFromRefLog(CString ref);
86 int FetchFullInfo(int i);
87 // void AddFullInfo(
89 Lanes m_Lns;
90 int m_FirstFreeLane;
91 MAP_HASH_REV m_HashMap;
92 void updateLanes(GitRev& c, Lanes& lns, CGitHash &sha) ;
93 void setLane(CGitHash& sha) ;
95 BYTE_VECTOR m_RawlogData;
96 std::vector<int> m_RawLogStart;
98 #if 0
99 /// Ascending date sorting.
100 struct AscDateSort
102 bool operator()(GitRev& pStart, GitRev& pEnd)
104 return pStart->tmDate < pEnd->tmDate;
107 /// Descending date sorting.
108 struct DescDateSort
110 bool operator()(GitRev& pStart, GitRev& pEnd)
112 return pStart->tmDate > pEnd->tmDate;
115 /// Ascending revision sorting.
116 struct AscRevSort
118 bool operator()(GitRev& pStart, GitRev& pEnd)
120 return pStart->Rev < pEnd->Rev;
123 /// Descending revision sorting.
124 struct DescRevSort
126 bool operator()(GitRev& pStart, GitRev& pEnd)
128 return pStart->Rev > pEnd->Rev;
131 /// Ascending author sorting.
132 struct AscAuthorSort
134 bool operator()(GitRev& pStart, GitRev& pEnd)
136 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
137 if (ret == 0)
138 return pStart->Rev < pEnd->Rev;
139 return ret<0;
142 /// Descending author sorting.
143 struct DescAuthorSort
145 bool operator()(GitRev& pStart, GitRev& pEnd)
147 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
148 if (ret == 0)
149 return pStart->Rev > pEnd->Rev;
150 return ret>0;
153 /// Ascending bugID sorting.
154 struct AscBugIDSort
156 bool operator()(GitRev& pStart, GitRev& pEnd)
158 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
159 if (ret == 0)
160 return pStart->Rev < pEnd->Rev;
161 return ret<0;
164 /// Descending bugID sorting.
165 struct DescBugIDSort
167 bool operator()(GitRev& pStart, GitRev& pEnd)
169 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
170 if (ret == 0)
171 return pStart->Rev > pEnd->Rev;
172 return ret>0;
175 /// Ascending message sorting.
176 struct AscMessageSort
178 bool operator()(GitRev& pStart, GitRev& pEnd)
180 return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)<0;
183 /// Descending message sorting.
184 struct DescMessageSort
186 bool operator()(GitRev& pStart, GitRev& pEnd)
188 return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)>0;
191 /// Ascending action sorting
192 struct AscActionSort
194 bool operator() (GitRev& pStart, GitRev& pEnd)
196 if (pStart->actions == pEnd->actions)
197 return pStart->Rev < pEnd->Rev;
198 return pStart->actions < pEnd->actions;
201 /// Descending action sorting
202 struct DescActionSort
204 bool operator() (GitRev& pStart, GitRev& pEnd)
206 if (pStart->actions == pEnd->actions)
207 return pStart->Rev > pEnd->Rev;
208 return pStart->actions > pEnd->actions;
211 #endif