1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2011-2014, 2016 - 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
/*=nullptr*/)
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
, nullptr, 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())
99 m_RepositoryURL
= m_RegRepositoryURL
;
100 m_cRepositoryURL
.SetWindowTextW(m_RepositoryURL
);
102 m_RegEndRevision
= CRegString(_T("Software\\TortoiseGit\\History\\RequestPull\\")+WorkingDir
+_T("\\endrevision"), _T("HEAD"));
103 if (m_EndRevision
.IsEmpty())
104 m_EndRevision
= m_RegEndRevision
;
105 m_cEndRevision
.SetWindowTextW(m_EndRevision
);
107 this->UpdateData(FALSE
);
112 void CRequestPullDlg::OnBnClickedOk()
114 CHorizontalResizableStandAloneDialog::UpdateData(TRUE
);
116 m_cRepositoryURL
.SaveHistory();
118 m_cStartRevision
.GetWindowTextW(m_StartRevision
);
119 m_RepositoryURL
= m_cRepositoryURL
.GetString();
120 m_cEndRevision
.GetWindowTextW(m_EndRevision
);
122 m_RegStartRevision
= m_StartRevision
;
123 m_RegRepositoryURL
= m_RepositoryURL
;
124 m_RegEndRevision
= m_EndRevision
.Trim();
126 if(!g_Git
.IsBranchNameValid(m_EndRevision
))
128 CMessageBox::Show(GetSafeHwnd(), IDS_B_T_NOTEMPTY
, IDS_APPNAME
, MB_OK
| MB_ICONEXCLAMATION
);
132 if(m_StartRevision
.Find(_T("remotes/")) == 0)
133 m_StartRevision
= m_StartRevision
.Mid(8);
135 m_regSendMail
= m_bSendMail
;
137 CHorizontalResizableStandAloneDialog::OnOK();
140 void CRequestPullDlg::OnBnClickedButtonLocalBranch()
142 // use the git log to allow selection of a version
145 m_cStartRevision
.GetWindowText(revision
);
146 dlg
.SetParams(CTGitPath(), CTGitPath(), revision
, revision
, 0);
147 // tell the dialog to use mode for selecting revisions
149 dlg
.ShowWorkingTreeChanges(false);
150 // only one revision must be selected however
151 dlg
.SingleSelection(true);
152 if ( dlg
.DoModal() == IDOK
)
153 m_cStartRevision
.SetWindowText(dlg
.GetSelectedHash().at(0).ToString());