OSDN Git Service

Pick Ref: Prepare ref picker to be able to leave out some ref types.
authorJohan 't Hart <johanthart@gmail.com>
Thu, 28 May 2009 12:46:00 +0000 (14:46 +0200)
committerFrank Li <lznuaa@gmail.com>
Fri, 29 May 2009 08:30:09 +0000 (16:30 +0800)
src/TortoiseProc/BrowseRefsDlg.cpp
src/TortoiseProc/BrowseRefsDlg.h
src/TortoiseProc/RebaseDlg.cpp

index d24bb47..0f6dac1 100644 (file)
@@ -42,7 +42,8 @@ CBrowseRefsDlg::CBrowseRefsDlg(CString cmdPath, CWnd* pParent /*=NULL*/)
        m_cmdPath(cmdPath),\r
        m_currSortCol(-1),\r
        m_currSortDesc(false),\r
-       m_initialRef(L"HEAD")\r
+       m_initialRef(L"HEAD"),\r
+       m_pickRef_Kind(gPickRef_All)\r
 {\r
 \r
 }\r
@@ -227,14 +228,19 @@ void CBrowseRefsDlg::Refresh(CString selectRef)
                int valuePos=0;\r
                CString refName=singleRef.Tokenize(L"\04",valuePos);\r
                CString refRest=singleRef.Mid(valuePos);\r
-               refMap[refName]=refRest;\r
-       }\r
 \r
+               //Use ref based on m_pickRef_Kind\r
+               if(wcsncmp(refName,L"refs/heads",10)==0 && !(m_pickRef_Kind & gPickRef_Head) )\r
+                       continue; //Skip\r
+               if(wcsncmp(refName,L"refs/tags",9)==0 && !(m_pickRef_Kind & gPickRef_Tag) )\r
+                       continue; //Skip\r
+               if(wcsncmp(refName,L"refs/remotes",12)==0 && !(m_pickRef_Kind & gPickRef_Remote) )\r
+                       continue; //Skip\r
+\r
+               refMap[refName] = refRest; //Use\r
+       }\r
 \r
 \r
-//     for(MAP_HASH_NAME::iterator iterRef=m_RefMap.begin();iterRef!=m_RefMap.end();++iterRef)\r
-//             for(STRING_VECTOR::iterator iterRefName=iterRef->second.begin();iterRefName!=iterRef->second.end();++iterRefName)\r
-//                     refName[*iterRefName]=iterRef->first;\r
 \r
        //Populate ref tree\r
        for(MAP_STRING_STRING::iterator iterRefMap=refMap.begin();iterRefMap!=refMap.end();++iterRefMap)\r
@@ -692,11 +698,12 @@ void CBrowseRefsDlg::OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult)
        EndDialog(IDOK);\r
 }\r
 \r
-CString CBrowseRefsDlg::PickRef(bool returnAsHash, CString initialRef)\r
+CString CBrowseRefsDlg::PickRef(bool returnAsHash, CString initialRef, int pickRef_Kind)\r
 {\r
        CBrowseRefsDlg dlg(CString(),NULL);\r
        \r
        dlg.m_initialRef = initialRef;\r
+       dlg.m_pickRef_Kind = pickRef_Kind;\r
 \r
        if(dlg.DoModal() != IDOK)\r
                return CString();\r
index 6a529b4..f383265 100644 (file)
@@ -5,6 +5,13 @@
 #include "afxcmn.h"\r
 #include "StandAloneDlg.h"\r
 \r
+\r
+const int gPickRef_Head                = 1;\r
+const int gPickRef_Tag         = 2;\r
+const int gPickRef_Remote      = 4;\r
+const int gPickRef_All         = gPickRef_Head | gPickRef_Tag | gPickRef_Remote;\r
+const int gPickRef_NoTag       = gPickRef_All & ~gPickRef_Tag;\r
+\r
 class CShadowTree\r
 {\r
 public:\r
@@ -123,7 +130,8 @@ public:
 \r
 public:\r
        CString m_initialRef;\r
+       int             m_pickRef_Kind;\r
        CString m_pickedRef;\r
 \r
-       static CString  PickRef(bool returnAsHash = false, CString initialRef = CString()); \r
+       static CString  PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All); \r
 };\r
index e1b7a3a..465ab4b 100644 (file)
@@ -1213,7 +1213,7 @@ void CRebaseDlg::OnBnClickedButtonBrowse()
 {\r
        CString origRef;\r
        m_UpstreamCtrl.GetLBText(m_UpstreamCtrl.GetCurSel(), origRef);\r
-       CString resultRef = CBrowseRefsDlg::PickRef(false,origRef);\r
+       CString resultRef = CBrowseRefsDlg::PickRef(false,origRef,gPickRef_NoTag);\r
        if(resultRef.IsEmpty())\r
                return;\r
        if(wcsncmp(resultRef,L"refs/",5)==0)\r