Changeset 784 for branches/replacing_gnuplot/lib/File.cc
- Timestamp:
- Apr 9, 2009, 10:18:54 PM (14 years ago)
- Location:
- branches/replacing_gnuplot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/replacing_gnuplot
- Property svn:ignore
-
old new 8 8 autom4te.cache 9 9 INSTALL 10 COPYING11 10 aclocal.m4 12 11 Makefile
-
- Property svn:ignore
-
branches/replacing_gnuplot/lib/File.cc
r646 r784 3 3 /* 4 4 Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson 5 6 This file is part of svndigest, http://trac.thep.lu.se/svndigest 5 Copyright (C) 2009 Peter Johansson 6 7 This file is part of svndigest, http://dev.thep.lu.se/svndigest 7 8 8 9 svndigest is free software; you can redistribute it and/or modify it 9 10 under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2of the License, or11 the Free Software Foundation; either version 3 of the License, or 11 12 (at your option) any later version. 12 13 … … 17 18 18 19 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 21 02111-1307, USA. 20 along with svndigest. If not, see <http://www.gnu.org/licenses/>. 22 21 */ 23 22 … … 59 58 60 59 60 std::string File::blame_output_file_name(void) const 61 { 62 return "blame_output/" + local_path() + ".html"; 63 } 64 65 61 66 std::map<int, std::set<Alias> > 62 File::copyright_map(std::map<std::string, Alias>& alias) const 67 File::copyright_map(std::map<std::string, Alias>& alias, 68 const std::map<int, svn_revnum_t>& year2rev) const 63 69 { 64 70 using namespace std; 65 71 map<int, set<Alias> > year_authors; 66 SVNlog log(path());67 72 const Stats& stats = stats_["add"]; 68 69 typedef std::vector<Commitment>::iterator LogIterator; 70 for (LogIterator i=log.commits().begin(); i<log.commits().end(); ++i){ 71 if (i->revision() && 72 (stats(LineTypeParser::code, i->author(), i->revision()) > 73 stats(LineTypeParser::code, i->author(), i->revision()-1) || 74 stats(LineTypeParser::comment, i->author(), i->revision()) > 75 stats(LineTypeParser::comment, i->author(), i->revision()-1)) 76 ) { 73 74 // loop over all years 75 for (std::map<int, svn_revnum_t>::const_iterator rev_iter=year2rev.begin(); 76 rev_iter!=year2rev.end(); ++rev_iter) { 77 78 svn_revnum_t last_rev_this_year = rev_iter->second; 79 svn_revnum_t last_rev_last_year = 0; 80 if (rev_iter != year2rev.begin()) { 81 last_rev_last_year = (--rev_iter)->second; 82 ++rev_iter; 83 } 84 // loop over authors 85 for (std::set<std::string>::const_iterator a_iter=stats.authors().begin(); 86 a_iter!=stats.authors().end(); ++a_iter) { 87 88 // check if anything has been added since last year 89 if ( (stats(LineTypeParser::code, *a_iter, last_rev_this_year) > 90 stats(LineTypeParser::code, *a_iter, last_rev_last_year)) || 91 (stats(LineTypeParser::comment, *a_iter, last_rev_this_year) > 92 stats(LineTypeParser::comment, *a_iter, last_rev_last_year)) ) { 77 93 78 time_t sec = str2time(i->date());79 tm* timeinfo = gmtime(&sec);80 94 81 // find username in map of aliases 82 std::map<string,Alias>::iterator name(alias.lower_bound(i->author())); 83 84 // if alias exist insert alias 85 if (name != alias.end() && name->first==i->author()) 86 year_authors[timeinfo->tm_year].insert(name->second); 87 else { 88 // else insert user name 89 Alias a(i->author(),alias.size()); 90 year_authors[timeinfo->tm_year].insert(a); 91 std::cerr << "svndigest: warning: no copyright alias found for `" 92 << i->author() << "'\n"; 93 // insert alias to avoid multiple warnings. 94 alias.insert(name, std::make_pair(i->author(), a)); 95 // find username in map of aliases 96 std::map<string,Alias>::iterator name(alias.lower_bound(*a_iter)); 97 98 // if alias exist insert alias 99 if (name != alias.end() && name->first==*a_iter) 100 year_authors[rev_iter->first].insert(name->second); 101 else { 102 // else insert user name 103 Alias a(*a_iter,alias.size()); 104 year_authors[rev_iter->first].insert(a); 105 std::cerr << "svndigest: warning: no copyright alias found for `" 106 << *a_iter << "'\n"; 107 // insert alias to avoid multiple warnings. 108 alias.insert(name, std::make_pair(*a_iter, a)); 109 } 95 110 } 96 111 } … … 159 174 160 175 161 SVNlog File::log_core(void) const 162 { 163 return SVNlog(path()); 176 void File::log_core(SVNlog&) const 177 { 164 178 } 165 179 … … 186 200 if (!ignore && node_exist(cache_file)){ 187 201 std::ifstream is(cache_file.c_str()); 188 if (stats_.load_cache(is)){ 202 if (stats_.load_cache(is)) { 203 is.close(); 189 204 return stats_; 190 205 } 191 206 is.close(); 192 207 } 193 else {208 else 194 209 stats_.parse(path_); 195 }196 210 if (!node_exist(cache_dir)) 197 211 mkdir(cache_dir); 198 std::ofstream os(cache_file.c_str()); 212 std::string tmp_cache_file(cache_file+"~"); 213 std::ofstream os(tmp_cache_file.c_str()); 199 214 stats_.print(os); 200 215 os.close(); 216 rename(tmp_cache_file.c_str(), cache_file.c_str()); 201 217 return stats_; 202 218 } … … 205 221 void File::print_blame(std::ofstream& os) const 206 222 { 207 os << "<br /><h3> Blame Information</h3>";223 os << "<br /><h3>" << local_path() << "</h3>"; 208 224 os << "<table class=\"blame\">\n"; 209 225 os << "<thead>\n"; … … 286 302 287 303 void File::print_copyright(std::map<std::string, Alias>& alias, 288 bool verbose) const 304 bool verbose, 305 const std::map<int,svn_revnum_t>& y2rev) const 289 306 { 290 307 if (ignore()) … … 301 318 return; 302 319 } 303 std::map<int, std::set<Alias> > map=copyright_map(alias );320 std::map<int, std::set<Alias> > map=copyright_map(alias, y2rev); 304 321 std::string new_block = copyright_block(map, prefix); 305 322 if (old_block==new_block) … … 313 330 void File::print_core(const bool verbose) const 314 331 { 332 std::ofstream os(blame_output_file_name().c_str()); 333 assert(os.good()); 334 print_html_start(os, "svndigest", level_+1); 335 print_blame(os); 336 print_footer(os); 337 os.close(); 315 338 } 316 339 … … 343 366 print_author_summary(os, stats_[stats_type], line_type, log); 344 367 os << "\n"; 345 346 print_blame(os); 368 os << "<h3>" 369 << anchor(blame_output_file_name(), 370 "Blame Information", level_+3) 371 << "</h3>\n"; 347 372 348 373 print_footer(os);
Note: See TracChangeset
for help on using the changeset viewer.