OSDN Git Service

Fixed Issue #135: Taskbar text says "TortoiseSVN"
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / DropExportCommand.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 "DropExportCommand.h"\r
21 #include "MessageBox.h"\r
22 #include "Git.h"\r
23 #include "GitAdminDir.h"\r
24 #include "DirFileEnum.h"\r
25 #include "SysProgressDlg.h"\r
26 \r
27 bool DropExportCommand::Execute()\r
28 {\r
29         bool bRet = true;\r
30 #if 0\r
31         CString droppath = parser.GetVal(_T("droptarget"));\r
32         if (CTGitPath(droppath).IsAdminDir())\r
33                 return false;\r
34 \r
35         SVN svn;\r
36         if ((pathList.GetCount() == 1)&&\r
37                 (pathList[0].IsEquivalentTo(CTSVNPath(droppath))))\r
38         {\r
39                 // exporting to itself:\r
40                 // remove all svn admin dirs, effectively unversion the 'exported' folder.\r
41                 CString msg;\r
42                 msg.Format(IDS_PROC_EXPORTUNVERSION, (LPCTSTR)droppath);\r
43                 if (CMessageBox::Show(hwndExplorer, msg, _T("TortoiseGit"), MB_ICONQUESTION|MB_YESNO) == IDYES)\r
44                 {\r
45                         CProgressDlg progress;\r
46                         progress.SetTitle(IDS_PROC_UNVERSION);\r
47                         progress.SetAnimation(IDR_MOVEANI);\r
48                         progress.FormatNonPathLine(1, IDS_SVNPROGRESS_EXPORTINGWAIT);\r
49                         progress.SetTime(true);\r
50                         progress.ShowModeless(hwndExplorer);\r
51                         std::vector<CTSVNPath> removeVector;\r
52 \r
53                         CDirFileEnum lister(droppath);\r
54                         CString srcFile;\r
55                         bool bFolder = false;\r
56                         while (lister.NextFile(srcFile, &bFolder))\r
57                         {\r
58                                 CTSVNPath item(srcFile);\r
59                                 if ((bFolder)&&(g_SVNAdminDir.IsAdminDirName(item.GetFileOrDirectoryName())))\r
60                                 {\r
61                                         removeVector.push_back(item);\r
62                                 }\r
63                         }\r
64                         DWORD count = 0;\r
65                         for (std::vector<CTSVNPath>::iterator it = removeVector.begin(); (it != removeVector.end()) && (!progress.HasUserCancelled()); ++it)\r
66                         {\r
67                                 progress.FormatPathLine(1, IDS_SVNPROGRESS_UNVERSION, (LPCTSTR)it->GetWinPath());\r
68                                 progress.SetProgress(count, removeVector.size());\r
69                                 count++;\r
70                                 it->Delete(false);\r
71                         }\r
72                         progress.Stop();\r
73                 }\r
74                 else\r
75                         return false;\r
76         }\r
77         else\r
78         {\r
79                 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)\r
80                 {\r
81                         CString dropper = droppath + _T("\\") + pathList[nPath].GetFileOrDirectoryName();\r
82                         if (PathFileExists(dropper))\r
83                         {\r
84                                 CString sMsg;\r
85                                 CString sBtn1(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_OVERWRITE));\r
86                                 CString sBtn2(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_RENAME));\r
87                                 CString sBtn3(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_CANCEL));\r
88                                 sMsg.Format(IDS_PROC_OVERWRITEEXPORT, (LPCTSTR)dropper);\r
89                                 UINT ret = CMessageBox::Show(hwndExplorer, sMsg, _T("TortoiseGit"), MB_DEFBUTTON1, IDI_QUESTION, sBtn1, sBtn2, sBtn3);\r
90                                 if (ret==2)\r
91                                 {\r
92                                         dropper.Format(IDS_PROC_EXPORTFOLDERNAME, (LPCTSTR)droppath, (LPCTSTR)pathList[nPath].GetFileOrDirectoryName());\r
93                                         int exportcount = 1;\r
94                                         while (PathFileExists(dropper))\r
95                                         {\r
96                                                 dropper.Format(IDS_PROC_EXPORTFOLDERNAME2, (LPCTSTR)droppath, exportcount++, (LPCTSTR)pathList[nPath].GetFileOrDirectoryName());\r
97                                         }\r
98                                 }\r
99                                 else if (ret == 3)\r
100                                         return false;\r
101                         }\r
102                         if (!svn.Export(pathList[nPath], CTSVNPath(dropper), SVNRev::REV_WC ,SVNRev::REV_WC, FALSE, FALSE, svn_depth_infinity, hwndExplorer, parser.HasKey(_T("extended"))))\r
103                         {\r
104                                 CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseGit"), MB_OK | MB_ICONERROR);\r
105                                 bRet = false;\r
106                         }\r
107                 }\r
108         }\r
109 #endif\r
110         return bRet;\r
111 }\r