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 "DropCopyCommand.h"
\r
22 #include "SysProgressDlg.h"
\r
23 #include "ProgressDlg.h"
\r
24 #include "MessageBox.h"
\r
25 #include "RenameDlg.h"
\r
27 #include "ShellUpdater.h"
\r
29 bool DropCopyCommand::Execute()
\r
32 CString sDroppath = parser.GetVal(_T("droptarget"));
\r
33 if (CTGitPath(sDroppath).IsAdminDir())
\r
36 unsigned long count = 0;
\r
38 pathList.RemoveAdminPaths();
\r
39 if ((parser.HasKey(_T("rename")))&&(pathList.GetCount()==1))
\r
41 // ask for a new name of the source item
\r
45 renDlg.m_windowtitle.LoadString(IDS_PROC_COPYRENAME);
\r
46 renDlg.m_name = pathList[0].GetFileOrDirectoryName();
\r
47 if (renDlg.DoModal() != IDOK)
\r
51 sNewName = renDlg.m_name;
\r
52 } while(sNewName.IsEmpty() || PathFileExists(sDroppath+_T("\\")+sNewName));
\r
54 CProgressDlg progress;
\r
55 progress.SetTitle(IDS_PROC_COPYING);
\r
56 progress.SetAnimation(IDR_MOVEANI);
\r
57 progress.SetTime(true);
\r
58 progress.ShowModeless(CWnd::FromHandle(hwndExplorer));
\r
59 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
\r
61 const CTSVNPath& sourcePath = pathList[nPath];
\r
63 CTSVNPath fullDropPath(sDroppath);
\r
64 if (sNewName.IsEmpty())
\r
65 fullDropPath.AppendPathString(sourcePath.GetFileOrDirectoryName());
\r
67 fullDropPath.AppendPathString(sNewName);
\r
69 // Check for a drop-on-to-ourselves
\r
70 if (sourcePath.IsEquivalentTo(fullDropPath))
\r
75 dlg.m_windowtitle.Format(IDS_PROC_NEWNAMECOPY, (LPCTSTR)sourcePath.GetUIFileOrDirectoryName());
\r
76 if (dlg.DoModal() != IDOK)
\r
80 // rebuild the progress dialog
\r
81 progress.EnsureValid();
\r
82 progress.SetTitle(IDS_PROC_COPYING);
\r
83 progress.SetAnimation(IDR_MOVEANI);
\r
84 progress.SetTime(true);
\r
85 progress.SetProgress(count, pathList.GetCount());
\r
86 progress.ShowModeless(CWnd::FromHandle(hwndExplorer));
\r
87 // Rebuild the destination path, with the new name
\r
88 fullDropPath.SetFromUnknown(sDroppath);
\r
89 fullDropPath.AppendPathString(dlg.m_name);
\r
91 if (!svn.Copy(CTSVNPathList(sourcePath), fullDropPath, SVNRev::REV_WC, SVNRev()))
\r
93 TRACE(_T("%s\n"), (LPCTSTR)svn.GetLastErrorMessage());
\r
94 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
\r
95 return FALSE; //get out of here
\r
98 CShellUpdater::Instance().AddPathForUpdate(fullDropPath);
\r
100 if (progress.IsValid())
\r
102 progress.FormatPathLine(1, IDS_PROC_COPYINGPROG, sourcePath.GetWinPath());
\r
103 progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, fullDropPath.GetWinPath());
\r
104 progress.SetProgress(count, pathList.GetCount());
\r
106 if ((progress.IsValid())&&(progress.HasUserCancelled()))
\r
108 CMessageBox::Show(hwndExplorer, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION);
\r