1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
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.
20 Description: start-up repository opening and reading
22 Author: Marco Costalba (C) 2005-2007
24 Copyright: See COPYING file that comes with this distribution
29 #include "TortoiseProc.h"
30 #include "GitLogList.h"
32 //#include "VssStyle.h"
38 #include "SVNProgressDlg.h"
39 #include "ProgressDlg.h"
40 //#include "RepositoryBrowser.h"
41 //#include "CopyDlg.h"
42 //#include "StatGraphDlg.h"
44 #include "MessageBox.h"
47 #include "PathUtils.h"
48 #include "StringUtils.h"
49 #include "UnicodeUtils.h"
51 //#include "GitInfo.h"
52 //#include "GitDiff.h"
54 //#include "RevisionRangeDlg.h"
55 //#include "BrowseFolder.h"
56 //#include "BlameDlg.h"
58 //#include "GitHelpers.h"
59 #include "GitStatus.h"
60 //#include "LogDlgHelper.h"
61 //#include "CachedLogInfo.h"
62 //#include "RepositoryInfo.h"
63 //#include "EditPropertiesDlg.h"
64 #include "FileDiffDlg.h"
66 int CLogDataVector::ParserShortLog()
72 begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
74 g_Git.GetShortLog(log);
75 if(log.GetLength()==0)
83 next=log.Find(begin,start);
85 length = next - start+4;
87 length = log.GetLength()-start+4;
90 onelog=log.Mid(start -4,length);
91 rev.ParserFromLog(onelog);
92 rev.m_Subject=_T("Load .................................");
94 m_HashMap[rev.m_CommitHash]=size()-1;
102 int CLogDataVector::FetchFullInfo(int i)
104 return at(i).SafeFetchFullInfo(&g_Git);
106 //CLogDataVector Class
107 int CLogDataVector::ParserFromLog()
112 g_Git.GetLog(log,emptyhash);
115 begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
117 if(log.GetLength()==0)
125 next=log.Find(begin,start);
127 length = next - start+4;
129 length = log.GetLength()-start+4;
132 onelog=log.Mid(start -4,length);
133 rev.ParserFromLog(onelog);
134 this->push_back(rev);
135 m_HashMap[rev.m_CommitHash]=size()-1;
142 void CLogDataVector::setLane(CString& sha)
144 Lanes* l = &(this->m_Lanes);
145 int i = m_FirstFreeLane;
147 // QVector<QByteArray> ba;
148 // const ShaString& ss = toPersistentSha(sha, ba);
149 // const ShaVect& shaVec(fh->revOrder);
151 for (int cnt = size(); i < cnt; ++i) {
153 GitRev* r = &(*this)[i];
154 CString &curSha=r->m_CommitHash;
156 if (r->m_Lanes.size() == 0)
157 updateLanes(*r, *l, curSha);
162 m_FirstFreeLane = ++i;
165 Lanes* l = &(this->m_Lanes);
166 int i = m_FirstFreeLane;
168 QVector<QByteArray> ba;
169 const ShaString& ss = toPersistentSha(sha, ba);
170 const ShaVect& shaVec(fh->revOrder);
172 for (uint cnt = shaVec.count(); i < cnt; ++i) {
174 const ShaString& curSha = shaVec[i];
175 Rev* r = m_HashMap[curSha]const_cast<Rev*>(revLookup(curSha, fh));
176 if (r->lanes.count() == 0)
177 updateLanes(*r, *l, curSha);
182 fh->firstFreeLane = ++i;
187 void CLogDataVector::updateLanes(GitRev& c, Lanes& lns, CString &sha)
189 // we could get third argument from c.sha(), but we are in fast path here
190 // and c.sha() involves a deep copy, so we accept a little redundancy
195 bool isDiscontinuity;
196 bool isFork = lns.isFork(sha, isDiscontinuity);
197 bool isMerge = (c.ParentsCount() > 1);
198 bool isInitial = (c.ParentsCount() == 0);
201 lns.changeActiveLane(sha); // uses previous isBoundary state
203 lns.setBoundary(0/*c.isBoundary()*/); // update must be here
208 lns.setMerge(c.m_ParentHash);
214 lns.getLanes(c.m_Lanes); // here lanes are snapshotted
216 CString nextSha = (isInitial) ? CString(_T("")) : QString(c.m_ParentHash[0]);
218 lns.nextParent(nextSha);
221 // lns.afterApplied();
229 // QString tmp = "", tmp2;
230 // for (uint i = 0; i < c.lanes.count(); i++) {
231 // tmp2.setNum(c.lanes[i]);
232 // tmp.append(tmp2 + "-");
234 // qDebug("%s %s",tmp.latin1(), c.sha.latin1());