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 "DropMoveCommand.h"
\r
22 #include "ProgressDlg.h"
\r
23 #include "MessageBox.h"
\r
25 #include "RenameDlg.h"
\r
26 #include "ShellUpdater.h"
\r
28 bool DropMoveCommand::Execute()
\r
30 CString droppath = parser.GetVal(_T("droptarget"));
\r
31 if (CTSVNPath(droppath).IsAdminDir())
\r
34 unsigned long count = 0;
\r
35 pathList.RemoveAdminPaths();
\r
37 if ((parser.HasKey(_T("rename")))&&(pathList.GetCount()==1))
\r
39 // ask for a new name of the source item
\r
43 renDlg.m_windowtitle.LoadString(IDS_PROC_MOVERENAME);
\r
44 renDlg.m_name = pathList[0].GetFileOrDirectoryName();
\r
45 if (renDlg.DoModal() != IDOK)
\r
49 sNewName = renDlg.m_name;
\r
50 } while(sNewName.IsEmpty() || PathFileExists(droppath+_T("\\")+sNewName));
\r
52 CProgressDlg progress;
\r
53 if (progress.IsValid())
\r
55 progress.SetTitle(IDS_PROC_MOVING);
\r
56 progress.SetAnimation(IDR_MOVEANI);
\r
57 progress.SetTime(true);
\r
58 progress.ShowModeless(CWnd::FromHandle(hwndExplorer));
\r
60 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
\r
63 if (sNewName.IsEmpty())
\r
64 destPath = CTSVNPath(droppath+_T("\\")+pathList[nPath].GetFileOrDirectoryName());
\r
66 destPath = CTSVNPath(droppath+_T("\\")+sNewName);
\r
67 if (destPath.Exists())
\r
69 CString name = pathList[nPath].GetFileOrDirectoryName();
\r
70 if (!sNewName.IsEmpty())
\r
75 dlg.m_windowtitle.Format(IDS_PROC_NEWNAMEMOVE, (LPCTSTR)name);
\r
76 if (dlg.DoModal() != IDOK)
\r
80 destPath.SetFromWin(droppath+_T("\\")+dlg.m_name);
\r
82 if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath, FALSE))
\r
84 if (svn.Err && (svn.Err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE ||
\r
85 svn.Err->apr_err == SVN_ERR_CLIENT_MODIFIED))
\r
87 // file/folder seems to have local modifications. Ask the user if
\r
88 // a force is requested.
\r
89 CString temp = svn.GetLastErrorMessage();
\r
90 CString sQuestion(MAKEINTRESOURCE(IDS_PROC_FORCEMOVE));
\r
91 temp += _T("\n") + sQuestion;
\r
92 if (CMessageBox::Show(hwndExplorer, temp, _T("TortoiseSVN"), MB_YESNO)==IDYES)
\r
94 if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath, TRUE))
\r
96 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
97 return FALSE; //get out of here
\r
99 CShellUpdater::Instance().AddPathForUpdate(destPath);
\r
104 TRACE(_T("%s\n"), (LPCTSTR)svn.GetLastErrorMessage());
\r
105 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
106 return FALSE; //get out of here
\r
110 CShellUpdater::Instance().AddPathForUpdate(destPath);
\r
112 if (progress.IsValid())
\r
114 progress.FormatPathLine(1, IDS_PROC_MOVINGPROG, pathList[nPath].GetWinPath());
\r
115 progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, destPath.GetWinPath());
\r
116 progress.SetProgress(count, pathList.GetCount());
\r
118 if ((progress.IsValid())&&(progress.HasUserCancelled()))
\r
120 CMessageBox::Show(hwndExplorer, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION);
\r