Update diff del rename ignore document.
[TortoiseGit.git] / src / TortoiseProc / PushDlg.cpp
blobe26b4621872a9b415d53550e402e2041d8fffa90
1 // PushDlg.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "TortoiseProc.h"
6 #include "PushDlg.h"
8 #include "Git.h"
9 #include "registry.h"
10 #include "AppUtils.h"
11 #include "BrowseRefsDlg.h"
13 // CPushDlg dialog
15 IMPLEMENT_DYNAMIC(CPushDlg, CResizableStandAloneDialog)
17 CPushDlg::CPushDlg(CWnd* pParent /*=NULL*/)
18 : CResizableStandAloneDialog(CPushDlg::IDD, pParent)
20 m_bAutoLoad = CAppUtils::IsSSHPutty();
23 CPushDlg::~CPushDlg()
27 void CPushDlg::DoDataExchange(CDataExchange* pDX)
29 CResizableStandAloneDialog::DoDataExchange(pDX);
30 DDX_Control(pDX, IDC_BRANCH_REMOTE, this->m_BranchRemote);
31 DDX_Control(pDX, IDC_BRANCH_SOURCE, this->m_BranchSource);
32 DDX_Control(pDX, IDC_REMOTE, this->m_Remote);
33 DDX_Control(pDX, IDC_URL, this->m_RemoteURL);
34 DDX_Check(pDX,IDC_FORCE,this->m_bForce);
35 DDX_Check(pDX,IDC_PACK,this->m_bPack);
36 DDX_Check(pDX,IDC_TAGS,this->m_bTags);
37 DDX_Check(pDX,IDC_PUTTYKEY_AUTOLOAD,this->m_bAutoLoad);
42 BEGIN_MESSAGE_MAP(CPushDlg, CResizableStandAloneDialog)
43 ON_BN_CLICKED(IDC_RD_REMOTE, &CPushDlg::OnBnClickedRd)
44 ON_BN_CLICKED(IDC_RD_URL, &CPushDlg::OnBnClickedRd)
45 ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE, &CPushDlg::OnCbnSelchangeBranchSource)
46 ON_BN_CLICKED(IDOK, &CPushDlg::OnBnClickedOk)
47 ON_BN_CLICKED(IDC_REMOTE_MANAGE, &CPushDlg::OnBnClickedRemoteManage)
48 ON_BN_CLICKED(IDC_BUTTON_BROWSE_SOURCE_BRANCH, &CPushDlg::OnBnClickedButtonBrowseSourceBranch)
49 ON_BN_CLICKED(IDC_BUTTON_BROWSE_DEST_BRANCH, &CPushDlg::OnBnClickedButtonBrowseDestBranch)
50 END_MESSAGE_MAP()
52 BOOL CPushDlg::OnInitDialog()
54 CResizableStandAloneDialog::OnInitDialog();
56 AddAnchor(IDOK,BOTTOM_RIGHT);
57 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
58 AddAnchor(IDC_BRANCH_GROUP, TOP_LEFT,TOP_RIGHT);
59 AddAnchor(IDC_STATIC_REMOTE, TOP_RIGHT);
60 AddAnchor(IDC_STATIC_SOURCE, TOP_LEFT);
62 AddAnchor(IDC_BRANCH_REMOTE, TOP_RIGHT);
63 AddAnchor(IDC_BUTTON_BROWSE_DEST_BRANCH, TOP_RIGHT);
64 AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT);
65 AddAnchor(IDC_BUTTON_BROWSE_SOURCE_BRANCH, TOP_LEFT);
67 AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT);
68 AddAnchor(IDC_RD_REMOTE, TOP_LEFT);
69 AddAnchor(IDC_RD_URL, TOP_LEFT);
71 AddAnchor(IDC_REMOTE, TOP_LEFT, TOP_RIGHT);
73 AddAnchor(IDC_URL, TOP_LEFT,TOP_RIGHT);
75 AddAnchor(IDC_OPTION_GROUP, TOP_LEFT,TOP_RIGHT);
77 AddAnchor(IDC_FORCE, TOP_LEFT);
78 AddAnchor(IDC_PACK, TOP_LEFT);
79 AddAnchor(IDC_TAGS, TOP_LEFT);
80 AddAnchor(IDC_PUTTYKEY_AUTOLOAD,TOP_LEFT);
82 AddAnchor(IDC_REMOTE_MANAGE,TOP_RIGHT);
84 AddOthersToAnchor();
86 this->GetDlgItem(IDC_PUTTYKEY_AUTOLOAD)->EnableWindow(m_bAutoLoad);
88 EnableSaveRestore(_T("PushDlg"));
90 m_RemoteURL.SetURLHistory(TRUE);
92 CString WorkingDir=g_Git.m_CurrentDir;
93 WorkingDir.Replace(_T(':'),_T('_'));
94 m_RemoteURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\PushURLS\\"))+WorkingDir, _T("url"));
95 CString clippath=CAppUtils::GetClipboardLink();
96 if(clippath.IsEmpty())
97 m_RemoteURL.SetCurSel(0);
98 else
99 m_RemoteURL.SetWindowText(clippath);
101 m_RemoteURL.EnableWindow(FALSE);
102 CheckRadioButton(IDC_RD_REMOTE,IDC_RD_URL,IDC_RD_REMOTE);
104 STRING_VECTOR list;
105 CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));
106 m_RemoteReg = remote;
107 int sel=0;
109 if(!g_Git.GetRemoteList(list))
111 for(unsigned int i=0;i<list.size();i++)
113 m_Remote.AddString(list[i]);
114 if(list[i] == remote)
115 sel = i;
118 m_Remote.SetCurSel(sel);
120 int current=0;
121 list.clear();
122 if(!g_Git.GetBranchList(list,&current))
124 for(unsigned int i=0;i<list.size();i++)
125 m_BranchSource.AddString(list[i]);
127 m_BranchSource.SetCurSel(current);
129 m_BranchRemote.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\RemoteBranch\\"))+WorkingDir, _T("branch"));
130 m_BranchRemote.SetCurSel(0);
132 //m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());
135 return TRUE;
138 // CPushDlg message handlers
140 void CPushDlg::OnBnClickedRd()
142 // TODO: Add your control notification handler code here
143 // TODO: Add your control notification handler code here
144 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)
146 m_Remote.EnableWindow(TRUE);
147 m_RemoteURL.EnableWindow(FALSE);;
149 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)
151 m_Remote.EnableWindow(FALSE);
152 m_RemoteURL.EnableWindow(TRUE);
157 void CPushDlg::OnCbnSelchangeBranchSource()
159 // TODO: Add your control notification handler code here
160 m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());
163 void CPushDlg::OnBnClickedOk()
165 // TODO: Add your control notification handler code here
166 CResizableStandAloneDialog::UpdateData(TRUE);
168 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)
170 m_URL=m_Remote.GetString();
172 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)
174 m_URL=m_RemoteURL.GetString();
177 this->m_BranchRemoteName=m_BranchRemote.GetString();
178 this->m_BranchSourceName=m_BranchSource.GetString();
180 this->m_RemoteURL.SaveHistory();
181 this->m_BranchRemote.SaveHistory();
183 m_RemoteReg = m_Remote.GetString();
185 CResizableStandAloneDialog::OnOK();
188 void CPushDlg::OnBnClickedRemoteManage()
190 // TODO: Add your control notification handler code here
191 CAppUtils::LaunchRemoteSetting();
194 void CPushDlg::OnBnClickedButtonBrowseSourceBranch()
196 if(CBrowseRefsDlg::PickRefForCombo(&m_BranchSource, gPickRef_Head))
197 OnCbnSelchangeBranchSource();
200 void CPushDlg::OnBnClickedButtonBrowseDestBranch()
202 CString remoteBranchName;
203 m_BranchRemote.GetWindowText(remoteBranchName);
204 remoteBranchName = CBrowseRefsDlg::PickRef(false, remoteBranchName, gPickRef_Remote);
205 if(remoteBranchName.IsEmpty())
206 return; //Canceled
207 remoteBranchName = remoteBranchName.Mid(13);//Strip 'refs/remotes/'
208 remoteBranchName = remoteBranchName.Mid(remoteBranchName.Find('/') + 1); //Strip remote name (for example 'origin/')
210 m_BranchRemote.SetWindowText(remoteBranchName);