OSDN Git Service

Add return value handle of format patch
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / BlameCommand.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 "BlameCommand.h"\r
21 \r
22 #include "BlameDlg.h"\r
23 #include "Blame.h"\r
24 #include "Git.h"\r
25 #include "AppUtils.h"\r
26 #include "MessageBox.h"\r
27 \r
28 \r
29 bool BlameCommand::Execute()\r
30 {\r
31 //      bool bRet = false;\r
32 //      bool bShowDialog = true;\r
33 //      CBlameDlg dlg;\r
34 //      CString options;\r
35 //      dlg.DoModal();\r
36 //      dlg.EndRev = GitRev::REV_HEAD;\r
37         CAppUtils::LaunchTortoiseBlame(orgCmdLinePath.GetWinPath(), _T(""),_T(""));\r
38 #if 0\r
39         if (parser.HasKey(_T("startrev")) && parser.HasKey(_T("endrev")))\r
40         {\r
41                 bShowDialog = false;\r
42                 dlg.StartRev = parser.GetLongVal(_T("startrev"));\r
43                 dlg.EndRev = parser.GetLongVal(_T("endrev"));\r
44                 if (parser.HasKey(_T("ignoreeol")) || parser.HasKey(_T("ignorespaces")) || parser.HasKey(_T("ignoreallspaces")))\r
45                 {\r
46                         options = SVN::GetOptionsString(parser.HasKey(_T("ignoreeol")), parser.HasKey(_T("ignorespaces")), parser.HasKey(_T("ignoreallspaces")));\r
47                 }\r
48         }\r
49         if ((!bShowDialog)||(dlg.DoModal() == IDOK))\r
50         {\r
51                 CBlame blame;\r
52                 CString tempfile;\r
53                 CString logfile;\r
54                 if (bShowDialog)\r
55                         options = SVN::GetOptionsString(dlg.m_bIgnoreEOL, dlg.m_IgnoreSpaces);\r
56                 \r
57                 tempfile = blame.BlameToTempFile(cmdLinePath, dlg.StartRev, dlg.EndRev, \r
58                         cmdLinePath.IsUrl() ? SVNRev() : SVNRev::REV_WC, logfile, \r
59                         options, dlg.m_bIncludeMerge, TRUE, TRUE);\r
60                 if (!tempfile.IsEmpty())\r
61                 {\r
62                         if (dlg.m_bTextView)\r
63                         {\r
64                                 //open the default text editor for the result file\r
65                                 bRet = !!CAppUtils::StartTextViewer(tempfile);\r
66                         }\r
67                         else\r
68                         {\r
69                                 CString sVal;\r
70                                 if (parser.HasVal(_T("line")))\r
71                                 {\r
72                                         sVal = _T("/line:");\r
73                                         sVal += parser.GetVal(_T("line"));\r
74                                         sVal += _T(" ");\r
75                                 }\r
76                                 sVal += _T("/path:\"") + cmdLinePath.GetSVNPathString() + _T("\" ");\r
77                                 if (bShowDialog)\r
78                                 {\r
79                                         if (dlg.m_bIgnoreEOL)\r
80                                                 sVal += _T("/ignoreeol ");\r
81                                         switch (dlg.m_IgnoreSpaces)\r
82                                         {\r
83                                         case svn_diff_file_ignore_space_change:\r
84                                                 sVal += _T("/ignorespaces ");\r
85                                                 break;\r
86                                         case svn_diff_file_ignore_space_all:\r
87                                                 sVal += _T("/ignoreallspaces ");\r
88                                         }\r
89                                 }\r
90                                 else \r
91                                 {\r
92                                         if (parser.HasKey(_T("ignoreeol")))\r
93                                                 sVal += _T("/ignoreeol ");\r
94                                         if (parser.HasKey(_T("ignorespaces")))\r
95                                                 sVal += _T("/ignorespaces ");\r
96                                         if (parser.HasKey(_T("ignoreallspaces")))\r
97                                                 sVal += _T("/ignoreallspaces ");\r
98                                 }\r
99 \r
100                                 bRet = CAppUtils::LaunchTortoiseBlame(tempfile, logfile, cmdLinePath.GetFileOrDirectoryName(), sVal);\r
101                         }\r
102                 }\r
103                 else\r
104                 {\r
105                         CMessageBox::Show(hwndExplorer, blame.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
106                 }\r
107         }\r
108 #endif\r
109         return TRUE;\r
110 }\r