From 98c8df352f89bcd87f089c2bbcebb3b7bf9e0208 Mon Sep 17 00:00:00 2001 From: Johan 't Hart Date: Thu, 28 May 2009 20:03:46 +0200 Subject: [PATCH] Pick Ref: Implemented ref picking for push dialog --- src/Resources/TortoiseProcENG.rc | Bin 429816 -> 430150 bytes src/TortoiseProc/BrowseRefsDlg.cpp | 32 ++++++++++++++++++++++++++++++++ src/TortoiseProc/BrowseRefsDlg.h | 1 + src/TortoiseProc/PushDlg.cpp | 24 ++++++++++++++++++++++++ src/TortoiseProc/PushDlg.h | 2 ++ src/TortoiseProc/RebaseDlg.cpp | 12 +----------- src/TortoiseProc/resource.h | Bin 159476 -> 159754 bytes 7 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 522f9bb173f8af9ac68537764b57e11354b1c6fc..950b0a6eefaf31c0ee7f18f610099d70829100a5 100644 GIT binary patch delta 468 zcmZutJxc>Y6nyvg)WnY<9tjdtXlyOKGk4KK$Y}%>{8kVQ#DIlmigY%jk~9jD178t^ z_zw~|JcEVF6&8Y>q_?xx%F?$HY?Nh(-PxJh+5NhSK2@W~XNrs6F4aP!*Bf+k0<{E8 z!vq*G#W)Rplxej3%QckK2~9|s#0;2p(L|flEsW7SQ(f{JgX$}&IW;@}+j6qc>b%YX?&*Ad zhN;}bgB}iGy-6GWVu=D3?5A}fW5FNV;-2=d*fX=R1#7San=lUxkcBy3*|5sHMRw~P zEc+Wgf3AQib zrKP8IXjPCd-Gn`cm*|+CI`*uHVdgMDX6FB&v7i0A%{DJ+0P!GJBo)GCG5{M4mvCZ{ zq6$lO3#yhyy|aT?4=@z9NYg9-n3JlQPFxHpkdnTH2Gtz}ZQ}gQaZwjG9`>QE&kv|Y z3RuL!L7H*-+=nw7vlXafeGD#o`=DX?0&#i%2$vcwkpkX5!8)$BXdY`DV9qrx;b{oV zl;f+;GU$h}CA4c3-$O8!4J90>9yPF$W1HB#hXfuBz)HGG)SoFa`^<=s?K~dsF%5eI z*j?bHq^OJO7PZmWnTd%Gr0{qMxy4^rR!^7(tL^RxWOu|)3|hqW4O?k@5mTv2FN(eO Fz5!j5WC{QP diff --git a/src/TortoiseProc/BrowseRefsDlg.cpp b/src/TortoiseProc/BrowseRefsDlg.cpp index 0f6dac1..ef93ba1 100644 --- a/src/TortoiseProc/BrowseRefsDlg.cpp +++ b/src/TortoiseProc/BrowseRefsDlg.cpp @@ -711,3 +711,35 @@ CString CBrowseRefsDlg::PickRef(bool returnAsHash, CString initialRef, int pickR return dlg.m_pickedRef; } +bool CBrowseRefsDlg::PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind) +{ + CString origRef; + pComboBox->GetLBText(pComboBox->GetCurSel(), origRef); + CString resultRef = PickRef(false,origRef,pickRef_Kind); + if(resultRef.IsEmpty()) + return false; + if(wcsncmp(resultRef,L"refs/",5)==0) + resultRef = resultRef.Mid(5); +// if(wcsncmp(resultRef,L"heads/",6)==0) +// resultRef = resultRef.Mid(6); + + //Find closest match of choice in combobox + int ixFound = -1; + int matchLength = 0; + CString comboRefName; + for(int i = 0; i < pComboBox->GetCount(); ++i) + { + pComboBox->GetLBText(i, comboRefName); + if(matchLength < comboRefName.GetLength() && resultRef.Right(comboRefName.GetLength()) == comboRefName) + { + matchLength = comboRefName.GetLength(); + ixFound = i; + } + } + if(ixFound >= 0) + pComboBox->SetCurSel(ixFound); + else + ASSERT(FALSE);//No match found. So either pickRef_Kind is wrong or the combobox does not contain the ref specified in the picker (which it should unless the repo has changed before creating the CBrowseRef dialog) + + return true; +} diff --git a/src/TortoiseProc/BrowseRefsDlg.h b/src/TortoiseProc/BrowseRefsDlg.h index f383265..16391be 100644 --- a/src/TortoiseProc/BrowseRefsDlg.h +++ b/src/TortoiseProc/BrowseRefsDlg.h @@ -134,4 +134,5 @@ public: CString m_pickedRef; static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All); + static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All); }; diff --git a/src/TortoiseProc/PushDlg.cpp b/src/TortoiseProc/PushDlg.cpp index 7022c2a..e26b462 100644 --- a/src/TortoiseProc/PushDlg.cpp +++ b/src/TortoiseProc/PushDlg.cpp @@ -8,6 +8,7 @@ #include "Git.h" #include "registry.h" #include "AppUtils.h" +#include "BrowseRefsDlg.h" // CPushDlg dialog @@ -44,6 +45,8 @@ BEGIN_MESSAGE_MAP(CPushDlg, CResizableStandAloneDialog) ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE, &CPushDlg::OnCbnSelchangeBranchSource) ON_BN_CLICKED(IDOK, &CPushDlg::OnBnClickedOk) ON_BN_CLICKED(IDC_REMOTE_MANAGE, &CPushDlg::OnBnClickedRemoteManage) + ON_BN_CLICKED(IDC_BUTTON_BROWSE_SOURCE_BRANCH, &CPushDlg::OnBnClickedButtonBrowseSourceBranch) + ON_BN_CLICKED(IDC_BUTTON_BROWSE_DEST_BRANCH, &CPushDlg::OnBnClickedButtonBrowseDestBranch) END_MESSAGE_MAP() BOOL CPushDlg::OnInitDialog() @@ -57,7 +60,9 @@ BOOL CPushDlg::OnInitDialog() AddAnchor(IDC_STATIC_SOURCE, TOP_LEFT); AddAnchor(IDC_BRANCH_REMOTE, TOP_RIGHT); + AddAnchor(IDC_BUTTON_BROWSE_DEST_BRANCH, TOP_RIGHT); AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT); + AddAnchor(IDC_BUTTON_BROWSE_SOURCE_BRANCH, TOP_LEFT); AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_RD_REMOTE, TOP_LEFT); @@ -185,3 +190,22 @@ void CPushDlg::OnBnClickedRemoteManage() // TODO: Add your control notification handler code here CAppUtils::LaunchRemoteSetting(); } + +void CPushDlg::OnBnClickedButtonBrowseSourceBranch() +{ + if(CBrowseRefsDlg::PickRefForCombo(&m_BranchSource, gPickRef_Head)) + OnCbnSelchangeBranchSource(); +} + +void CPushDlg::OnBnClickedButtonBrowseDestBranch() +{ + CString remoteBranchName; + m_BranchRemote.GetWindowText(remoteBranchName); + remoteBranchName = CBrowseRefsDlg::PickRef(false, remoteBranchName, gPickRef_Remote); + if(remoteBranchName.IsEmpty()) + return; //Canceled + remoteBranchName = remoteBranchName.Mid(13);//Strip 'refs/remotes/' + remoteBranchName = remoteBranchName.Mid(remoteBranchName.Find('/') + 1); //Strip remote name (for example 'origin/') + + m_BranchRemote.SetWindowText(remoteBranchName); +} diff --git a/src/TortoiseProc/PushDlg.h b/src/TortoiseProc/PushDlg.h index e753a66..72cb135 100644 --- a/src/TortoiseProc/PushDlg.h +++ b/src/TortoiseProc/PushDlg.h @@ -41,4 +41,6 @@ public: afx_msg void OnCbnSelchangeBranchSource(); afx_msg void OnBnClickedOk(); afx_msg void OnBnClickedRemoteManage(); + afx_msg void OnBnClickedButtonBrowseSourceBranch(); + afx_msg void OnBnClickedButtonBrowseDestBranch(); }; diff --git a/src/TortoiseProc/RebaseDlg.cpp b/src/TortoiseProc/RebaseDlg.cpp index 465ab4b..7665567 100644 --- a/src/TortoiseProc/RebaseDlg.cpp +++ b/src/TortoiseProc/RebaseDlg.cpp @@ -1211,15 +1211,5 @@ void CRebaseDlg::OnBnClickedAbort() void CRebaseDlg::OnBnClickedButtonBrowse() { - CString origRef; - m_UpstreamCtrl.GetLBText(m_UpstreamCtrl.GetCurSel(), origRef); - CString resultRef = CBrowseRefsDlg::PickRef(false,origRef,gPickRef_NoTag); - if(resultRef.IsEmpty()) - return; - if(wcsncmp(resultRef,L"refs/",5)==0) - resultRef = resultRef.Mid(5); - if(wcsncmp(resultRef,L"heads/",6)==0) - resultRef = resultRef.Mid(6); - m_UpstreamCtrl.SetCurSel(m_UpstreamCtrl.FindStringExact(0,resultRef)); - + CBrowseRefsDlg::PickRefForCombo(&m_UpstreamCtrl, gPickRef_NoTag); } diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index d0f02e94d0b5bcc75000d9f398737e8e98a5ffc1..d1dc252656c93a367fd8d27851b55fa8f389fd77 100644 GIT binary patch delta 149 zcmexzm$T~uXTui8b2gJdT;Z8sXT!)R9nTQV;Li}s5X9ij;K~rs-~?njGWY>`9@F1j zGpbMikk2>$jt%1~xE5JFS{RI`$J>H5L5=5(XK(=;8_WF;U19X#fBK -- 2.11.0