OSDN Git Service

Add Version Graph Tree Code but there are some problem
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / LogDataVector.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control
2
3 // Copyright (C) 2007-2008 - TortoiseSVN
4
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.
9
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.
14
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.
18 //
19 /*
20         Description: start-up repository opening and reading
21
22         Author: Marco Costalba (C) 2005-2007
23
24         Copyright: See COPYING file that comes with this distribution
25
26 */
27
28 #include "stdafx.h"
29 #include "TortoiseProc.h"
30 #include "GitLogList.h"
31 #include "GitRev.h"
32 //#include "VssStyle.h"
33 #include "IconMenu.h"
34 // CGitLogList
35 #include "cursor.h"
36 #include "InputDlg.h"
37 #include "PropDlg.h"
38 #include "SVNProgressDlg.h"
39 #include "ProgressDlg.h"
40 //#include "RepositoryBrowser.h"
41 //#include "CopyDlg.h"
42 //#include "StatGraphDlg.h"
43 #include "Logdlg.h"
44 #include "MessageBox.h"
45 #include "Registry.h"
46 #include "AppUtils.h"
47 #include "PathUtils.h"
48 #include "StringUtils.h"
49 #include "UnicodeUtils.h"
50 #include "TempFile.h"
51 //#include "GitInfo.h"
52 //#include "GitDiff.h"
53 #include "IconMenu.h"
54 //#include "RevisionRangeDlg.h"
55 //#include "BrowseFolder.h"
56 //#include "BlameDlg.h"
57 //#include "Blame.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"
65
66 //CLogDataVector Class
67 int CLogDataVector::ParserFromLog()
68 {
69         CString log;
70         GitRev rev;
71         g_Git.GetLog(log);
72
73         CString begin;
74         begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
75         
76         if(log.GetLength()==0)
77                 return 0;
78         
79         int start=4;
80         int length;
81         int next =1;
82         while( next>0 )
83         {
84                 next=log.Find(begin,start);
85                 if(next >0 )
86                         length = next - start+4;
87                 else
88                         length = log.GetLength()-start+4;
89
90                 CString onelog =log;
91                 onelog=log.Mid(start -4,length);
92                 rev.ParserFromLog(onelog);
93                 this->push_back(rev);
94                 m_HashMap[rev.m_CommitHash]=&rev;
95                 start = next +4;
96         }
97
98         return 0;
99 }
100
101 void CLogDataVector::setLane(CString& sha) 
102 {
103         Lanes* l = &(this->m_Lanes);
104         int i = m_FirstFreeLane;
105         
106 //      QVector<QByteArray> ba;
107 //      const ShaString& ss = toPersistentSha(sha, ba);
108 //      const ShaVect& shaVec(fh->revOrder);
109
110         for (int cnt = size(); i < cnt; ++i) {
111
112                 GitRev* r = &(*this)[i]; 
113                 CString &curSha=r->m_CommitHash;
114
115                 if (r->m_Lanes.size() == 0)
116                         updateLanes(*r, *l, curSha);
117
118                 if (curSha == sha)
119                         break;
120         }
121         m_FirstFreeLane = ++i;
122
123 #if 0
124         Lanes* l = &(this->m_Lanes);
125         int i = m_FirstFreeLane;
126         
127         QVector<QByteArray> ba;
128         const ShaString& ss = toPersistentSha(sha, ba);
129         const ShaVect& shaVec(fh->revOrder);
130
131         for (uint cnt = shaVec.count(); i < cnt; ++i) {
132
133                 const ShaString& curSha = shaVec[i];
134                 Rev* r = m_HashMap[curSha]const_cast<Rev*>(revLookup(curSha, fh));
135                 if (r->lanes.count() == 0)
136                         updateLanes(*r, *l, curSha);
137
138                 if (curSha == ss)
139                         break;
140         }
141         fh->firstFreeLane = ++i;
142 #endif
143 }
144
145
146 void CLogDataVector::updateLanes(GitRev& c, Lanes& lns, CString &sha) 
147 {
148 // we could get third argument from c.sha(), but we are in fast path here
149 // and c.sha() involves a deep copy, so we accept a little redundancy
150
151         if (lns.isEmpty())
152                 lns.init(sha);
153
154         bool isDiscontinuity;
155         bool isFork = lns.isFork(sha, isDiscontinuity);
156         bool isMerge = (c.ParentsCount() > 1);
157         bool isInitial = (c.ParentsCount() == 0);
158
159         if (isDiscontinuity)
160                 lns.changeActiveLane(sha); // uses previous isBoundary state
161
162         lns.setBoundary(0/*c.isBoundary()*/); // update must be here
163
164         if (isFork)
165                 lns.setFork(sha);
166         if (isMerge)
167                 lns.setMerge(c.m_ParentHash);
168         //if (c.isApplied)
169         //      lns.setApplied();
170         if (isInitial)
171                 lns.setInitial();
172
173         lns.getLanes(c.m_Lanes); // here lanes are snapshotted
174
175         CString nextSha = (isInitial) ? CString(_T("")) : QString(c.m_ParentHash[0]);
176
177         lns.nextParent(nextSha);
178
179         //if (c.isApplied)
180         //      lns.afterApplied();
181         if (isMerge)
182                 lns.afterMerge();
183         if (isFork)
184                 lns.afterFork();
185         if (lns.isBranch())
186                 lns.afterBranch();
187
188 //      QString tmp = "", tmp2;
189 //      for (uint i = 0; i < c.lanes.count(); i++) {
190 //              tmp2.setNum(c.lanes[i]);
191 //              tmp.append(tmp2 + "-");
192 //      }
193 //      qDebug("%s %s",tmp.latin1(), c.sha.latin1());
194 }