Changeset 803
- Timestamp:
- Jul 11, 2009, 1:23:45 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/AddStats.cc
r703 r803 2 2 3 3 /* 4 Copyright (C) 2008 Peter Johansson4 Copyright (C) 2008, 2009 Peter Johansson 5 5 6 6 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 33 33 #include <string> 34 34 #include <vector> 35 36 //debug37 #include <iostream>38 35 39 36 namespace theplu{ … … 69 66 if (*rev_iter==svn_blame.revision()) 70 67 add(svn_blame.author(), *rev_iter, lt); 71 // I dont trust blame and log behave consistent (stop-on-copy).68 // I dont trust blame and log behave consistently (stop-on-copy). 72 69 revs.insert(svn_blame.revision()); 73 70 svn_blame.next_line(); -
trunk/lib/BlameStats.cc
r703 r803 4 4 Copyright (C) 2005 Peter Johansson 5 5 Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson 6 Copyright (C) 2009 Peter Johansson 6 7 7 8 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 63 64 void BlameStats::fill_in(Author2Vector& a2v, svn_revnum_t rev) 64 65 { 65 assert(rev); 66 if (rev==0) 67 return; 66 68 for (std::set<std::string>::const_iterator iter(authors().begin()); 67 69 iter!=authors().end(); ++iter) { … … 96 98 // filling in pristine revisions 97 99 RevSet::iterator rev_iter=revs.begin(); 98 for (svn_revnum_t rev = first_rev +1; rev<=revision(); ++rev){100 for (svn_revnum_t rev = first_rev; rev<=revision(); ++rev){ 99 101 if (rev==*rev_iter) 100 102 ++rev_iter; -
trunk/lib/ClassicStats.cc
r703 r803 61 61 void ClassicStats::do_parse(const std::string& path, svn_revnum_t rev) 62 62 { 63 reset(); 63 64 LineTypeParser parser(path); 64 65 SVNblame svn_blame(path); 65 66 while (svn_blame.valid()) { 66 if (svn_blame.revision()>=rev) { 67 add(svn_blame.author(), svn_blame.revision(), 68 parser.parse(svn_blame.line())); 69 } 67 add(svn_blame.author(), svn_blame.revision(), 68 parser.parse(svn_blame.line())); 70 69 svn_blame.next_line(); 71 70 } 72 accumulate_stats( rev);71 accumulate_stats(); 73 72 } 74 73 -
trunk/lib/Stats.cc
r768 r803 4 4 Copyright (C) 2005 Peter Johansson 5 5 Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson 6 Copyright (C) 2008 Peter Johansson6 Copyright (C) 2008, 2009 Peter Johansson 7 7 8 8 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 118 118 vec.reserve(rev+1); 119 119 vec.resize(rev); 120 assert(vec.size()+1<vec.max_size()); 120 121 if (x) { 121 assert(vec.size()+1<vec.max_size());122 122 vec.push_back(n); 123 123 } 124 124 else { 125 assert(vec.size()+1<vec.max_size());126 125 vec.push_back(0); 127 126 } … … 154 153 { 155 154 std::vector<unsigned int> init(revision()+1); 156 code_stats()["all"]=std::accumulate(code_stats().begin(), 157 code_stats().end(), init, 158 PairValuePlus<std::string,unsigned int>()); 159 comment_stats()["all"]=std::accumulate(comment_stats().begin(), 160 comment_stats().end(), init, 161 PairValuePlus<std::string,unsigned int>()); 162 other_stats()["all"]=std::accumulate(other_stats().begin(), 163 other_stats().end(), init, 164 PairValuePlus<std::string,unsigned int>()); 165 copyright_stats()["all"]=std::accumulate(copyright_stats().begin(), 166 copyright_stats().end(), init, 167 PairValuePlus<std::string,unsigned int>()); 155 for (int lt=0; lt <= 4; ++lt) { 156 stats_[lt]["all"].clear(); 157 stats_[lt]["all"] = 158 std::accumulate(stats_[lt].begin(), 159 stats_[lt].end(), init, 160 PairValuePlus<std::string,unsigned int>()); 161 } 168 162 VectorPlus<unsigned int> vp; 169 163 comment_or_copy_stats()["all"] = … … 171 165 172 166 total_stats()["all"] = 173 vp(vp(code_stats()["all"], comment_or_copy_stats()["all"]), 174 167 vp(vp(code_stats()["all"], comment_or_copy_stats()["all"]), 168 other_stats()["all"]); 175 169 } 176 170 … … 339 333 void Stats::parse(const std::string& path, svn_revnum_t rev) 340 334 { 335 // reset stats to zero for [rev, inf) 336 for (size_t i=0; i<stats_.size(); ++i) 337 for (A2VIter iter=stats_[i].begin(); iter!=stats_[i].end(); ++iter) { 338 iter->second.resize(rev,0); 339 iter->second.resize(revision(),0); 340 } 341 341 do_parse(path, rev); 342 342 calc_comment_or_copy(); -
trunk/lib/StatsCollection.cc
r752 r803 63 63 svn_revnum_t cache_rev = i->second->load_cache(is); 64 64 if (cache_rev < i->second->last_changed_rev()) { 65 cache_rev=0; // tmp hack to avoid partial cache66 65 result = false; 67 66 // reset if load cache failed -
trunk/test/Suite.cc
r801 r803 29 29 #include "../lib/utility.h" 30 30 31 #include <algorithm> 31 32 #include <cassert> 32 33 #include <fstream> 33 34 #include <iostream> 35 #include <iterator> 34 36 #include <string> 35 37 … … 92 94 93 95 96 bool check_all(const Stats& stats, test::Suite& suite) 97 { 98 for (int lt=0; lt<=LineTypeParser::total; ++lt) { 99 for (svn_revnum_t rev=0; rev<=stats.revision(); ++rev) { 100 size_t all = 0; 101 for (std::set<std::string>::const_iterator a=stats.authors().begin(); 102 a!=stats.authors().end(); ++a) { 103 all += stats(lt, *a, rev); 104 } 105 if (all!=stats(lt, "all", rev)) { 106 suite.out() << "error: check_all\n" 107 << " lt = " << lt << "\n" 108 << " rev = " << rev << "\n" 109 << " all = " << all << "\n" 110 << " stats = " << stats(lt, "all", rev) << "\n"; 111 for (std::set<std::string>::const_iterator a=stats.authors().begin(); 112 a!=stats.authors().end(); ++a) { 113 suite.out() << *a << " " << stats(lt, *a, rev) << "\n"; 114 } 115 return false; 116 } 117 } 118 } 119 return true; 120 } 121 122 123 bool check_total(const Stats& stats, test::Suite& suite) 124 { 125 for (svn_revnum_t rev=0; rev<=stats.revision(); ++rev) { 126 for (std::set<std::string>::const_iterator a=stats.authors().begin(); 127 a!=stats.authors().end(); ++a) { 128 unsigned int total=0; 129 for (int lt=0; lt<4; ++lt) { 130 total += stats(lt, *a, rev); 131 } 132 unsigned int total2=stats(LineTypeParser::total, *a, rev); 133 134 if (total!=total2) { 135 suite.out() << "error: check_total\n" 136 << " author = " << *a << "\n" 137 << " rev = " << rev << "\n" 138 << " sum = " << total << "\n" 139 << " total = " << total2 << "\n"; 140 return false; 141 } 142 } 143 } 144 return true; 145 } 146 147 148 bool check_comment_or_copy(const Stats& stats, test::Suite& suite) 149 { 150 for (svn_revnum_t rev=0; rev<=stats.revision(); ++rev) { 151 for (std::set<std::string>::const_iterator a=stats.authors().begin(); 152 a!=stats.authors().end(); ++a) { 153 unsigned int x=stats(LineTypeParser::comment, *a, rev); 154 x+=stats(LineTypeParser::copyright, *a, rev); 155 unsigned int y=stats(LineTypeParser::comment_or_copy, *a, rev); 156 157 if (x!=y) { 158 suite.out() << "error: check_total\n" 159 << " author = " << *a << "\n" 160 << " rev = " << rev << "\n" 161 << " comment + copyright = " << x << "\n" 162 << " comment_or_copy = " << y << "\n"; 163 return false; 164 } 165 } 166 } 167 return true; 168 } 169 170 171 bool consistent(const StatsCollection& sc, test::Suite& suite) 172 { 173 std::map<std::string, Stats*>::const_iterator iter = sc.stats().begin(); 174 while (iter != sc.stats().end()) { 175 if (!consistent(*iter->second, suite)) { 176 suite.out() << "error in " << iter->first << "\n"; 177 return false; 178 } 179 ++iter; 180 } 181 return true; 182 } 183 184 185 bool consistent(const Stats& stats, test::Suite& suite) 186 { 187 suite.add(check_all(stats, suite)); 188 suite.add(check_total(stats, suite)); 189 suite.add(check_comment_or_copy(stats, suite)); 190 return true; 191 } 192 193 94 194 bool equal(const StatsCollection& a, const StatsCollection& b, 95 195 Suite& suite) … … 122 222 if (a.authors() != b.authors()) { 123 223 suite.out() << "authors are not equal\n"; 224 suite.out() << "lhs:\n"; 225 std::copy(a.authors().begin(), a.authors().end(), 226 std::ostream_iterator<std::string>(suite.out(), "\n")); 227 suite.out() << "rhs:\n"; 228 std::copy(b.authors().begin(), b.authors().end(), 229 std::ostream_iterator<std::string>(suite.out(), "\n")); 124 230 return false; 125 231 } -
trunk/test/Suite.h
r801 r803 68 68 }; 69 69 70 bool check_all(const Stats&, test::Suite&); 71 bool check_total(const Stats&, test::Suite&); 72 bool check_comment_or_copy(const Stats&, test::Suite&); 73 74 bool consistent(const StatsCollection&, test::Suite&); 75 bool consistent(const Stats&, test::Suite&); 76 70 77 bool equal(const StatsCollection& a, const StatsCollection& b, 71 78 test::Suite& suite); -
trunk/test/cache_partial_test.cc
r801 r803 54 54 File file(0,filename,""); 55 55 const StatsCollection& stats1 = file.parse(suite.verbose(), true); 56 suite.add(test::consistent(stats1, suite)); 56 57 57 58 // create file using partial cache … … 59 60 File file2(0,filename,""); 60 61 const StatsCollection& stats2 = file2.parse(suite.verbose(), false); 62 suite.add(test::consistent(stats2, suite)); 61 63 62 64 suite.add(equal(stats1, stats2, suite));
Note: See TracChangeset
for help on using the changeset viewer.