OSDN Git Service

Pick Ref: Made user able to pick a ref in the logviewer to view the log from.
authorJohan 't Hart <johanthart@gmail.com>
Thu, 28 May 2009 22:30:53 +0000 (00:30 +0200)
committerFrank Li <lznuaa@gmail.com>
Fri, 29 May 2009 08:30:11 +0000 (16:30 +0800)
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/BrowseRefsDlg.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/LogDlg.cpp
src/TortoiseProc/LogDlg.h
src/TortoiseProc/resource.h

index 950b0a6..234fdb2 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index ef93ba1..05d046c 100644 (file)
@@ -542,7 +542,7 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh
        case eCmd_ViewLog:\r
                {\r
                        CLogDlg dlg;\r
-                       dlg.SetStartRef(selectedLeafs[0]->m_csRefHash);\r
+                       dlg.SetStartRef(selectedLeafs[0]->GetRefName());\r
                        dlg.DoModal();\r
                }\r
                break;\r
index 9de0785..937fb46 100644 (file)
@@ -201,6 +201,8 @@ public:
                m_StartRef=StartRef;\r
        }\r
 \r
+       CString GetStartRef() const {return m_StartRef;}\r
+\r
        \r
        volatile bool           m_bExitThread;\r
        CWinThread*                     m_LoadingThread;\r
index 52c1720..2a209e8 100644 (file)
@@ -45,7 +45,7 @@
 //#include "RepositoryInfo.h"\r
 //#include "EditPropertiesDlg.h"\r
 #include "FileDiffDlg.h"\r
-\r
+#include "BrowseRefsDlg.h"\r
 \r
 const UINT CLogDlg::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING);\r
 \r
@@ -144,6 +144,7 @@ BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)
        ON_WM_SIZE()\r
        ON_BN_CLICKED(IDC_LOG_FIRSTPARENT, &CLogDlg::OnBnClickedFirstParent)\r
        ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)\r
+       ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CLogDlg::OnBnClickedBrowseRef)\r
        ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)\r
        ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)\r
        ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)\r
@@ -236,6 +237,8 @@ BOOL CLogDlg::OnInitDialog()
        m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);\r
 \r
        // resizable stuff\r
+       AddAnchor(IDC_STATIC_REF, TOP_LEFT);\r
+       AddAnchor(IDC_BUTTON_BROWSE_REF, TOP_LEFT);\r
        AddAnchor(IDC_FROMLABEL, TOP_LEFT);\r
        AddAnchor(IDC_DATEFROM, TOP_LEFT);\r
        AddAnchor(IDC_TOLABEL, TOP_LEFT);\r
@@ -331,6 +334,8 @@ BOOL CLogDlg::OnInitDialog()
        m_LogList.FetchLogAsync(this);\r
 \r
        GetDlgItem(IDC_LOGLIST)->SetFocus();\r
+\r
+       ShowStartRef();\r
        return FALSE;\r
 }\r
 \r
@@ -2923,6 +2928,7 @@ void CLogDlg::OnSize(UINT nType, int cx, int cy)
 void CLogDlg::OnRefresh()\r
 {\r
        //if (GetDlgItem(IDC_GETALL)->IsWindowEnabled())\r
+       ShowStartRef();\r
        {\r
                m_limit = 0;\r
                this->m_LogProgress.SetPos(0);\r
@@ -3042,6 +3048,54 @@ void CLogDlg::OnBnClickedAllBranch()
        FillLogMessageCtrl(false);\r
 }\r
 \r
+void CLogDlg::OnBnClickedBrowseRef()\r
+{\r
+       CString newRef = CBrowseRefsDlg::PickRef(false,m_LogList.GetStartRef());        \r
+       if(newRef.IsEmpty())\r
+               return;\r
+\r
+       SetStartRef(newRef);\r
+       ((CButton*)GetDlgItem(IDC_LOG_ALLBRANCH))->SetCheck(0);\r
+\r
+       OnBnClickedAllBranch();\r
+}\r
+\r
+void CLogDlg::ShowStartRef()\r
+{\r
+       //Show ref name on top\r
+       if(!::IsWindow(m_hWnd))\r
+               return;\r
+       if(m_bAllBranch)\r
+       {\r
+               GetDlgItem(IDC_STATIC_REF)->SetWindowText(L"<All Branches>");\r
+               return;\r
+       }\r
+\r
+       CString showStartRef = m_LogList.GetStartRef();\r
+       if(showStartRef.IsEmpty())\r
+       {\r
+               //Ref name is HEAD\r
+               g_Git.Run(L"git symbolic-ref HEAD",&showStartRef,CP_UTF8);\r
+               showStartRef.Trim(L"\r\n\t ");\r
+       }\r
+\r
+\r
+       if(wcsncmp(showStartRef,L"refs/",5) == 0)\r
+               showStartRef = showStartRef.Mid(5);\r
+       if(wcsncmp(showStartRef,L"heads/",6) == 0)\r
+               showStartRef = showStartRef.Mid(6);\r
+\r
+       GetDlgItem(IDC_STATIC_REF)->SetWindowText(showStartRef);\r
+}\r
+\r
+void CLogDlg::SetStartRef(const CString& StartRef)\r
+{\r
+       m_LogList.SetStartRef(StartRef);\r
+\r
+       ShowStartRef();\r
+}\r
+\r
+\r
 \r
 void CLogDlg::OnBnClickedFirstParent()\r
 {\r
index b67ff14..37883ee 100644 (file)
@@ -91,7 +91,8 @@ public:
        void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}\r
        void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}\r
        void SetMergePath(const CTGitPath& mergepath) {m_mergePath = mergepath;}\r
-       void SetStartRef(const CString& StartRef) {m_LogList.SetStartRef(StartRef);}\r
+       void SetStartRef(const CString& StartRef);\r
+       void ShowStartRef();\r
        /**\r
         * Provides selected commit hash if available, call after OK return from here\r
         * Empty if none\r
@@ -137,6 +138,7 @@ protected:
        afx_msg void OnBnClickShowWholeProject();\r
        afx_msg void OnBnClickedHidepaths();\r
        afx_msg void OnBnClickedAllBranch();\r
+       afx_msg void OnBnClickedBrowseRef();\r
        afx_msg void OnBnClickedCheckStoponcopy();\r
        \r
        afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);\r
index d1dc252..bf74599 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ