OSDN Git Service

Show commit command at log dialog when choose work copy
authorFrank Li <lznuaa@gmail.com>
Wed, 28 Oct 2009 14:20:10 +0000 (22:20 +0800)
committerFrank Li <lznuaa@gmail.com>
Wed, 28 Oct 2009 14:20:10 +0000 (22:20 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/CommonResource.h
src/Resources/TortoiseCommon.rc2
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/resource.h

index 9d5d738..9dc59c5 100644 (file)
@@ -69,3 +69,4 @@
 #define IDS_COPY_COMMIT_HASH                   20067\r
 #define IDS_CREATE_PATCH                               20068\r
 #define IDS_DELETE_BRANCHTAG                   20069\r
+#define IDS_LOG_POPUP_COMMIT            20070\r
index e829d96..1bd03d9 100644 (file)
@@ -78,6 +78,7 @@ BEGIN
        IDS_COPY_COMMIT_HASH            "Copy Commit Hash"\r
        IDS_CREATE_PATCH                        "Format Patch..."\r
        IDS_DELETE_BRANCHTAG            "Del"\r
+       IDS_LOG_POPUP_COMMIT            "Commit..."\r
 END \r
 \r
 \r
index 0ab5e82..0839948 100644 (file)
@@ -1000,7 +1000,10 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                        \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
@@ -1278,8 +1281,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
@@ -1290,6 +1294,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
@@ -1325,30 +1333,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
@@ -1387,7 +1398,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
@@ -2070,7 +2081,17 @@ UINT CGitLogListBase::LogThread()
        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
                        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
index 97ca779..5b7051f 100644 (file)
@@ -148,6 +148,7 @@ public:
        ID_REBASE_TO_VERSION,\r
        ID_CREATE_PATCH,\r
        ID_DELETE,\r
+       ID_COMMIT,\r
        };\r
        inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<<i ;}\r
        void InsertGitColumn();\r
@@ -185,6 +186,8 @@ public:
                g_Git.GetMapHashToFriendName(m_HashMap);\r
                m_CurrentBranch=g_Git.GetCurrentBranch();\r
                this->m_HeadHash=g_Git.GetHash(CString(_T("HEAD"))).Left(40);\r
+               m_wcRev.m_ParentHash.clear();\r
+               m_wcRev.m_ParentHash.push_back(m_HeadHash);\r
        }\r
        void TerminateThread()\r
        {\r
index 056a11c..775a248 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ