- Timestamp:
- Sep 6, 2006, 4:39:18 AM (17 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Directory.cc
r182 r185 91 91 } 92 92 93 bool Directory::binary(void) const94 {95 return false;96 }97 98 93 bool Directory::dir(void) const 99 94 { … … 109 104 { 110 105 stats_.reset(); 111 112 // Directories give no contribution to statistics. 106 // Directories themselved give no contribution to statistics. 113 107 for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); ++i) 114 stats_ += (*i)->parse(verbose); 108 if (!(*i)->ignore()) 109 stats_ += (*i)->parse(verbose); 115 110 return stats_; 116 111 } -
trunk/lib/Directory.h
r182 r185 85 85 Directory(const Directory&); 86 86 87 ///88 /// @return false89 ///90 bool binary(void) const;91 92 87 typedef std::list<Node*> NodeContainer; 93 88 typedef NodeContainer::iterator NodeIterator; -
trunk/lib/File.cc
r182 r185 33 33 namespace svndigest{ 34 34 35 bool File::binary(void) const36 {37 return binary_;38 }39 40 35 41 36 std::string File::href(void) const … … 51 46 52 47 53 54 48 const Stats& File::parse(const bool verbose) 49 { 55 50 if (verbose) 56 51 std::cout << "Parsing " << path_ << std::endl; 57 58 binary_ =stats_.parse(path_);52 stats_.reset(); 53 stats_.parse(path_); 59 54 return stats_; 60 } 55 } 56 61 57 62 58 void File::print(const bool verbose) const 63 59 { 64 60 // no output page for binary files 65 if ( binary_)61 if (ignore()) 66 62 return; 67 63 std::string output(output_name() + ".html"); … … 91 87 dark=!dark; 92 88 93 94 89 // print authors 95 90 for (std::set<std::string>::const_iterator i=stats_.authors().begin(); -
trunk/lib/File.h
r182 r185 40 40 File(const u_int level, const std::string& path, 41 41 const std::string& output="") 42 : Node(level,path,output) , binary_(false), ignore_(false){}42 : Node(level,path,output) {} 43 43 44 44 /// … … 65 65 66 66 private: 67 ///68 /// @return true if file is binary69 ///70 bool binary(void) const;71 67 72 68 /// … … 82 78 File(const File&); 83 79 84 bool binary_;85 bool ignore_;86 80 }; 87 81 -
trunk/lib/Makefile.am
r177 r185 27 27 noinst_HEADERS = Directory.h File.h Gnuplot.h GnuplotFE.h html_utility.h 28 28 Node.h \ 29 Parser.h rmdirhier.h Stats.h SVN.h SVNblame.h SVNinfo.h utility.h 29 Parser.h rmdirhier.h Stats.h SVN.h SVNblame.h SVNinfo.h \ 30 SVNproperty.h utility.h 30 31 31 32 libsvndigest_la_SOURCES = Directory.cc File.cc Gnuplot.cc GnuplotFE.cc \ 32 33 html_utility.cc \ 33 34 Node.cc Parser.cc rmdirhier.cc Stats.cc SVN.cc SVNblame.cc \ 34 SVNinfo.cc utility.cc35 SVNinfo.cc SVNproperty.cc utility.cc 35 36 36 37 clean-local: -
trunk/lib/Node.cc
r182 r185 24 24 #include "Node.h" 25 25 #include "html_utility.h" 26 #include "SVNproperty.h" 26 27 #include "utility.h" 27 28 #include <config.h> // this header file is created by configure … … 29 30 #include <ctime> 30 31 #include <fstream> 31 #include <iostream>32 32 #include <sstream> 33 33 … … 39 39 : level_(level), path_(path), stats_(path), svninfo_(path) 40 40 { 41 SVNproperty property(path); 42 binary_=property.binary(); 43 svndigest_ignore_=property.svndigest_ignore(); 41 44 output_name_ = output+file_name(path_); 42 45 } 46 43 47 44 48 bool Node::dir(void) const … … 46 50 return false; 47 51 } 52 48 53 49 54 void Node::path_anchor(std::ostream& os) const … … 63 68 } 64 69 70 65 71 void Node::html_tablerow(std::ostream& os, 66 72 const std::string& css_class) const … … 68 74 os << "<tr class=\"" << css_class << "\">\n" 69 75 << "<td class=\"" << node_type() << "\">"; 70 if (binary()) 76 if (svndigest_ignore()) 77 os << name() << " (<i>svndigest:ignore</i>)"; 78 else if (binary()) 71 79 os << name() << " (<i>binary</i>)"; 72 80 else … … 80 88 << "</tr>\n"; 81 89 } 90 82 91 83 92 void Node::print_footer(std::ostream& os) const -
trunk/lib/Node.h
r182 r185 67 67 { return svninfo_.last_changed_author(); } 68 68 69 /** 70 @brief Check whether node is binary. 71 72 @return True if node is binary. 73 */ 74 inline bool binary(void) const { return binary_; } 75 69 76 /// 70 77 /// @return true if directory … … 77 84 virtual std::string href(void) const=0; 78 85 79 ///80 ///81 ///82 86 void html_tablerow(std::ostream&, const std::string&) const; 87 88 /** 89 @brief Check whether node should be ignored in statistics. 90 91 If a node is to be ignored the statistics implementer should 92 respect this state. Currently binary files and items with 93 property svndigest:ignore are to be ignored by svndigest. If 94 the node is a directory then the direcotry and its siblings 95 should be ignored by statistics. 96 97 @return True of node should be ignored by statistics. 98 99 @see SVNproperty::svndigest_ingorable 100 */ 101 inline bool ignore(void) const { return binary_ || svndigest_ignore_; } 83 102 84 103 /// … … 113 132 virtual void print(const bool verbose=false) const=0; 114 133 134 /** 135 @brief Check if item used to create this object has been 136 assigned property svndigest:ignore. 137 138 Currently files with property svndigest:ignore are to be 139 ignored by svndigest. It is the responsibility of the 140 statistics implementer to obey the ignore state. 141 142 @return True if item property svndigest:digest was set. 143 */ 144 inline bool svndigest_ignore(void) const { return svndigest_ignore_; } 145 115 146 protected: 116 117 ///118 /// @note Directories are not consider binary.119 ///120 virtual bool binary(void) const=0;121 147 122 148 /// … … 153 179 void path_anchor(std::ostream& os) const; 154 180 181 bool binary_; 182 bool svndigest_ignore_; 155 183 SVNinfo svninfo_; 156 184 }; -
trunk/lib/SVN.cc
r164 r185 24 24 #include "SVN.h" 25 25 26 #include <map> 26 27 #include <string> 28 #include <vector> 27 29 28 30 #include <apr_allocator.h> … … 33 35 #include <subversion-1/svn_pools.h> 34 36 #include <subversion-1/svn_wc.h> 37 #include <subversion-1/svn_subst.h> 35 38 36 39 namespace theplu { … … 129 132 subpool); 130 133 if (err && err->apr_err!=SVN_ERR_CLIENT_IS_BINARY_FILE) { 131 svn_handle_error2(err, stderr, false, "svndigest: "); 132 svn_error_clear(err); 133 svn_pool_destroy(subpool); 134 cleanup(err,subpool); 134 135 throw SVNException("SVN::client_blame: svn_client_blame3 failed"); 135 136 } … … 145 146 if (svn_error_t *err=svn_client_info(path.c_str(), NULL, NULL, receiver, 146 147 baton, false, context_, subpool)) { 147 svn_handle_error2(err, stderr, false, "svndigest: "); 148 svn_error_clear(err); 149 svn_pool_destroy(subpool); 148 cleanup(err,subpool); 150 149 throw SVNException("repository: svn_client_info failed"); 150 } 151 svn_pool_destroy(subpool); 152 } 153 154 155 void SVN::client_proplist(const std::string& path, 156 std::map<std::string, std::string>& property) 157 { 158 svn_opt_revision_t peg, revision; 159 peg.kind=svn_opt_revision_unspecified; 160 revision.kind=svn_opt_revision_head; 161 apr_pool_t *subpool = svn_pool_create(pool_); 162 apr_array_header_t * properties; 163 svn_error_t *err=svn_client_proplist2(&properties, path.c_str(), &peg, 164 &revision, false, context_, subpool); 165 if (err) { 166 cleanup(err,subpool); 167 throw SVNException("repository: svn_client_proplist2 failed"); 168 } 169 for (int j = 0; j < properties->nelts; ++j) { 170 svn_client_proplist_item_t *item = 171 ((svn_client_proplist_item_t **)properties->elts)[j]; 172 for (apr_hash_index_t *hi = apr_hash_first(subpool, item->prop_hash); hi; 173 hi = apr_hash_next (hi)) { 174 const void *key; 175 void *val; 176 apr_hash_this (hi, &key, NULL, &val); 177 svn_string_t *value; 178 err=svn_subst_detranslate_string(&value, 179 static_cast<const svn_string_t*>(val), 180 false, subpool); 181 if (err) { 182 cleanup(err,subpool); 183 throw SVNException("property: svn_subst_detranslate_string failed"); 184 } 185 property[static_cast<const char*>(key)]=value->data; 186 } 151 187 } 152 188 svn_pool_destroy(subpool); … … 174 210 if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number), 175 211 subpool))) { 176 svn_handle_error2(err, stderr, false, "svndigest: "); 177 svn_error_clear(err); 178 svn_pool_destroy(subpool); 212 cleanup(err,subpool); 179 213 throw SVNException("commit_dates: svn_ra_get_latest_revnum failed"); 180 214 } … … 187 221 log_message_receiver, static_cast<void*>(&lb), 188 222 context_, subpool))) { 189 svn_handle_error2(err, stderr, false, "svndigest: "); 190 svn_error_clear(err); 191 svn_pool_destroy(subpool); 223 cleanup(err,subpool); 192 224 throw SVNException("commit_dates: svn_client_log3 failed"); 193 225 } … … 197 229 198 230 199 void SVN::cleanup _failed_initialization(svn_error_t *err)231 void SVN::cleanup(svn_error_t *err,apr_pool_t *pool) 200 232 { 201 233 svn_handle_error2(err,stderr,false,"svndigest:"); 202 234 svn_error_clear(err); 203 svn_pool_destroy(pool_); 235 svn_pool_destroy(pool); 236 } 237 238 239 void SVN::cleanup_failed_initialization(svn_error_t *err) 240 { 241 cleanup(err,pool_); 204 242 apr_allocator_destroy(allocator_); 205 243 } … … 224 262 if (svn_error_t *err=svn_client_open_ra_session(&ra_session_, path.c_str(), 225 263 context_,pool_)) { 264 // cleanup could be called if a null pool can be passed to 265 // svn_pool_destroy (which is just a #define to apr_pool_destroy 226 266 svn_handle_error2(err,stderr,false,"svndigest:"); 227 267 svn_error_clear(err); … … 239 279 false, -1, context_->cancel_func, 240 280 context_->cancel_baton, pool_)) { 281 // cleanup could be called if a null pool can be passed to 282 // svn_pool_destroy (which is just a #define to apr_pool_destroy 241 283 svn_handle_error2(err,stderr,false,"svndigest:"); 242 284 svn_error_clear(err); … … 253 295 svn_wc_status2(&status,svn_path_internal_style(path.c_str(), subpool), 254 296 adm_access_, subpool)) { 255 svn_handle_error2(err,stderr,false,"svndigest:"); 256 svn_error_clear(err); 257 svn_pool_destroy(subpool); 297 cleanup(err,subpool); 258 298 throw SVNException("version_controlled(): svn_config_get_config failed"); 259 299 } -
trunk/lib/SVN.h
r165 r185 25 25 */ 26 26 27 #include <map> 27 28 #include <stdexcept> 28 29 #include <string> … … 106 107 void *baton); 107 108 109 /** 110 @brief Get the properties for \a path. 111 112 The retrieved properties are stored in \a properties. To check 113 whether \a is a binary item use SVNproperty::binary(void). 114 */ 115 void client_proplist(const std::string& path, 116 std::map<std::string, std::string>& properties); 117 108 118 /// 109 119 /// @brief Get revision dates. … … 168 178 SVN(const SVN&); 169 179 170 /// 171 /// Free resources when failing to reach end of constructor. 172 /// 180 /** 181 @brief Free resources when svn API calls fail. 182 */ 183 void cleanup(svn_error_t *err,apr_pool_t *pool); 184 185 /** 186 @brief Free resources when failing to reach end of 187 constructor. 188 */ 173 189 void cleanup_failed_initialization(svn_error_t *err); 174 190 -
trunk/lib/Stats.cc
r183 r185 126 126 127 127 128 boolStats::parse(const std::string& path)128 void Stats::parse(const std::string& path) 129 129 { 130 SVNblame svn_blame(path);131 if (svn_blame.binary())132 return true;133 134 130 Parser parser(path); 135 131 std::vector<Parser::line_type>::const_iterator count=parser.type().begin(); 136 132 133 SVNblame svn_blame(path); 137 134 while (const SVNblame::blame_information * bi=svn_blame.next()) { 138 135 // to handle symbolic links … … 143 140 ++count; 144 141 } 145 146 return false;147 142 } 148 143 -
trunk/lib/Stats.h
r165 r185 81 81 inline u_int last_changed_rev(void) const { return last_changed_rev_; } 82 82 83 /// 84 /// @return true if file is binary 85 /// 86 bool parse(const std::string&); 83 void parse(const std::string&); 87 84 88 85 ///
Note: See TracChangeset
for help on using the changeset viewer.