37 |
13 Jan 06 |
peter |
// $Id$ |
37 |
13 Jan 06 |
peter |
2 |
|
84 |
13 Mar 06 |
jari |
3 |
/* |
978 |
12 Dec 09 |
peter |
Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson |
1515 |
26 Sep 12 |
peter |
Copyright (C) 2009, 2010, 2012 Peter Johansson |
84 |
13 Mar 06 |
jari |
6 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
84 |
13 Mar 06 |
jari |
8 |
|
149 |
12 Aug 06 |
jari |
svndigest is free software; you can redistribute it and/or modify it |
84 |
13 Mar 06 |
jari |
under the terms of the GNU General Public License as published by |
693 |
11 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
84 |
13 Mar 06 |
jari |
(at your option) any later version. |
84 |
13 Mar 06 |
jari |
13 |
|
149 |
12 Aug 06 |
jari |
svndigest is distributed in the hope that it will be useful, but |
84 |
13 Mar 06 |
jari |
WITHOUT ANY WARRANTY; without even the implied warranty of |
149 |
12 Aug 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
84 |
13 Mar 06 |
jari |
General Public License for more details. |
84 |
13 Mar 06 |
jari |
18 |
|
84 |
13 Mar 06 |
jari |
You should have received a copy of the GNU General Public License |
693 |
11 Sep 08 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
84 |
13 Mar 06 |
jari |
21 |
*/ |
84 |
13 Mar 06 |
jari |
22 |
|
960 |
07 Dec 09 |
peter |
23 |
#include <config.h> // this header file is created by configure |
960 |
07 Dec 09 |
peter |
24 |
|
1060 |
02 Jun 10 |
peter |
25 |
#include "svndigestParameter.h" |
234 |
09 Apr 07 |
peter |
26 |
|
1119 |
04 Jul 10 |
peter |
27 |
#include "lib/OptionVersion.h" |
1119 |
04 Jul 10 |
peter |
28 |
#include "lib/utility.h" |
795 |
30 Jun 09 |
peter |
29 |
|
1060 |
02 Jun 10 |
peter |
30 |
#ifdef HAVE_PLPLOT |
1060 |
02 Jun 10 |
peter |
31 |
#include <plplot/plstream.h> |
1060 |
02 Jun 10 |
peter |
32 |
#endif |
1060 |
02 Jun 10 |
peter |
33 |
|
795 |
30 Jun 09 |
peter |
34 |
#include "yat/ColumnStream.h" |
795 |
30 Jun 09 |
peter |
35 |
#include "yat/Exception.h" |
795 |
30 Jun 09 |
peter |
36 |
#include "yat/OptionArg.h" |
795 |
30 Jun 09 |
peter |
37 |
#include "yat/OptionHelp.h" |
795 |
30 Jun 09 |
peter |
38 |
#include "yat/OptionSwitch.h" |
795 |
30 Jun 09 |
peter |
39 |
|
705 |
25 Nov 08 |
peter |
40 |
#include <cerrno> |
540 |
29 Dec 07 |
peter |
41 |
#include <cstddef> |
727 |
11 Dec 08 |
jari |
42 |
#include <cstring> |
226 |
11 Mar 07 |
peter |
43 |
#include <fstream> |
37 |
13 Jan 06 |
peter |
44 |
#include <iostream> |
226 |
11 Mar 07 |
peter |
45 |
#include <sstream> |
49 |
14 Jan 06 |
jari |
46 |
#include <stdexcept> |
37 |
13 Jan 06 |
peter |
47 |
#include <string> |
104 |
27 Jun 06 |
peter |
48 |
#include <sys/stat.h> |
37 |
13 Jan 06 |
peter |
49 |
|
37 |
13 Jan 06 |
peter |
50 |
namespace theplu { |
149 |
12 Aug 06 |
jari |
51 |
namespace svndigest { |
37 |
13 Jan 06 |
peter |
52 |
|
1060 |
02 Jun 10 |
peter |
53 |
svndigestParameter::svndigestParameter(void) |
1060 |
02 Jun 10 |
peter |
54 |
: Parameter(), |
1513 |
23 Sep 12 |
peter |
55 |
anchor_format_(cmd_,"anchor-format", |
1023 |
10 Jan 10 |
peter |
56 |
"override anchor image format defined in config file"), |
1513 |
23 Sep 12 |
peter |
57 |
force_(cmd_, "f,force", |
1082 |
08 Jun 10 |
peter |
58 |
std::string("if sub-directory named <ROOT> exists in target dire")+ |
1082 |
08 Jun 10 |
peter |
59 |
std::string("ctory, remove sub-directory before writing results")), |
1015 |
09 Jan 10 |
peter |
60 |
format_(cmd_,"format", "override image format defined in config file"), |
820 |
12 Sep 09 |
peter |
61 |
report_(cmd_, "report", "create no HTML report", true), |
1513 |
23 Sep 12 |
peter |
62 |
revisions_(cmd_, "revisions", |
820 |
12 Sep 09 |
peter |
63 |
"use revision number as time scale instead of dates [dates]"), |
1531 |
04 Oct 12 |
peter |
64 |
target_(cmd_, "t,target", "output directory [.]"), |
1531 |
04 Oct 12 |
peter |
65 |
update_(cmd_, "u,update", |
1531 |
04 Oct 12 |
peter |
66 |
"write output only when NODE has changed since last write") |
37 |
13 Jan 06 |
peter |
67 |
{ |
705 |
25 Nov 08 |
peter |
68 |
} |
705 |
25 Nov 08 |
peter |
69 |
|
705 |
25 Nov 08 |
peter |
70 |
|
1060 |
02 Jun 10 |
peter |
71 |
svndigestParameter::~svndigestParameter(void) |
705 |
25 Nov 08 |
peter |
72 |
{ |
705 |
25 Nov 08 |
peter |
73 |
} |
705 |
25 Nov 08 |
peter |
74 |
|
705 |
25 Nov 08 |
peter |
75 |
|
1513 |
23 Sep 12 |
peter |
76 |
const yat::utility::OptionArg<std::string>& |
1060 |
02 Jun 10 |
peter |
77 |
svndigestParameter::anchor_format(void) const |
1023 |
10 Jan 10 |
peter |
78 |
{ |
1023 |
10 Jan 10 |
peter |
79 |
return anchor_format_; |
1023 |
10 Jan 10 |
peter |
80 |
} |
1023 |
10 Jan 10 |
peter |
81 |
|
1023 |
10 Jan 10 |
peter |
82 |
|
1060 |
02 Jun 10 |
peter |
83 |
void svndigestParameter::analyse2(void) |
705 |
25 Nov 08 |
peter |
84 |
{ |
705 |
25 Nov 08 |
peter |
85 |
std::string save_wd = pwd(); |
705 |
25 Nov 08 |
peter |
86 |
|
705 |
25 Nov 08 |
peter |
87 |
if (!generate_config()) { |
705 |
25 Nov 08 |
peter |
// check target (only if we write report) |
705 |
25 Nov 08 |
peter |
89 |
if (report()) { |
820 |
12 Sep 09 |
peter |
90 |
check_existence(target_.value()); |
820 |
12 Sep 09 |
peter |
91 |
check_readable(target_.value()); |
1220 |
13 Oct 10 |
peter |
92 |
check_is_dir(target_.value()); |
1513 |
23 Sep 12 |
peter |
93 |
std::string path = concatenate_path(target_.value(),root_basename()); |
1186 |
27 Aug 10 |
peter |
94 |
if (access_rights(target_.value(), "w")) { |
705 |
25 Nov 08 |
peter |
95 |
std::stringstream ss; |
1513 |
23 Sep 12 |
peter |
96 |
ss << "svndigest: cannot create directory '" << path |
705 |
25 Nov 08 |
peter |
97 |
<< "': " << strerror(errno); |
795 |
30 Jun 09 |
peter |
98 |
throw yat::utility::cmd_error(ss.str()); |
475 |
31 Aug 07 |
peter |
99 |
} |
1534 |
06 Oct 12 |
peter |
// dont complain about existence if --force or --update |
1534 |
06 Oct 12 |
peter |
101 |
if (node_exist(path) && !force() && !update()) { |
705 |
25 Nov 08 |
peter |
102 |
std::stringstream ss; |
1220 |
13 Oct 10 |
peter |
103 |
ss << "svndigest: cannot create directory '" << path << "' " |
705 |
25 Nov 08 |
peter |
104 |
<< strerror(EEXIST); |
795 |
30 Jun 09 |
peter |
105 |
throw yat::utility::cmd_error(ss.str()); |
52 |
15 Jan 06 |
jari |
106 |
} |
1085 |
12 Jun 10 |
peter |
107 |
chdir(target_.value()); |
820 |
12 Sep 09 |
peter |
108 |
target_.value(pwd()); |
1085 |
12 Jun 10 |
peter |
109 |
chdir(save_wd); |
52 |
15 Jan 06 |
jari |
110 |
} |
705 |
25 Nov 08 |
peter |
111 |
} |
626 |
23 Apr 08 |
peter |
112 |
} |
37 |
13 Jan 06 |
peter |
113 |
|
705 |
25 Nov 08 |
peter |
114 |
|
1082 |
08 Jun 10 |
peter |
115 |
bool svndigestParameter::force(void) const |
1082 |
08 Jun 10 |
peter |
116 |
{ |
1082 |
08 Jun 10 |
peter |
117 |
return force_.present(); |
1082 |
08 Jun 10 |
peter |
118 |
} |
1082 |
08 Jun 10 |
peter |
119 |
|
1082 |
08 Jun 10 |
peter |
120 |
|
1513 |
23 Sep 12 |
peter |
121 |
const yat::utility::OptionArg<std::string>& |
1060 |
02 Jun 10 |
peter |
122 |
svndigestParameter::format(void) const |
1015 |
09 Jan 10 |
peter |
123 |
{ |
1015 |
09 Jan 10 |
peter |
124 |
return format_; |
1015 |
09 Jan 10 |
peter |
125 |
} |
1015 |
09 Jan 10 |
peter |
126 |
|
1015 |
09 Jan 10 |
peter |
127 |
|
1060 |
02 Jun 10 |
peter |
128 |
void svndigestParameter::init2(void) |
240 |
28 Apr 07 |
peter |
129 |
{ |
1023 |
10 Jan 10 |
peter |
130 |
anchor_format_.print_arg("=FMT"); |
1015 |
09 Jan 10 |
peter |
131 |
format_.print_arg("=FMT"); |
820 |
12 Sep 09 |
peter |
132 |
target_.print_arg("=TARGET"); |
1513 |
23 Sep 12 |
peter |
133 |
help_.synopsis() = |
705 |
25 Nov 08 |
peter |
134 |
"Generate statistical report for a subversion repository\n"; |
1060 |
02 Jun 10 |
peter |
135 |
|
1060 |
02 Jun 10 |
peter |
136 |
std::stringstream ss; |
1060 |
02 Jun 10 |
peter |
137 |
#ifdef HAVE_PLPLOT |
1060 |
02 Jun 10 |
peter |
138 |
ss << "using libplplot "; |
1060 |
02 Jun 10 |
peter |
139 |
plstream pls; |
1060 |
02 Jun 10 |
peter |
140 |
char* plplot_version = new char[32]; |
1060 |
02 Jun 10 |
peter |
141 |
pls.gver(plplot_version); |
1060 |
02 Jun 10 |
peter |
142 |
ss << plplot_version << "\n"; |
1060 |
02 Jun 10 |
peter |
143 |
delete [] plplot_version; |
1060 |
02 Jun 10 |
peter |
144 |
#endif |
1060 |
02 Jun 10 |
peter |
145 |
version_.extra(ss.str()); |
1060 |
02 Jun 10 |
peter |
146 |
version_.program_name("svndigest"); |
37 |
13 Jan 06 |
peter |
147 |
} |
37 |
13 Jan 06 |
peter |
148 |
|
37 |
13 Jan 06 |
peter |
149 |
|
1060 |
02 Jun 10 |
peter |
150 |
bool svndigestParameter::report(void) const |
73 |
04 Mar 06 |
jari |
151 |
{ |
820 |
12 Sep 09 |
peter |
152 |
return report_.value(); |
705 |
25 Nov 08 |
peter |
153 |
} |
234 |
09 Apr 07 |
peter |
154 |
|
234 |
09 Apr 07 |
peter |
155 |
|
1060 |
02 Jun 10 |
peter |
156 |
bool svndigestParameter::revisions(void) const |
705 |
25 Nov 08 |
peter |
157 |
{ |
820 |
12 Sep 09 |
peter |
158 |
return revisions_.present(); |
705 |
25 Nov 08 |
peter |
159 |
} |
234 |
09 Apr 07 |
peter |
160 |
|
280 |
06 May 07 |
peter |
161 |
|
1060 |
02 Jun 10 |
peter |
162 |
void svndigestParameter::set_default2(void) |
705 |
25 Nov 08 |
peter |
163 |
{ |
1087 |
12 Jun 10 |
peter |
164 |
if (!target_.present()) |
1087 |
12 Jun 10 |
peter |
165 |
target_.value("."); |
37 |
13 Jan 06 |
peter |
166 |
} |
37 |
13 Jan 06 |
peter |
167 |
|
1060 |
02 Jun 10 |
peter |
168 |
|
1060 |
02 Jun 10 |
peter |
169 |
std::string svndigestParameter::targetdir(void) const |
626 |
23 Apr 08 |
peter |
170 |
{ |
820 |
12 Sep 09 |
peter |
171 |
return target_.value(); |
626 |
23 Apr 08 |
peter |
172 |
} |
626 |
23 Apr 08 |
peter |
173 |
|
1531 |
04 Oct 12 |
peter |
174 |
|
1531 |
04 Oct 12 |
peter |
175 |
bool svndigestParameter::update(void) const |
1531 |
04 Oct 12 |
peter |
176 |
{ |
1531 |
04 Oct 12 |
peter |
177 |
return update_.present(); |
1531 |
04 Oct 12 |
peter |
178 |
} |
1531 |
04 Oct 12 |
peter |
179 |
|
442 |
16 Aug 07 |
peter |
180 |
}} // of namespace svndigest and namespace theplu |