Changeset 1124 for trunk


Ignore:
Timestamp:
Jul 7, 2010, 7:35:17 AM (11 years ago)
Author:
Peter Johansson
Message:

detecting old cache files and re-writing them in new format (version 8). closes #443 and #289

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r1122 r1124  
    289289
    290290
    291   svn_revnum_t Stats::load_cache(std::istream& is)
     291  svn_revnum_t Stats::load_cache(std::istream& is, bool& latest_ver)
    292292  {
    293293    std::string str;
    294294    getline(is, str);
    295     if (str == "CACHE FILE VERSION 8")
     295    if (str == "CACHE FILE VERSION 8") {
     296      latest_ver = true;
    296297      return load_cache8(is);
     298    }
     299    latest_ver = false;
    297300    if (str == "CACHE FILE VERSION 7")
    298301      return load_cache7(is);
  • trunk/lib/Stats.h

    r1122 r1124  
    9393    /**
    9494       Load object from a stream.
    95        
     95
     96       \a latest_ver is set to true if cache_file is latest version;
     97       otherwise it is set to false.
     98
    9699       \return revision the cache represents - 0 if failed
    97100     */
    98     svn_revnum_t load_cache(std::istream&);
     101    svn_revnum_t load_cache(std::istream&, bool& latest_ver);
    99102
    100103    /**
  • trunk/lib/StatsCollection.cc

    r1081 r1124  
    6363    bool result = true;
    6464    for (map::const_iterator i(stats_.begin()); i!=stats_.end(); ++i) {
    65       svn_revnum_t cache_rev = i->second->load_cache(is);
     65      bool latest_ver=true;
     66      svn_revnum_t cache_rev = i->second->load_cache(is, latest_ver);
     67      result &= latest_ver;
    6668      if (cache_rev < i->second->last_changed_rev()) {
    6769        result = false;
  • trunk/test/cache_partial_test.cc

    r1122 r1124  
    2424#include "Suite.h"
    2525
    26 #include "lib/ClassicStats.h"
     26#include "lib/AddStats.h"
    2727#include "lib/File.h"
    2828#include "lib/SVN.h"
    2929#include "lib/SVNinfo.h"
     30#include "lib/StatsCollection.h"
    3031#include "lib/utility.h"
    3132
     
    6566  // test that load of partial cache is successful
    6667  copy_file(test::src_filename("data/AUTHORS.svndigest-cache-r61"), cache_file);
    67   ClassicStats cstats(filename);
     68  AddStats cstats(filename);
    6869  std::ifstream is(cache_file.c_str());
    69   svn_revnum_t rev = cstats.load_cache(is);
     70  bool cache_ok=true;
     71  cstats.load_cache(is, cache_ok);
     72  cstats.load_cache(is, cache_ok);
     73  svn_revnum_t rev = cstats.load_cache(is, cache_ok);
     74  if (!cache_ok) {
     75    suite.out() << "error: seems cache file " << cache_file << " is old\n";
     76    suite.add(false);
     77  }
    7078  if (rev!=48) {
    7179    suite.out() << "load cache: " << cache_file << " returned " << rev << "\n"
  • trunk/test/stats_test.cc

    r1119 r1124  
    194194    ClassicStats stats2(path());
    195195    assert(in.good());
    196     if (!stats2.load_cache(in)){
     196    bool new_cache=true;
     197    if (!stats2.load_cache(in, new_cache)){
    197198      std::cout << "load_cache() failed\n";
    198199      return false;
Note: See TracChangeset for help on using the changeset viewer.