OSDN Git Service

Show Ignore Sub Menu
[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 \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         while (bFailed)\r
70         {\r
71                 bFailed = false;\r
72                 CCommitDlg dlg;\r
73                 if (parser.HasKey(_T("bugid")))\r
74                 {\r
75                         dlg.m_sBugID = parser.GetVal(_T("bugid"));\r
76                 }\r
77                 dlg.m_sLogMessage = sLogMsg;\r
78                 dlg.m_pathList = pathList;\r
79                 dlg.m_checkedPathList = selectedList;\r
80                 dlg.m_bSelectFilesForCommit = bSelectFilesForCommit;\r
81                 if (dlg.DoModal() == IDOK)\r
82                 {\r
83                         if (dlg.m_pathList.GetCount()==0)\r
84                                 return false;\r
85                         // if the user hasn't changed the list of selected items\r
86                         // we don't use that list. Because if we would use the list\r
87                         // of pre-checked items, the dialog would show different\r
88                         // checked items on the next startup: it would only try\r
89                         // to check the parent folder (which might not even show)\r
90                         // instead, we simply use an empty list and let the\r
91                         // default checking do its job.\r
92                         if (!dlg.m_pathList.IsEqual(pathList))\r
93                                 selectedList = dlg.m_pathList;\r
94                         pathList = dlg.m_updatedPathList;\r
95                         sLogMsg = dlg.m_sLogMessage;\r
96                         bSelectFilesForCommit = true;\r
97 //                      CGitProgressDlg progDlg;\r
98 //                      progDlg.SetChangeList(dlg.m_sChangeList, !!dlg.m_bKeepChangeList);\r
99 //                      if (parser.HasVal(_T("closeonend")))\r
100 //                              progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
101 //                      progDlg.SetCommand(CGitProgressDlg::GitProgress_Commit);\r
102 //                      progDlg.SetOptions(dlg.m_bKeepLocks ? ProgOptKeeplocks : ProgOptNone);\r
103 //                      progDlg.SetPathList(dlg.m_pathList);\r
104 //                      progDlg.SetCommitMessage(dlg.m_sLogMessage);\r
105 //                      progDlg.SetDepth(dlg.m_bRecursive ? Git_depth_infinity : svn_depth_empty);\r
106 //                      progDlg.SetSelectedList(dlg.m_selectedPathList);\r
107 //                      progDlg.SetItemCount(dlg.m_itemsCount);\r
108 //                      progDlg.SetBugTraqProvider(dlg.m_BugTraqProvider);\r
109 //                      progDlg.DoModal();\r
110 //                      CRegDWORD err = CRegDWORD(_T("Software\\TortoiseSVN\\ErrorOccurred"), FALSE);\r
111 //                      err = (DWORD)progDlg.DidErrorsOccur();\r
112 //                      bFailed = progDlg.DidErrorsOccur();\r
113 //                      bRet = progDlg.DidErrorsOccur();\r
114 //                      CRegDWORD bFailRepeat = CRegDWORD(_T("Software\\TortoiseSVN\\CommitReopen"), FALSE);\r
115 //                      if (DWORD(bFailRepeat)==0)\r
116 //                              bFailed = false;                // do not repeat if the user chose not to in the settings.\r
117                 }\r
118         }\r
119         return bRet;\r
120 }\r