17 GitRev::GitRev(GitRev
& rev
)
20 GitRev
& GitRev::operator=(GitRev
&rev
)
28 this->m_Files
.Clear();
30 this->m_ParentHash
.clear();
31 m_CommitterName
.Empty();
32 m_CommitterEmail
.Empty();
39 int GitRev::CopyFrom(GitRev
&rev
)
41 m_AuthorName
=rev
.m_AuthorName
;
42 m_AuthorEmail
=rev
.m_AuthorEmail
;
43 m_AuthorDate
=rev
.m_AuthorDate
;
44 m_CommitterName
=rev
.m_CommitterName
;
45 m_CommitterEmail
=rev
.m_CommitterEmail
;
46 m_CommitterDate
=rev
.m_CommitterDate
;
47 m_Subject
=rev
.m_Subject
;
49 m_CommitHash
=rev
.m_CommitHash
;
50 m_ParentHash
=rev
.m_ParentHash
;
51 m_Files
=rev
.m_Files
;
52 m_Action
=rev
.m_Action
;
56 int GitRev::ParserFromLog(CString
&log
)
65 this->m_Files
.Clear();
70 one
=log
.Tokenize(_T("\n"),pos
);
71 if(one
[0]==_T('#') && one
[1] == _T('<') && one
[3] == _T('>'))
73 text
= one
.Right(one
.GetLength()-4);
77 case LOG_REV_ITEM_BEGIN
:
80 case LOG_REV_AUTHOR_NAME
:
81 this->m_AuthorName
= text
;
83 case LOG_REV_AUTHOR_EMAIL
:
84 this->m_AuthorEmail
= text
;
86 case LOG_REV_AUTHOR_DATE
:
87 this->m_AuthorDate
=ConverFromString(text
);
89 case LOG_REV_COMMIT_NAME
:
90 this->m_CommitterName
= text
;
92 case LOG_REV_COMMIT_EMAIL
:
93 this->m_CommitterEmail
= text
;
95 case LOG_REV_COMMIT_DATE
:
96 this->m_CommitterDate
=ConverFromString(text
);
98 case LOG_REV_COMMIT_SUBJECT
:
99 this->m_Subject
= text
;
101 case LOG_REV_COMMIT_BODY
:
102 this->m_Body
= text
+_T("\n");
104 case LOG_REV_COMMIT_HASH
:
105 this->m_CommitHash
= text
.Right(40);
106 if(text
.GetLength()>40)
108 this->m_Mark
=text
[0];
111 case LOG_REV_COMMIT_PARENT
:
112 while(text
.GetLength()>0)
114 this->m_ParentHash
.insert(this->m_ParentHash
.end(),text
.Left(40));
115 if(text
.GetLength()>40)
116 text
=text
.Right(text
.GetLength()-41);
121 case LOG_REV_COMMIT_FILE
:
128 case LOG_REV_COMMIT_BODY
:
129 this->m_Body
+= one
+_T("\n");
131 case LOG_REV_COMMIT_FILE
:
132 filelist
+= one
+_T("\n");
138 this->m_Files
.ParserFromLog(filelist
);
139 this->m_Action
=this->m_Files
.GetAction();
143 CTime
GitRev::ConverFromString(CString input
)
145 CTime
tm(_wtoi(input
.Mid(0,4)),
146 _wtoi(input
.Mid(5,2)),
147 _wtoi(input
.Mid(8,2)),
148 _wtoi(input
.Mid(11,2)),
149 _wtoi(input
.Mid(14,2)),
150 _wtoi(input
.Mid(17,2)),
151 _wtoi(input
.Mid(20,4)));
155 int GitRev::SafeFetchFullInfo(CGit
*git
)
157 if(InterlockedExchange(&m_IsUpdateing
,TRUE
) == FALSE
)
161 TCHAR oldmark
=this->m_Mark
;
163 git
->GetLog(onelog
,m_CommitHash
,NULL
,1,CGit::LOG_INFO_STAT
|CGit::LOG_INFO_FILESTATE
);
164 CString oldhash
=m_CommitHash
;
165 ParserFromLog(onelog
);
167 //ASSERT(oldhash==m_CommitHash);
169 this->m_Mark
=oldmark
; //parser full log will cause old mark overwrited.
170 //So we need keep old bound mark.
172 InterlockedExchange(&m_IsUpdateing
,FALSE
);
173 InterlockedExchange(&m_IsFull
,TRUE
);