- Timestamp:
- Oct 23, 2010, 6:41:33 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/svncopyright.cc
r1119 r1234 67 67 Directory tree(0,option.root(),""); 68 68 69 if (option.verbose()) 70 std::cout << "Parsing directory tree" << std::endl; 71 tree.parse(option.verbose(), option.ignore_cache()); 72 update_copyright(tree, option.verbose()); 69 update_copyright(tree, option.verbose(), option.ignore_cache()); 73 70 } 74 71 catch (std::runtime_error& e) { -
trunk/bin/svndigest.cc
r1197 r1234 34 34 #include "lib/StatsCollection.h" 35 35 #include "lib/SVN.h" 36 #include "lib/SvndigestVisitor.h" 36 37 #include "lib/SVNinfo.h" 37 38 #include "lib/SVNlog.h" … … 58 59 const theplu::svndigest::Stats& stats); 59 60 60 void write_report(const svndigestParameter& option, const std::string& repo,61 const Node& tree, const StatsCollection& stats);61 void prepare_report(const svndigestParameter& option, const std::string& repo, 62 const Node& tree); 62 63 63 64 int main( int argc, char* argv[]) … … 113 114 Directory tree(0,option.root(),""); 114 115 116 if (option.report()) 117 prepare_report(option, repo, tree); 118 115 119 if (option.verbose()) 116 120 std::cout << "Parsing directory tree" << std::endl; 117 const StatsCollection& stats(tree.parse(option.verbose(), 118 option.ignore_cache())); 121 122 SvndigestVisitor visitor(option.verbose(), option.ignore_cache(), 123 option.report()); 124 tree.traverse(visitor); 125 // const StatsCollection& stats(tree.parse(option.verbose(), 126 // option.ignore_cache())); 119 127 120 128 if (option.report()) 121 write_report(option, repo, tree, stats); 122 123 if (option.copyright()){ 124 update_copyright(tree, option.verbose()); 125 } 129 print_main_page(tree.name(), tree.log(), tree.stats(), tree.url()); 130 126 131 } 127 132 catch (std::runtime_error& e) { … … 211 216 } 212 217 213 void write_report(const svndigestParameter& option, const std::string& repo,214 const Node& tree, const StatsCollection& stats)218 void prepare_report(const svndigestParameter& option, const std::string& repo, 219 const Node& tree) 215 220 { 216 221 std::string target_path = concatenate_path(option.targetdir(), … … 232 237 chdir(tree.name()); 233 238 print_css("svndigest.css"); 234 print_main_page(tree.name(), tree.log(), stats, tree.url());235 239 // create structure StatsType/Author/LineType 240 /* 236 241 for (std::map<std::string, Stats*>::const_iterator i(stats.stats().begin()); 237 242 i!=stats.stats().end(); ++i) 238 243 create_file_struct(i->first+std::string("/"), *i->second); 239 tree.print(option.verbose());240 } 244 */ 245 } -
trunk/bin/svndigestParameter.cc
r1220 r1234 56 56 anchor_format_(cmd_,"anchor-format", 57 57 "override anchor image format defined in config file"), 58 copyright_(cmd_, "copyright", "update copyright statement [deprecated]"),59 58 force_(cmd_, "f,force", 60 59 std::string("if sub-directory named <ROOT> exists in target dire")+ … … 109 108 chdir(save_wd); 110 109 } 111 if (copyright()) {112 std::cerr << "svndigest: WARNING: option `--copyright' is deprecated; "113 << "use svncopyright instaed.\n";114 }115 110 } 116 }117 118 119 bool svndigestParameter::copyright(void) const120 {121 return copyright_.present();122 111 } 123 112 -
trunk/bin/svndigestParameter.h
r1121 r1234 51 51 const yat::utility::OptionArg<std::string>& anchor_format(void) const; 52 52 53 bool copyright(void) const;54 53 bool force(void) const; 55 54 const yat::utility::OptionArg<std::string>& format(void) const; … … 65 64 66 65 yat::utility::OptionArg<std::string> anchor_format_; 67 yat::utility::OptionSwitch copyright_;68 66 yat::utility::OptionSwitch force_; 69 67 yat::utility::OptionArg<std::string> format_; -
trunk/lib/Directory.cc
r1186 r1234 27 27 #include "html_utility.h" 28 28 #include "Node.h" 29 #include "NodeVisitor.h" 29 30 #include "SVN.h" 30 31 #include "SVNlog.h" 32 #include "TinyStats.h" 31 33 #include "utility.h" 32 34 … … 99 101 } 100 102 103 104 void Directory::collect_stats(void) 105 { 106 stats_.reset(); 107 for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); ++i) 108 if (!(*i)->ignore()) { 109 stats_ += (*i)->stats(); 110 (*i)->stats().reset(); 111 } 112 } 113 114 101 115 bool Directory::dir(void) const 102 116 { 103 117 return true; 104 118 } 119 105 120 106 121 std::string Directory::href(void) const … … 139 154 { 140 155 stats_.reset(); 141 // Directories themselved give no contribution to statistics. 156 assert(0 && "we are not using this function, are we?"); 157 /* 142 158 for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); ++i) 143 159 if (!(*i)->ignore()) 144 160 stats_ += (*i)->parse(verbose, ignore); 161 */ 145 162 return stats_; 146 163 } … … 149 166 void Directory::print_core(const bool verbose) const 150 167 { 151 mkdir("blame_output/" + local_path());168 //mkdir("blame_output/" + local_path()); 152 169 // print daughter nodes 153 for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i)154 (*i)->print(verbose);170 //for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i) 171 // (*i)->print(verbose); 155 172 } 156 173 … … 169 186 outdir += "/"+local_path(); 170 187 } 171 mkdir (outdir);188 mkdir_p(outdir); 172 189 if (user=="all") 173 mkdir (imagedir);190 mkdir_p(imagedir); 174 191 std::string html_name = outdir+"/index.html"; 175 192 std::ofstream os(html_name.c_str()); … … 278 295 } 279 296 297 298 void Directory::traverse(NodeVisitor& visitor) 299 { 300 visitor.enter(*this); 301 for (NodeIterator first=daughters_.begin(), end=daughters_.end(); 302 first!=end; ++first) 303 (*first)->traverse(visitor); 304 visitor.leave(*this); 305 } 306 307 280 308 }} // end of namespace svndigest and namespace theplu -
trunk/lib/Directory.h
r978 r1234 33 33 namespace svndigest{ 34 34 35 class NodeVisitor; 36 35 37 /// 36 38 /// Class taking care of directories. … … 39 41 { 40 42 public: 41 42 43 /// 43 44 /// @brief Constructor … … 59 60 /// 60 61 ~Directory(void); 62 63 /** 64 Collect stats from daughter nodes and reset stats in daughter 65 nodes. 66 */ 67 void collect_stats(void); 61 68 62 69 /// … … 96 103 const std::map<int, svn_revnum_t>&) const; 97 104 105 /** 106 Calls visitor.enter(*this). If enter returns true, daughter 107 nodes are traverses. Finally visitor visitor.leave(*this) i called. 108 */ 109 void traverse(NodeVisitor& visitor); 110 98 111 private: 99 112 /** -
trunk/lib/File.cc
r1220 r1234 30 30 #include "html_utility.h" 31 31 #include "HtmlStream.h" 32 #include "NodeVisitor.h" 32 33 #include "Stats.h" 33 34 #include "SVNblame.h" 34 35 #include "SVNlog.h" 36 #include "TinyStats.h" 35 37 36 38 #include <algorithm> … … 223 225 std::string tmp_cache_file(cache_file+"~"); 224 226 std::ofstream os(tmp_cache_file.c_str()); 227 assert(os); 225 228 stats_.print(os); 226 229 os.close(); … … 350 353 void File::print_core(const bool verbose) const 351 354 { 355 mkdir_p(directory_name(blame_output_file_name())); 352 356 std::ofstream os(blame_output_file_name().c_str()); 353 357 assert(os.good()); … … 370 374 std::string imagefile = stats_type+"/"+"images/"+line_type+"/"+lpath; 371 375 std::string html_name(outpath + ".html"); 376 mkdir_p(directory_name(html_name)); 377 mkdir_p(directory_name(imagefile)); 372 378 std::ofstream os(html_name.c_str()); 379 assert(os); 373 380 print_header(os, name(), level_+3, user, line_type, lpath+".html", 374 381 stats_type); … … 398 405 } 399 406 407 408 void File::traverse(NodeVisitor& visitor) 409 { 410 visitor.visit(*this); 411 } 412 413 400 414 void File::update_copyright(const std::string& new_block, 401 415 size_t start_at_line, size_t end_at_line) const … … 405 419 "#" + file_name(path()) + "#"); 406 420 std::ofstream tmp(tmpname.c_str()); 407 421 assert(tmp); 408 422 using namespace std; 409 423 ifstream is(path().c_str()); -
trunk/lib/File.h
r978 r1234 31 31 namespace theplu{ 32 32 namespace svndigest{ 33 34 class NodeVisitor; 33 35 34 36 class File : public Node … … 77 79 void print_copyright(std::map<std::string, Alias>&, bool verbose, 78 80 const std::map<int, svn_revnum_t>&) const; 81 82 /** 83 Let the visitor perform its mission via visitor(*this) 84 */ 85 void traverse(NodeVisitor& visitor); 79 86 80 87 private: -
trunk/lib/Makefile.am
r1194 r1234 31 31 32 32 noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h \ 33 Colors.h Commitment.h Configuration.h css.h \33 Colors.h Commitment.h Configuration.h CopyrightVisitor.h css.h \ 34 34 Date.h Directory.h File.h first_page.h Functor.h \ 35 35 Graph.h \ 36 36 HtmlBuf.h HtmlStream.h html_utility.h LineTypeParser.h \ 37 main_utility.h Node.h \37 main_utility.h Node.h NodeVisitor.h \ 38 38 OptionVersion.h rmdirhier.h \ 39 Stats.h StatsCollection.h subversion_info.h SVN.h SVNblame.h \ 40 SVNdiff.h SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h Vector.h 39 Stats.h StatsCollection.h subversion_info.h \ 40 SvndigestVisitor.h SVN.h SVNblame.h \ 41 SVNdiff.h SVNinfo.h SVNlog.h SVNproperty.h TinyStats.h \ 42 Trac.h utility.h Vector.h 41 43 42 44 libsvndigest_a_SOURCES = AddStats.cc Alias.cc BlameStats.cc \ 43 45 ClassicStats.cc Colors.cc \ 44 Commitment.cc Configuration.cc \46 Commitment.cc Configuration.cc CopyrightVisitor.cc \ 45 47 css.cc Date.cc Directory.cc File.cc first_page.cc\ 46 48 Functor.cc Graph.cc HtmlBuf.cc HtmlStream.cc \ … … 48 50 OptionVersion.cc \ 49 51 rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc \ 50 SVNblame.cc SVNdiff.cc SVNinfo.cc SVNlog.cc SVNproperty.cc \ 52 SVNblame.cc SVNdiff.cc SvndigestVisitor.cc SVNinfo.cc \ 53 SVNlog.cc SVNproperty.cc TinyStats.cc \ 51 54 Trac.cc utility.cc Vector.cc 52 55 -
trunk/lib/Node.cc
r1220 r1234 27 27 #include "HtmlStream.h" 28 28 #include "html_utility.h" 29 #include "LineTypeParser.h" 29 30 #include "SVNlog.h" 30 31 #include "SVNproperty.h" … … 95 96 const std::string& user) const 96 97 { 97 const Stats& stats = stats_[stats_type];98 98 os << "<tr class=\"" << css_class << "\">\n" 99 99 << "<td class=\"" << node_type() << "\">"; … … 105 105 os << name() << " (<i>link</i>)"; 106 106 // there is no output for nodes when user has zero contribution 107 else if (user!="all" && ! stats.lines(user))107 else if (user!="all" && !tiny_stats_(stats_type,user,LineTypeParser::total)) 108 108 os << name(); 109 109 else if (!Configuration::instance().output_file() && !this->dir()) … … 112 112 os << anchor(href(), name()); 113 113 os << "</td>\n"; 114 if (user=="all") { 115 os << "<td>" << stats.lines() << "</td>\n" 116 << "<td>" << stats.code() << "</td>\n" 117 << "<td>" << stats.comments() << "</td>\n" 118 << "<td>" << stats.empty() << "</td>\n"; 119 } 120 else { 121 os << "<td>" << stats.lines(user); 122 if (stats.lines(user)) 123 os << " (" << percent(stats.lines(user),stats.lines()) << "%)"; 124 os << "</td>\n"; 125 os << "<td>" << stats.code(user); 126 if (stats.code(user)) 127 os << " (" << percent(stats.code(user),stats.code()) << "%)"; 128 os << "</td>\n"; 129 os << "<td>" << stats.comments(user); 130 if (stats.comments(user)) 131 os << " (" << percent(stats.comments(user),stats.comments()) << "%)"; 132 os << "</td>\n"; 133 os << "<td>" << stats.empty(user); 134 if (stats.empty(user)) 135 os << " (" << percent(stats.empty(user),stats.empty()) << "%)"; 136 os << "</td>\n"; 137 138 } 139 114 115 std::cerr << "table row: " << path() << std::endl; 116 117 html_tabletd(os, stats_type, user, LineTypeParser::total); 118 html_tabletd(os, stats_type, user, LineTypeParser::code); 119 html_tabletd(os, stats_type, user, LineTypeParser::comment); 120 html_tabletd(os, stats_type, user, LineTypeParser::other); 121 140 122 os << "<td>" << trac_revision(last_changed_rev()) << "</td>\n" 141 123 << "<td>" << author() << "</td>\n" 142 124 << "</tr>\n"; 125 } 126 127 128 void Node::html_tabletd(std::ostream& os, const std::string& stats_type, 129 const std::string& user, 130 LineTypeParser::line_type lt) const 131 { 132 os << "<td>" << tiny_stats_(stats_type, user, lt); 133 if (user!="all" && tiny_stats_(stats_type, user, lt)) 134 os << " (" << percent(tiny_stats_(stats_type, user, lt), 135 tiny_stats_(stats_type, "all", lt)) << "%)"; 136 os << "</td>\n"; 137 } 138 139 140 void Node::init_tiny_stats(void) 141 { 142 tiny_stats_.init(stats_); 143 143 } 144 144 … … 221 221 } 222 222 } 223 223 print_core(verbose); 224 224 } 225 225 … … 327 327 328 328 329 const StatsCollection& Node::stats(void) const 330 { 331 return stats_; 332 } 333 334 335 StatsCollection& Node::stats(void) 336 { 337 return stats_; 338 } 339 340 329 341 bool Node::svncopyright_ignore(void) const 330 342 { -
trunk/lib/Node.h
r1137 r1234 26 26 27 27 #include "html_utility.h" 28 #include "LineTypeParser.h" 28 29 #include "StatsCollection.h" 29 30 #include "SVNinfo.h" 30 31 #include "SVNlog.h" 32 #include "TinyStats.h" 31 33 #include "utility.h" 32 34 … … 40 42 41 43 class Alias; 44 class NodeVisitor; 42 45 43 46 /// … … 108 111 { return binary_ || svndigest_ignore_ || link_; } 109 112 113 /** 114 Create the TinyStats based on the stored CollectionStats 115 */ 116 void init_tiny_stats(void); 117 110 118 /// 111 119 /// @brief Get the revision number of the latest commit. … … 183 191 184 192 /** 193 \return true if svncopyright::ignore property was set 194 */ 195 bool svncopyright_ignore(void) const; 196 197 /** 185 198 @brief Check if item used to create this object has been 186 199 assigned property svndigest:ignore. … … 195 208 196 209 /** 210 */ 211 const StatsCollection& stats(void) const; 212 213 StatsCollection& stats(void); 214 215 /** 216 Access point for a NodeVisitor to start traversing Node and its 217 daughter nodes. 218 */ 219 virtual void traverse(NodeVisitor& visitor)=0; 220 221 /** 197 222 \see SVNinfo::url(void) 198 223 */ … … 200 225 201 226 protected: 202 /**203 \return true if svncopyright::ignore property was set204 */205 bool svncopyright_ignore(void) const;206 207 227 /// 208 228 /// print path in html format (with anchors) to @a os … … 217 237 static std::string project_; 218 238 StatsCollection stats_; 239 TinyStats tiny_stats_; 219 240 220 241 private: … … 223 244 /// 224 245 Node(const Node&); 246 247 void html_tabletd(std::ostream&, const std::string& stats_type, 248 const std::string& user, 249 LineTypeParser::line_type lt) const; 225 250 226 251 virtual void log_core(SVNlog&) const=0; -
trunk/lib/main_utility.cc
r1102 r1234 23 23 24 24 #include "Configuration.h" 25 #include "CopyrightVisitor.h" 25 26 #include "Node.h" 26 27 #include "utility.h" … … 58 59 59 60 60 void update_copyright( const Node& tree, bool verbose)61 void update_copyright(Node& tree, bool verbose, bool ignore_cache) 61 62 { 62 63 if (verbose) … … 64 65 const Configuration& config = Configuration::instance(); 65 66 std::map<std::string, Alias> alias(config.copyright_alias()); 66 tree.print_copyright(alias, verbose); 67 68 // map with last rev for every year 69 std::map<int, svn_revnum_t> year2rev; 70 // get log for entire project 71 SVNlog log(SVNinfo(tree.path()).repos_root_url()); 72 typedef SVNlog::container::const_iterator LogIterator; 73 for (LogIterator i=log.commits().begin(); i!=log.commits().end(); ++i){ 74 time_t sec = str2time(i->date()); 75 tm* timeinfo = gmtime(&sec); 76 // ignore commits in repository not present in wc 77 year2rev[timeinfo->tm_year] = std::min(i->revision(), 78 tree.last_changed_rev()); 79 } 80 81 CopyrightVisitor visitor(alias, verbose, year2rev, ignore_cache); 82 tree.traverse(visitor); 67 83 } 68 84 -
trunk/lib/main_utility.h
r1102 r1234 46 46 \brief update copyright statements in \a node 47 47 */ 48 void update_copyright( const Node& node, bool verbose);48 void update_copyright(Node& node, bool verbose, bool ignore_cache); 49 49 50 50 }} // end of namespace svndigest end of namespace theplu
Note: See TracChangeset
for help on using the changeset viewer.