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 "RemoveCommand.h"
\r
22 #include "MessageBox.h"
\r
23 #include "ProgressDlg.h"
\r
25 #include "InputLogDlg.h"
\r
26 #include "ShellUpdater.h"
\r
28 bool RemoveCommand::Execute()
\r
31 // removing items from a working copy is done item-by-item so we
\r
32 // have a chance to show a progress bar
\r
34 // removing items from an URL in the repository requires that we
\r
35 // ask the user for a log message.
\r
36 BOOL bForce = FALSE;
\r
38 if ((pathList.GetCount())&&(SVN::PathIsURL(pathList[0])))
\r
40 // Delete using URL's, not wc paths
\r
41 svn.SetPromptApp(&theApp);
\r
44 svn.GetRepositoryRootAndUUID(pathList[0], sUUID);
\r
47 if (pathList.GetCount() == 1)
\r
48 sHint.Format(IDS_INPUT_REMOVEONE, (LPCTSTR)pathList[0].GetSVNPathString());
\r
50 sHint.Format(IDS_INPUT_REMOVEMORE, pathList.GetCount());
\r
51 dlg.SetActionText(sHint);
\r
52 if (dlg.DoModal()==IDOK)
\r
54 if (!svn.Remove(pathList, TRUE, parser.HasKey(_T("keep")), dlg.GetLogMessage()))
\r
56 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
65 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
\r
67 TRACE(_T("remove file %s\n"), (LPCTSTR)pathList[nPath].GetUIPathString());
\r
68 // even though SVN::Remove takes a list of paths to delete at once
\r
69 // we delete each item individually so we can prompt the user
\r
70 // if something goes wrong or unversioned/modified items are
\r
72 CTSVNPathList removePathList(pathList[nPath]);
\r
75 CTSVNPath delPath = removePathList[0];
\r
76 delPath.Delete(true);
\r
78 if (!svn.Remove(removePathList, bForce, parser.HasKey(_T("keep"))))
\r
80 if ((svn.Err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE) ||
\r
81 (svn.Err->apr_err == SVN_ERR_CLIENT_MODIFIED))
\r
83 CString msg, yes, no, yestoall;
\r
84 if (pathList[nPath].IsDirectory())
\r
86 msg.Format(IDS_PROC_REMOVEFORCEFOLDER, pathList[nPath].GetWinPath());
\r
90 msg.Format(IDS_PROC_REMOVEFORCE, (LPCTSTR)svn.GetLastErrorMessage());
\r
92 yes.LoadString(IDS_MSGBOX_YES);
\r
93 no.LoadString(IDS_MSGBOX_NO);
\r
94 yestoall.LoadString(IDS_PROC_YESTOALL);
\r
95 UINT ret = CMessageBox::Show(hwndExplorer, msg, _T("TortoiseSVN"), 2, IDI_ERROR, yes, no, yestoall);
\r
98 if ((ret == 1)||(ret==3))
\r
100 CTSVNPath delPath = removePathList[0];
\r
101 delPath.Delete(true);
\r
102 if (!svn.Remove(removePathList, TRUE, parser.HasKey(_T("keep"))))
\r
104 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
111 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
116 CShellUpdater::Instance().AddPathsForUpdate(pathList);
\r