- m_RawLogStart.clear();
-
- GitRev rev;
-
- if(g_Git.IsInitRepos())
- return 0;
-
- CString begin;
- begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
-
- //g_Git.GetShortLog(log,path,count);
- ULONGLONG t1,t2;
- t1=GetTickCount();
- g_Git.GetLog(m_RawlogData, hash,path,count,mask);
- t2=GetTickCount();
-
- TRACE(_T("GetLog Time %ld\r\n"),t2-t1);
-
- if(m_RawlogData.size()==0)
- return 0;
-
- int start=4;
- int length;
- int next =0;
- t1=GetTickCount();
- int a1=0,b1=0;
-
- while( next>=0 && next<m_RawlogData.size())
- {
- static const BYTE dataToFind[]={0,0};
- m_RawLogStart.push_back(next);
- //this->at(i).m_Subject=_T("parser...");
- next=m_RawlogData.findData(dataToFind,2,next+1);
- //next=log.find(0,next);
- }
-
- resize(m_RawLogStart.size());
-
- t2=GetTickCount();
-
- return 0;
-}
-int CLogDataVector::FetchFullInfo(int i)
-{
- return at(i).SafeFetchFullInfo(&g_Git);
-}
-//CLogDataVector Class
-int CLogDataVector::ParserFromLog(CTGitPath *path ,int count ,int infomask,CString *from,CString *to)
-{
- BYTE_VECTOR log;
- GitRev rev;
- CString emptyhash;
- g_Git.GetLog(log,emptyhash,path,count,infomask,from,to);
-
- CString begin;
- begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
-
- if(log.size()==0)
- return 0;
-
- int start=4;
- int length;
- int next =0;
- while( next>=0 )
- {
- next=rev.ParserFromLog(log,next);
- this->push_back(rev);
- m_HashMap[rev.m_CommitHash]=size()-1;
- }
-
- return 0;
-}
-
-int CLogDataVector::ParserFromRefLog(CString ref)
-{
- CString cmd,out;
- GitRev rev;
- cmd.Format(_T("git.exe reflog show %s"),ref);
- if(g_Git.Run(cmd,&out,CP_UTF8))
- return -1;
-
- int pos=0;
- while(pos>=0)
- {
- CString one=out.Tokenize(_T("\n"),pos);
- int ref=one.Find(_T(' '),0);
- if(ref<0)
- continue;
-
- rev.m_CommitHash=one.Left(ref);
- int action=one.Find(_T(' '),ref+1);
- int message;
- if(action>0)
- {
- rev.m_Ref=one.Mid(ref+1,action-ref-2);
- message=one.Find(_T(":"),action);
- if(message>0)
- {
- rev.m_RefAction=one.Mid(action+1,message-action-1);
- rev.m_Subject=one.Right(one.GetLength()-message-1);
- }
- }
- this->push_back(rev);
- }
- return 0;
-}
-
-void CLogDataVector::setLane(CString& sha)
-{
- Lanes* l = &(this->m_Lns);
- int i = m_FirstFreeLane;
-
-// QVector<QByteArray> ba;
-// const ShaString& ss = toPersistentSha(sha, ba);
-// const ShaVect& shaVec(fh->revOrder);
-
- for (int cnt = size(); i < cnt; ++i) {
-
- GitRev* r = &(*this)[i];
- CString &curSha=r->m_CommitHash;
-
- if (r->m_Lanes.size() == 0)
- updateLanes(*r, *l, curSha);
-
- if (curSha == sha)
- break;
- }
- m_FirstFreeLane = ++i;
-
-#if 0
- Lanes* l = &(this->m_Lanes);
- int i = m_FirstFreeLane;
-
- QVector<QByteArray> ba;
- const ShaString& ss = toPersistentSha(sha, ba);
- const ShaVect& shaVec(fh->revOrder);
-
- for (uint cnt = shaVec.count(); i < cnt; ++i) {
-
- const ShaString& curSha = shaVec[i];
- Rev* r = m_HashMap[curSha]const_cast<Rev*>(revLookup(curSha, fh));
- if (r->lanes.count() == 0)
- updateLanes(*r, *l, curSha);
-
- if (curSha == ss)
- break;
- }
- fh->firstFreeLane = ++i;
-#endif
-}
-
-
-void CLogDataVector::updateLanes(GitRev& c, Lanes& lns, CString &sha)
-{
-// we could get third argument from c.sha(), but we are in fast path here
-// and c.sha() involves a deep copy, so we accept a little redundancy
-
- if (lns.isEmpty())
- lns.init(sha);
-
- bool isDiscontinuity;
- bool isFork = lns.isFork(sha, isDiscontinuity);
- bool isMerge = (c.ParentsCount() > 1);
- bool isInitial = (c.ParentsCount() == 0);
-
- if (isDiscontinuity)
- lns.changeActiveLane(sha); // uses previous isBoundary state
-
- lns.setBoundary(c.IsBoundary() == TRUE); // update must be here
- TRACE(_T("%s %d"),c.m_CommitHash,c.IsBoundary());
-
- if (isFork)
- lns.setFork(sha);
- if (isMerge)
- lns.setMerge(c.m_ParentHash);
- //if (c.isApplied)
- // lns.setApplied();
- if (isInitial)
- lns.setInitial();
-
- lns.getLanes(c.m_Lanes); // here lanes are snapshotted
-
- CString nextSha = (isInitial) ? CString(_T("")) : QString(c.m_ParentHash[0]);
-
- lns.nextParent(nextSha);
-
- //if (c.isApplied)
- // lns.afterApplied();
- if (isMerge)
- lns.afterMerge();
- if (isFork)
- lns.afterFork();
- if (lns.isBranch())
- lns.afterBranch();
-
-// QString tmp = "", tmp2;
-// for (uint i = 0; i < c.lanes.count(); i++) {
-// tmp2.setNum(c.lanes[i]);
-// tmp.append(tmp2 + "-");
-// }
-// qDebug("%s %s",tmp.latin1(), c.sha.latin1());
+ m_RawLogStart.clear();\r
+\r
+ GitRev rev;\r
+ \r
+ if(g_Git.IsInitRepos())\r
+ return 0;\r
+\r
+ CString begin;\r
+ begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);\r
+\r
+ //g_Git.GetShortLog(log,path,count);\r
+ ULONGLONG t1,t2;\r
+ t1=GetTickCount();\r
+ g_Git.GetLog(m_RawlogData, hash,path,count,mask);\r
+ t2=GetTickCount();\r
+\r
+ TRACE(_T("GetLog Time %ld\r\n"),t2-t1);\r
+\r
+ if(m_RawlogData.size()==0)\r
+ return 0;\r
+ \r
+ int start=4;\r
+ int length;\r
+ int next =0;\r
+ t1=GetTickCount();\r
+ int a1=0,b1=0;\r
+\r
+ while( next>=0 && next<m_RawlogData.size())\r
+ {\r
+ static const BYTE dataToFind[]={0,0};\r
+ m_RawLogStart.push_back(next);\r
+ //this->at(i).m_Subject=_T("parser...");\r
+ next=m_RawlogData.findData(dataToFind,2,next+1);\r
+ //next=log.find(0,next);\r
+ }\r
+\r
+ resize(m_RawLogStart.size());\r
+\r
+ t2=GetTickCount();\r
+\r
+ return 0;\r
+}\r
+int CLogDataVector::FetchFullInfo(int i)\r
+{\r
+ return at(i).SafeFetchFullInfo(&g_Git);\r
+}\r
+//CLogDataVector Class\r
+int CLogDataVector::ParserFromLog(CTGitPath *path ,int count ,int infomask,CString *from,CString *to)\r
+{\r
+ BYTE_VECTOR log;\r
+ GitRev rev;\r
+ CString emptyhash;\r
+ g_Git.GetLog(log,emptyhash,path,count,infomask,from,to);\r
+\r
+ CString begin;\r
+ begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);\r
+ \r
+ if(log.size()==0)\r
+ return 0;\r
+ \r
+ int start=4;\r
+ int length;\r
+ int next =0;\r
+ while( next>=0 )\r
+ {\r
+ next=rev.ParserFromLog(log,next);\r
+ this->push_back(rev);\r
+ m_HashMap[rev.m_CommitHash]=size()-1; \r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+int CLogDataVector::ParserFromRefLog(CString ref)\r
+{\r
+ CString cmd,out;\r
+ GitRev rev;\r
+ cmd.Format(_T("git.exe reflog show %s"),ref);\r
+ if(g_Git.Run(cmd,&out,CP_UTF8))\r
+ return -1;\r
+ \r
+ int pos=0;\r
+ while(pos>=0)\r
+ {\r
+ CString one=out.Tokenize(_T("\n"),pos);\r
+ int ref=one.Find(_T(' '),0);\r
+ if(ref<0)\r
+ continue;\r
+\r
+ rev.m_CommitHash=one.Left(ref);\r
+ int action=one.Find(_T(' '),ref+1);\r
+ int message;\r
+ if(action>0)\r
+ {\r
+ rev.m_Ref=one.Mid(ref+1,action-ref-2);\r
+ message=one.Find(_T(":"),action);\r
+ if(message>0)\r
+ {\r
+ rev.m_RefAction=one.Mid(action+1,message-action-1);\r
+ rev.m_Subject=one.Right(one.GetLength()-message-1);\r
+ }\r
+ }\r
+ this->push_back(rev);\r
+ }\r
+ return 0;\r
+}\r
+\r
+void CLogDataVector::setLane(CString& sha) \r
+{\r
+ Lanes* l = &(this->m_Lns);\r
+ int i = m_FirstFreeLane;\r
+ \r
+// QVector<QByteArray> ba;\r
+// const ShaString& ss = toPersistentSha(sha, ba);\r
+// const ShaVect& shaVec(fh->revOrder);\r
+\r
+ for (int cnt = size(); i < cnt; ++i) {\r
+\r
+ GitRev* r = &(*this)[i]; \r
+ CString &curSha=r->m_CommitHash;\r
+\r
+ if (r->m_Lanes.size() == 0)\r
+ updateLanes(*r, *l, curSha);\r
+\r
+ if (curSha == sha)\r
+ break;\r
+ }\r
+ m_FirstFreeLane = ++i;\r
+\r
+#if 0\r
+ Lanes* l = &(this->m_Lanes);\r
+ int i = m_FirstFreeLane;\r
+ \r
+ QVector<QByteArray> ba;\r
+ const ShaString& ss = toPersistentSha(sha, ba);\r
+ const ShaVect& shaVec(fh->revOrder);\r
+\r
+ for (uint cnt = shaVec.count(); i < cnt; ++i) {\r
+\r
+ const ShaString& curSha = shaVec[i];\r
+ Rev* r = m_HashMap[curSha]const_cast<Rev*>(revLookup(curSha, fh));\r
+ if (r->lanes.count() == 0)\r
+ updateLanes(*r, *l, curSha);\r
+\r
+ if (curSha == ss)\r
+ break;\r
+ }\r
+ fh->firstFreeLane = ++i;\r
+#endif\r
+}\r
+\r
+\r
+void CLogDataVector::updateLanes(GitRev& c, Lanes& lns, CString &sha) \r
+{\r
+// we could get third argument from c.sha(), but we are in fast path here\r
+// and c.sha() involves a deep copy, so we accept a little redundancy\r
+\r
+ if (lns.isEmpty())\r
+ lns.init(sha);\r
+\r
+ bool isDiscontinuity;\r
+ bool isFork = lns.isFork(sha, isDiscontinuity);\r
+ bool isMerge = (c.ParentsCount() > 1);\r
+ bool isInitial = (c.ParentsCount() == 0);\r
+\r
+ if (isDiscontinuity)\r
+ lns.changeActiveLane(sha); // uses previous isBoundary state\r
+\r
+ lns.setBoundary(c.IsBoundary() == TRUE); // update must be here\r
+ TRACE(_T("%s %d"),c.m_CommitHash,c.IsBoundary());\r
+\r
+ if (isFork)\r
+ lns.setFork(sha);\r
+ if (isMerge)\r
+ lns.setMerge(c.m_ParentHash);\r
+ //if (c.isApplied)\r
+ // lns.setApplied();\r
+ if (isInitial)\r
+ lns.setInitial();\r
+\r
+ lns.getLanes(c.m_Lanes); // here lanes are snapshotted\r
+\r
+ CString nextSha = (isInitial) ? CString(_T("")) : QString(c.m_ParentHash[0]);\r
+\r
+ lns.nextParent(nextSha);\r
+\r
+ //if (c.isApplied)\r
+ // lns.afterApplied();\r
+ if (isMerge)\r
+ lns.afterMerge();\r
+ if (isFork)\r
+ lns.afterFork();\r
+ if (lns.isBranch())\r
+ lns.afterBranch();\r
+\r
+// QString tmp = "", tmp2;\r
+// for (uint i = 0; i < c.lanes.count(); i++) {\r
+// tmp2.setNum(c.lanes[i]);\r
+// tmp.append(tmp2 + "-");\r
+// }\r
+// qDebug("%s %s",tmp.latin1(), c.sha.latin1());\r