OSDN Git Service

BranchView: Show commit subject and date
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / LogDataVector.cpp
index a748856..d0281b7 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "stdafx.h"
 #include "TortoiseProc.h"
-#include "GitLogList.h"
+#include "GitLogListBase.h"
 #include "GitRev.h"
 //#include "VssStyle.h"
 #include "IconMenu.h"
 //#include "EditPropertiesDlg.h"
 #include "FileDiffDlg.h"
 
+void CLogDataVector::ClearAll()\r
+{\r
+\r
+       clear();\r
+       m_HashMap.clear();\r
+       m_Lns.clear();\r
+\r
+       m_FirstFreeLane=0;\r
+       m_Lns.clear();\r
+\r
+       m_RawlogData.clear();\r
+       m_RawLogStart.clear();\r
+}
+
+int CLogDataVector::ParserShortLog(CTGitPath *path ,CString &hash,int count ,int mask )
+{
+       BYTE_VECTOR log;
+       GitRev rev;
+
+       if(g_Git.IsInitRepos())
+               return 0;
+
+       CString begin;
+       begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
+
+       //g_Git.GetShortLog(log,path,count);
+
+       g_Git.GetLog(log,hash,path,count,mask);
+
+       if(log.size()==0)
+               return 0;
+       
+       int start=4;
+       int length;
+       int next =0;
+       while( next>=0 && next<log.size())
+       {
+               next=rev.ParserFromLog(log,next);
+
+               rev.m_Subject=_T("Load .................................");
+               this->push_back(rev);
+               m_HashMap[rev.m_CommitHash]=size()-1;
+
+               //next=log.find(0,next);
+       }
+
+       return 0;
+
+}
+int CLogDataVector::FetchShortLog(CTGitPath *path ,CString &hash,int count ,int mask )
+{
+       //BYTE_VECTOR log;
+       m_RawlogData.clear();\r
+       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()
+int CLogDataVector::ParserFromLog(CTGitPath *path ,int count ,int infomask,CString *from,CString *to)
 {
-       CString log;
+       BYTE_VECTOR log;
        GitRev rev;
-       g_Git.GetLog(log);
+       CString emptyhash;
+       g_Git.GetLog(log,emptyhash,path,count,infomask,from,to);
 
        CString begin;
        begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
        
-       if(log.GetLength()==0)
+       if(log.size()==0)
                return 0;
        
        int start=4;
        int length;
-       int next =1;
-       while( next>0 )
+       int next =0;
+       while( next>=0 )
        {
-               next=log.Find(begin,start);
-               if(next >0 )
-                       length = next - start+4;
-               else
-                       length = log.GetLength()-start+4;
-
-               CString onelog =log;
-               onelog=log.Mid(start -4,length);
-               rev.ParserFromLog(onelog);
+               next=rev.ParserFromLog(log,next);
                this->push_back(rev);
-               m_HashMap[rev.m_CommitHash]=size()-1;
-               start = next +4;
+               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_Lanes);
+       Lanes* l = &(this->m_Lns);
        int i = m_FirstFreeLane;
        
 //     QVector<QByteArray> ba;
@@ -159,7 +284,8 @@ void CLogDataVector::updateLanes(GitRev& c, Lanes& lns, CString &sha)
        if (isDiscontinuity)
                lns.changeActiveLane(sha); // uses previous isBoundary state
 
-       lns.setBoundary(0/*c.isBoundary()*/); // update must be here
+       lns.setBoundary(c.IsBoundary() == TRUE); // update must be here
+       TRACE(_T("%s %d"),c.m_CommitHash,c.IsBoundary());
 
        if (isFork)
                lns.setFork(sha);