1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 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 "PasteMoveCommand.h"
\r
22 #include "ProgressDlg.h"
\r
23 #include "MessageBox.h"
\r
25 #include "SVNStatus.h"
\r
26 #include "RenameDlg.h"
\r
27 #include "ShellUpdater.h"
\r
29 bool PasteMoveCommand::Execute()
\r
31 CString sDroppath = parser.GetVal(_T("droptarget"));
\r
32 CTSVNPath dropPath(sDroppath);
\r
33 ProjectProperties props;
\r
34 props.ReadProps(dropPath);
\r
35 if (dropPath.IsAdminDir())
\r
39 unsigned long count = 0;
\r
40 pathList.RemoveAdminPaths();
\r
42 CProgressDlg progress;
\r
43 progress.SetTitle(IDS_PROC_MOVING);
\r
44 progress.SetAnimation(IDR_MOVEANI);
\r
45 progress.SetTime(true);
\r
46 progress.ShowModeless(CWnd::FromHandle(hwndExplorer));
\r
47 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
\r
50 if (sNewName.IsEmpty())
\r
51 destPath = CTSVNPath(sDroppath+_T("\\")+pathList[nPath].GetFileOrDirectoryName());
\r
53 destPath = CTSVNPath(sDroppath+_T("\\")+sNewName);
\r
54 if (destPath.Exists())
\r
56 CString name = pathList[nPath].GetFileOrDirectoryName();
\r
57 if (!sNewName.IsEmpty())
\r
62 dlg.m_windowtitle.Format(IDS_PROC_NEWNAMEMOVE, (LPCTSTR)name);
\r
63 if (dlg.DoModal() != IDOK)
\r
67 destPath.SetFromWin(sDroppath+_T("\\")+dlg.m_name);
\r
69 svn_wc_status_kind s = status.GetAllStatus(pathList[nPath]);
\r
70 if ((s == svn_wc_status_none)||(s == svn_wc_status_unversioned)||(s == svn_wc_status_ignored))
\r
72 // source file is unversioned: move the file to the target, then add it
\r
73 MoveFile(pathList[nPath].GetWinPath(), destPath.GetWinPath());
\r
74 if (!svn.Add(CTSVNPathList(destPath), &props, svn_depth_infinity, true, false, true))
\r
76 TRACE(_T("%s\n"), (LPCTSTR)svn.GetLastErrorMessage());
\r
77 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
78 return FALSE; //get out of here
\r
80 CShellUpdater::Instance().AddPathForUpdate(destPath);
\r
84 if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath, FALSE))
\r
86 if (svn.Err && (svn.Err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE ||
\r
87 svn.Err->apr_err == SVN_ERR_CLIENT_MODIFIED))
\r
89 // file/folder seems to have local modifications. Ask the user if
\r
90 // a force is requested.
\r
91 CString temp = svn.GetLastErrorMessage();
\r
92 CString sQuestion(MAKEINTRESOURCE(IDS_PROC_FORCEMOVE));
\r
93 temp += _T("\n") + sQuestion;
\r
94 if (CMessageBox::Show(hwndExplorer, temp, _T("TortoiseSVN"), MB_YESNO)==IDYES)
\r
96 if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath, TRUE))
\r
98 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
99 return FALSE; //get out of here
\r
101 CShellUpdater::Instance().AddPathForUpdate(destPath);
\r
106 TRACE(_T("%s\n"), (LPCTSTR)svn.GetLastErrorMessage());
\r
107 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
108 return FALSE; //get out of here
\r
112 CShellUpdater::Instance().AddPathForUpdate(destPath);
\r
115 if (progress.IsValid())
\r
117 progress.FormatPathLine(1, IDS_PROC_MOVINGPROG, pathList[nPath].GetWinPath());
\r
118 progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, destPath.GetWinPath());
\r
119 progress.SetProgress(count, pathList.GetCount());
\r
121 if ((progress.IsValid())&&(progress.HasUserCancelled()))
\r
123 CMessageBox::Show(hwndExplorer, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION);
\r