OSDN Git Service

Show Ignore Sub Menu
[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 "SVN.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.EndRev = SVNRev::REV_HEAD;\r
36         if (parser.HasKey(_T("startrev")) && parser.HasKey(_T("endrev")))\r
37         {\r
38                 bShowDialog = false;\r
39                 dlg.StartRev = parser.GetLongVal(_T("startrev"));\r
40                 dlg.EndRev = parser.GetLongVal(_T("endrev"));\r
41                 if (parser.HasKey(_T("ignoreeol")) || parser.HasKey(_T("ignorespaces")) || parser.HasKey(_T("ignoreallspaces")))\r
42                 {\r
43                         options = SVN::GetOptionsString(parser.HasKey(_T("ignoreeol")), parser.HasKey(_T("ignorespaces")), parser.HasKey(_T("ignoreallspaces")));\r
44                 }\r
45         }\r
46         if ((!bShowDialog)||(dlg.DoModal() == IDOK))\r
47         {\r
48                 CBlame blame;\r
49                 CString tempfile;\r
50                 CString logfile;\r
51                 if (bShowDialog)\r
52                         options = SVN::GetOptionsString(dlg.m_bIgnoreEOL, dlg.m_IgnoreSpaces);\r
53                 \r
54                 tempfile = blame.BlameToTempFile(cmdLinePath, dlg.StartRev, dlg.EndRev, \r
55                         cmdLinePath.IsUrl() ? SVNRev() : SVNRev::REV_WC, logfile, \r
56                         options, dlg.m_bIncludeMerge, TRUE, TRUE);\r
57                 if (!tempfile.IsEmpty())\r
58                 {\r
59                         if (dlg.m_bTextView)\r
60                         {\r
61                                 //open the default text editor for the result file\r
62                                 bRet = !!CAppUtils::StartTextViewer(tempfile);\r
63                         }\r
64                         else\r
65                         {\r
66                                 CString sVal;\r
67                                 if (parser.HasVal(_T("line")))\r
68                                 {\r
69                                         sVal = _T("/line:");\r
70                                         sVal += parser.GetVal(_T("line"));\r
71                                         sVal += _T(" ");\r
72                                 }\r
73                                 sVal += _T("/path:\"") + cmdLinePath.GetSVNPathString() + _T("\" ");\r
74                                 if (bShowDialog)\r
75                                 {\r
76                                         if (dlg.m_bIgnoreEOL)\r
77                                                 sVal += _T("/ignoreeol ");\r
78                                         switch (dlg.m_IgnoreSpaces)\r
79                                         {\r
80                                         case svn_diff_file_ignore_space_change:\r
81                                                 sVal += _T("/ignorespaces ");\r
82                                                 break;\r
83                                         case svn_diff_file_ignore_space_all:\r
84                                                 sVal += _T("/ignoreallspaces ");\r
85                                         }\r
86                                 }\r
87                                 else \r
88                                 {\r
89                                         if (parser.HasKey(_T("ignoreeol")))\r
90                                                 sVal += _T("/ignoreeol ");\r
91                                         if (parser.HasKey(_T("ignorespaces")))\r
92                                                 sVal += _T("/ignorespaces ");\r
93                                         if (parser.HasKey(_T("ignoreallspaces")))\r
94                                                 sVal += _T("/ignoreallspaces ");\r
95                                 }\r
96 \r
97                                 bRet = CAppUtils::LaunchTortoiseBlame(tempfile, logfile, cmdLinePath.GetFileOrDirectoryName(), sVal);\r
98                         }\r
99                 }\r
100                 else\r
101                 {\r
102                         CMessageBox::Show(hwndExplorer, blame.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
103                 }\r
104         }\r
105         return bRet;\r
106 }\r