OSDN Git Service

Share resource file between TortoiseGitBlame and TortoiseProc
[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 \r
28 CString CommitCommand::LoadLogMessage()\r
29 {\r
30         CString msg;\r
31         if (parser.HasKey(_T("logmsg")))\r
32         {\r
33                 msg = parser.GetVal(_T("logmsg"));\r
34         }\r
35         if (parser.HasKey(_T("logmsgfile")))\r
36         {\r
37                 CString logmsgfile = parser.GetVal(_T("logmsgfile"));\r
38                 CStringUtils::ReadStringFromTextFile(logmsgfile, msg);\r
39         }\r
40         return msg;\r
41 }\r
42 \r
43 bool CommitCommand::Execute()\r
44 {\r
45         bool bRet = false;\r
46         bool bFailed = true;\r
47         CTGitPathList selectedList;\r
48         if (parser.HasKey(_T("logmsg")) && (parser.HasKey(_T("logmsgfile"))))\r
49         {\r
50                 CMessageBox::Show(hwndExplorer, IDS_ERR_TWOLOGPARAMS, IDS_APPNAME, MB_ICONERROR);\r
51                 return false;\r
52         }\r
53         CString sLogMsg = LoadLogMessage();\r
54         bool bSelectFilesForCommit = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE));\r
55         DWORD exitcode = 0;\r
56         CString error;\r
57 #if 0\r
58         if (CHooks::Instance().StartCommit(pathList, sLogMsg, exitcode, error))\r
59         {\r
60                 if (exitcode)\r
61                 {\r
62                         CString temp;\r
63                         temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);\r
64                         CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONERROR);\r
65                         return false;\r
66                 }\r
67         }\r
68 #endif\r
69                 \r
70         while (bFailed)\r
71         {\r
72                 bFailed = false;\r
73                 CCommitDlg dlg;\r
74                 if (parser.HasKey(_T("bugid")))\r
75                 {\r
76                         dlg.m_sBugID = parser.GetVal(_T("bugid"));\r
77                 }\r
78                 dlg.m_sLogMessage = sLogMsg;\r
79                 dlg.m_pathList = pathList;\r
80                 dlg.m_checkedPathList = selectedList;\r
81                 dlg.m_bSelectFilesForCommit = bSelectFilesForCommit;\r
82                 if (dlg.DoModal() == IDOK)\r
83                 {\r
84                         if (dlg.m_pathList.GetCount()==0)\r
85                                 return false;\r
86                         // if the user hasn't changed the list of selected items\r
87                         // we don't use that list. Because if we would use the list\r
88                         // of pre-checked items, the dialog would show different\r
89                         // checked items on the next startup: it would only try\r
90                         // to check the parent folder (which might not even show)\r
91                         // instead, we simply use an empty list and let the\r
92                         // default checking do its job.\r
93                         if (!dlg.m_pathList.IsEqual(pathList))\r
94                                 selectedList = dlg.m_pathList;\r
95                         pathList = dlg.m_updatedPathList;\r
96                         sLogMsg = dlg.m_sLogMessage;\r
97                         bSelectFilesForCommit = true;\r
98 //                      CGitProgressDlg progDlg;\r
99 //                      progDlg.SetChangeList(dlg.m_sChangeList, !!dlg.m_bKeepChangeList);\r
100 //                      if (parser.HasVal(_T("closeonend")))\r
101 //                              progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
102 //                      progDlg.SetCommand(CGitProgressDlg::GitProgress_Commit);\r
103 //                      progDlg.SetOptions(dlg.m_bKeepLocks ? ProgOptKeeplocks : ProgOptNone);\r
104 //                      progDlg.SetPathList(dlg.m_pathList);\r
105 //                      progDlg.SetCommitMessage(dlg.m_sLogMessage);\r
106 //                      progDlg.SetDepth(dlg.m_bRecursive ? Git_depth_infinity : svn_depth_empty);\r
107 //                      progDlg.SetSelectedList(dlg.m_selectedPathList);\r
108 //                      progDlg.SetItemCount(dlg.m_itemsCount);\r
109 //                      progDlg.SetBugTraqProvider(dlg.m_BugTraqProvider);\r
110 //                      progDlg.DoModal();\r
111 //                      CRegDWORD err = CRegDWORD(_T("Software\\TortoiseGit\\ErrorOccurred"), FALSE);\r
112 //                      err = (DWORD)progDlg.DidErrorsOccur();\r
113 //                      bFailed = progDlg.DidErrorsOccur();\r
114 //                      bRet = progDlg.DidErrorsOccur();\r
115 //                      CRegDWORD bFailRepeat = CRegDWORD(_T("Software\\TortoiseGit\\CommitReopen"), FALSE);\r
116 //                      if (DWORD(bFailRepeat)==0)\r
117 //                              bFailed = false;                // do not repeat if the user chose not to in the settings.\r
118                 }\r
119         }\r
120         return bRet;\r
121 }\r