Use static method
[TortoiseGit.git] / src / TortoiseProc / Commands / LogCommand.cpp
blob364346c8fd0b04f91e6aed02f566b771167ac047
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008,2011 - TortoiseSVN
4 // Copyright (C) 2008-2012 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "LogCommand.h"
22 #include "StringUtils.h"
23 #include "LogDlg.h"
25 bool LogCommand::Execute()
27 //the log command line looks like this:
28 //command:log path:<path_to_file_or_directory_to_show_the_log_messages> [startrev:<startrevision>] [endrev:<endrevision>]
30 CString val = parser.GetVal(_T("startrev"));
31 if ( val.IsEmpty() )
33 // support deprecated parameter prior 1.5.0
34 val = parser.GetVal(_T("revstart"));
36 CString revstart =val;
37 val = parser.GetVal(_T("endrev"));
38 if ( val.IsEmpty() )
40 // support deprecated parameter prior 1.5.0
41 val = parser.GetVal(_T("revend"));
43 CString revend =val;
44 val = parser.GetVal(_T("limit"));
45 int limit = _tstoi(val);
46 val = parser.GetVal(_T("rev"));
47 if ( val.IsEmpty() )
49 // support deprecated parameter prior 1.5.0
50 val = parser.GetVal(_T("rev"));
53 CString rev = val;
55 #if 0
56 SVNRev pegrev = val.IsEmpty() ? SVNRev() : SVNRev(val);
57 if (!revstart.IsValid())
58 revstart = SVNRev::REV_HEAD;
59 if (!revend.IsValid())
60 revend = 0;
61 #endif
63 if (limit == 0)
65 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);
66 limit = (int)(LONG)reg;
69 CString findStr = parser.GetVal(_T("findstring"));
70 LONG findType = parser.GetLongVal(_T("findtype"));
71 bool findRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), FALSE);
72 if (parser.HasKey(_T("findtext")))
73 findRegex = false;
74 if (parser.HasKey(_T("findregex")))
75 findRegex = true;
77 CLogDlg dlg;
78 theApp.m_pMainWnd = &dlg;
79 //dlg.SetParams(cmdLinePath);
80 dlg.SetParams(orgCmdLinePath, cmdLinePath, rev, revstart, revend, limit);
81 dlg.SetFilter(findStr, findType, findRegex);
82 // dlg.SetIncludeMerge(!!parser.HasKey(_T("merge")));
83 // val = parser.GetVal(_T("propspath"));
84 // if (!val.IsEmpty())
85 // dlg.SetProjectPropertiesPath(CTSVNPath(val));
86 dlg.DoModal();
87 if (parser.HasVal(_T("outfile")))
89 CString sText = dlg.GetSelectedHash();
90 CStringUtils::WriteStringToTextFile(parser.GetVal(L"outfile"), (LPCTSTR)sText, true);
92 return true;