Changeset 138
- Timestamp:
- Aug 3, 2006, 11:40:15 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/Makefile.am
r100 r138 29 29 30 30 LDADD = @top_srcdir@/lib/libsvnstat.a -L$(APR_PATH)/lib -L$(SVN_PATH)/lib \ 31 -lsvn_client-1 -lsvn_ wc-1 -lsvn_ra-1 -lsvn_subr-1 -lapr-031 -lsvn_client-1 -lsvn_diff-1 -lsvn_wc-1 -lsvn_ra-1 -lsvn_subr-1 -lapr-0 32 32 33 33 INCLUDES = -I@top_srcdir@/lib \ 34 34 -I$(SVN_PATH)/include/subversion-1 -I$(APR_PATH)/include/apr-0 35 35 36 # Needed to compile svn API stuff37 svnstat_CXXFLAGS = -Wno-long-long38 39 36 clean-local: 40 rm -rf svnstat _output*~37 rm -rf svnstat *~ -
trunk/configure.ac
r96 r138 42 42 AC_PROG_RANLIB 43 43 44 CXXFLAGS="-g -O -Wall -pedantic" 44 # -Wno-long-long is needed to suppress compiler diagnostics regarding 45 # using extension beyond the C++ standard (usage of non C++ standard 46 # 'long long' types). 47 CXXFLAGS="-g -O -Wall -pedantic -Wno-long-long" 45 48 CPPFLAGS="-DHAVE_INLINE=1" 46 49 # Use these flags when compiling a production library 47 #CXXFLAGS="-O3 -Wall -pedantic "50 #CXXFLAGS="-O3 -Wall -pedantic -Wno-long-long" 48 51 #CPPFLAGS="-DNDEBUG -DGSL_RANGE_CHECK_OFF -DHAVE_INLINE=1" 49 52 -
trunk/lib/Makefile.am
r129 r138 26 26 27 27 noinst_HEADERS = Directory.h File.h Gnuplot.h GnuplotFE.h Node.h \ 28 Parser.h rmdirhier.h Stats.h SVN.h SVN info.h utility.h28 Parser.h rmdirhier.h Stats.h SVN.h SVNblame.h SVNinfo.h utility.h 29 29 30 30 libsvnstat_a_SOURCES = Directory.cc File.cc Gnuplot.cc GnuplotFE.cc \ 31 Node.cc Parser.cc rmdirhier.cc Stats.cc SVN.cc SVNinfo.cc utility.cc 31 Node.cc Parser.cc rmdirhier.cc Stats.cc SVN.cc SVNblame.cc \ 32 SVNinfo.cc utility.cc 32 33 33 34 INCLUDES = -I$(SVN_PATH)/include/subversion-1 -I$(APR_PATH)/include/apr-0 34 35 # Needed to compile svn API stuff36 libsvnstat_a_CXXFLAGS = -Wno-long-long -
trunk/lib/Node.h
r129 r138 30 30 31 31 #include <ostream> 32 #include <sstream>33 32 #include <stdexcept> 34 33 #include <string> -
trunk/lib/SVN.cc
r129 r138 103 103 APR_HASH_KEY_STRING)), 104 104 context_->cancel_func, 105 context_->cancel_baton, pool_))) 106 svn_handle_error2(err, stderr, TRUE, "svnstat: "); 105 context_->cancel_baton, pool_))) { 106 svn_handle_error2(err, stderr, false, "svnstat: "); 107 svn_error_clear(err); 108 throw SVNException("SVN(void): svn_cmdline_setup_auth_baton failed"); 109 } 107 110 } 108 111 … … 115 118 // at program exit, ok since SVN is a singleton 116 119 delete instance_; 120 } 121 122 123 svn_error_t* SVN::client_blame(const std::string& path, 124 svn_client_blame_receiver_t receiver, 125 void *baton) 126 { 127 // Setup to use all revisions 128 svn_opt_revision_t peg, start, head; 129 peg.kind=svn_opt_revision_unspecified; 130 start.kind=svn_opt_revision_number; 131 start.value.number=0; 132 head.kind=svn_opt_revision_head; 133 svn_error_t* err=svn_client_blame3(path.c_str(), &peg, &start, &head, 134 // Jari, below line creates memory leaks 135 svn_diff_file_options_create(pool_), 136 false, receiver, baton, context_, pool_); 137 if (err && err->apr_err!=SVN_ERR_CLIENT_IS_BINARY_FILE) { 138 svn_handle_error2(err, stderr, false, "svnstat: "); 139 svn_error_clear(err); 140 throw SVNException("SVN::client_blame: svn_client_blame3 failed"); 141 } 142 return err; 117 143 } 118 144 -
trunk/lib/SVN.h
r129 r138 70 70 71 71 /// 72 /// @Brief Call the underlying svn_client_info for \a path with \a 72 /// @brief Call the underlying svn_client_blame3 for \a path with 73 /// \a receiver and \a baton. 74 /// 75 /// This function is called from SVNblame to do 'svn blame' on an 76 /// item. The \a receiver and \a baton is defined in SVNblame and 77 /// the \a receiver is called by the underlying subversion API for 78 /// every line in \a path provided it the item is under subversion 79 /// control. The \a baton is used to communicate anonymous 80 /// information through the API to the \a receiver. If \a path is 81 /// a binary object an error is returned, all other errors will 82 /// generate an SVNException. 83 /// 84 /// @return SVN_NO_ERROR or SVN_ERR_CLIENT_IS_BINARY_FILE, the 85 /// latter can be used to trigger on binary files. Note that 86 /// errors return from underlying subversion API must be cleared 87 /// by the receiver. 88 /// 89 /// @see Subversion API (svn_error_clear). 90 /// 91 svn_error_t * client_blame(const std::string& path, 92 svn_client_blame_receiver_t receiver, 93 void *baton); 94 95 /// 96 /// @brief Call the underlying svn_client_info for \a path with \a 73 97 /// receiver and \a baton. 74 98 /// -
trunk/lib/SVNinfo.cc
r135 r138 32 32 33 33 SVNinfo::SVNinfo(const std::string& path) 34 : instance_(SVN::instance()) 34 35 { 35 instance_=SVN::instance();36 36 instance_->client_info(path.c_str(), info_receiver, 37 37 static_cast<void*>(&info_receiver_baton_)); … … 41 41 svn_error_t * 42 42 SVNinfo::info_receiver(void *baton, const char *, const svn_info_t *info, 43 apr_pool_t *pool)43 apr_pool_t *pool) 44 44 { 45 45 if (!info) -
trunk/lib/Stats.cc
r131 r138 26 26 27 27 #include "GnuplotFE.h" 28 #include "SVNblame.h" 28 29 #include "SVNinfo.h" 29 30 #include "utility.h" … … 32 33 #include <cassert> 33 34 #include <cstdlib> 34 #include <fstream>35 35 #include <iostream> 36 36 #include <map> 37 37 #include <numeric> 38 38 #include <string> 39 #include <sstream> 39 40 #include <unistd.h> 40 41 #include <utility> … … 86 87 87 88 void Stats::add(const std::string& user, const u_int& rev, 88 const Parser::line_type lt)89 const Parser::line_type& lt) 89 90 { 90 91 authors_.insert(user); … … 127 128 bool Stats::parse(const std::string& path) 128 129 { 129 // Calling svn blame 130 if (blame(path)) 131 return true; 132 133 // Check if file is binary 134 std::ifstream is("/tmp/svnstat.tmp"); 135 std::string line; 136 getline(is,line,' '); 137 if (line==std::string("Skipping")){ 138 getline(is,line,' '); 139 if (line==std::string("binary")){ 140 is.close(); 141 return true; 142 } 143 } 144 is.close(); 130 SVNblame svn_blame(path); 131 if (svn_blame.binary()) 132 return true; 145 133 146 134 Parser parser(path); 147 135 std::vector<Parser::line_type>::const_iterator count=parser.type().begin(); 148 136 149 is.open("/tmp/svnstat.tmp"); 150 while (getline(is,line, '\n')){ 151 if (!line.size()) // skip empty line 137 while (const SVNblame::blame_information * bi=svn_blame.next()) { 138 if (!bi->line.size()) { // skip empty line 139 ++count; // keep Parser information in sync with Stats parsing 152 140 continue; 153 std::stringstream ss(line); 154 u_int revision; 155 std::string user; 156 ss >> revision; 157 ss >> user; 141 } 158 142 // to handle symbolic links 159 143 if (count==parser.type().end()) 160 add( user,revision, Parser::empty);144 add(bi->author, bi->revision, Parser::empty); 161 145 else 162 add( user,revision, *count);146 add(bi->author, bi->revision, *count); 163 147 count++; 164 } 165 is.close(); 148 } 166 149 167 150 return false; -
trunk/lib/Stats.h
r129 r138 144 144 /// 145 145 void add(const std::string& user, const u_int& revision, 146 const Parser::line_type );146 const Parser::line_type&); 147 147 148 148 -
trunk/lib/utility.cc
r129 r138 34 34 namespace svnstat{ 35 35 36 int blame(const std::string& path)37 {38 std::string mod_path = mod_str(path);39 std::string system_call="svn blame " + mod_path +40 " 1> /tmp/svnstat.tmp 2> /dev/null";41 int system_return = system(system_call.c_str());42 if (system_return)43 std::cerr << "Error: svn blame " << path << std::endl;44 return system_return;45 }46 47 36 std::string file_name(const std::string& full_path) 48 37 { … … 51 40 while (getline(ss,name,'/')) {} 52 41 return name; 53 }54 55 std::string mod_str(const std::string& str)56 {57 std::string mod_str="";58 for (size_t i=0; i<str.size(); ++i){59 if (str[i]==' ')60 mod_str+="\\ ";61 else62 mod_str+=str[i];63 }64 return mod_str;65 42 } 66 43 -
trunk/lib/utility.h
r129 r138 38 38 39 39 /// 40 /// @return 0 if ok41 ///42 int blame(const std::string&);43 44 ///45 40 /// Create directory \a dir. The call can fail in many ways, cf. 'man 46 41 /// mkdir'. … … 52 47 /// 53 48 std::string file_name(const std::string&); 54 55 ///56 /// stupid function needed for systems calls to be correct for57 /// filenames containing spaces.58 /// @note this function will be removed.59 ///60 /// @return passed string with ' ' changed to '\ '61 ///62 std::string mod_str(const std::string&);63 49 64 50 ///
Note: See TracChangeset
for help on using the changeset viewer.