OSDN Git Service

Add Export Command
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / ExportCommand.cpp
index a38d7be..21a7f3c 100644 (file)
 #include "ExportCommand.h"\r
 \r
 #include "ExportDlg.h"\r
-#include "SVNProgressDlg.h"\r
-#include "SVNAdminDir.h"\r
+#include "ProgressDlg.h"\r
+#include "GitAdminDir.h"\r
 #include "ProgressDlg.h"\r
 #include "BrowseFolder.h"\r
 #include "DirFileEnum.h"\r
 #include "MessageBox.h"\r
-#include "SVNStatus.h"\r
+#include "GitStatus.h"\r
 \r
 bool ExportCommand::Execute()\r
 {\r
        bool bRet = false;\r
-       // When the user clicked on a working copy, we know that the export should\r
-       // be done from that. We then have to ask where the export should go to.\r
-       // If however the user clicked on an unversioned folder, we assume that\r
-       // this is where the export should go to and have to ask from where\r
-       // the export should be done from.\r
-       TCHAR saveto[MAX_PATH];\r
-       bool bURL = !!SVN::PathIsURL(cmdLinePath);\r
-       svn_wc_status_kind s = SVNStatus::GetAllStatus(cmdLinePath);\r
-       if ((bURL)||(s == svn_wc_status_unversioned)||(s == svn_wc_status_none))\r
-       {\r
-               // ask from where the export has to be done\r
-               CExportDlg dlg;\r
-               if (bURL)\r
-                       dlg.m_URL = cmdLinePath.GetSVNPathString();\r
-               else\r
-                       dlg.m_strExportDirectory = cmdLinePath.GetWinPathString();\r
-               if (parser.HasKey(_T("revision")))\r
-               {\r
-                       SVNRev Rev = SVNRev(parser.GetVal(_T("revision")));\r
-                       dlg.Revision = Rev;\r
-               }\r
-               if (dlg.DoModal() == IDOK)\r
-               {\r
-                       CTSVNPath exportPath(dlg.m_strExportDirectory);\r
 \r
-                       CSVNProgressDlg progDlg;\r
-                       theApp.m_pMainWnd = &progDlg;\r
-                       progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Export);\r
-                       if (parser.HasVal(_T("closeonend")))\r
-                               progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
-                       DWORD options = dlg.m_bNoExternals ? ProgOptIgnoreExternals : ProgOptNone;\r
-                       if (dlg.m_eolStyle.CompareNoCase(_T("CRLF"))==0)\r
-                               options |= ProgOptEolCRLF;\r
-                       if (dlg.m_eolStyle.CompareNoCase(_T("CR"))==0)\r
-                               options |= ProgOptEolCR;\r
-                       if (dlg.m_eolStyle.CompareNoCase(_T("LF"))==0)\r
-                               options |= ProgOptEolLF;\r
-                       progDlg.SetOptions(options);\r
-                       progDlg.SetPathList(CTSVNPathList(exportPath));\r
-                       progDlg.SetUrl(dlg.m_URL);\r
-                       progDlg.SetRevision(dlg.Revision);\r
-                       progDlg.SetDepth(dlg.m_depth);\r
-                       progDlg.DoModal();\r
-                       bRet = !progDlg.DidErrorsOccur();\r
-               }\r
-       }\r
-       else\r
+               // ask from where the export has to be done\r
+       CExportDlg dlg;\r
+       \r
+       if (dlg.DoModal() == IDOK)\r
        {\r
-               // ask where the export should go to.\r
-               CBrowseFolder folderBrowser;\r
-               CString strTemp;\r
-               strTemp.LoadString(IDS_PROC_EXPORT_1);\r
-               folderBrowser.SetInfo(strTemp);\r
-               folderBrowser.m_style = BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | BIF_VALIDATE;\r
-               strTemp.LoadString(IDS_PROC_EXPORT_2);\r
-               folderBrowser.SetCheckBoxText(strTemp);\r
-               strTemp.LoadString(IDS_PROC_OMMITEXTERNALS);\r
-               folderBrowser.SetCheckBoxText2(strTemp);\r
-               folderBrowser.DisableCheckBox2WhenCheckbox1IsEnabled(true);\r
-               CRegDWORD regExtended = CRegDWORD(_T("Software\\TortoiseSVN\\ExportExtended"), FALSE);\r
-               CBrowseFolder::m_bCheck = regExtended;\r
-               if (folderBrowser.Show(hwndExplorer, saveto, MAX_PATH)==CBrowseFolder::OK)\r
-               {\r
-                       CString saveplace = CString(saveto);\r
-\r
-                       if (cmdLinePath.IsEquivalentTo(CTSVNPath(saveplace)))\r
-                       {\r
-                               // exporting to itself:\r
-                               // remove all svn admin dirs, effectively unversion the 'exported' folder.\r
-                               CString msg;\r
-                               msg.Format(IDS_PROC_EXPORTUNVERSION, (LPCTSTR)saveplace);\r
-                               if (CMessageBox::Show(hwndExplorer, msg, _T("TortoiseSVN"), MB_ICONQUESTION|MB_YESNO) == IDYES)\r
-                               {\r
-                                       CProgressDlg progress;\r
-                                       progress.SetTitle(IDS_PROC_UNVERSION);\r
-                                       progress.SetAnimation(IDR_MOVEANI);\r
-                                       progress.FormatNonPathLine(1, IDS_SVNPROGRESS_EXPORTINGWAIT);\r
-                                       progress.SetTime(true);\r
-                                       progress.ShowModeless(hwndExplorer);\r
-                                       std::vector<CTSVNPath> removeVector;\r
-\r
-                                       CDirFileEnum lister(saveplace);\r
-                                       CString srcFile;\r
-                                       bool bFolder = false;\r
-                                       while (lister.NextFile(srcFile, &bFolder))\r
-                                       {\r
-                                               CTSVNPath item(srcFile);\r
-                                               if ((bFolder)&&(g_SVNAdminDir.IsAdminDirName(item.GetFileOrDirectoryName())))\r
-                                               {\r
-                                                       removeVector.push_back(item);\r
-                                               }\r
-                                       }\r
-                                       DWORD count = 0;\r
-                                       for (std::vector<CTSVNPath>::iterator it = removeVector.begin(); (it != removeVector.end()) && (!progress.HasUserCancelled()); ++it)\r
-                                       {\r
-                                               progress.FormatPathLine(1, IDS_SVNPROGRESS_UNVERSION, (LPCTSTR)it->GetWinPath());\r
-                                               progress.SetProgress(count, removeVector.size());\r
-                                               count++;\r
-                                               it->Delete(false);\r
-                                       }\r
-                                       progress.Stop();\r
-                                       bRet = true;\r
-                               }\r
-                               else\r
-                                       return false;\r
-                       }\r
-                       else\r
-                       {\r
-                               saveplace += _T("\\") + cmdLinePath.GetFileOrDirectoryName();\r
-                               TRACE(_T("export %s to %s\n"), (LPCTSTR)cmdLinePath.GetUIPathString(), (LPCTSTR)saveto);\r
-                               SVN svn;\r
-                               if (!svn.Export(cmdLinePath, CTSVNPath(saveplace), bURL ? SVNRev::REV_HEAD : SVNRev::REV_WC, \r
-                                       bURL ? SVNRev::REV_HEAD : SVNRev::REV_WC, FALSE, folderBrowser.m_bCheck2, svn_depth_infinity,\r
-                                       hwndExplorer, folderBrowser.m_bCheck))\r
-                               {\r
-                                       CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_OK | MB_ICONERROR);\r
-                                       bRet = false;\r
-                               }\r
-                               else\r
-                                       bRet = true;\r
-                               regExtended = CBrowseFolder::m_bCheck;\r
-                       }\r
-               }\r
        }\r
        return bRet;\r
 }\r