1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2011-2013, 2015-2017 - TortoiseGit
4 // Copyright (C) 2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "PasteCopyCommand.h"
23 #include "SysProgressDlg.h"
24 #include "MessageBox.h"
25 #include "RenameDlg.h"
27 #include "ShellUpdater.h"
29 bool PasteCopyCommand::Execute()
31 CString sDroppath
= parser
.GetVal(L
"droptarget");
32 CTGitPath
dropPath(sDroppath
);
33 if (dropPath
.IsAdminDir())
36 if(!dropPath
.HasAdminDir(&g_Git
.m_CurrentDir
))
40 unsigned long count
= 0;
42 orgPathList
.RemoveAdminPaths();
43 CSysProgressDlg progress
;
44 progress
.SetTitle(IDS_PROC_COPYING
);
45 progress
.SetTime(true);
46 progress
.ShowModeless(CWnd::FromHandle(hwndExplorer
));
47 for (int nPath
= 0; nPath
< orgPathList
.GetCount(); ++nPath
)
49 const CTGitPath
& sourcePath
= orgPathList
[nPath
];
51 CTGitPath fullDropPath
= dropPath
;
52 if (sNewName
.IsEmpty())
53 fullDropPath
.AppendPathString(sourcePath
.GetFileOrDirectoryName());
55 fullDropPath
.AppendPathString(sNewName
);
57 // Check for a drop-on-to-ourselves
58 if (sourcePath
.IsEquivalentTo(fullDropPath
))
63 dlg
.m_windowtitle
.Format(IDS_PROC_NEWNAMECOPY
, (LPCTSTR
)sourcePath
.GetUIFileOrDirectoryName());
64 if (dlg
.DoModal() != IDOK
)
66 // rebuild the progress dialog
67 progress
.EnsureValid();
68 progress
.SetTitle(IDS_PROC_COPYING
);
69 progress
.SetTime(true);
70 progress
.SetProgress(count
, orgPathList
.GetCount());
71 progress
.ShowModeless(CWnd::FromHandle(hwndExplorer
));
72 // Rebuild the destination path, with the new name
73 fullDropPath
.SetFromUnknown(sDroppath
);
74 fullDropPath
.AppendPathString(dlg
.m_name
);
77 //svn_wc_status_kind s = status.GetAllStatus(sourcePath);
78 //if ((s == svn_wc_status_none)||(s == svn_wc_status_unversioned)||(s == svn_wc_status_ignored))
80 // source file is unversioned: move the file to the target, then add it
81 CopyFile(sourcePath
.GetWinPath(), fullDropPath
.GetWinPath(), FALSE
);
83 cmd
.Format(L
"git.exe add -- \"%s\"", fullDropPath
.GetWinPath());
84 if (g_Git
.Run(cmd
, &output
, CP_UTF8
))
86 TRACE(L
"%s\n", (LPCTSTR
)output
);
87 CMessageBox::Show(hwndExplorer
, output
, L
"TortoiseGit", MB_ICONERROR
);
88 return FALSE
; //get out of here
91 CShellUpdater::Instance().AddPathForUpdate(fullDropPath
);
95 // if (!svn.Copy(CTSVNPathList(sourcePath), fullDropPath, SVNRev::REV_WC, SVNRev()))
97 // TRACE(L"%s\n", (LPCTSTR)svn.GetLastErrorMessage());
98 // CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), L"TortoiseSVN", MB_ICONERROR);
99 // return FALSE; //get out of here
102 // CShellUpdater::Instance().AddPathForUpdate(fullDropPath);
105 if (progress
.IsValid())
107 progress
.FormatPathLine(1, IDS_PROC_COPYINGPROG
, sourcePath
.GetWinPath());
108 progress
.FormatPathLine(2, IDS_PROC_CPYMVPROG2
, fullDropPath
.GetWinPath());
109 progress
.SetProgress(count
, orgPathList
.GetCount());
111 if ((progress
.IsValid())&&(progress
.HasUserCancelled()))
113 CMessageBox::Show(hwndExplorer
, IDS_USERCANCELLED
, IDS_APPNAME
, MB_ICONINFORMATION
);