- Timestamp:
- Mar 23, 2006, 11:56:17 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r84 r91 22 22 23 23 version 0.x: 24 - Using subversion API instead of system calls. 24 25 - Added copyright statement to files. 25 26 - Proper version information is displayed using --version option. -
trunk/bin/Makefile.am
r84 r91 28 28 noinst_HEADERS = Parameter.h rmdirhier.h 29 29 30 LDADD = @top_srcdir@/lib/libsvnstat.a 30 LDADD = @top_srcdir@/lib/libsvnstat.a -L/usr/local/apr/lib \ 31 -lsvn_client-1 -lsvn_wc-1 -lsvn_ra-1 -lsvn_subr-1 -lapr-0 31 32 32 INCLUDES = -I@top_srcdir@/lib 33 INCLUDES = -I@top_srcdir@/lib -I/usr/local/include/subversion-1 -I/usr/local/apr/include/apr-0 34 35 # Needed to compile svn API stuff 36 svnstat_CXXFLAGS = -Wno-long-long 33 37 34 38 clean-local: -
trunk/bin/svnstat.cc
r84 r91 23 23 24 24 #include "Parameter.h" 25 25 26 #include "CommitStat.h" 26 27 #include "Directory.h" 27 28 #include "GnuplotFE.h" 28 29 #include "rmdirhier.h" 30 #include "SVN.h" 29 31 30 32 #include <stdexcept> … … 50 52 Parameter option(argc,argv); 51 53 54 SVN* svn=SVN::instance(); 55 try { 56 svn->setup_wc_adm_access(option.root()); 57 } 58 catch (SVNException e) { 59 std::cerr << "\nsvtstat: " << e.what() << "\nsvnstat: " << option.root() 60 << " is not under subversion control\n" << std::endl; 61 exit(-1); 62 } 63 52 64 if (createdir(option.targetdir(),option.force())) { 53 65 std::cerr << "\nFailed to create target directory '" << option.targetdir() … … 63 75 GnuplotFE::instance()->set_dates(cs.date()); 64 76 } 65 66 string prefix("svnstat_"); 67 Directory tree(option.root(),prefix); 68 tree.purge(option.verbose()); 77 78 Directory tree(option.root(),"svnstat_"); 69 79 tree.parse(option.verbose()); 70 80 -
trunk/lib/Directory.cc
r84 r91 25 25 #include "File.h" 26 26 #include "Node.h" 27 #include "SVN.h" 27 28 28 29 #include <algorithm> … … 40 41 namespace svnstat{ 41 42 43 42 44 Directory::Directory(const std::string& path, const std::string& output) 43 45 : Node(path,output) … … 45 47 using namespace std; 46 48 DIR* directory=opendir(path.c_str()); // C API from dirent.h 47 if (!directory) { 48 // Jari, throw exception 49 cerr << "ERROR: opendir() failed; terminating" << endl; 50 exit(1); 51 } 49 if (!directory) 50 throw NodeException("ERROR: opendir() failed; " + path + 51 " is not a directory"); 52 52 list<string> entries; 53 53 struct dirent* entry; … … 55 55 while ((entry=readdir(directory))) // C API from dirent.h 56 56 entries.push_back(string(entry->d_name)); 57 if (errno) { 58 // Jari, throw exception 59 cerr << "ERROR: readdir() failure; terminating" << endl; 60 exit(1); 61 } 57 if (errno) 58 throw NodeException("ERROR: readdir() failed on " + path); 62 59 closedir(directory); 63 60 64 // Jari, change this to some STL algo?61 SVN* svn=SVN::instance(); 65 62 for (list<string>::iterator i=entries.begin(); i!=entries.end(); i++) 66 63 if ((*i)!=string(".") && (*i)!=string("..") && (*i)!=string(".svn")) { 67 64 string fullpath(path_+'/'+(*i)); 68 struct stat nodestat; // C api from sys/stat.h 69 lstat(fullpath.c_str(),&nodestat); // C api from sys/stat.h 70 if (S_ISDIR(nodestat.st_mode)) // C api from sys/stat.h 71 daughters_.push_back(new Directory(fullpath, output_name()+"_")); 72 else 73 daughters_.push_back(new File(fullpath,output_name()+"_")); 65 switch (svn->version_controlled(fullpath)) { 66 case SVN::uptodate: 67 struct stat nodestat; // C api from sys/stat.h 68 lstat(fullpath.c_str(),&nodestat); // C api from sys/stat.h 69 if (S_ISDIR(nodestat.st_mode)) // C api from sys/stat.h 70 daughters_.push_back(new Directory(fullpath, output_name()+"_")); 71 else 72 daughters_.push_back(new File(fullpath,output_name()+"_")); 73 break; 74 case SVN::unresolved: 75 throw NodeException(fullpath+" is not up to date"); 76 case SVN::unversioned: ; // do nothing 77 } 74 78 } 75 79 } … … 122 126 } 123 127 124 void Directory::purge(const bool verbose)125 {126 if (verbose)127 std::cout << "Purging " << path_ << std::endl;128 for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); )129 if (!((*i)->subversion_controlled())) {130 delete *i;131 i=daughters_.erase(i);132 }133 else {134 (*i)->purge(verbose);135 i++;136 }137 }138 139 128 }} // end of namespace svnstat and namespace theplu -
trunk/lib/Directory.h
r84 r91 39 39 { 40 40 public: 41 41 42 /// 42 43 /// @brief Constructor … … 62 63 void print(const bool verbose=false) const; 63 64 64 void purge(const bool verbose=false);65 66 65 private: 67 66 /// … … 70 69 Directory(const Directory&); 71 70 72 typedef std::list<Node*>::iterator NodeIterator; 73 typedef std::list<Node*>::const_iterator NodeConstIter_; 74 std::list<Node*> daughters_; 71 typedef std::list<Node*> NodeContainer; 72 typedef NodeContainer::iterator NodeIterator; 73 typedef NodeContainer::const_iterator NodeConstIterator; 74 NodeContainer daughters_; 75 75 }; 76 76 -
trunk/lib/Makefile.am
r84 r91 3 3 ## $Id$ 4 4 5 # Copyright (C) 2005, 2006 Jari Häkkinen 5 # Copyright (C) 2005 Jari Häkkinen 6 # Copyright (C) 2006 Jari Häkkinen, Peter Johansson 6 7 # 7 8 # This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat … … 25 26 26 27 noinst_HEADERS = CommitStat.h Directory.h File.h Gnuplot.h GnuplotFE.h \ 27 Node.h Stats.h utility.h28 Node.h Stats.h SVN.h utility.h 28 29 29 30 libsvnstat_a_SOURCES = CommitStat.cc Directory.cc File.cc Gnuplot.cc \ 30 GnuplotFE.cc Node.cc Stats.cc utility.cc 31 GnuplotFE.cc Node.cc Stats.cc SVN.cc utility.cc 32 33 INCLUDES = -I/usr/local/include/subversion-1 -I/usr/local/apr/include/apr-0 34 35 # Needed to compile svn API stuff 36 libsvnstat_a_CXXFLAGS = -Wno-long-long -
trunk/lib/Node.cc
r84 r91 66 66 67 67 68 bool Node::subversion_controlled(void) const69 {70 std::string system_call = "svn proplist " + path_ + ">&/dev/null";71 return !system(system_call.c_str());72 }73 74 68 }} // end of namespace svnstat and namespace theplu -
trunk/lib/Node.h
r84 r91 29 29 #include <ostream> 30 30 #include <sstream> 31 #include <stdexcept> 31 32 #include <string> 32 33 33 34 namespace theplu{ 34 35 namespace svnstat{ 36 37 /// 38 /// If something goes wrong in the use of the Node or its derived 39 /// classes, a NodeException is thrown. 40 /// 41 struct NodeException : public std::runtime_error 42 { inline NodeException(const std::string& msg) : runtime_error(msg) {} }; 35 43 36 44 /// … … 40 48 { 41 49 public: 50 51 /// 52 /// @brief Constructor 53 /// 54 // Node(void) : path_("JARI_trixar"), stats_("JARI_trixar") { }; 55 42 56 /// 43 57 /// @brief Constructor … … 73 87 virtual const Stats& parse(const bool verbose=false)=0; 74 88 89 inline const std::string& path(void) const { return path_; } 90 75 91 /// 76 92 /// Function printing HTML in current working directory 77 93 /// 78 94 virtual void print(const bool verbose=false) const=0; 79 80 ///81 ///82 ///83 inline virtual void purge(const bool verbose=false)84 { /* Nothing to be done */ };85 86 ///87 /// Check if the node is under subversion control. This is done by88 /// checking the return status of 'svn proplist <Node>.89 ///90 /// @return True if subversion controlled, false otherwise.91 ///92 bool subversion_controlled(void) const;93 95 94 96 protected:
Note: See TracChangeset
for help on using the changeset viewer.