OSDN Git Service

Update first commit can't show when launch log dialog
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / GitLogListBase.cpp
index 68039f3..f4e2314 100644 (file)
@@ -58,6 +58,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
        , m_pStoreSelection(NULL)\r
        , m_nSelectedFilter(LOGFILTER_ALL)\r
        , m_bVista(false)\r
+       , m_bShowWC(false)\r
 {\r
        // use the default GUI font, create a copy of it and\r
        // change the copy to BOLD (leave the rest of the font\r
@@ -73,7 +74,11 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
        m_IsIDReplaceAction=FALSE;\r
 \r
        m_wcRev.m_CommitHash=GIT_REV_ZERO;\r
-       m_wcRev.m_Subject=_T("Working Copy");\r
+       m_wcRev.m_Subject=_T("Working dir changes");\r
+       m_wcRev.m_ParentHash.clear();\r
+       m_wcRev.m_Mark=_T('-');\r
+       m_wcRev.m_IsUpdateing=FALSE;\r
+       m_wcRev.m_IsFull = TRUE;\r
 \r
        m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);\r
        m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);\r
@@ -206,7 +211,7 @@ void CGitLogListBase::InsertGitColumn()
 {\r
        CString temp;\r
 \r
-       int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
+       int c = GetHeaderCtrl()->GetItemCount()-1;\r
        \r
        while (c>=0)\r
                DeleteColumn(c--);\r
@@ -396,7 +401,7 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
                                brush = ::CreateSolidBrush(RGB(156,156,156));\r
                        else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)\r
                                brush = ::CreateSolidBrush(RGB(200,200,128));\r
-                       else \r
+                       else\r
                                brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));\r
                }\r
                if (brush == NULL)\r
@@ -873,7 +878,6 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
        }\r
 #endif\r
 \r
-       TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());\r
 }\r
 \r
 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
@@ -929,7 +933,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                                pLVCD->clrTextBk = RGB(156,156,156);\r
                                        else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)\r
                                                pLVCD->clrTextBk  = RGB(200,200,128);\r
-                                       else \r
+                                       else\r
                                                pLVCD->clrTextBk  = ::GetSysColor(COLOR_WINDOW);\r
 \r
                                        if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)\r
@@ -946,13 +950,15 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
 \r
 //                                     if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))\r
 //                                             crText = GetSysColor(COLOR_GRAYTEXT);\r
-//                                     if (data->Rev == m_wcRev)\r
-//                                     {\r
-//                                             SelectObject(pLVCD->nmcd.hdc, m_boldFont);\r
+//                                     \r
+                                       if (data->m_CommitHash == GIT_REV_ZERO)\r
+                                       {\r
+                                               //crText = GetSysColor(RGB(200,200,0));\r
+                                               //SelectObject(pLVCD->nmcd.hdc, m_boldFont);\r
                                                // We changed the font, so we're returning CDRF_NEWFONT. This\r
                                                // tells the control to recalculate the extent of the text.\r
-//                                             *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;\r
-//                                     }\r
+                                               *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;\r
+                                       }\r
                                }\r
                        }\r
                        if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
@@ -978,9 +984,19 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                {\r
                                        CRect rect;\r
                                        GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
+                                       if(pLVCD->iSubItem == 0)\r
+                                       {\r
+                                               CRect second;\r
+                                               GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem+1, LVIR_BOUNDS, second);\r
+                                               rect.right=second.left;\r
+                                       }\r
                                        \r
+                                       TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);\r
                                        FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);\r
-                                       DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);\r
+                                       \r
+                                       GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);\r
+                                       if( data ->m_CommitHash != GIT_REV_ZERO)\r
+                                               DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);\r
 \r
                                        *pResult = CDRF_SKIPDEFAULT;\r
                                        return;\r
@@ -1013,7 +1029,8 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                                return;\r
 \r
                                        }\r
-                               }\r
+\r
+                               }       \r
                        }\r
                        \r
                        if (pLVCD->iSubItem == 1)\r
@@ -1035,6 +1052,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));\r
                                CRect rect;\r
                                GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
+                               TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);\r
                                // Get the selected state of the\r
                                // item being drawn.                                                    \r
 \r
@@ -1133,7 +1151,7 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                        lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);\r
                break;\r
        case this->LOGLIST_DATE: //Date\r
-               if (pLogEntry)\r
+               if (pLogEntry && pLogEntry->m_CommitHash != GIT_REV_ZERO)\r
                        lstrcpyn(pItem->pszText,\r
                                CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ), \r
                                pItem->cchTextMax);\r
@@ -1256,8 +1274,9 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
 \r
                if (GetSelectedCount() == 1)\r
                {\r
+                       \r
                        {\r
-                               //if (m_hasWC)\r
+                               if(pSelLogEntry->m_CommitHash != GIT_REV_ZERO)\r
                                {\r
                                        if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))\r
                                                popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);\r
@@ -1268,6 +1287,10 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
                                        // But until that's implemented, the context menu entry for\r
                                        // this feature is commented out.\r
                                        //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);\r
+                               }else\r
+                               {\r
+                                       if(m_ContextMenuMask&GetContextMenuBit(ID_COMMIT))\r
+                                               popup.AppendMenuIcon(ID_COMMIT, IDS_LOG_POPUP_COMMIT, IDI_COMMIT);\r
                                }\r
                                if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))\r
                                        popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);\r
@@ -1303,30 +1326,33 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
                        format.LoadString(IDS_RESET_TO_THIS_FORMAT);\r
                        str.Format(format,g_Git.GetCurrentBranch());\r
 \r
-                       if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))\r
-                               popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);\r
+                       if(pSelLogEntry->m_CommitHash != GIT_REV_ZERO)\r
+                       {\r
+                               if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))\r
+                                       popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);\r
 \r
-                       if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))\r
-                               popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);\r
+                               if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))\r
+                                       popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);\r
 \r
-                       if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))\r
-                               popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);\r
+                               if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))\r
+                                       popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);\r
 \r
-                       if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))\r
-                               popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);\r
+                               if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))\r
+                                       popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);\r
                        \r
-                       format.LoadString(IDS_REBASE_THIS_FORMAT);\r
-                       str.Format(format,g_Git.GetCurrentBranch());\r
+                               format.LoadString(IDS_REBASE_THIS_FORMAT);\r
+                               str.Format(format,g_Git.GetCurrentBranch());\r
 \r
-                       if(pSelLogEntry->m_CommitHash != m_HeadHash)\r
-                               if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))\r
-                                       popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);                   \r
+                               if(pSelLogEntry->m_CommitHash != m_HeadHash)\r
+                                       if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))\r
+                                               popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);                   \r
 \r
-                       if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))\r
-                               popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT); \r
+                               if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))\r
+                                       popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT); \r
                        \r
 \r
-                       popup.AppendMenu(MF_SEPARATOR, NULL);\r
+                               popup.AppendMenu(MF_SEPARATOR, NULL);\r
+                       }\r
 \r
                }\r
 \r
@@ -1365,7 +1391,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
                                popup.AppendMenu(MF_SEPARATOR, NULL);\r
                }\r
 \r
-               if ( GetSelectedCount() >0 )\r
+               if ( GetSelectedCount() >0 && pSelLogEntry->m_CommitHash != GIT_REV_ZERO)\r
                {\r
                        if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )\r
                        {\r
@@ -1735,20 +1761,29 @@ int CGitLogListBase::FillGitShortLog()
        mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;\r
 //     if(this->m_bAllBranch)\r
        mask |= m_ShowMask;\r
-\r
-       this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask);\r
        \r
+       if(m_bShowWC)\r
+               this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev);\r
+\r
+       this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask,m_bShowWC?1:0);\r
+\r
        //this->m_logEntries.ParserFromLog();\r
        if(IsInWorkingThread())\r
+       {\r
                PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);\r
+       }\r
        else\r
+       {\r
                SetItemCountEx(this->m_logEntries.size());\r
+       }\r
 \r
        this->m_arShownList.RemoveAll();\r
 \r
        for(unsigned int i=0;i<m_logEntries.size();i++)\r
        {\r
-               m_logEntries[i].m_Subject=_T("parser...");\r
+               if(i>0 || m_logEntries[i].m_CommitHash != GIT_REV_ZERO)\r
+                       m_logEntries[i].m_Subject=_T("parser...");\r
+\r
                if(this->m_IsOldFirst)\r
                {\r
                        this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);\r
@@ -1956,6 +1991,7 @@ void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to)
 {\r
        CGitCall_FetchFullLogInfo fetcher(this);\r
        int mask=\r
+               CGit::LOG_INFO_FULL_DIFF|\r
                CGit::LOG_INFO_STAT|\r
                CGit::LOG_INFO_FILESTATE|\r
                CGit::LOG_INFO_DETECT_COPYRENAME|\r
@@ -2041,6 +2077,21 @@ UINT CGitLogListBase::LogThread()
        int update=0;\r
        for(int i=0;i<m_logEntries.size();i++)\r
        {\r
+               if( i==0 && m_logEntries[i].m_CommitHash == GIT_REV_ZERO)\r
+               {\r
+                       m_logEntries[i].m_Files.Clear();\r
+                       m_logEntries[i].m_ParentHash.clear();\r
+                       m_logEntries[i].m_ParentHash.push_back(m_HeadHash);\r
+                       g_Git.GetCommitDiffList(m_logEntries[i].m_CommitHash,this->m_HeadHash,m_logEntries[i].m_Files);\r
+                       m_logEntries[i].m_Action =0;\r
+                       for(int j=0;j< m_logEntries[i].m_Files.GetCount();j++)\r
+                               m_logEntries[i].m_Action |= m_logEntries[i].m_Files[j].m_Action;\r
+                       \r
+                       m_logEntries[i].m_Body.Format(_T("%d files changed"),m_logEntries[i].m_Files.GetCount());\r
+                       ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0);\r
+                       continue;\r
+               }\r
+\r
                start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start);\r
                m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i;\r
 \r
@@ -2056,6 +2107,8 @@ UINT CGitLogListBase::LogThread()
                        InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);\r
                        update++;\r
                }\r
+               ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0);\r
+\r
                if(start<0)\r
                        break;\r
                if(start>=m_logEntries.m_RawlogData.size())\r
@@ -2064,7 +2117,6 @@ UINT CGitLogListBase::LogThread()
                int percent=i*30/m_logEntries.size() + GITLOG_START+1;\r
 \r
                ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0);\r
-               ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0);\r
 \r
                if(this->m_bExitThread)\r
                {       \r
@@ -2127,7 +2179,8 @@ void CGitLogListBase::Refresh()
                if(ret == WAIT_TIMEOUT)\r
                        TerminateThread();\r
        }\r
-\r
+       \r
+       this->SetItemCountEx(0);\r
        this->Clear();\r
 \r
        //Update branch and Tag info\r
@@ -2135,7 +2188,7 @@ void CGitLogListBase::Refresh()
        //Assume Thread have exited\r
        //if(!m_bThreadRunning)\r
        {\r
-               this->SetItemCountEx(0);\r
+               \r
                m_logEntries.clear();\r
                m_bExitThread=FALSE;\r
                InterlockedExchange(&m_bThreadRunning, TRUE);\r
@@ -2453,6 +2506,11 @@ LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
        int i=(int)wParam;\r
        this->GetItemRect(i,&rect,LVIR_BOUNDS);\r
        this->InvalidateRect(rect);\r
+\r
+       if(this->GetItemState(i,LVIF_STATE) & LVIS_SELECTED)\r
+       {\r
+               int i=0;\r
+       }\r
        return 0;\r
 }\r
 \r