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
22 #include "CommitDlg.h"
\r
23 //#include "SVNProgressDlg.h"
\r
24 #include "StringUtils.h"
\r
26 #include "MessageBox.h"
\r
28 CString CommitCommand::LoadLogMessage()
\r
31 if (parser.HasKey(_T("logmsg")))
\r
33 msg = parser.GetVal(_T("logmsg"));
\r
35 if (parser.HasKey(_T("logmsgfile")))
\r
37 CString logmsgfile = parser.GetVal(_T("logmsgfile"));
\r
38 CStringUtils::ReadStringFromTextFile(logmsgfile, msg);
\r
43 bool CommitCommand::Execute()
\r
46 bool bFailed = true;
\r
47 CTGitPathList selectedList;
\r
48 if (parser.HasKey(_T("logmsg")) && (parser.HasKey(_T("logmsgfile"))))
\r
50 CMessageBox::Show(hwndExplorer, IDS_ERR_TWOLOGPARAMS, IDS_APPNAME, MB_ICONERROR);
\r
53 CString sLogMsg = LoadLogMessage();
\r
54 bool bSelectFilesForCommit = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE));
\r
58 if (CHooks::Instance().StartCommit(pathList, sLogMsg, exitcode, error))
\r
63 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
\r
64 CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONERROR);
\r
73 if (parser.HasKey(_T("bugid")))
\r
75 dlg.m_sBugID = parser.GetVal(_T("bugid"));
\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
83 if (dlg.m_pathList.GetCount()==0)
\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