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
37 BOOL bForce = FALSE;
\r
39 if ((pathList.GetCount())&&(SVN::PathIsURL(pathList[0])))
\r
41 // Delete using URL's, not wc paths
\r
42 svn.SetPromptApp(&theApp);
\r
45 svn.GetRepositoryRootAndUUID(pathList[0], sUUID);
\r
48 if (pathList.GetCount() == 1)
\r
49 sHint.Format(IDS_INPUT_REMOVEONE, (LPCTSTR)pathList[0].GetSVNPathString());
\r
51 sHint.Format(IDS_INPUT_REMOVEMORE, pathList.GetCount());
\r
52 dlg.SetActionText(sHint);
\r
53 if (dlg.DoModal()==IDOK)
\r
55 if (!svn.Remove(pathList, TRUE, parser.HasKey(_T("keep")), dlg.GetLogMessage()))
\r
57 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
66 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
\r
68 TRACE(_T("remove file %s\n"), (LPCTSTR)pathList[nPath].GetUIPathString());
\r
69 // even though SVN::Remove takes a list of paths to delete at once
\r
70 // we delete each item individually so we can prompt the user
\r
71 // if something goes wrong or unversioned/modified items are
\r
73 CTSVNPathList removePathList(pathList[nPath]);
\r
76 CTSVNPath delPath = removePathList[0];
\r
77 delPath.Delete(true);
\r
79 if (!svn.Remove(removePathList, bForce, parser.HasKey(_T("keep"))))
\r
81 if ((svn.Err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE) ||
\r
82 (svn.Err->apr_err == SVN_ERR_CLIENT_MODIFIED))
\r
84 CString msg, yes, no, yestoall;
\r
85 if (pathList[nPath].IsDirectory())
\r
87 msg.Format(IDS_PROC_REMOVEFORCEFOLDER, pathList[nPath].GetWinPath());
\r
91 msg.Format(IDS_PROC_REMOVEFORCE, (LPCTSTR)svn.GetLastErrorMessage());
\r
93 yes.LoadString(IDS_MSGBOX_YES);
\r
94 no.LoadString(IDS_MSGBOX_NO);
\r
95 yestoall.LoadString(IDS_PROC_YESTOALL);
\r
96 UINT ret = CMessageBox::Show(hwndExplorer, msg, _T("TortoiseSVN"), 2, IDI_ERROR, yes, no, yestoall);
\r
99 if ((ret == 1)||(ret==3))
\r
101 CTSVNPath delPath = removePathList[0];
\r
102 delPath.Delete(true);
\r
103 if (!svn.Remove(removePathList, TRUE, parser.HasKey(_T("keep"))))
\r
105 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
112 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
117 CShellUpdater::Instance().AddPathsForUpdate(pathList);
\r
119 int key=CMessageBox::Show(hwndExplorer, _T("File will removed from version control\r\n Do you want to keep local copy"), _T("TortoiseGit"), MB_ICONINFORMATION|MB_YESNOCANCEL);
\r
120 if(key == IDCANCEL)
\r
125 cmd=_T("git.exe rm -r -f ");
\r
128 cmd= _T("git.exe update-index --force-remove -- ");
\r
130 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
\r
133 if(g_Git.Run(cmd+pathList[nPath].GetGitPathString(),&output,CP_OEMCP))
\r
135 key=CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONINFORMATION|MB_OKCANCEL);
\r
136 if(key == IDCANCEL)
\r