- Timestamp:
- Dec 27, 2007, 7:37:39 AM (16 years ago)
- Location:
- trunk/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/BlameStats.cc
r536 r537 29 29 #include "SVNblame.h" 30 30 #include "SVNinfo.h" 31 #include "SVNlog.h" 31 32 #include "utility.h" 32 33 … … 62 63 63 64 65 void BlameStats::fill_in(Author2Vector& a2v, svn_revnum_t rev) 66 { 67 assert(rev); 68 for (std::set<std::string>::const_iterator iter(authors().begin()); 69 iter!=authors().end(); ++iter) { 70 std::vector<u_int>& vec = a2v[*iter]; 71 vec.resize(revision()+1); 72 assert(rev<static_cast<svn_revnum_t>(vec.size())); 73 vec[rev]=vec[rev-1]; 74 } 75 } 76 77 64 78 void BlameStats::do_parse(const std::string& path) 65 79 { 66 80 Parser parser(path); 67 SVNblame svn_blame(path); 68 while (svn_blame.valid()) { 69 add(svn_blame.author(), svn_blame.revision(), 70 parser.parse(svn_blame.line())); 71 svn_blame.next_line(); 81 SVNlog log(path); 82 typedef std::set<svn_revnum_t> RevSet; 83 RevSet revs; 84 std::copy(log.revision().begin(), log.revision().end(), 85 std::inserter(revs, revs.begin())); 86 for (RevSet::iterator rev_iter=revs.begin();rev_iter!=revs.end();++rev_iter){ 87 SVNblame svn_blame(path, *rev_iter); 88 while (svn_blame.valid()) { 89 add(svn_blame.author(), *rev_iter, parser.parse(svn_blame.line())); 90 // I dont trust blame and log behave consistent (stop-on-copy). 91 revs.insert(svn_blame.revision()); 92 svn_blame.next_line(); 93 } 94 } 95 96 // filling in pristine revisions 97 RevSet::iterator rev_iter=revs.begin(); 98 for (svn_revnum_t rev = 1; rev<=revision(); ++rev){ 99 if (rev==*rev_iter) 100 ++rev_iter; 101 else { 102 fill_in(code_,rev); 103 fill_in(comments_,rev); 104 fill_in(other_,rev); 105 } 72 106 } 73 107 } -
trunk/lib/BlameStats.h
r533 r537 47 47 private: 48 48 void do_parse(const std::string&); 49 void fill_in(Author2Vector&, svn_revnum_t rev); 49 50 50 51 }; -
trunk/lib/ClassicStats.cc
r536 r537 71 71 svn_blame.next_line(); 72 72 } 73 accumulate_stats(); 74 73 75 } 74 76 -
trunk/lib/Stats.cc
r534 r537 87 87 std::vector<u_int>& other = other_[*iter]; 88 88 accumulate(other); 89 90 VectorPlus<u_int> vp; 91 total_[*iter] = vp(vp(code, comments),other); 92 } 93 std::vector<u_int> init(revision()+1); 94 code_["all"]=std::accumulate(code_.begin(), code_.end(), init, 95 PairValuePlus<std::string,u_int>()); 96 comments_["all"]=std::accumulate(comments_.begin(), comments_.end(), init, 97 PairValuePlus<std::string,u_int>()); 98 other_["all"]=std::accumulate(other_.begin(), other_.end(), init, 99 PairValuePlus<std::string,u_int>()); 100 VectorPlus<u_int> vp; 101 total_["all"] = vp(vp(code_["all"], comments_["all"]), other_["all"]); 89 } 102 90 } 103 91 … … 108 96 assert(user.size()); 109 97 add_author(user); 110 111 std::vector<u_int>& total = total_[user];112 if (total.size() < rev+1){113 total.reserve(revision() + 1);114 total.insert(total.end(), rev - total.size(), 0);115 total.push_back(n);116 }117 else118 total[rev]+=n;119 98 120 99 std::vector<u_int>& code = code_[user]; … … 172 151 { 173 152 return authors_; 153 } 154 155 156 void Stats::calc_all(void) 157 { 158 std::vector<u_int> init(revision()+1); 159 code_["all"]=std::accumulate(code_.begin(), code_.end(), init, 160 PairValuePlus<std::string,u_int>()); 161 comments_["all"]=std::accumulate(comments_.begin(), comments_.end(), init, 162 PairValuePlus<std::string,u_int>()); 163 other_["all"]=std::accumulate(other_.begin(), other_.end(), init, 164 PairValuePlus<std::string,u_int>()); 165 VectorPlus<u_int> vp; 166 total_["all"] = vp(vp(code_["all"], comments_["all"]), other_["all"]); 167 } 168 169 170 void Stats::calc_total(void) 171 { 172 for (std::set<std::string>::const_iterator iter(authors().begin()); 173 iter!=authors().end(); ++iter) { 174 std::vector<u_int>& code = code_[*iter]; 175 std::vector<u_int>& comments = comments_[*iter]; 176 std::vector<u_int>& other = other_[*iter]; 177 178 VectorPlus<u_int> vp; 179 total_[*iter] = vp(vp(code, comments),other); 180 } 181 174 182 } 175 183 … … 323 331 { 324 332 do_parse(path); 325 accumulate_stats(); 333 calc_total(); 334 calc_all(); 326 335 } 327 336 -
trunk/lib/Stats.h
r532 r537 143 143 typedef Author2Vector::const_iterator A2VConstIter; 144 144 145 void accumulate_stats(void); 145 146 void add_author(std::string); 146 147 void add_authors(std::set<std::string>::const_iterator, … … 169 170 private: 170 171 void accumulate(std::vector<u_int>& vec) const; 171 void accumulate_stats(void);172 172 virtual void do_parse(const std::string&)=0; 173 173 … … 175 175 // that all old cache files are obsolete. 176 176 inline std::string end_of_cache(void) const 177 {return "END OF OK CACHE FILE VERSION 300";}177 {return "END OF OK CACHE FILE VERSION 4";} 178 178 inline std::string code_cache(void) const {return "CACHE CODE";} 179 179 inline std::string comments_cache(void) const {return "CACHE COMMENTS";} … … 183 183 184 184 185 void calc_all(void); 186 void calc_total(void); 185 187 u_int get_back(const Author2Vector&, std::string user) const; 186 188 void load(std::istream& is, Author2Vector& m);
Note: See TracChangeset
for help on using the changeset viewer.