1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "CommitCommand.h"
21 #include "CommonResource.h"
22 #include "CommitDlg.h"
23 //#include "SVNProgressDlg.h"
24 #include "StringUtils.h"
26 #include "MessageBox.h"
29 CString
CommitCommand::LoadLogMessage()
32 if (parser
.HasKey(_T("logmsg")))
34 msg
= parser
.GetVal(_T("logmsg"));
36 if (parser
.HasKey(_T("logmsgfile")))
38 CString logmsgfile
= parser
.GetVal(_T("logmsgfile"));
39 CStringUtils::ReadStringFromTextFile(logmsgfile
, msg
);
44 bool CommitCommand::Execute()
48 CTGitPathList selectedList
;
49 if (parser
.HasKey(_T("logmsg")) && (parser
.HasKey(_T("logmsgfile"))))
51 CMessageBox::Show(hwndExplorer
, IDS_ERR_TWOLOGPARAMS
, IDS_APPNAME
, MB_ICONERROR
);
54 CString sLogMsg
= LoadLogMessage();
55 bool bSelectFilesForCommit
= !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE
));
59 if (CHooks::Instance().StartCommit(pathList
, sLogMsg
, exitcode
, error
))
64 temp
.Format(IDS_ERR_HOOKFAILED
, (LPCTSTR
)error
);
65 CMessageBox::Show(hwndExplorer
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
75 if (parser
.HasKey(_T("bugid")))
77 dlg
.m_sBugID
= parser
.GetVal(_T("bugid"));
80 if (parser
.HasKey(_T("wholeproject")))
82 dlg
.m_bWholeProject
= TRUE
;
85 dlg
.m_sLogMessage
= sLogMsg
;
86 dlg
.m_pathList
= pathList
;
87 dlg
.m_checkedPathList
= selectedList
;
88 dlg
.m_bSelectFilesForCommit
= bSelectFilesForCommit
;
89 if (dlg
.DoModal() == IDOK
)
91 if (dlg
.m_pathList
.GetCount()==0)
93 // if the user hasn't changed the list of selected items
94 // we don't use that list. Because if we would use the list
95 // of pre-checked items, the dialog would show different
96 // checked items on the next startup: it would only try
97 // to check the parent folder (which might not even show)
98 // instead, we simply use an empty list and let the
99 // default checking do its job.
100 if (!dlg
.m_pathList
.IsEqual(pathList
))
101 selectedList
= dlg
.m_pathList
;
102 pathList
= dlg
.m_updatedPathList
;
103 sLogMsg
= dlg
.m_sLogMessage
;
104 bSelectFilesForCommit
= true;
106 if( dlg
.m_bPushAfterCommit
)
110 // CGitProgressDlg progDlg;
111 // progDlg.SetChangeList(dlg.m_sChangeList, !!dlg.m_bKeepChangeList);
112 // if (parser.HasVal(_T("closeonend")))
113 // progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));
114 // progDlg.SetCommand(CGitProgressDlg::GitProgress_Commit);
115 // progDlg.SetOptions(dlg.m_bKeepLocks ? ProgOptKeeplocks : ProgOptNone);
116 // progDlg.SetPathList(dlg.m_pathList);
117 // progDlg.SetCommitMessage(dlg.m_sLogMessage);
118 // progDlg.SetDepth(dlg.m_bRecursive ? Git_depth_infinity : svn_depth_empty);
119 // progDlg.SetSelectedList(dlg.m_selectedPathList);
120 // progDlg.SetItemCount(dlg.m_itemsCount);
121 // progDlg.SetBugTraqProvider(dlg.m_BugTraqProvider);
122 // progDlg.DoModal();
123 // CRegDWORD err = CRegDWORD(_T("Software\\TortoiseGit\\ErrorOccurred"), FALSE);
124 // err = (DWORD)progDlg.DidErrorsOccur();
125 // bFailed = progDlg.DidErrorsOccur();
126 // bRet = progDlg.DidErrorsOccur();
127 // CRegDWORD bFailRepeat = CRegDWORD(_T("Software\\TortoiseGit\\CommitReopen"), FALSE);
128 // if (DWORD(bFailRepeat)==0)
129 // bFailed = false; // do not repeat if the user chose not to in the settings.