Changeset 303
- Timestamp:
- May 11, 2007, 10:13:00 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/svndigest.cc
r297 r303 183 183 if (option->verbose()) 184 184 std::cout << "Updating copyright statements" << std::endl; 185 std::map<std::string, std::string> alias(config.copyright_alias());185 std::map<std::string, Alias> alias(config.copyright_alias()); 186 186 tree.print_copyright(alias); 187 187 } -
trunk/lib/Configuration.cc
r289 r303 31 31 #include <string> 32 32 #include <sstream> 33 #include <stdexcept> 33 34 #include <utility> 34 35 … … 41 42 Configuration::Configuration(void) 42 43 { 44 } 45 46 47 const std::map<std::string,Alias>& Configuration::copyright_alias(void) const 48 { 49 return copyright_alias_; 43 50 } 44 51 … … 72 79 getline(ss, tmp); 73 80 std::string name = trim(tmp); 74 copyright_alias_[key] = name; 81 std::map<std::string,Alias>::iterator iter = 82 copyright_alias_.lower_bound(key); 83 if (iter!=copyright_alias_.end() && iter->first==key){ 84 std::stringstream mess; 85 mess << "svndigest: invalid config file: " 86 << "in copright-alias section" << key + "defined twice."; 87 throw std::runtime_error(mess.str()); 88 } 89 90 // insert alias 91 copyright_alias_.insert(iter,std::make_pair(key, Alias(name,copyright_alias_.size()))); 75 92 } 76 93 else if (section == "trac"){ … … 126 143 << "[copyright-alias]\n" 127 144 << "# jdoe = John Doe\n"; 128 129 typedef std::map<std::string, std::string> map; 130 for (map::const_iterator i=conf.copyright_alias().begin(); 131 i!=conf.copyright_alias().end(); ++i) { 132 os << i->first << " = " << i->second << " \n"; 145 146 typedef std::vector<std::pair<std::string, Alias> > vector; 147 vector vec; 148 std::back_insert_iterator<vector> back_insert_iterator(vec); 149 vec.reserve(conf.copyright_alias().size()); 150 std::copy(conf.copyright_alias().begin(), conf.copyright_alias().end(), 151 back_insert_iterator); 152 // sort with respect to Alias.id 153 IdCompare id; 154 PairSecondCompare<const std::string, Alias, IdCompare> comp(id); 155 std::sort(vec.begin(),vec.end(), comp); 156 157 158 for (vector::const_iterator i(vec.begin()); i!=vec.end(); ++i) { 159 os << i->first << " = " << i->second.name() << " \n"; 133 160 } 134 161 -
trunk/lib/Configuration.h
r289 r303 25 25 */ 26 26 27 #include "Alias.h" 28 27 29 #include <iostream> 28 #include < map>30 #include <vector> 29 31 #include <string> 30 32 #include <utility> … … 55 57 /// @brief Aliases for Copyright 56 58 /// 57 inline const std::map<std::string, std::string>& 58 copyright_alias(void) const { return copyright_alias_; } 59 const std::map<std::string, Alias>& copyright_alias(void) const; 59 60 60 61 /// … … 82 83 static Configuration* instance_; 83 84 84 std::map<std::string, std::string> copyright_alias_;85 std::map<std::string, Alias> copyright_alias_; 85 86 86 87 std::string trac_root_; -
trunk/lib/Directory.cc
r274 r303 24 24 25 25 #include "Directory.h" 26 27 #include "Alias.h" 26 28 #include "File.h" 27 29 #include "html_utility.h" … … 220 222 221 223 222 void Directory::print_copyright 223 (std::map<std::string, std::string>& alias) const { 224 void Directory::print_copyright(std::map<std::string, Alias>& alias) const { 224 225 if (!ignore()){ 225 226 // print daughter nodes, i.e, this function is recursive -
trunk/lib/Directory.h
r258 r303 79 79 const Stats& parse(const bool verbose=false); 80 80 81 void print_copyright(std::map<std::string, std::string>&) const;81 void print_copyright(std::map<std::string, Alias>&) const; 82 82 83 83 private: -
trunk/lib/File.cc
r258 r303 24 24 25 25 #include "File.h" 26 27 #include "Alias.h" 26 28 #include "html_utility.h" 27 29 #include "Stats.h" … … 101 103 102 104 103 void File::print_copyright (std::map<std::string,std::string>& alias) const{ 105 void File::print_copyright(std::map<std::string, Alias>& alias) const 106 { 104 107 if (ignore()) 105 108 return; … … 108 111 SVNlog log(path()); 109 112 110 typedef map<int, set<string> > Container; 111 Container copyright; 112 113 113 map<int, set<Alias> > year_authors; 114 114 115 assert(log.author().size()==log.date().size()); 115 116 vector<string>::const_iterator author=log.author().begin(); … … 120 121 121 122 // find username in map of aliases 122 map<string, string>::iterator name = alias.lower_bound(*author); 123 std::map<string,Alias>::iterator name(alias.lower_bound(*author)); 124 123 125 // if alias exist insert alias 124 126 if (name != alias.end() && name->first==*author) 125 copyright[timeinfo->tm_year].insert(name->second);127 year_authors[timeinfo->tm_year].insert(name->second); 126 128 else { 127 129 // else insert user name 128 copyright[timeinfo->tm_year].insert(*author); 130 Alias a(*author,alias.size()); 131 year_authors[timeinfo->tm_year].insert(a); 129 132 std::cerr << "svndigest: warning: no copyright alias found for `" 130 133 << *author << "`\n"; 131 134 // insert alias to avoid multiple warnings. 132 alias.insert(name, std::make_pair(*author, *author));135 alias.insert(name, std::make_pair(*author, a)); 133 136 } 134 137 } … … 176 179 found_copyright = true; 177 180 // Printing copyright statement 178 for (Container::const_iterator i=copyright.begin(); 179 i!=copyright.end();) { 180 tmp << prefix << "Copyright (C) " 181 << 1900+i->first; 182 Container::const_iterator j = i; 183 assert(i!=copyright.end()); 184 while (++j!=copyright.end() && i->second == j->second){ 185 tmp << ", " << 1900+(j->first); 186 } 187 // printing authors 188 for (set<string>::iterator a=i->second.begin(); 189 a!=i->second.end(); ++a){ 190 if (a!=i->second.begin()) 191 tmp << ","; 192 tmp << " " << *a; 193 } 194 tmp << "\n"; 195 i = j; 181 for (map<int, set<Alias> >::const_iterator i(year_authors.begin()); 182 i!=year_authors.end();) { 183 tmp << prefix << "Copyright (C) " 184 << 1900+i->first; 185 map<int, set<Alias> >::const_iterator j = i; 186 assert(i!=year_authors.end()); 187 while (++j!=year_authors.end() && 188 i->second == j->second){ 189 tmp << ", " << 1900+(j->first); 190 } 191 // printing authors 192 std::vector<Alias> vec_alias; 193 back_insert_iterator<std::vector<Alias> > ii(vec_alias); 194 std::copy(i->second.begin(), i->second.end(), ii); 195 // sort with respect to id 196 std::sort(vec_alias.begin(), vec_alias.end(), IdCompare()); 197 for (std::vector<Alias>::iterator a=vec_alias.begin(); 198 a!=vec_alias.end(); ++a){ 199 if (a!=vec_alias.begin()) 200 tmp << ","; 201 tmp << " " << a->name(); 202 } 203 tmp << "\n"; 204 i = j; 196 205 } 197 206 } … … 203 212 // finally move printed temporary file to original file 204 213 rename(tmpname, path().c_str()); 214 205 215 } 206 216 }} // end of namespace svndigest and namespace theplu -
trunk/lib/File.h
r259 r303 66 66 void print_blame(std::ofstream&, const std::string line_type) const; 67 67 68 void print_copyright(std::map<std::string, std::string>&) const;68 void print_copyright(std::map<std::string, Alias>&) const; 69 69 70 70 private: -
trunk/lib/Makefile.am
r286 r303 26 26 noinst_LTLIBRARIES = libsvndigest.la 27 27 28 noinst_HEADERS = ColumnStream.h Commitment.h Configuration.h css.h\28 noinst_HEADERS = Alias.h ColumnStream.h Commitment.h Configuration.h css.h\ 29 29 Date.h Directory.h File.h first_page.h Gnuplot.h GnuplotFE.h \ 30 30 HtmlStream.h html_utility.h Node.h Parser.h rmdirhier.h \ … … 32 32 SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h 33 33 34 libsvndigest_la_SOURCES = ColumnStream.cc Commitment.cc Configuration.cc \ 34 libsvndigest_la_SOURCES = Alias.cc ColumnStream.cc \ 35 Commitment.cc Configuration.cc \ 35 36 css.cc Date.cc Directory.cc File.cc first_page.cc\ 36 37 Gnuplot.cc GnuplotFE.cc HtmlStream.cc \ -
trunk/lib/Node.h
r285 r303 39 39 namespace theplu{ 40 40 namespace svndigest{ 41 42 class Alias; 41 43 42 44 /// … … 145 147 void print_author_summary(std::ostream&, std::string, const SVNlog&) const; 146 148 147 virtual void 148 print_copyright(std::map<std::string, std::string>&) const=0; 149 virtual void print_copyright(std::map<std::string,Alias>& ) const=0; 149 150 150 151 /** -
trunk/lib/utility.cc
r297 r303 193 193 {} 194 194 195 196 195 }} // end of namespace svndigest and namespace theplu -
trunk/lib/utility.h
r297 r303 222 222 (!(y.second<x.second) && (x.first<y.first))); 223 223 } 224 }; 225 226 template <class T1,class T2, class T3> 227 struct PairSecondCompare 228 { 229 230 /// 231 /// @brief Constructor 232 /// 233 explicit PairSecondCompare(const T3& comp) 234 : compare_(comp) {} 235 236 /// 237 /// @return true if x.second<y.second or (x.second==y.second and 238 /// x.first<y.first) 239 /// 240 inline bool operator()(const std::pair<T1,T2>& x, 241 const std::pair<T1,T2>& y) const 242 { return compare_(x.second,y.second); } 243 244 private: 245 T3 compare_; 246 224 247 }; 225 248
Note: See TracChangeset
for help on using the changeset viewer.