OSDN Git Service

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