1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 Description: start-up repository opening and reading
\r
22 Author: Marco Costalba (C) 2005-2007
\r
24 Copyright: See COPYING file that comes with this distribution
\r
29 #include "TortoiseProc.h"
\r
30 #include "GitLogListBase.h"
\r
32 //#include "VssStyle.h"
\r
33 #include "IconMenu.h"
\r
36 #include "InputDlg.h"
\r
37 #include "PropDlg.h"
\r
38 #include "SVNProgressDlg.h"
\r
39 #include "ProgressDlg.h"
\r
40 //#include "RepositoryBrowser.h"
\r
41 //#include "CopyDlg.h"
\r
42 //#include "StatGraphDlg.h"
\r
44 #include "MessageBox.h"
\r
45 #include "Registry.h"
\r
46 #include "AppUtils.h"
\r
47 #include "PathUtils.h"
\r
48 #include "StringUtils.h"
\r
49 #include "UnicodeUtils.h"
\r
50 #include "TempFile.h"
\r
51 //#include "GitInfo.h"
\r
52 //#include "GitDiff.h"
\r
53 #include "IconMenu.h"
\r
54 //#include "RevisionRangeDlg.h"
\r
55 //#include "BrowseFolder.h"
\r
56 //#include "BlameDlg.h"
\r
57 //#include "Blame.h"
\r
58 //#include "GitHelpers.h"
\r
59 #include "GitStatus.h"
\r
60 //#include "LogDlgHelper.h"
\r
61 //#include "CachedLogInfo.h"
\r
62 //#include "RepositoryInfo.h"
\r
63 //#include "EditPropertiesDlg.h"
\r
64 #include "FileDiffDlg.h"
\r
66 void CLogDataVector::ClearAll()
\r
76 m_RawlogData.clear();
\r
77 m_RawLogStart.clear();
\r
80 int CLogDataVector::ParserShortLog(CTGitPath *path ,CString &hash,int count ,int mask )
\r
85 if(g_Git.IsInitRepos())
\r
89 begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
\r
91 //g_Git.GetShortLog(log,path,count);
\r
93 g_Git.GetLog(log,hash,path,count,mask);
\r
101 while( next>=0 && next<log.size())
\r
103 next=rev.ParserFromLog(log,next);
\r
105 rev.m_Subject=_T("Load .................................");
\r
106 this->push_back(rev);
\r
107 m_HashMap[rev.m_CommitHash]=size()-1;
\r
109 //next=log.find(0,next);
\r
115 int CLogDataVector::FetchShortLog(CTGitPath *path ,CString &hash,int count ,int mask )
\r
118 m_RawlogData.clear();
\r
119 m_RawLogStart.clear();
\r
123 if(g_Git.IsInitRepos())
\r
127 begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
\r
129 //g_Git.GetShortLog(log,path,count);
\r
132 g_Git.GetLog(m_RawlogData, hash,path,count,mask);
\r
135 TRACE(_T("GetLog Time %ld\r\n"),t2-t1);
\r
137 if(m_RawlogData.size()==0)
\r
146 while( next>=0 && next<m_RawlogData.size())
\r
148 static const BYTE dataToFind[]={0,0};
\r
149 m_RawLogStart.push_back(next);
\r
150 //this->at(i).m_Subject=_T("parser...");
\r
151 next=m_RawlogData.findData(dataToFind,2,next+1);
\r
152 //next=log.find(0,next);
\r
155 resize(m_RawLogStart.size());
\r
161 int CLogDataVector::FetchFullInfo(int i)
\r
163 return at(i).SafeFetchFullInfo(&g_Git);
\r
165 //CLogDataVector Class
\r
166 int CLogDataVector::ParserFromLog(CTGitPath *path ,int count ,int infomask,CString *from,CString *to)
\r
171 g_Git.GetLog(log,emptyhash,path,count,infomask,from,to);
\r
174 begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
\r
184 next=rev.ParserFromLog(log,next);
\r
185 this->push_back(rev);
\r
186 m_HashMap[rev.m_CommitHash]=size()-1;
\r
192 int CLogDataVector::ParserFromRefLog(CString ref)
\r
196 cmd.Format(_T("git.exe reflog show %s"),ref);
\r
197 if(g_Git.Run(cmd,&out,CP_UTF8))
\r
203 CString one=out.Tokenize(_T("\n"),pos);
\r
204 int ref=one.Find(_T(' '),0);
\r
208 rev.m_CommitHash=one.Left(ref);
\r
209 int action=one.Find(_T(' '),ref+1);
\r
213 rev.m_Ref=one.Mid(ref+1,action-ref-2);
\r
214 message=one.Find(_T(":"),action);
\r
217 rev.m_RefAction=one.Mid(action+1,message-action-1);
\r
218 rev.m_Subject=one.Right(one.GetLength()-message-1);
\r
221 this->push_back(rev);
\r
226 void CLogDataVector::setLane(CString& sha)
\r
228 Lanes* l = &(this->m_Lns);
\r
229 int i = m_FirstFreeLane;
\r
231 // QVector<QByteArray> ba;
\r
232 // const ShaString& ss = toPersistentSha(sha, ba);
\r
233 // const ShaVect& shaVec(fh->revOrder);
\r
235 for (int cnt = size(); i < cnt; ++i) {
\r
237 GitRev* r = &(*this)[i];
\r
238 CString &curSha=r->m_CommitHash;
\r
240 if (r->m_Lanes.size() == 0)
\r
241 updateLanes(*r, *l, curSha);
\r
246 m_FirstFreeLane = ++i;
\r
249 Lanes* l = &(this->m_Lanes);
\r
250 int i = m_FirstFreeLane;
\r
252 QVector<QByteArray> ba;
\r
253 const ShaString& ss = toPersistentSha(sha, ba);
\r
254 const ShaVect& shaVec(fh->revOrder);
\r
256 for (uint cnt = shaVec.count(); i < cnt; ++i) {
\r
258 const ShaString& curSha = shaVec[i];
\r
259 Rev* r = m_HashMap[curSha]const_cast<Rev*>(revLookup(curSha, fh));
\r
260 if (r->lanes.count() == 0)
\r
261 updateLanes(*r, *l, curSha);
\r
266 fh->firstFreeLane = ++i;
\r
271 void CLogDataVector::updateLanes(GitRev& c, Lanes& lns, CString &sha)
\r
273 // we could get third argument from c.sha(), but we are in fast path here
\r
274 // and c.sha() involves a deep copy, so we accept a little redundancy
\r
279 bool isDiscontinuity;
\r
280 bool isFork = lns.isFork(sha, isDiscontinuity);
\r
281 bool isMerge = (c.ParentsCount() > 1);
\r
282 bool isInitial = (c.ParentsCount() == 0);
\r
284 if (isDiscontinuity)
\r
285 lns.changeActiveLane(sha); // uses previous isBoundary state
\r
287 lns.setBoundary(c.IsBoundary() == TRUE); // update must be here
\r
288 TRACE(_T("%s %d"),c.m_CommitHash,c.IsBoundary());
\r
293 lns.setMerge(c.m_ParentHash);
\r
295 // lns.setApplied();
\r
299 lns.getLanes(c.m_Lanes); // here lanes are snapshotted
\r
301 CString nextSha = (isInitial) ? CString(_T("")) : QString(c.m_ParentHash[0]);
\r
303 lns.nextParent(nextSha);
\r
306 // lns.afterApplied();
\r
311 if (lns.isBranch())
\r
314 // QString tmp = "", tmp2;
\r
315 // for (uint i = 0; i < c.lanes.count(); i++) {
\r
316 // tmp2.setNum(c.lanes[i]);
\r
317 // tmp.append(tmp2 + "-");
\r
319 // qDebug("%s %s",tmp.latin1(), c.sha.latin1());
\r