Changeset 123 for trunk/lib/SVN.cc
- Timestamp:
- Jul 30, 2006, 12:42:54 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/SVN.cc
r91 r123 44 44 // doing, most bits here are stolen from subversion source for the 45 45 // svn command line binary (subverion/svn/main.c) 46 47 svn_error_t* err=NULL; 46 48 47 49 // initialize something (APR subsystem and more). The APR … … 56 58 if (apr_allocator_create(&allocator_)) 57 59 throw SVNException("SVN(void): apr_allocator_create failed"); 58 59 60 apr_allocator_max_free_set(allocator_,SVN_ALLOCATOR_RECOMMENDED_MAX_FREE); 60 61 pool_ = svn_pool_create_ex(NULL, allocator_); … … 62 63 63 64 // initialize the repository access library 64 svn_error_t* err = svn_ra_initialize(pool_); 65 if (err) { 65 if ((err=svn_ra_initialize(pool_))) { 66 66 // destroys pool and clears err 67 67 svn_cmdline_handle_exit_error(err, pool_, "svnstat: "); … … 74 74 // command line option to change the location of the .subversion 75 75 // stuff (compare with the svn binary). 76 err = svn_config_ensure(NULL, pool_); 77 if (err) { 76 if ((err=svn_config_ensure(NULL, pool_))) { 78 77 // destroys pool and clears err 79 78 svn_cmdline_handle_exit_error(err, pool_, "svnstat: "); … … 83 82 84 83 // create a client context object 85 err = svn_client_create_context(&context_, pool_); 86 if (err) { 84 if ((err=svn_client_create_context(&context_, pool_))) { 87 85 // destroys pool and clears err 88 86 svn_cmdline_handle_exit_error(err, pool_, "svnstat: "); … … 91 89 } 92 90 93 err = svn_config_get_config(&(context_->config), NULL, pool_); 94 if (err) { 91 if ((err=svn_config_get_config(&(context_->config), NULL, pool_))) { 95 92 // destroys pool and clears err 96 93 svn_cmdline_handle_exit_error(err, pool_, "svnstat: "); … … 121 118 122 119 120 std::vector<std::string> SVN::commit_dates(const std::string& path) 121 { 122 // Allocate space in pool_ for apr_path (here a string). 123 apr_array_header_t* apr_path=apr_array_make(pool_,1,4); 124 // Copy path to apr_path. 125 (*((const char **) apr_array_push(apr_path))) = 126 apr_pstrdup(pool_, svn_path_internal_style(path.c_str(),pool_)); 127 128 // Setup to retrieve all commit logs. 129 svn_opt_revision_t peg, start, head; 130 peg.kind=svn_opt_revision_unspecified; 131 start.kind=svn_opt_revision_number; 132 start.value.number=0; 133 head.kind=svn_opt_revision_head; 134 svn_error_t* err=NULL; 135 // Retrieving the last revision is only needed for the reserve 136 // call below, not needed for the functionality here. 137 if ((err=svn_ra_get_latest_revnum(ra_session_,&(head.value.number),pool_))) { 138 svn_cmdline_handle_exit_error(err, pool_, "svnstat: "); 139 throw SVNException("commit_dates: svn_ra_get_latest_revnum failed"); 140 } 141 // The struct we want to pass through to all log_message_receiver 142 // calls, here we only want to push all commit dates into a 143 // std::vector<std::string>. 144 struct log_receiver_baton lb; 145 lb.commit_dates.reserve(head.value.number+1); // revision 0 is also stored. 146 if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, true, 147 log_message_receiver, static_cast<void*>(&lb), 148 context_, pool_))) { 149 svn_cmdline_handle_exit_error(err, pool_, "svnstat: "); 150 throw SVNException("commit_dates: svn_client_log3 failed"); 151 } 152 return lb.commit_dates; 153 } 154 155 156 svn_error_t * 157 SVN::info_receiver(void *baton, const char *, const svn_info_t *info, 158 apr_pool_t *) 159 { 160 if (!info || !info->repos_root_URL) 161 throw SVNException("Failed to acquire repository root URL"); 162 static_cast<struct info_receiver_baton*>(baton)->repos_root_url= 163 info->repos_root_URL; 164 return SVN_NO_ERROR; 165 } 166 167 168 svn_error_t * 169 SVN::log_message_receiver(void *baton, apr_hash_t *changed_paths, 170 svn_revnum_t rev, const char *author, 171 const char *date, const char *msg, apr_pool_t *pool) 172 { 173 struct log_receiver_baton *lb=static_cast<struct log_receiver_baton*>(baton); 174 if (date && date[0]) 175 lb->commit_dates.push_back(date); 176 else 177 throw SVNException("No date defined for revision: " + rev); 178 return SVN_NO_ERROR; 179 } 180 181 182 std::string SVN::repository(const std::string& path) 183 { 184 struct info_receiver_baton ib; 185 if (svn_client_info(path.c_str(), NULL, NULL, info_receiver, 186 static_cast<void*>(&ib), false, context_, pool_)) 187 throw SVNException("repository: svn_client_info failed"); 188 return ib.repos_root_url; 189 } 190 191 192 void SVN::setup_ra_session(const std::string& path) { 193 // get a session to the repository 194 if (svn_client_open_ra_session(&ra_session_, path.c_str(), context_,pool_)) { 195 // Jari, should the error space be cleared? 196 throw SVNException("setup_ra_session: svn_client_open_ra_session failed"); 197 } 198 } 199 200 123 201 void SVN::setup_wc_adm_access(const std::string& path) 124 202 { … … 128 206 if (svn_wc_adm_open3(&adm_access_, NULL, canonical_path, false, -1, 129 207 context_->cancel_func,context_->cancel_baton, pool_)) 130 // should the error space be cleared?208 // Jari, should the error space be cleared? 131 209 throw SVNException("setup_wc_adm_access: svn_wc_adm_open3 failed"); 132 210 }
Note: See TracChangeset
for help on using the changeset viewer.