Changeset 1246 for branches/0.8-stable


Ignore:
Timestamp:
Oct 30, 2010, 4:41:51 AM (9 years ago)
Author:
Peter Johansson
Message:

fixes #477

Location:
branches/0.8-stable
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/0.8-stable/bin/Parameter.cc

    r1119 r1246  
    9797      check_existence(root_.value());
    9898      check_readable(root_.value());
     99
     100      // check that root is directory (or link pointing to directory)
     101      struct stat stats;
     102      stat(root_.value().c_str(), &stats);
     103      if (!S_ISDIR(stats.st_mode)) {
     104        std::stringstream ss;
     105        ss << cmd_.program_name() << ": '" << root_.value()
     106           << "': Not a directory";
     107        throw yat::utility::cmd_error(ss.str());
     108      }
    99109      chdir(root_.value());
    100       root_.value(pwd());
     110      root_full_ = pwd();
    101111      chdir(save_wd);
     112
     113      // take care of when root is a symlink (see ticket #477)
     114      lstat(root_.value().c_str(), &stats);
     115      if (S_ISLNK(stats.st_mode))
     116        root_basename_ = file_name(root_.value());
     117      else
     118        root_basename_ = file_name(root_full_);
    102119    }
    103120
     
    181198  std::string Parameter::root(void) const
    182199  {
    183     return root_.value();
    184   }
     200    return root_full_;
     201  }
     202
     203
     204  const std::string& Parameter::root_basename(void) const
     205  {
     206    assert(root_basename_.size());
     207    return root_basename_;
     208  }
     209
    185210
    186211  void Parameter::set_default(void)
  • branches/0.8-stable/bin/Parameter.h

    r1119 r1246  
    5555    bool generate_config(void) const ;
    5656    bool ignore_cache(void) const;
    57     /// @return absolute path to root directory
     57
     58    /**
     59       @return Dereferenced absolute path to root directory
     60    */
    5861    std::string root(void) const;
     62
     63    /**
     64       If --root argument is a link we return the file_name(argument).
     65       Otherwise we return file_name(root()). See root(void).
     66
     67       \return basename of --root argument.
     68     */
     69    const std::string& root_basename(void) const;
    5970    bool verbose(void) const;
    6071
     
    8394    yat::utility::OptionSwitch ignore_cache_;
    8495    yat::utility::OptionArg<std::string> root_;
     96    std::string root_basename_;
     97    std::string root_full_;
    8598    yat::utility::OptionSwitch verbose_;
    8699  protected:
  • branches/0.8-stable/bin/svncopyright.cc

    r1119 r1246  
    6565    if (option.verbose())
    6666      std::cout << "Building directory tree" << std::endl;
    67     Directory tree(0,option.root(),"");
     67    Directory tree(0,option.root(),"",option.root_basename());
    6868
    6969    if (option.verbose())
  • branches/0.8-stable/bin/svndigest.cc

    r1180 r1246  
    109109    if (option.verbose())
    110110      std::cout << "Building directory tree" << std::endl;
    111     Directory tree(0,option.root(),"");
     111    Directory tree(0,option.root(),"", option.root_basename());
    112112
    113113    if (option.verbose())
     
    227227  if (option.verbose())
    228228    std::cout << "Generating output" << std::endl;
    229   mkdir(tree.name());
    230   chdir(tree.name().c_str());
     229  mkdir(option.root_basename());
     230  chdir(option.root_basename());
    231231  print_css("svndigest.css");
    232232  print_main_page(tree.name(), tree.log(), stats, tree.url());
  • branches/0.8-stable/bin/svndigestParameter.cc

    r1119 r1246  
    9191        check_existence(target_.value());
    9292        check_readable(target_.value());
    93         std::string base_root = file_name(root());
    94         std::string path = concatenate_path(target_.value(),base_root);
     93        std::string path = concatenate_path(target_.value(),root_basename());
    9594        if (access_rights(target_.value().c_str(), "w")) {
    9695          std::stringstream ss;
  • branches/0.8-stable/lib/Directory.cc

    r1024 r1246  
    5050
    5151  Directory::Directory(const unsigned int level, const std::string& path,
    52                        const std::string& output)
    53     : Node(level,path,output)
     52                       const std::string& output, const std::string& project)
     53    : Node(level,path,output,project)
    5454  {
    5555    output_dir_=local_path();
  • branches/0.8-stable/lib/Directory.h

    r978 r1246  
    5353    ///
    5454    Directory(const unsigned int level, const std::string& path,
    55               const std::string& output="");
     55              const std::string& output="", const std::string& project="");
    5656
    5757    ///
  • branches/0.8-stable/lib/Node.cc

    r978 r1246  
    4646
    4747  Node::Node(const unsigned int level, const std::string& path,
    48              const std::string& local_path)
     48             const std::string& local_path, const std::string& project)
    4949    : level_(level), path_(path), stats_(path), log_(NULL), 
    5050      svninfo_(path)
     
    5454    svndigest_ignore_=property.svndigest_ignore();
    5555    if (Node::project_==std::string()) // no root directory in local path
    56       Node::project_ = file_name(path);
     56      Node::project_ = project;
    5757    else if (local_path.empty())
    5858      local_path_ = file_name(path);
  • branches/0.8-stable/lib/Node.h

    r1017 r1246  
    5858    /// @brief Constructor
    5959    ///
    60     Node(const unsigned int, const std::string&, const std::string&);
     60    Node(const unsigned int, const std::string&, const std::string&,
     61         const std::string& = "");
    6162
    6263    ///
  • branches/0.8-stable/test/Makefile.am

    r1166 r1246  
    2828EXTRA_PROGRAMS = cache_partial_test color_test \
    2929  config_test copyright_test date_test \
    30   graph_test htmlstream_test \
     30  graph_test htmlstream_test parameter_test \
    3131  parser_test stats_test trac_test utility_test
    3232
    3333CLEANFILES = $(EXTRA_PROGRAMS)
     34
     35parameter_test_SOURCES = parameter_test.cc $(top_srcdir)/bin/Parameter.cc \
     36  $(top_srcdir)/bin/svndigestParameter.cc
    3437
    3538distributed_TESTS =
     
    3841distributed_TESTS += config3_test.sh
    3942distributed_TESTS += copyright2_test.sh
     43distributed_TESTS += link_root_test.sh
    4044distributed_TESTS += repo_status_test.sh
    4145distributed_TESTS += repo_test.sh
Note: See TracChangeset for help on using the changeset viewer.