OSDN Git Service

Compare previous version ok
[tortoisegit/TortoiseGitJp.git] / src / Git / GitRev.cpp
1 #include "StdAfx.h"\r
2 #include "GitRev.h"\r
3 \r
4 \r
5 GitRev::GitRev(void)\r
6 {\r
7         m_Action=0;\r
8 }\r
9 \r
10 GitRev::~GitRev(void)\r
11 {\r
12 }\r
13 \r
14 #if 0\r
15 GitRev::GitRev(GitRev & rev)\r
16 {\r
17 }\r
18 GitRev& GitRev::operator=(GitRev &rev)\r
19 {\r
20         return *this;\r
21 }\r
22 #endif\r
23 void GitRev::Clear()\r
24 {\r
25         this->m_Action=0;\r
26         this->m_Files.Clear();\r
27         this->m_Action=0;\r
28         this->m_ParentHash.clear();\r
29         m_CommitterName.Empty();\r
30         m_CommitterEmail.Empty();\r
31         m_Body.Empty();\r
32         m_Subject.Empty();\r
33         m_CommitHash.Empty();\r
34 \r
35 }\r
36 int GitRev::ParserFromLog(CString &log)\r
37 {\r
38         int pos=0;\r
39         CString one;\r
40         CString key;\r
41         CString text;\r
42         CString filelist;\r
43         TCHAR mode;\r
44         CTGitPath  path;\r
45         this->m_Files.Clear();\r
46     m_Action=0;\r
47 \r
48         while( pos>=0 )\r
49         {\r
50                 one=log.Tokenize(_T("\n"),pos);\r
51                 if(one[0]==_T('#') && one[1] == _T('<') && one[3] == _T('>'))\r
52                 {\r
53                         text = one.Right(one.GetLength()-4);\r
54                         mode = one[2];\r
55                         switch(mode)\r
56                         {\r
57                         case LOG_REV_ITEM_BEGIN:\r
58                                 this->Clear();\r
59 \r
60                         case LOG_REV_AUTHOR_NAME:\r
61                                 this->m_AuthorName = text;\r
62                                 break;\r
63                         case LOG_REV_AUTHOR_EMAIL:\r
64                                 this->m_AuthorEmail = text;\r
65                                 break;\r
66                         case LOG_REV_AUTHOR_DATE:\r
67                                 this->m_AuthorDate =ConverFromString(text);\r
68                                 break;\r
69                         case LOG_REV_COMMIT_NAME:\r
70                                 this->m_CommitterName = text;\r
71                                 break;\r
72                         case LOG_REV_COMMIT_EMAIL:\r
73                                 this->m_CommitterEmail = text;\r
74                                 break;\r
75                         case LOG_REV_COMMIT_DATE:\r
76                                 this->m_CommitterDate =ConverFromString(text);\r
77                                 break;\r
78                         case LOG_REV_COMMIT_SUBJECT:\r
79                                 this->m_Subject = text;\r
80                                 break;\r
81                         case LOG_REV_COMMIT_BODY:\r
82                                 this->m_Body = text +_T("\n");\r
83                                 break;\r
84                         case LOG_REV_COMMIT_HASH:\r
85                                 this->m_CommitHash = text;\r
86                                 break;\r
87                         case LOG_REV_COMMIT_PARENT:\r
88                                 this->m_ParentHash.insert(this->m_ParentHash.end(),text);\r
89                                 break;\r
90                         case LOG_REV_COMMIT_FILE:\r
91                                 break;\r
92                         }\r
93                 }else\r
94                 {\r
95                         switch(mode)\r
96                         {\r
97                         case LOG_REV_COMMIT_BODY:\r
98                                 this->m_Body += one+_T("\n");\r
99                                 break;\r
100                         case LOG_REV_COMMIT_FILE:\r
101                                 filelist += one +_T("\n");\r
102                                 break;\r
103                         }\r
104                 }\r
105         }\r
106         \r
107         this->m_Files.ParserFromLog(filelist);\r
108         this->m_Action=this->m_Files.GetAction();\r
109         return 0;\r
110 }\r
111 \r
112 CTime GitRev::ConverFromString(CString input)\r
113 {\r
114         CTime tm(_wtoi(input.Mid(0,4)),\r
115                          _wtoi(input.Mid(5,2)),\r
116                          _wtoi(input.Mid(8,2)),\r
117                          _wtoi(input.Mid(11,2)),\r
118                          _wtoi(input.Mid(14,2)),\r
119                          _wtoi(input.Mid(17,2)),\r
120                          _wtoi(input.Mid(20,4)));\r
121         return tm;\r
122 }\r