Changes from tags/release-0.4/bin at r1638 to tags/release-0.5/bin at r1638
- Location:
- tags/release-0.5/bin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/release-0.5/bin/Makefile.am
r1638 r1638 28 28 noinst_HEADERS = Parameter.h 29 29 30 LDADD = @top_srcdir@/lib/libsvndigest.a -L$(APR_PATH)/lib -L$(SVN_PATH)/lib \ 31 -lsvn_client-1 -lsvn_diff-1 -lsvn_wc-1 -lsvn_ra-1 -lsvn_subr-1 -lapr-0 30 LDADD = $(STATICFLAG) @top_srcdir@/lib/libsvndigest.la 32 31 33 INCLUDES = -I@top_srcdir@/lib \ 34 -I$(SVN_PATH)/include/subversion-1 -I$(APR_PATH)/include/apr-0 32 AM_CPPFLAGS = -I@top_srcdir@/lib 35 33 36 34 clean-local: -
tags/release-0.5/bin/Parameter.cc
r1638 r1638 37 37 { 38 38 defaults(); 39 for (int i=1; i<argc; i++) {39 for (int i=1; i<argc; ++i) { 40 40 bool ok=false; 41 41 std::string myargv(argv[i]); … … 72 72 exit(0); 73 73 } 74 else if (myargv=="-vf" || myargv=="-fv"){ 75 verbose_=true; 76 force_=true; 77 ok=true; 78 } 74 79 75 80 if (!ok) … … 84 89 void Parameter::analyse(void) 85 90 { 86 // making root absolute 87 std::string workdir(pwd()); 88 chdir(root_.c_str()); 91 using namespace std; 92 93 string workdir(pwd()); // remember current working directory (cwd). 94 95 // Checking that root_ exists and retrieve the absolute path to root_ 96 if (chdir(root_.c_str())) 97 throw runtime_error(string("svndigest: Root directory (") + root_ + 98 ") access failed."); 89 99 root_ = pwd(); 90 // remove trailing '/'91 if (*root_.rbegin()=='/')92 root_.erase(root_.begin()+root_.size()-1);93 chdir(workdir.c_str());94 100 95 // making targetdir absolute 96 chdir(targetdir_.c_str()); 101 // need to get back to cwd if relative paths are used. 102 if (chdir(workdir.c_str())) 103 runtime_error(string("svndigest: Failed to access cwd: ") + workdir); 104 105 // Checking that targetdir_ exists and retrieve the absolute path 106 // to targetdir_ 107 if (chdir(targetdir_.c_str())) 108 throw runtime_error(string("svndigest: Target directory (") + targetdir_ + 109 ") access failed."); 97 110 targetdir_ = pwd(); 98 // remove trailing '/'99 if ( *targetdir_.rbegin()=='/')100 root_.erase(targetdir_.begin()+targetdir_.size()-1);101 chdir(workdir.c_str());111 // Checking write permissions for targetdir_ 112 if (access_rights(targetdir_,"w")) 113 throw runtime_error(string("svndigest: No write permission on target ") + 114 "directory (" + targetdir_ +")."); 102 115 103 struct stat buf; 104 // check that root directory exists 105 if (stat(root_.c_str(),&buf)) 106 throw std::runtime_error("\nsvndigest: " + root_ + ": No such directory."); 107 108 // check that target directory exists 109 if (stat(targetdir_.c_str(),&buf)){ 110 throw std::runtime_error("\nsvndigest: " + targetdir_ + 111 ": No such directory."); 112 } 113 116 // return back to cwd 117 if (chdir(workdir.c_str())) 118 runtime_error(string("svndigest: Failed to access cwd: ") + workdir); 114 119 } 115 120 -
tags/release-0.5/bin/Parameter.h
r1638 r1638 1 #ifndef _theplu_svndigest_parameter_ 2 #define _theplu_svndigest_parameter_ 3 1 4 // $Id$ 2 5 … … 21 24 02111-1307, USA. 22 25 */ 23 24 #ifndef _theplu_svndigest_parameter_25 #define _theplu_svndigest_parameter_26 26 27 27 #include <string> -
tags/release-0.5/bin/svndigest.cc
r1638 r1638 13 13 svndigest is distributed in the hope that it will be useful, but 14 14 WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 16 General Public License for more details. 17 17 … … 26 26 #include "Directory.h" 27 27 #include "GnuplotFE.h" 28 #include "html_utility.h" 28 29 #include "rmdirhier.h" 29 30 #include "SVN.h" … … 37 38 #include <unistd.h> 38 39 39 using namespace std; 40 /// 41 /// @brief Check whether \a path already exists or not. 42 /// 43 /// @return True if \a path exists, false otherwise. 44 /// 45 bool check_target(const std::string& path) 46 { 47 struct stat buf; 48 return !stat(path.c_str(),&buf); 49 } 50 40 51 41 52 int main(const int argc,const char* argv[]) … … 62 73 } 63 74 75 // check if target already exists and behave appropriately 76 std::string target_path=option->targetdir() + '/' + file_name(option->root()); 77 bool need_to_erase_target = check_target(target_path); 78 if (need_to_erase_target && !option->force()) 79 throw std::runtime_error(std::string("svndigest: directory (") + 80 target_path + ") already exists"); 81 64 82 // Extract repository location 65 83 std::string repo; … … 74 92 } 75 93 94 // build directory tree already here ... if WC is upto date with 95 // repo an exception is thrown. This avoids several costly 96 // statements below and will not remove a digest tree below if a 97 // tree already exists. 98 Directory tree(0,option->root(),""); 99 tree.parse(option->verbose()); 100 76 101 // Retrieve commit dates. 77 102 std::vector<std::string> commit_dates; … … 85 110 } 86 111 87 // check if target already exists and behave appropriately 88 std::string root_path(option->targetdir()+'/'+file_name(option->root())); 89 struct stat buf; 90 if (!stat(root_path.c_str(),&buf)) 91 // root_path already exists 92 if (option->force()) { 93 // force true -> removal of root_path 112 // remove target if needed 113 if (need_to_erase_target) { 94 114 if (option->verbose()) 95 std::cout << "rm -rf " << root_path << "\n"; 96 rmdirhier(root_path); 97 } 98 else { 99 // force false -> exit 100 std::cerr << "\nsvndigest: " << root_path << ": directory already exists" 101 << std::endl; 102 exit(-1); 103 } 115 std::cout << "rm -rf " << target_path << "\n"; 116 rmdirhier(target_path); 117 } 104 118 105 119 if (!option->revisions()) 106 120 GnuplotFE::instance()->set_dates(commit_dates); 107 108 Directory tree(0,option->root(),""); 109 tree.parse(option->verbose()); 110 111 GnuplotFE::instance()->command(string("cd '")+option->targetdir()+"'"); 121 GnuplotFE::instance()->command(std::string("cd '")+option->targetdir()+"'"); 112 122 chdir(option->targetdir().c_str()); 113 123 try { … … 125 135 exit(0); // normal exit 126 136 } 127 128
Note: See TracChangeset
for help on using the changeset viewer.