OSDN Git Service

Change Dir Structure to be same as TortoiseSVN'
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / CopyCommand.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 "CopyCommand.h"\r
21 \r
22 #include "CopyDlg.h"\r
23 #include "SVNProgressDlg.h"\r
24 #include "StringUtils.h"\r
25 \r
26 bool CopyCommand::Execute()\r
27 {\r
28         bool bRet = false;\r
29         CString msg;\r
30         if (parser.HasKey(_T("logmsg")))\r
31         {\r
32                 msg = parser.GetVal(_T("logmsg"));\r
33         }\r
34         if (parser.HasKey(_T("logmsgfile")))\r
35         {\r
36                 CString logmsgfile = parser.GetVal(_T("logmsgfile"));\r
37                 CStringUtils::ReadStringFromTextFile(logmsgfile, msg);\r
38         }\r
39 \r
40         BOOL repeat = FALSE;\r
41         CCopyDlg dlg;\r
42         dlg.m_sLogMessage = msg;\r
43 \r
44         dlg.m_path = cmdLinePath;\r
45         CString url = parser.GetVal(_T("url"));\r
46         CString logmessage;\r
47         SVNRev copyRev = SVNRev::REV_HEAD;\r
48         BOOL doSwitch = FALSE;\r
49         do \r
50         {\r
51                 repeat = FALSE;\r
52                 dlg.m_URL = url;\r
53                 dlg.m_sLogMessage = logmessage;\r
54                 dlg.m_CopyRev = copyRev;\r
55                 dlg.m_bDoSwitch = doSwitch;\r
56                 if (dlg.DoModal() == IDOK)\r
57                 {\r
58                         theApp.m_pMainWnd = NULL;\r
59                         TRACE(_T("copy %s to %s\n"), (LPCTSTR)cmdLinePath.GetWinPathString(), (LPCTSTR)dlg.m_URL);\r
60                         CSVNProgressDlg progDlg;\r
61                         progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Copy);\r
62                         if (parser.HasVal(_T("closeonend")))\r
63                                 progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
64                         progDlg.SetOptions(dlg.m_bDoSwitch ? ProgOptSwitchAfterCopy : ProgOptNone);\r
65                         progDlg.SetPathList(pathList);\r
66                         progDlg.SetUrl(dlg.m_URL);\r
67                         progDlg.SetCommitMessage(dlg.m_sLogMessage);\r
68                         progDlg.SetRevision(dlg.m_CopyRev);\r
69                         url = dlg.m_URL;\r
70                         logmessage = dlg.m_sLogMessage;\r
71                         copyRev = dlg.m_CopyRev;\r
72                         doSwitch = dlg.m_bDoSwitch;\r
73                         progDlg.DoModal();\r
74                         CRegDWORD err = CRegDWORD(_T("Software\\TortoiseSVN\\ErrorOccurred"), FALSE);\r
75                         err = (DWORD)progDlg.DidErrorsOccur();\r
76                         bRet = !progDlg.DidErrorsOccur();\r
77                         repeat = progDlg.DidErrorsOccur();\r
78                         CRegDWORD bFailRepeat = CRegDWORD(_T("Software\\TortoiseSVN\\CommitReopen"), FALSE);\r
79                         if (DWORD(bFailRepeat) == FALSE)\r
80                                 repeat = false;         // do not repeat if the user chose not to in the settings.\r
81                 }\r
82         } while(repeat);\r
83         return bRet;\r
84 }\r