OSDN Git Service

merge original branch.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / CommitCommand.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 "CommitCommand.h"\r
21 #include "CommonResource.h"\r
22 #include "CommitDlg.h"\r
23 //#include "SVNProgressDlg.h"\r
24 #include "StringUtils.h"\r
25 #include "Hooks.h"\r
26 #include "MessageBox.h"\r
27 #include "AppUtils.h"\r
28 \r
29 CString CommitCommand::LoadLogMessage()\r
30 {\r
31         CString msg;\r
32         if (parser.HasKey(_T("logmsg")))\r
33         {\r
34                 msg = parser.GetVal(_T("logmsg"));\r
35         }\r
36         if (parser.HasKey(_T("logmsgfile")))\r
37         {\r
38                 CString logmsgfile = parser.GetVal(_T("logmsgfile"));\r
39                 CStringUtils::ReadStringFromTextFile(logmsgfile, msg);\r
40         }\r
41         return msg;\r
42 }\r
43 \r
44 bool CommitCommand::Execute()\r
45 {\r
46         bool bRet = false;\r
47         \r
48         CTGitPathList selectedList;\r
49         if (parser.HasKey(_T("logmsg")) && (parser.HasKey(_T("logmsgfile"))))\r
50         {\r
51                 CMessageBox::Show(hwndExplorer, IDS_ERR_TWOLOGPARAMS, IDS_APPNAME, MB_ICONERROR);\r
52                 return false;\r
53         }\r
54         CString sLogMsg = LoadLogMessage();\r
55         bool bSelectFilesForCommit = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE));\r
56         DWORD exitcode = 0;\r
57         CString error;\r
58 #if 0\r
59         if (CHooks::Instance().StartCommit(pathList, sLogMsg, exitcode, error))\r
60         {\r
61                 if (exitcode)\r
62                 {\r
63                         CString temp;\r
64                         temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);\r
65                         CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONERROR);\r
66                         return false;\r
67                 }\r
68         }\r
69 #endif\r
70 \r
71         return CAppUtils::Commit(       parser.GetVal(_T("bugid")),\r
72                                                                 parser.HasKey(_T("wholeproject")),\r
73                                                                 sLogMsg,\r
74                                                                 pathList,\r
75                                                                 selectedList,\r
76                                                                 bSelectFilesForCommit);\r
77         \r
78 }\r