OSDN Git Service

Parser Reflog output
authorFrank Li <lznuaa@gmail.com>
Mon, 16 Mar 2009 14:37:05 +0000 (22:37 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 16 Mar 2009 14:37:05 +0000 (22:37 +0800)
src/Git/GitRev.h
src/TortoiseProc/LogDataVector.cpp
src/TortoiseProc/LogDlgHelper.h
src/TortoiseProc/RefLogDlg.cpp
src/TortoiseProc/RefLogDlg.h
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/refloglist.cpp [new file with mode: 0644]
src/TortoiseProc/refloglist.h [new file with mode: 0644]

index 78bc016..2fc1cf2 100644 (file)
@@ -55,7 +55,9 @@ public:
        CTGitPathList m_Files;\r
        int     m_Action;\r
        TCHAR m_Mark;\r
-       \r
+       CString m_Ref;\r
+       CString m_RefAction;\r
+\r
        BOOL IsBoundary(){return m_Mark == _T('-');}\r
 \r
        void Clear();\r
index 1b265d2..9955dc7 100644 (file)
@@ -130,6 +130,39 @@ int CLogDataVector::ParserFromLog(CTGitPath *path ,int count ,int infomask,CStri
        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);
+                       }
+               }
+       }
+       return 0;
+}
+
 void CLogDataVector::setLane(CString& sha) 
 {
        Lanes* l = &(this->m_Lns);
index a96aeba..0836d64 100644 (file)
@@ -61,6 +61,9 @@ public:
        int  ParserFromLog(CTGitPath *path =NULL,int count = -1,int infomask=CGit::LOG_INFO_STAT|CGit::LOG_INFO_FILESTATE,\r
                                                                                         CString *from=NULL,CString *to=NULL);\r
        int  ParserShortLog(CTGitPath *path ,CString &hash,int count=-1 ,int mask=CGit::LOG_INFO_ONLY_HASH );\r
+\r
+       int  ParserFromRefLog(CString ref);\r
+\r
        int FetchFullInfo(int i);\r
 //     void AddFullInfo(\r
 \r
index f0c9664..0cadf34 100644 (file)
@@ -30,6 +30,7 @@ void CRefLogDlg::DoDataExchange(CDataExchange* pDX)
 \r
 BEGIN_MESSAGE_MAP(CRefLogDlg, CResizableStandAloneDialog)\r
        ON_BN_CLICKED(IDOK, &CRefLogDlg::OnBnClickedOk)\r
+       ON_CBN_SELCHANGE(IDC_COMBOBOXEX_REF,   &CRefLogDlg::OnCbnSelchangeRef)\r
 END_MESSAGE_MAP()\r
 \r
 BOOL CRefLogDlg::OnInitDialog()\r
@@ -50,6 +51,8 @@ BOOL CRefLogDlg::OnInitDialog()
        this->m_ChooseRef.AddString(list);\r
        m_ChooseRef.SetMaxHistoryItems(0x7FFFFFFF);\r
 \r
+       this->m_RefList.InsertRefLogColumn();\r
+       m_RefList.m_logEntries.ParserFromRefLog(_T("master"));\r
        return TRUE;\r
 }\r
 // CRefLogDlg message handlers\r
@@ -58,4 +61,9 @@ void CRefLogDlg::OnBnClickedOk()
 {\r
        // TODO: Add your control notification handler code here\r
        OnOK();\r
+}\r
+\r
+void CRefLogDlg::OnCbnSelchangeRef()\r
+{\r
+       \r
 }
\ No newline at end of file
index 4148acd..e75759c 100644 (file)
@@ -2,6 +2,7 @@
 #include "afxcmn.h"\r
 #include "StandAloneDlg.h"\r
 #include "HistoryCombo.h"\r
+#include "RefLoglist.h"\r
 // CRefLogDlg dialog\r
 \r
 class CRefLogDlg : public CResizableStandAloneDialog\r
@@ -18,12 +19,12 @@ public:
 protected:\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        BOOL OnInitDialog();\r
-\r
+       afx_msg void OnCbnSelchangeRef();       \r
        DECLARE_MESSAGE_MAP()\r
 public:\r
        CHistoryCombo m_ChooseRef;\r
 public:\r
-       CListCtrl m_RefList;\r
+       CRefLogList m_RefList;\r
 public:\r
        afx_msg void OnBnClickedOk();\r
 };\r
index f3ba758..afe72dc 100644 (file)
                                        RelativePath=".\RefLogDlg.h"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath=".\RefLoglist.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\RefLoglist.h"\r
+                                       >\r
+                               </File>\r
                        </Filter>\r
                        <Filter\r
                                Name="Submodule"\r
diff --git a/src/TortoiseProc/refloglist.cpp b/src/TortoiseProc/refloglist.cpp
new file mode 100644 (file)
index 0000000..23a7814
--- /dev/null
@@ -0,0 +1,39 @@
+#include "stdafx.h"\r
+#include "resource.h"\r
+#include "RefLogDlg.h"\r
+#include "git.h"\r
+#include "RefLogList.h"\r
+\r
+IMPLEMENT_DYNAMIC(CRefLogList, CGitLogList)\r
+\r
+CRefLogList::CRefLogList()\r
+{\r
+\r
+}\r
+\r
+void CRefLogList::InsertRefLogColumn()\r
+{\r
+       CString temp;\r
+\r
+       int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
+       \r
+       while (c>=0)\r
+               DeleteColumn(c--);\r
+       \r
+       temp=_T("Hash");\r
+       InsertColumn(REFLOG_HASH, temp);\r
+       \r
+       temp=_T("Ref");\r
+       InsertColumn(REFLOG_REF, temp);\r
+       \r
+       temp=_T("Action");\r
+       InsertColumn(REFLOG_ACTION, temp);\r
+       \r
+       temp=_T("Message");\r
+       InsertColumn(REFLOG_MESSAGE, temp);\r
+\r
+\r
+       SetRedraw(false);\r
+       ResizeAllListCtrlCols();\r
+       SetRedraw(true);\r
+}
\ No newline at end of file
diff --git a/src/TortoiseProc/refloglist.h b/src/TortoiseProc/refloglist.h
new file mode 100644 (file)
index 0000000..1dce5c3
--- /dev/null
@@ -0,0 +1,21 @@
+#pragma once\r
+#include "GitLoglist.h"\r
+\r
+class CGitLogListBase;\r
+\r
+class CRefLogList : public CGitLogList\r
+{\r
+       DECLARE_DYNAMIC(CRefLogList)\r
+public:\r
+       CRefLogList();\r
+       void InsertRefLogColumn();\r
+       enum\r
+       {\r
+               REFLOG_HASH,\r
+               REFLOG_REF,\r
+               REFLOG_ACTION,\r
+               REFLOG_MESSAGE\r
+       };\r
+protected:\r
+       \r
+};
\ No newline at end of file