OSDN Git Service

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