Use processdlg to format patch.
[TortoiseGit.git] / src / TortoiseProc / Commands / DropCopyAddCommand.cpp
blob0f55bfb3462f7718a28fd62308b2abd36babfc6f
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "StdAfx.h"
20 #include "DropCopyAddCommand.h"
22 #include "SVNProgressDlg.h"
23 #include "MessageBox.h"
25 bool DropCopyAddCommand::Execute()
27 bool bRet = false;
28 #if 0
29 CString droppath = parser.GetVal(_T("droptarget"));
30 if (CTSVNPath(droppath).IsAdminDir())
31 return FALSE;
33 pathList.RemoveAdminPaths();
34 CTSVNPathList copiedFiles;
35 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
37 if (!pathList[nPath].IsEquivalentTo(CTSVNPath(droppath)))
39 //copy the file to the new location
40 CString name = pathList[nPath].GetFileOrDirectoryName();
41 if (::PathFileExists(droppath+_T("\\")+name))
43 CString strMessage;
44 strMessage.Format(IDS_PROC_OVERWRITE_CONFIRM, (LPCTSTR)(droppath+_T("\\")+name));
45 int ret = CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseSVN"), MB_YESNOCANCEL | MB_ICONQUESTION);
46 if (ret == IDYES)
48 if (!::CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))
50 //the copy operation failed! Get out of here!
51 LPVOID lpMsgBuf;
52 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
53 FORMAT_MESSAGE_FROM_SYSTEM |
54 FORMAT_MESSAGE_IGNORE_INSERTS,
55 NULL,
56 GetLastError(),
57 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
58 (LPTSTR) &lpMsgBuf,
60 NULL
62 CString strMessage;
63 strMessage.Format(IDS_ERR_COPYFILES, (LPTSTR)lpMsgBuf);
64 CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseSVN"), MB_OK | MB_ICONINFORMATION);
65 LocalFree( lpMsgBuf );
66 return FALSE;
69 if (ret == IDCANCEL)
71 return FALSE; //cancel the whole operation
74 else if (!CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))
76 //the copy operation failed! Get out of here!
77 LPVOID lpMsgBuf;
78 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
79 FORMAT_MESSAGE_FROM_SYSTEM |
80 FORMAT_MESSAGE_IGNORE_INSERTS,
81 NULL,
82 GetLastError(),
83 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
84 (LPTSTR) &lpMsgBuf,
86 NULL
88 CString strMessage;
89 strMessage.Format(IDS_ERR_COPYFILES, lpMsgBuf);
90 CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseSVN"), MB_OK | MB_ICONINFORMATION);
91 LocalFree( lpMsgBuf );
92 return FALSE;
94 copiedFiles.AddPath(CTSVNPath(droppath+_T("\\")+name)); //add the new filepath
97 //now add all the newly copied files to the working copy
98 CSVNProgressDlg progDlg;
99 theApp.m_pMainWnd = &progDlg;
100 progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Add);
101 if (parser.HasVal(_T("closeonend")))
102 progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));
103 progDlg.SetPathList(copiedFiles);
104 ProjectProperties props;
105 props.ReadPropsPathList(copiedFiles);
106 progDlg.SetProjectProperties(props);
107 progDlg.DoModal();
108 bRet = !progDlg.DidErrorsOccur();
109 #endif
110 return bRet;