1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-2008 - TortoiseSVN
\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
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
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
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
26 #include "MessageBox.h"
\r
27 #include "AppUtils.h"
\r
29 CString CommitCommand::LoadLogMessage()
\r
32 if (parser.HasKey(_T("logmsg")))
\r
34 msg = parser.GetVal(_T("logmsg"));
\r
36 if (parser.HasKey(_T("logmsgfile")))
\r
38 CString logmsgfile = parser.GetVal(_T("logmsgfile"));
\r
39 CStringUtils::ReadStringFromTextFile(logmsgfile, msg);
\r
44 bool CommitCommand::Execute()
\r
47 bool bFailed = true;
\r
48 CTGitPathList selectedList;
\r
49 if (parser.HasKey(_T("logmsg")) && (parser.HasKey(_T("logmsgfile"))))
\r
51 CMessageBox::Show(hwndExplorer, IDS_ERR_TWOLOGPARAMS, IDS_APPNAME, MB_ICONERROR);
\r
54 CString sLogMsg = LoadLogMessage();
\r
55 bool bSelectFilesForCommit = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE));
\r
59 if (CHooks::Instance().StartCommit(pathList, sLogMsg, exitcode, error))
\r
64 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
\r
65 CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
75 if (parser.HasKey(_T("bugid")))
\r
77 dlg.m_sBugID = parser.GetVal(_T("bugid"));
\r
80 if (parser.HasKey(_T("wholeproject")))
\r
82 dlg.m_bWholeProject = TRUE;
\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
91 if (dlg.m_pathList.GetCount()==0)
\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
106 if( dlg.m_bPushAfterCommit )
\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