OSDN Git Service

Fixed issue #155: Fix SVN Rebase sets upstream as remotes/trunk
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / DropCopyAddCommand.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2007-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #include "StdAfx.h"\r
20 #include "DropCopyAddCommand.h"\r
21 \r
22 #include "SVNProgressDlg.h"\r
23 #include "MessageBox.h"\r
24 \r
25 bool DropCopyAddCommand::Execute()\r
26 {\r
27         bool bRet = false;\r
28 #if 0\r
29         CString droppath = parser.GetVal(_T("droptarget"));\r
30         if (CTSVNPath(droppath).IsAdminDir())\r
31                 return FALSE;\r
32 \r
33         pathList.RemoveAdminPaths();\r
34         CTSVNPathList copiedFiles;\r
35         for(int nPath = 0; nPath < pathList.GetCount(); nPath++)\r
36         {\r
37                 if (!pathList[nPath].IsEquivalentTo(CTSVNPath(droppath)))\r
38                 {\r
39                         //copy the file to the new location\r
40                         CString name = pathList[nPath].GetFileOrDirectoryName();\r
41                         if (::PathFileExists(droppath+_T("\\")+name))\r
42                         {\r
43                                 CString strMessage;\r
44                                 strMessage.Format(IDS_PROC_OVERWRITE_CONFIRM, (LPCTSTR)(droppath+_T("\\")+name));\r
45                                 int ret = CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseGit"), MB_YESNOCANCEL | MB_ICONQUESTION);\r
46                                 if (ret == IDYES)\r
47                                 {\r
48                                         if (!::CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))\r
49                                         {\r
50                                                 //the copy operation failed! Get out of here!\r
51                                                 LPVOID lpMsgBuf;\r
52                                                 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | \r
53                                                         FORMAT_MESSAGE_FROM_SYSTEM | \r
54                                                         FORMAT_MESSAGE_IGNORE_INSERTS,\r
55                                                         NULL,\r
56                                                         GetLastError(),\r
57                                                         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language\r
58                                                         (LPTSTR) &lpMsgBuf,\r
59                                                         0,\r
60                                                         NULL \r
61                                                         );\r
62                                                 CString strMessage;\r
63                                                 strMessage.Format(IDS_ERR_COPYFILES, (LPTSTR)lpMsgBuf);\r
64                                                 CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION);\r
65                                                 LocalFree( lpMsgBuf );\r
66                                                 return FALSE;\r
67                                         }\r
68                                 }\r
69                                 if (ret == IDCANCEL)\r
70                                 {\r
71                                         return FALSE;           //cancel the whole operation\r
72                                 }\r
73                         }\r
74                         else if (!CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))\r
75                         {\r
76                                 //the copy operation failed! Get out of here!\r
77                                 LPVOID lpMsgBuf;\r
78                                 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | \r
79                                         FORMAT_MESSAGE_FROM_SYSTEM | \r
80                                         FORMAT_MESSAGE_IGNORE_INSERTS,\r
81                                         NULL,\r
82                                         GetLastError(),\r
83                                         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language\r
84                                         (LPTSTR) &lpMsgBuf,\r
85                                         0,\r
86                                         NULL \r
87                                         );\r
88                                 CString strMessage;\r
89                                 strMessage.Format(IDS_ERR_COPYFILES, lpMsgBuf);\r
90                                 CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION);\r
91                                 LocalFree( lpMsgBuf );\r
92                                 return FALSE;\r
93                         }\r
94                         copiedFiles.AddPath(CTSVNPath(droppath+_T("\\")+name));         //add the new filepath\r
95                 }\r
96         }\r
97         //now add all the newly copied files to the working copy\r
98         CSVNProgressDlg progDlg;\r
99         theApp.m_pMainWnd = &progDlg;\r
100         progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Add);\r
101         if (parser.HasVal(_T("closeonend")))\r
102                 progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
103         progDlg.SetPathList(copiedFiles);\r
104         ProjectProperties props;\r
105         props.ReadPropsPathList(copiedFiles);\r
106         progDlg.SetProjectProperties(props);\r
107         progDlg.DoModal();\r
108         bRet = !progDlg.DidErrorsOccur();\r
109 #endif\r
110         return bRet;\r
111 }\r