OSDN Git Service

Show Tag branch at loglist
authorFrank Li <lznuaa@gmail.com>
Fri, 26 Dec 2008 13:26:25 +0000 (21:26 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 26 Dec 2008 13:26:25 +0000 (21:26 +0800)
src/Git/Git.cpp
src/Git/Git.h
src/TortoiseProc/GitLogList.cpp
src/TortoiseProc/GitLogList.h
src/TortoiseProc/TortoiseProc.vcproj

index 094158f..4e28fb1 100644 (file)
@@ -145,7 +145,7 @@ int CGit::GetLog(CString& logOut)
        cmd += log;\r
        log.Format(_T("#<%c>%%n"),LOG_REV_COMMIT_FILE);\r
        cmd += log;\r
-       cmd += CString(_T("\""));\r
+       cmd += CString(_T("\" HEAD~4..HEAD"));\r
        Run(cmd,&logOut);\r
        return 0;\r
 }\r
@@ -321,4 +321,33 @@ int CGit::GetRemoteList(CStringList &list)
                }\r
        }\r
        return ret;\r
+}\r
+\r
+int CGit::GetMapHashToFriendName(MAP_HASH_NAME &map)\r
+{\r
+       int ret;\r
+       CString cmd,output;\r
+       cmd=_T("git show-ref");\r
+       ret=g_Git.Run(cmd,&output);\r
+       if(!ret)\r
+       {\r
+               int pos=0;\r
+               CString one;\r
+               while( pos>=0 )\r
+               {\r
+                       one=output.Tokenize(_T("\n"),pos);\r
+                       int start=one.Find(_T(" "),0);\r
+                       if(start>0)\r
+                       {\r
+                               CString name;\r
+                               name=one.Right(one.GetLength()-start-1);\r
+\r
+                               CString hash;\r
+                               hash=one.Left(start);\r
+\r
+                               map[hash].push_back(name);\r
+                       }\r
+               }\r
+       }\r
+       return ret;\r
 }
\ No newline at end of file
index f07687d..be3aa97 100644 (file)
@@ -9,6 +9,10 @@ enum
        GIT_ERROR_CREATE_PROCESS,\r
        GIT_ERROR_GET_EXIT_CODE\r
 };\r
+\r
+typedef std::vector<CString> STRING_VECTOR;\r
+typedef std::map<CString, STRING_VECTOR> MAP_HASH_NAME;\r
+\r
 class CGit\r
 {\r
 private:\r
@@ -40,6 +44,7 @@ public:
        int GetRemoteList(CStringList &list);\r
        int GetBranchList(CStringList &list, int *Current,BRANCH_TYPE type=BRANCH_LOCAL);\r
        int GetTagList(CStringList &list);\r
+       int GetMapHashToFriendName(MAP_HASH_NAME &map);\r
        \r
        int GetLog(CString& logOut);\r
        git_revnum_t GetHash(CString &friendname);\r
index a00acb2..2fe5c00 100644 (file)
@@ -66,7 +66,7 @@ CGitLogList::CGitLogList():CHintListCtrl()
        m_hAddedIcon    =  (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);\r
        m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);\r
 \r
-\r
+       g_Git.GetMapHashToFriendName(m_HashMap);\r
 }\r
 \r
 CGitLogList::~CGitLogList()\r
@@ -243,7 +243,133 @@ void CGitLogList::ResizeAllListCtrlCols()
        }\r
 \r
 }\r
+BOOL CGitLogList::GetShortName(CString ref, CString &shortname,CString prefix)\r
+{\r
+       if(ref.Left(prefix.GetLength()) ==  prefix)\r
+       {\r
+               shortname = ref.Right(ref.GetLength()-prefix.GetLength());\r
+               return TRUE;\r
+       }\r
+       return FALSE;\r
+}\r
+void CGitLogList::FillBackGround(HDC hdc, int Index,CRect &rect)\r
+{      \r
+       HBRUSH brush;\r
+       LVITEM   rItem;\r
+       SecureZeroMemory(&rItem, sizeof(LVITEM));\r
+       rItem.mask  = LVIF_STATE;\r
+       rItem.iItem = Index;\r
+       rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;\r
+       GetItem(&rItem);\r
+\r
+       if (m_Theme.IsAppThemed() && m_bVista)\r
+       {\r
+               m_Theme.Open(m_hWnd, L"Explorer");\r
+               int state = LISS_NORMAL;\r
+               if (rItem.state & LVIS_SELECTED)\r
+               {\r
+                       if (::GetFocus() == m_hWnd)\r
+                               state |= LISS_SELECTED;\r
+                       else\r
+                               state |= LISS_SELECTEDNOTFOCUS;\r
+               }\r
+               else\r
+               {\r
+#if 0\r
+                       if (pLogEntry->bCopiedSelf)\r
+                       {\r
+                               // unfortunately, the pLVCD->nmcd.uItemState does not contain valid\r
+                               // information at this drawing stage. But we can check the whether the\r
+                               // previous stage changed the background color of the item\r
+                               if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))\r
+                               {\r
+                                       HBRUSH brush;\r
+                                       brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
+                                       if (brush)\r
+                                       {\r
+                                               ::FillRect(pLVCD->nmcd.hdc, &rect, brush);\r
+                                               ::DeleteObject(brush);\r
+                                       }\r
+                               }\r
+                       }\r
+#endif\r
+               }\r
+\r
+               if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))\r
+                       m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);\r
+\r
+                       m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);\r
+       }\r
+       else\r
+       {\r
+               HBRUSH brush;\r
+               if (rItem.state & LVIS_SELECTED)\r
+               {\r
+                       if (::GetFocus() == m_hWnd)\r
+                               brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));\r
+                       else\r
+                               brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));\r
+               }\r
+               else\r
+               {\r
+                       //if (pLogEntry->bCopiedSelf)\r
+                       //      brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
+                       //else\r
+                               brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));\r
+               }\r
+               if (brush == NULL)\r
+                       return;\r
+\r
+               ::FillRect(hdc, &rect, brush);\r
+               ::DeleteObject(brush);\r
+               \r
+       }\r
+}\r
+\r
+void CGitLogList::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)\r
+{\r
+       GitRev* data = (GitRev*)m_arShownList.GetAt(index);\r
+       CRect rt=rect;\r
+       for(int i=0;i<m_HashMap[data->m_CommitHash].size();i++)\r
+       {\r
+               CString str;\r
+               str=m_HashMap[data->m_CommitHash][i];\r
+               \r
+               CString shortname;\r
+               HBRUSH brush=0;\r
+               shortname=_T("");\r
+               if(GetShortName(str,shortname,_T("refs/heads/")))\r
+               {\r
+                       brush = ::CreateSolidBrush(RGB(0xff, 0, 0));\r
+               }else if(GetShortName(str,shortname,_T("refs/remotes/")))\r
+               {\r
+                       brush = ::CreateSolidBrush(RGB(0xff, 0xff, 0));\r
+               }\r
+               else if(GetShortName(str,shortname,_T("refs/tags/")))\r
+               {\r
+                       brush = ::CreateSolidBrush(RGB(0, 0, 0xff));\r
+               }\r
 \r
+               if(!shortname.IsEmpty())\r
+               {\r
+                       SIZE size;\r
+                       memset(&size,0,sizeof(SIZE));\r
+                       GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);\r
+               \r
+                       rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);\r
+               \r
+                       ::FillRect(hdc, &rt, brush);\r
+                       ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);\r
+                               \r
+                       rt.left=rt.right+3;\r
+               }\r
+               if(brush)\r
+                       ::DeleteObject(brush);\r
+       }               \r
+       rt.right=rect.right;\r
+       ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);\r
+       \r
+}\r
 \r
 void CGitLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
 {\r
@@ -316,6 +442,25 @@ void CGitLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                        {\r
                                pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);\r
                        }\r
+                       if (pLVCD->iSubItem == LOGLIST_MESSAGE)\r
+                       {\r
+                               if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
+                               {\r
+                                       GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);\r
+                                       if(m_HashMap[data->m_CommitHash].size()!=0)\r
+                                       {\r
+                                               CRect rect;\r
+                                               GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
+                                       \r
+                                               FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);\r
+                                               DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);\r
+\r
+                                               *pResult = CDRF_SKIPDEFAULT;\r
+                                               return;\r
+\r
+                                       }\r
+                               }\r
+                       }\r
                        if (pLVCD->iSubItem == 1)\r
                        {\r
                                *pResult = CDRF_DODEFAULT;\r
@@ -328,82 +473,14 @@ void CGitLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                int             iconheight = ::GetSystemMetrics(SM_CYSMICON);\r
 \r
                                GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));\r
-\r
-                               // Get the selected state of the\r
-                               // item being drawn.\r
-                               LVITEM   rItem;\r
-                               SecureZeroMemory(&rItem, sizeof(LVITEM));\r
-                               rItem.mask  = LVIF_STATE;\r
-                               rItem.iItem = pLVCD->nmcd.dwItemSpec;\r
-                               rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;\r
-                               GetItem(&rItem);\r
-\r
                                CRect rect;\r
                                GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
+                               // Get the selected state of the\r
+                               // item being drawn.                                                    \r
 \r
                                // Fill the background\r
-                               if (m_Theme.IsAppThemed() && m_bVista)\r
-                               {\r
-                                       m_Theme.Open(m_hWnd, L"Explorer");\r
-                                       int state = LISS_NORMAL;\r
-                                       if (rItem.state & LVIS_SELECTED)\r
-                                       {\r
-                                               if (::GetFocus() == m_hWnd)\r
-                                                       state |= LISS_SELECTED;\r
-                                               else\r
-                                                       state |= LISS_SELECTEDNOTFOCUS;\r
-                                       }\r
-                                       else\r
-                                       {\r
-#if 0\r
-                                               if (pLogEntry->bCopiedSelf)\r
-                                               {\r
-                                                       // unfortunately, the pLVCD->nmcd.uItemState does not contain valid\r
-                                                       // information at this drawing stage. But we can check the whether the\r
-                                                       // previous stage changed the background color of the item\r
-                                                       if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))\r
-                                                       {\r
-                                                               HBRUSH brush;\r
-                                                               brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
-                                                               if (brush)\r
-                                                               {\r
-                                                                       ::FillRect(pLVCD->nmcd.hdc, &rect, brush);\r
-                                                                       ::DeleteObject(brush);\r
-                                                               }\r
-                                                       }\r
-                                               }\r
-#endif\r
-                                       }\r
-\r
-                                       if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))\r
-                                               m_Theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);\r
-\r
-                                       m_Theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);\r
-                               }\r
-                               else\r
-                               {\r
-                                       HBRUSH brush;\r
-                                       if (rItem.state & LVIS_SELECTED)\r
-                                       {\r
-                                               if (::GetFocus() == m_hWnd)\r
-                                                       brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));\r
-                                               else\r
-                                                       brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               //if (pLogEntry->bCopiedSelf)\r
-                                               //      brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
-                                               //else\r
-                                                       brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));\r
-                                       }\r
-                                       if (brush == NULL)\r
-                                               return;\r
-\r
-                                       ::FillRect(pLVCD->nmcd.hdc, &rect, brush);\r
-                                       ::DeleteObject(brush);\r
-                               }\r
-\r
+                               FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);\r
+                               \r
                                // Draw the icon(s) into the compatible DC\r
                                if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)\r
                                        ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
index 38cedfe..83247a3 100644 (file)
@@ -131,7 +131,9 @@ protected:
        virtual BOOL PreTranslateMessage(MSG* pMsg);\r
        static UINT LogThreadEntry(LPVOID pVoid);\r
        UINT LogThread();\r
-\r
+       void FillBackGround(HDC hdc, int Index,CRect &rect);\r
+       void DrawTagBranch(HDC,CRect &rect,INT_PTR index);\r
+       BOOL GetShortName(CString ref, CString &shortname,CString prefix);\r
        \r
        CXPTheme                        m_Theme;\r
        BOOL                            m_bVista;\r
@@ -149,6 +151,7 @@ protected:
        CALLBACK_PROCESS    *m_ProcCallBack;\r
        void                            *m_ProcData;\r
        CStoreSelection*        m_pStoreSelection;\r
+       MAP_HASH_NAME           m_HashMap;\r
 };\r
 \r
 \r
index 060df3f..6d0fc77 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\open.ico"\r
+                               RelativePath="..\Resources\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\open.ico"\r
+                               RelativePath=".\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\saveas.ico"\r
+                               RelativePath="..\Resources\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\saveas.ico"\r
+                               RelativePath=".\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                        </File>\r
                </Filter>\r
                <File\r
+                       RelativePath="..\..\..\..\tortoisegit\src\TortoiseProc\CloneDlg.htm"\r
+                       DeploymentContent="true"\r
+                       >\r
+               </File>\r
+               <File\r
                        RelativePath="Resource.h"\r
                        >\r
                </File>\r