- Timestamp:
- Jul 30, 2006, 12:42:54 AM (17 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Gnuplot.h
r111 r123 49 49 /// The Gnuplot class creates a pipe to 'gnuplot' and facilitates 50 50 /// communication with the gnuplot binary. 51 /// 52 /// @see GnuplotFE 51 53 /// 52 54 class Gnuplot -
trunk/lib/GnuplotFE.h
r97 r123 35 35 /// 36 36 /// The GnuplotFE class is a front end to the Gnuplot class. This is 37 /// a utility functionneeded to communicate plotting related37 /// a utility class needed to communicate plotting related 38 38 /// information between objects. 39 39 /// … … 43 43 /// 44 44 /// @see Design Patterns (the singleton pattern). 45 /// @see Gnuplot 45 46 /// 46 47 class GnuplotFE : public Gnuplot … … 85 86 /// 86 87 inline void set_dates(const std::vector<std::string>& date, 87 const std::string& format="%Y-%m-%d ")88 const std::string& format="%Y-%m-%dT%H:%M:%SZ") 88 89 { date_=date; date_input_format_=format; } 89 90 -
trunk/lib/Makefile.am
r103 r123 25 25 noinst_LIBRARIES = libsvnstat.a 26 26 27 noinst_HEADERS = CommitStat.h Directory.h File.h Gnuplot.h GnuplotFE.h \28 Node.hParser.h rmdirhier.h Stats.h SVN.h utility.h27 noinst_HEADERS = Directory.h File.h Gnuplot.h GnuplotFE.h Node.h \ 28 Parser.h rmdirhier.h Stats.h SVN.h utility.h 29 29 30 libsvnstat_a_SOURCES = CommitStat.cc Directory.cc File.cc Gnuplot.cc \31 GnuplotFE.ccNode.cc Parser.cc rmdirhier.cc Stats.cc SVN.cc utility.cc30 libsvnstat_a_SOURCES = Directory.cc File.cc Gnuplot.cc GnuplotFE.cc \ 31 Node.cc Parser.cc rmdirhier.cc Stats.cc SVN.cc utility.cc 32 32 33 33 INCLUDES = -I$(SVN_PATH)/include/subversion-1 -I$(APR_PATH)/include/apr-0 -
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 } -
trunk/lib/SVN.h
r91 r123 26 26 27 27 #include <stdexcept> 28 #include <string> 29 #include <vector> 28 30 31 // Jari, most of these can be replaced with forward declarations. 29 32 #include <apr_allocator.h> 30 33 #include <svn_client.h> 34 #include <svn_ra.h> 31 35 #include <svn_wc.h> 32 36 … … 48 52 /// SVN provides one single global access point to the underlying 49 53 /// subversion API and makes sure that there is only one point of 50 /// access tothe binary.54 /// access for the binary. 51 55 /// 52 56 /// @see Design Patterns (the singleton pattern). Subversion API … … 68 72 69 73 /// 74 /// @brief Get revision dates. 75 /// 76 /// Get dates for all commits to the repository. \a root can be a 77 /// repository path or a path within a working copy. In the latter 78 /// case the corresponding repository will be used to retrieve 79 /// commit dates. 80 /// 81 /// @return Revision dates in a vector where revision is 82 /// implicitly defined by vector index, i.e., element 56 in the 83 /// resulting vector implies revision 56. 84 /// 85 /// @note Currently revision 0 (repositoy creation) is not 86 /// supported. 87 /// 88 /// @throw Various error messages generated from the subversion 89 /// API. 90 /// 91 std::vector<std::string> commit_dates(const std::string& path); 92 93 /// 70 94 /// @brief Get an instance of SVN. 71 95 /// 72 /// @throw Throws a SVNException if one is received fromthe73 /// underlying constructor call.96 /// @throw Throws an SVNException if initialization fails in the 97 /// underlying subversion API calls. 74 98 /// 75 99 /// @todo Make sure that the underlying constructor performs … … 80 104 81 105 /// 82 /// @throws SCNException if access setup fails. 106 /// @brief Determine the repository root URL for \a path. 107 /// 108 /// @throws SVNException if repository location cannot be 109 /// determined. 110 /// 111 /// @return The repository root URL. 112 /// 113 std::string repository(const std::string& path); 114 115 /// 116 /// @throws SVNException if session setup fails. 117 /// 118 void setup_ra_session(const std::string& path); 119 120 /// 121 /// @throws SVNException if access setup fails. 83 122 /// 84 123 void setup_wc_adm_access(const std::string& path); … … 111 150 static SVN* instance_; 112 151 113 // subversion API stuff 152 // Subversion API stuff 153 154 // Info receiver 155 struct info_receiver_baton { 156 std::string repos_root_url; 157 }; 158 static svn_error_t * info_receiver(void *baton, const char *path, 159 const svn_info_t *info, apr_pool_t *pool); 160 161 // Log message receiver 162 struct log_receiver_baton { 163 std::vector<std::string> commit_dates; 164 }; 165 static svn_error_t * 166 log_message_receiver(void *baton, apr_hash_t *changed_paths, 167 svn_revnum_t rev, const char *author, const char *date, 168 const char *msg, apr_pool_t *pool); 169 114 170 svn_wc_adm_access_t* adm_access_; 115 171 apr_allocator_t* allocator_; 116 172 svn_client_ctx_t* context_; 117 173 apr_pool_t* pool_; 174 svn_ra_session_t* ra_session_; 118 175 }; 119 176
Note: See TracChangeset
for help on using the changeset viewer.