1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2011-2014 - TortoiseGit
5 // with code of PullFetchDlg.cpp
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "TortoiseProc.h"
24 #include "RequestPullDlg.h"
27 #include "MessageBox.h"
30 IMPLEMENT_DYNAMIC(CRequestPullDlg
, CHorizontalResizableStandAloneDialog
)
32 CRequestPullDlg::CRequestPullDlg(CWnd
* pParent
/*=NULL*/)
33 : CHorizontalResizableStandAloneDialog(CRequestPullDlg::IDD
, pParent
)
34 , m_regSendMail(_T("Software\\TortoiseGit\\TortoiseProc\\RequestPull\\SendMail"), FALSE
)
36 m_bSendMail
= m_regSendMail
;
39 CRequestPullDlg::~CRequestPullDlg()
43 void CRequestPullDlg::DoDataExchange(CDataExchange
* pDX
)
45 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX
);
46 DDX_Control(pDX
, IDC_COMBOBOXEX_LOCAL_BRANCH
, m_cStartRevision
);
47 DDX_Control(pDX
, IDC_COMBOBOXEX_URL
, m_cRepositoryURL
);
48 DDX_Control(pDX
, IDC_REMOTE_BRANCH
, m_cEndRevision
);
49 DDX_Check(pDX
, IDC_CHECK_SENDMAIL
, m_bSendMail
);
53 BEGIN_MESSAGE_MAP(CRequestPullDlg
, CHorizontalResizableStandAloneDialog
)
54 ON_BN_CLICKED(IDOK
, &CRequestPullDlg::OnBnClickedOk
)
55 ON_BN_CLICKED(IDC_BUTTON_LOCAL_BRANCH
, &CRequestPullDlg::OnBnClickedButtonLocalBranch
)
58 BOOL
CRequestPullDlg::OnInitDialog()
60 CHorizontalResizableStandAloneDialog::OnInitDialog();
61 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
63 AddAnchor(IDOK
,BOTTOM_RIGHT
);
64 AddAnchor(IDCANCEL
,BOTTOM_RIGHT
);
65 AddAnchor(IDHELP
,BOTTOM_RIGHT
);
67 AddAnchor(IDC_BUTTON_LOCAL_BRANCH
, TOP_RIGHT
);
68 AddAnchor(IDC_COMBOBOXEX_LOCAL_BRANCH
, TOP_LEFT
,TOP_RIGHT
);
69 AddAnchor(IDC_COMBOBOXEX_URL
, TOP_LEFT
,TOP_RIGHT
);
70 AddAnchor(IDC_REMOTE_BRANCH
, TOP_LEFT
,TOP_RIGHT
);
72 EnableSaveRestore(_T("RequestPullDlg"));
75 GetWindowText(sWindowTitle
);
76 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, sWindowTitle
);
79 g_Git
.GetBranchList(list
, NULL
, CGit::BRANCH_ALL
);
80 m_cStartRevision
.SetMaxHistoryItems(0x7FFFFFFF);
81 m_cStartRevision
.SetList(list
);
83 CString WorkingDir
=g_Git
.m_CurrentDir
;
84 WorkingDir
.Replace(_T(':'), _T('_'));
86 m_RegStartRevision
= CRegString(_T("Software\\TortoiseGit\\History\\RequestPull\\")+WorkingDir
+_T("\\startrevision"));
87 if(m_StartRevision
.IsEmpty()) {
88 m_StartRevision
= m_RegStartRevision
;
90 m_cStartRevision
.SetWindowTextW(m_StartRevision
);
92 // store URLs in global history, but save last used local url separately,
93 // because one normally has only one writable repository
94 m_cRepositoryURL
.SetCaseSensitive(TRUE
);
95 m_cRepositoryURL
.SetURLHistory(TRUE
);
96 m_cRepositoryURL
.LoadHistory(_T("Software\\TortoiseGit\\History\\RequestPull"), _T("url"));
97 m_RegRepositoryURL
= CRegString(_T("Software\\TortoiseGit\\History\\RequestPull\\")+WorkingDir
+_T("\\repositoryurl"));
98 if(m_RepositoryURL
.IsEmpty())
100 m_RepositoryURL
= m_RegRepositoryURL
;
102 m_cRepositoryURL
.SetWindowTextW(m_RepositoryURL
);
104 m_RegEndRevision
= CRegString(_T("Software\\TortoiseGit\\History\\RequestPull\\")+WorkingDir
+_T("\\endrevision"), _T("HEAD"));
105 if(m_EndRevision
.IsEmpty()) {
106 m_EndRevision
= m_RegEndRevision
;
108 m_cEndRevision
.SetWindowTextW(m_EndRevision
);
110 this->UpdateData(FALSE
);
115 void CRequestPullDlg::OnBnClickedOk()
117 CHorizontalResizableStandAloneDialog::UpdateData(TRUE
);
119 m_cRepositoryURL
.SaveHistory();
121 m_cStartRevision
.GetWindowTextW(m_StartRevision
);
122 m_RepositoryURL
= m_cRepositoryURL
.GetString();
123 m_cEndRevision
.GetWindowTextW(m_EndRevision
);
125 m_RegStartRevision
= m_StartRevision
;
126 m_RegRepositoryURL
= m_RepositoryURL
;
127 m_RegEndRevision
= m_EndRevision
.Trim();
129 if(!g_Git
.IsBranchNameValid(m_EndRevision
))
131 CMessageBox::Show(NULL
, IDS_B_T_NOTEMPTY
, IDS_APPNAME
, MB_OK
);
135 if(m_StartRevision
.Find(_T("remotes/")) == 0)
136 m_StartRevision
= m_StartRevision
.Mid(8);
138 m_regSendMail
= m_bSendMail
;
140 CHorizontalResizableStandAloneDialog::OnOK();
143 void CRequestPullDlg::OnBnClickedButtonLocalBranch()
145 // use the git log to allow selection of a version
148 m_cStartRevision
.GetWindowText(revision
);
149 dlg
.SetParams(CTGitPath(), CTGitPath(), revision
, revision
, 0);
150 // tell the dialog to use mode for selecting revisions
152 // only one revision must be selected however
153 dlg
.SingleSelection(true);
154 if ( dlg
.DoModal() == IDOK
)
156 // get selected hash if any
157 CString selectedHash
= dlg
.GetSelectedHash();
158 // load into window, do this even if empty so that it is clear that nothing has been selected
159 m_cStartRevision
.SetWindowText( selectedHash
);