1 // PullFetchDlg.cpp : implementation file
\r
5 #include "TortoiseProc.h"
\r
6 #include "PullFetchDlg.h"
\r
8 #include "AppUtils.h"
\r
9 #include "BrowseRefsDlg.h"
\r
10 // CPullFetchDlg dialog
\r
12 IMPLEMENT_DYNAMIC(CPullFetchDlg, CResizableStandAloneDialog)
\r
14 CPullFetchDlg::CPullFetchDlg(CWnd* pParent /*=NULL*/)
\r
15 : CResizableStandAloneDialog(CPullFetchDlg::IDD, pParent),
\r
19 m_bAutoLoad = CAppUtils::IsSSHPutty();
\r
20 m_bAutoLoadEnable=true;
\r
23 CPullFetchDlg::~CPullFetchDlg()
\r
27 void CPullFetchDlg::DoDataExchange(CDataExchange* pDX)
\r
29 CDialog::DoDataExchange(pDX);
\r
30 DDX_Control(pDX, IDC_REMOTE_COMBO, this->m_Remote);
\r
31 DDX_Control(pDX, IDC_OTHER, this->m_Other);
\r
32 DDX_Control(pDX, IDC_REMOTE_BRANCH, this->m_RemoteBranch);
\r
33 DDX_Control(pDX,IDC_REMOTE_MANAGE, this->m_RemoteManage);
\r
34 DDX_Check(pDX,IDC_PUTTYKEY_AUTOLOAD,m_bAutoLoad);
\r
35 DDX_Check(pDX,IDC_CHECK_REBASE,m_bRebase);
\r
40 BEGIN_MESSAGE_MAP(CPullFetchDlg,CResizableStandAloneDialog )
\r
41 ON_BN_CLICKED(IDC_REMOTE_RD, &CPullFetchDlg::OnBnClickedRd)
\r
42 ON_BN_CLICKED(IDC_OTHER_RD, &CPullFetchDlg::OnBnClickedRd)
\r
43 ON_BN_CLICKED(IDOK, &CPullFetchDlg::OnBnClickedOk)
\r
44 ON_STN_CLICKED(IDC_REMOTE_MANAGE, &CPullFetchDlg::OnStnClickedRemoteManage)
\r
45 ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CPullFetchDlg::OnBnClickedButtonBrowseRef)
\r
48 BOOL CPullFetchDlg::OnInitDialog()
\r
50 CResizableStandAloneDialog::OnInitDialog();
\r
51 AddAnchor(IDC_REMOTE_COMBO, TOP_LEFT, TOP_RIGHT);
\r
52 AddAnchor(IDC_OTHER, TOP_LEFT,TOP_RIGHT);
\r
54 AddAnchor(IDC_REMOTE_BRANCH, TOP_LEFT,TOP_RIGHT);
\r
56 AddAnchor(IDOK,BOTTOM_RIGHT);
\r
57 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
\r
58 AddAnchor(IDC_GROUPT_REMOTE,TOP_LEFT,BOTTOM_RIGHT);
\r
59 AddAnchor(IDC_PUTTYKEY_AUTOLOAD,BOTTOM_LEFT);
\r
60 AddAnchor(IDC_CHECK_REBASE,BOTTOM_LEFT);
\r
61 AddAnchor(IDC_REMOTE_MANAGE,BOTTOM_LEFT);
\r
62 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
64 this->AddOthersToAnchor();
\r
66 this->GetDlgItem(IDC_PUTTYKEY_AUTOLOAD)->EnableWindow(m_bAutoLoadEnable);
\r
68 CheckRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD,IDC_REMOTE_RD);
\r
69 m_Remote.EnableWindow(TRUE);
\r
70 m_Other.EnableWindow(FALSE);
\r
72 m_RemoteBranch.EnableWindow(FALSE);
\r
75 //Todo: implement rebase option sometime with rebase dialog
\r
76 GetDlgItem(IDC_CHECK_REBASE)->ShowWindow(SW_HIDE);
\r
78 m_Other.SetURLHistory(TRUE);
\r
79 m_Other.LoadHistory(_T("Software\\TortoiseGit\\History\\PullURLS"), _T("url"));
\r
80 CString clippath=CAppUtils::GetClipboardLink();
\r
81 if(clippath.IsEmpty())
\r
82 m_Other.SetCurSel(0);
\r
84 m_Other.SetWindowText(clippath);
\r
86 m_RemoteBranch.LoadHistory(_T("Software\\TortoiseGit\\History\\PullRemoteBranch"), _T("br"));
\r
87 m_RemoteBranch.SetCurSel(0);
\r
89 CString WorkingDir=g_Git.m_CurrentDir;
\r
92 this->SetWindowTextW(CString(_T("Pull - "))+WorkingDir);
\r
94 this->SetWindowTextW(CString(_T("Fetch - "))+WorkingDir);
\r
98 CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PullRemote\\")+WorkingDir));
\r
99 m_RemoteReg = remote;
\r
102 //Select pull-remote from current branch
\r
103 CString currentBranch = g_Git.GetSymbolicRef();
\r
104 CString configName;
\r
105 configName.Format(L"branch.%s.remote", currentBranch);
\r
106 CString pullRemote = g_Git.GetConfigValue(configName);
\r
108 //Select pull-branch from current branch
\r
109 configName.Format(L"branch.%s.merge", currentBranch);
\r
110 CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
\r
111 m_RemoteBranch.AddString(pullBranch);
\r
113 if(pullRemote.IsEmpty())
\r
114 pullRemote = remote;
\r
116 if(!g_Git.GetRemoteList(list))
\r
118 for(unsigned int i=0;i<list.size();i++)
\r
120 m_Remote.AddString(list[i]);
\r
121 if(list[i] == pullRemote)
\r
125 m_Remote.SetCurSel(sel);
\r
127 EnableSaveRestore(_T("PullFetchDlg"));
\r
128 this->m_RemoteManage.SetURL(CString());
\r
131 // CPullFetchDlg message handlers
\r
133 void CPullFetchDlg::OnBnClickedRd()
\r
136 // TODO: Add your control notification handler code here
\r
137 if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_REMOTE_RD)
\r
139 m_Remote.EnableWindow(TRUE);
\r
140 m_Other.EnableWindow(FALSE);
\r
142 m_RemoteBranch.EnableWindow(FALSE);
\r
144 if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_OTHER_RD)
\r
146 m_Remote.EnableWindow(FALSE);
\r
147 m_Other.EnableWindow(TRUE);;
\r
149 m_RemoteBranch.EnableWindow(TRUE);
\r
155 void CPullFetchDlg::OnBnClickedOk()
\r
157 // TODO: Add your control notification handler code here
\r
158 if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_REMOTE_RD)
\r
160 m_RemoteURL=m_Remote.GetString();
\r
162 m_RemoteBranchName.Empty();
\r
164 m_RemoteBranchName=m_RemoteBranch.GetString();
\r
167 if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_OTHER_RD)
\r
169 m_Other.GetWindowTextW(m_RemoteURL);
\r
170 m_RemoteBranchName=m_RemoteBranch.GetString();
\r
174 m_RemoteReg = m_Remote.GetString();
\r
176 m_Other.SaveHistory();
\r
177 m_RemoteBranch.SaveHistory();
\r
181 void CPullFetchDlg::OnStnClickedRemoteManage()
\r
183 // TODO: Add your control notification handler code here
\r
184 CAppUtils::LaunchRemoteSetting();
\r
187 void CPullFetchDlg::OnBnClickedButtonBrowseRef()
\r
189 CString initialRef;
\r
190 initialRef.Format(L"refs/remotes/%s/%s", m_Remote.GetString(), m_RemoteBranch.GetString());
\r
191 CString selectedRef = CBrowseRefsDlg::PickRef(false, initialRef, gPickRef_Remote);
\r
192 if(selectedRef.Left(13) != "refs/remotes/")
\r
195 selectedRef = selectedRef.Mid(13);
\r
196 int ixSlash = selectedRef.Find('/');
\r
198 CString remoteName = selectedRef.Left(ixSlash);
\r
199 CString remoteBranch = selectedRef.Mid(ixSlash + 1);
\r
201 int ixFound = m_Remote.FindStringExact(0, remoteName);
\r
203 m_Remote.SetCurSel(ixFound);
\r
204 m_RemoteBranch.AddString(remoteBranch);
\r
206 CheckRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD,IDC_REMOTE_RD);
\r