Enable security checks and features
[TortoiseGit.git] / src / TortoiseProc / Commands / UpdateCommand.cpp
blobce699d8ec5a6edc9b3abc8350673aa2a6b9f0be5
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "StdAfx.h"
20 #include "UpdateCommand.h"
22 #include "UpdateDlg.h"
23 #include "SVNProgressDlg.h"
24 #include "Hooks.h"
25 #include "MessageBox.h"
27 bool UpdateCommand::Execute()
29 SVNRev rev = SVNRev(_T("HEAD"));
30 int options = 0;
31 svn_depth_t depth = svn_depth_unknown;
32 DWORD exitcode = 0;
33 CString error;
34 if (CHooks::Instance().StartUpdate(pathList, exitcode, error))
36 if (exitcode)
38 CString temp;
39 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
40 CMessageBox::Show(hwndExplorer, temp, _T("TortoiseSVN"), MB_ICONERROR);
41 return FALSE;
44 if ((parser.HasKey(_T("rev")))&&(!parser.HasVal(_T("rev"))))
46 CUpdateDlg dlg;
47 if (pathList.GetCount()>0)
48 dlg.m_wcPath = pathList[0];
49 if (dlg.DoModal() == IDOK)
51 rev = dlg.Revision;
52 depth = dlg.m_depth;
53 options |= dlg.m_bNoExternals ? ProgOptIgnoreExternals : 0;
55 else
56 return FALSE;
58 else
60 if (parser.HasVal(_T("rev")))
61 rev = SVNRev(parser.GetVal(_T("rev")));
62 if (parser.HasKey(_T("nonrecursive")))
63 depth = svn_depth_empty;
64 if (parser.HasKey(_T("ignoreexternals")))
65 options |= ProgOptIgnoreExternals;
68 CSVNProgressDlg progDlg;
69 theApp.m_pMainWnd = &progDlg;
70 progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Update);
71 if (parser.HasVal(_T("closeonend")))
72 progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));
73 progDlg.SetOptions(options);
74 progDlg.SetPathList(pathList);
75 progDlg.SetRevision(rev);
76 progDlg.SetDepth(depth);
77 progDlg.DoModal();
78 return !progDlg.DidErrorsOccur();