Changeset 1222
- Timestamp:
- Oct 17, 2010, 5:51:36 PM (13 years ago)
- Location:
- branches/visitor
- Files:
-
- 24 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/visitor
-
branches/visitor/bin/Parameter.cc
r1119 r1222 97 97 check_existence(root_.value()); 98 98 check_readable(root_.value()); 99 check_is_dir(root_.value()); 99 100 chdir(root_.value()); 100 101 root_.value(pwd()); … … 116 117 if (S_ISDIR(nodestat.st_mode)) { 117 118 std::stringstream ss; 118 ss << cmd_.program_name() << ": `" << config_file_.value()119 ss << cmd_.program_name() << ": '" << config_file_.value() 119 120 << "' is a directory"; 120 121 throw yat::utility::cmd_error(ss.str()); … … 130 131 return; 131 132 std::stringstream ss; 132 ss << cmd_.program_name() << ": cannot stat `" << path << "': "133 ss << cmd_.program_name() << ": cannot stat '" << path << "': " 133 134 << strerror(errno); 134 135 throw yat::utility::cmd_error(ss.str()); … … 136 137 137 138 139 void Parameter::check_is_dir(std::string path) const 140 { 141 if (node_exist(path)) { 142 struct stat buf; 143 stat(path.c_str(), &buf); 144 if (S_ISDIR(buf.st_mode)) 145 return; 146 } 147 std::stringstream ss; 148 ss << cmd_.program_name() << ": '" << path << "': " 149 << strerror(errno); 150 throw yat::utility::cmd_error(ss.str()); 151 } 152 153 138 154 void Parameter::check_readable(std::string path) const 139 155 { … … 141 157 return; 142 158 std::stringstream ss; 143 ss << cmd_.program_name() << ": cannot open `" << path << "': "159 ss << cmd_.program_name() << ": cannot open '" << path << "': " 144 160 << strerror(errno); 145 161 throw yat::utility::cmd_error(ss.str()); -
branches/visitor/bin/svndigestParameter.cc
r1186 r1222 85 85 std::string save_wd = pwd(); 86 86 87 // check root but not if -g option given88 87 if (!generate_config()) { 89 88 // check target (only if we write report) … … 91 90 check_existence(target_.value()); 92 91 check_readable(target_.value()); 92 check_is_dir(target_.value()); 93 93 std::string base_root = file_name(root()); 94 94 std::string path = concatenate_path(target_.value(),base_root); 95 95 if (access_rights(target_.value(), "w")) { 96 96 std::stringstream ss; 97 ss << "svndigest: cannot create directory `" << path97 ss << "svndigest: cannot create directory '" << path 98 98 << "': " << strerror(errno); 99 99 throw yat::utility::cmd_error(ss.str()); … … 101 101 if (node_exist(path) && !force()) { 102 102 std::stringstream ss; 103 ss << "svndigest: cannot create directory `" << path << "' "103 ss << "svndigest: cannot create directory '" << path << "' " 104 104 << strerror(EEXIST); 105 105 throw yat::utility::cmd_error(ss.str()); -
branches/visitor/lib/File.cc
r1197 r1222 205 205 { 206 206 if (verbose) 207 std::cout << "Parsing " << path_<< std::endl;207 std::cout << "Parsing '" << path_ << "'" << std::endl; 208 208 stats_.reset(); 209 209 std::string cache_dir = directory_name(path()) + std::string(".svndigest/"); … … 343 343 return; 344 344 if (verbose) 345 std::cout << "Updating copyright in " << path_<< std::endl;345 std::cout << "Updating copyright in '" << path_ << "'" << std::endl; 346 346 update_copyright(new_block, start_line, end_line); 347 347 } -
branches/visitor/lib/Node.cc
r1186 r1222 203 203 return; 204 204 if (verbose) 205 std::cout << "Printing output for " << path_<< std::endl;205 std::cout << "Printing output for '" << path_ << "'" << std::endl; 206 206 const SVNlog& log = this->log(); 207 207 typedef std::map<std::string, Stats*>::const_iterator iter; -
branches/visitor/lib/SVN.cc
r978 r1222 38 38 #include <subversion-1/svn_subst.h> 39 39 40 #include <string> 41 40 42 namespace theplu { 41 43 namespace svndigest { 44 45 46 SVNException::SVNException(const std::string& msg, svn_error_t* error) 47 : std::runtime_error(""), error_(error), msg_(msg) 48 { 49 ref_count_ = new int(1); 50 if (error_) { 51 apr_size_t bufsize=255; 52 char buf[255]; 53 msg_ = svn_err_best_message(error_, buf, bufsize); 54 } 55 if (msg.size()) { 56 msg_ += msg; 57 } 58 } 59 60 SVNException::SVNException(const SVNException& other) 61 : std::runtime_error(other), error_(other.error_), msg_(other.msg_), 62 ref_count_(other.ref_count_) 63 { 64 ++(*ref_count_); 65 } 66 67 68 SVNException::~SVNException(void) throw() 69 { 70 --(*ref_count_); 71 if (!(*ref_count_)) { 72 delete ref_count_; 73 ref_count_=NULL; 74 svn_error_clear(error_); 75 error_=SVN_NO_ERROR; 76 } 77 } 78 79 80 const char* SVNException::what(void) const throw() 81 { 82 return msg_.c_str(); 83 } 84 85 86 const svn_error_t* SVNException::error(void) const 87 { 88 return error_; 89 } 42 90 43 91 … … 100 148 context_->cancel_baton, pool_))){ 101 149 if (err->apr_err == SVN_ERR_WC_NOT_DIRECTORY) 102 cleanup_failed_init(err, std::string(err->message) , true);150 cleanup_failed_init(err, std::string(err->message)); 103 151 cleanup_failed_init(err, "SVN: svn_wc_adm_open3 failed"); 104 152 } … … 128 176 std::string message, bool mute) 129 177 { 130 if (!mute)131 svn_handle_error2(err,stderr,false,"svndigest: ");132 178 svn_error_clear(err); 133 179 if (pool){ … … 135 181 pool=NULL; 136 182 } 137 if (message.length()>0) 138 throw SVNException(message); 139 } 140 141 142 void SVN::cleanup_failed_init(svn_error_t *err, const std::string& message, 143 bool mute) 144 { 145 cleanup(err,pool_, "", true); 183 assert(message.size()); // compatible with r1213 184 if (!mute) 185 throw SVNException(message, err); 186 // mute implies we don't wanna hear the message from svn_error_t 146 187 throw SVNException(message); 147 188 } 148 189 149 190 150 svn_error_t* SVN::client_blame(const std::string& path, 151 svn_client_blame_receiver_t receiver, 152 void *baton, svn_revnum_t rev) 191 void SVN::cleanup_failed_init(svn_error_t *err, const std::string& message) 192 { 193 assert(message.size()); // compatible with r1213 194 cleanup(err,pool_, message, true); 195 assert(false && "cleanup should throw"); 196 } 197 198 199 void SVN::client_blame(const std::string& path, 200 svn_client_blame_receiver_t receiver, 201 void *baton, svn_revnum_t rev) 153 202 { 154 203 svn_opt_revision_t head; 155 204 head.kind=svn_opt_revision_number; 156 205 head.value.number=rev; 157 returnclient_blame_call(path, receiver, baton, head);158 } 159 160 svn_error_t*SVN::client_blame(const std::string& path,161 162 206 client_blame_call(path, receiver, baton, head); 207 } 208 209 void SVN::client_blame(const std::string& path, 210 svn_client_blame_receiver_t receiver, 211 void *baton) 163 212 { 164 213 svn_opt_revision_t head; 165 214 head.kind = ( svn_path_is_url(path.c_str()) ? 166 215 svn_opt_revision_head : svn_opt_revision_base ); 167 returnclient_blame_call(path, receiver, baton, head);168 } 169 170 171 svn_error_t*SVN::client_blame_call(const std::string& path,172 173 216 client_blame_call(path, receiver, baton, head); 217 } 218 219 220 void SVN::client_blame_call(const std::string& path, 221 svn_client_blame_receiver_t receiver, 222 void *baton, svn_opt_revision_t& head) 174 223 { 175 224 // Setup to use all revisions … … 183 232 false, receiver, baton, context_, 184 233 subpool); 185 if (err && err->apr_err!=SVN_ERR_CLIENT_IS_BINARY_FILE)234 if (err) 186 235 // cleanup will throw an exception 187 236 cleanup(err, subpool, "SVN::client_blame: svn_client_blame3 failed"); 188 237 svn_pool_destroy(subpool); 189 return err;190 238 } 191 239 … … 295 343 if (info->repos_root_URL) 296 344 rurb->path=info->repos_root_URL; 297 298 345 return SVN_NO_ERROR; 299 346 } -
branches/visitor/lib/SVN.h
r978 r1222 50 50 /// 51 51 struct SVNException : public std::runtime_error 52 { inline SVNException(const std::string& msg) : runtime_error(msg) {} }; 52 { 53 SVNException(const std::string& msg, svn_error_t* error=NULL); 54 55 /** 56 Copy constructor 57 */ 58 SVNException(const SVNException& other); 59 60 /** 61 Destructor 62 */ 63 virtual ~SVNException(void) throw(); 64 65 /** 66 override base implementation 67 */ 68 const char* what(void) const throw(); 69 70 /** 71 access svn_error_t 72 */ 73 const svn_error_t* error(void) const; 74 private: 75 svn_error_t* error_; 76 std::string msg_; 77 int* ref_count_; 78 79 // assignment not allowed 80 SVNException& operator=(const SVNException&); 81 }; 53 82 54 83 /** … … 96 125 97 126 \a path can be either a URL or an WC target. 98 99 \return SVN_NO_ERROR or SVN_ERR_CLIENT_IS_BINARY_FILE, the 100 latter can be used to trigger on binary files. Note that errors 101 return from underlying subversion API must be cleared by the 102 receiver. 103 104 \see Subversion API (svn_error_clear). 105 */ 106 svn_error_t * client_blame(const std::string& path, 107 svn_client_blame_receiver_t receiver, 108 void *baton); 127 */ 128 void client_blame(const std::string& path, 129 svn_client_blame_receiver_t receiver, 130 void *baton); 109 131 110 132 /** … … 112 134 \a rev can be set. 113 135 */ 114 svn_error_t *client_blame(const std::string& path,115 116 136 void client_blame(const std::string& path, 137 svn_client_blame_receiver_t receiver, 138 void *baton, svn_revnum_t rev); 117 139 118 140 /** … … 227 249 @brief Free resources when svn API calls fail. 228 250 229 This function will write an error message to stdout, free \a 230 err and \a pool resources. If \a err or \a pool are a NULL 231 pointers the function will do nothing with these resources. If 232 \a mute is true, no error message is written. 233 234 cleanup will throw a SVNException if \a message has 235 length>0. The default bahaviour is to free resources and return 236 normally. 251 This function will free \a pool resources and throw an 252 exception holding the \a message. If mute is false, the thrown 253 exception also contains \a err. 254 255 \throw cleanup will throw a SVNException 237 256 238 257 @see SVNException … … 251 270 @see SVNException 252 271 */ 253 void cleanup_failed_init(svn_error_t *err, const std::string& message, 254 bool mute=false); 272 void cleanup_failed_init(svn_error_t *err, const std::string& message); 255 273 256 274 static SVN* instance_; … … 276 294 */ 277 295 static svn_error_t* 278 root_url_receiver(void *baton, const char *path, const svn_info_t *info,279 apr_pool_t *pool);280 281 svn_error_t*client_blame_call(const std::string& path,282 283 296 root_url_receiver(void *baton, const char *path, 297 const svn_info_t *info, apr_pool_t *pool); 298 299 void client_blame_call(const std::string& path, 300 svn_client_blame_receiver_t receiver, 301 void *baton, svn_opt_revision_t& head); 284 302 285 303 svn_wc_adm_access_t* adm_access_; -
branches/visitor/lib/SVNblame.cc
r978 r1222 31 31 32 32 SVNblame::SVNblame(const std::string& path) 33 : binary_(false),instance_(SVN::instance())33 : instance_(SVN::instance()) 34 34 { 35 if (svn_error_t* err= 36 instance_->client_blame(path.c_str(), blame_receiver, 37 static_cast<void*>(&blame_receiver_baton_))) { 38 // SVN_ERR_CLIENT_IS_BINARY_FILE is the only error allowed to 39 // escape the client_blame call 40 svn_error_clear(err); 41 binary_=true; 42 } 35 instance_->client_blame(path.c_str(), blame_receiver, 36 static_cast<void*>(&blame_receiver_baton_)); 43 37 blame_info_iterator_ = blame_receiver_baton_.blame_info.begin(); 44 38 } … … 46 40 47 41 SVNblame::SVNblame(const std::string& path, svn_revnum_t rev) 48 : binary_(false),instance_(SVN::instance())42 : instance_(SVN::instance()) 49 43 { 50 if (svn_error_t* err= 51 instance_->client_blame(path.c_str(), blame_receiver, 52 static_cast<void*>(&blame_receiver_baton_), 53 rev)) { 54 // SVN_ERR_CLIENT_IS_BINARY_FILE is the only error allowed to 55 // escape the client_blame call 56 svn_error_clear(err); 57 binary_=true; 58 } 44 instance_->client_blame(path.c_str(), blame_receiver, 45 static_cast<void*>(&blame_receiver_baton_), 46 rev); 59 47 blame_info_iterator_ = blame_receiver_baton_.blame_info.begin(); 60 48 } … … 75 63 { 76 64 return (*blame_info_iterator_)->author; 77 }78 79 80 bool SVNblame::binary(void)81 {82 return binary_;83 65 } 84 66 -
branches/visitor/lib/SVNblame.h
r978 r1222 76 76 */ 77 77 std::string author(void); 78 79 /**80 Returns true if item is binary false otherwise81 82 Binary files are invalid for 'svn blame'.83 */84 bool binary(void);85 78 86 79 /** … … 164 157 }; 165 158 166 // binary_ is true if item in any revision has been binary.167 bool binary_;168 159 // blame_info_iterator_ is used in statistics analysis to traverse 169 160 // blame_receiver_baton.blame_info vector through calls to next(). -
branches/visitor/lib/rmdirhier.cc
r1186 r1222 25 25 #include "utility.h" 26 26 27 #include <cstdio> 27 28 #include <cstring> 28 29 #include <dirent.h> … … 75 76 // Make sure file is removable before removing it 76 77 chmod(dir.c_str(),S_IWRITE); 77 if ( unlink(dir.c_str()))78 if (remove(dir.c_str())) 78 79 throw FileDeleteError(concatenate_path(pwd(),dir)); 79 80 return; … … 97 98 // Remove the directory from its parent 98 99 chdir(".."); 99 if (r mdir(dir.c_str()))100 if (remove(dir.c_str())) 100 101 throw DirectoryDeleteError(concatenate_path(pwd(),dir)); 101 102 } -
branches/visitor/m4/apache_LICENSE-2.0.txt
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/m4/ax_cxx_check_flag.m4
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/m4/ax_cxxcpp_check_flag.m4
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/m4/ax_ld_check_flag.m4
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/m4/find_apr.m4
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/m4/pkg.m4
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/m4/version.m4
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/m4/yat_add_flag.m4
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/visitor/test/Makefile.am
r1187 r1222 39 39 distributed_TESTS += config3_test.sh 40 40 distributed_TESTS += copyright2_test.sh 41 distributed_TESTS += error_test.sh 41 42 distributed_TESTS += repo_status_test.sh 42 43 distributed_TESTS += repo_test.sh -
branches/visitor/test/cmd_format_test.sh
r1092 r1222 27 27 SVNDIGEST_run 1 -f --format=banana 28 28 test -s stderr || exit_fail 29 grep'invalid argument.*banana.*format' stderr || exit_fail29 $GREP 'invalid argument.*banana.*format' stderr || exit_fail 30 30 31 31 SVNDIGEST_run 0 -g --format=svg --anchor-format=svg 32 grep'format = svg' stdout || exit_fail33 grep'anchor_format = svg' stdout || exit_fail32 $GREP 'format = svg' stdout || exit_fail 33 $GREP 'anchor_format = svg' stdout || exit_fail 34 34 35 35 exit_success; -
branches/visitor/test/config2_test.sh
r1092 r1222 36 36 37 37 SVNDIGEST_run 1 -g --config-file tmp_config 38 grep'unknown format.* apple' stderr || exit_fail38 $GREP 'unknown format.* apple' stderr || exit_fail 39 39 40 40 exit_success -
branches/visitor/test/config3_test.sh
r1092 r1222 28 28 SVNDIGEST_run 0 -g --config-file /dev/null 29 29 SVNDIGEST_run 1 -g --config-file . 30 grep'is a directory' stderr || exit_fail30 $GREP 'is a directory' stderr || exit_fail 31 31 32 32 exit_success -
branches/visitor/test/init.sh.in
r1153 r1222 54 54 test -z "$srcdir" && srcdir="@srcdir@"; 55 55 test -z "$SVN" && SVN=svn; 56 test -z "$GREP" && GREP=@GREP@; 56 57 57 58 # some helpful derived variables -
branches/visitor/test/svncopyright_test.sh
r1092 r1222 31 31 done 32 32 33 $SVNCOPYRIGHT --version | head -n 1 | grepsvncopyright || exit_fail33 $SVNCOPYRIGHT --version | head -n 1 | $GREP svncopyright || exit_fail 34 34 35 35 exit_success
Note: See TracChangeset
for help on using the changeset viewer.