Merge branch 'next'

This commit is contained in:
John Wiegley 2009-11-01 06:10:49 -05:00
commit 0cb80a51ea
13 changed files with 126 additions and 61 deletions

1
.gitignore vendored
View file

@ -61,3 +61,4 @@
/stamp-h1
/test/python/
/util_tests
/mkinstalldirs

26
acprep
View file

@ -18,9 +18,13 @@ import shutil
import string
import sys
import time
import hashlib
import tempfile
try:
import hashlib
except:
import md5
from os.path import *
from stat import *
from subprocess import Popen, PIPE, call
@ -580,18 +584,19 @@ class PrepareBuild(CommandLineApp):
]
self.log.info('Executing: ' + string.join(packages, ' '))
self.execute(*packages)
elif exists('/etc/redhat-release'):
if exists('/etc/redhat-release'):
release = open('/etc/redhat-release')
if issue.readline().startswith('CentOS'):
if release.readline().startswith('CentOS'):
self.log.info('Looks like you are using YUM on CentOS')
packages = [
'sudo', 'yum', 'install', 'gcc', 'make',
'libtool', 'autoconf', 'automake',
'zlib-devel', 'bzip2-devel', 'python-devel',
'bboost-devel',
'sudo', 'yum', 'install', 'gcc', 'gcc-c++',
'compat-gcc-*', 'make', 'libtool', 'autoconf',
'automake', 'zlib-devel', 'bzip2-devel',
'python-devel', 'bboost-devel',
'gmp-devel', 'gettext-devel',
#'mpfr-devel'
#'libedit-dev',
'libedit-devel',
'cppunit-devel',
#'texlive-full',
#'doxygen', 'graphviz', 'texinfo',
@ -623,7 +628,10 @@ class PrepareBuild(CommandLineApp):
sys.exit(1)
fd = open(tarball)
csum = hashlib.md5()
try:
csum = hashlib.md5()
except:
csum = md5.md5()
csum.update(fd.read())
fd.close()
digest = csum.hexdigest()

View file

@ -50,7 +50,6 @@
namespace ledger {
class session_t;
class account_t;
class xact_t;
class post_t;

View file

@ -192,7 +192,7 @@ public:
explicit annotated_commodity_t(commodity_t * _ptr,
const annotation_t& _details)
: commodity_t(_ptr->parent_, _ptr->base), ptr(_ptr), details(_details) {
TRACE_CTOR(annotated_commodity_t, "");
TRACE_CTOR(annotated_commodity_t, "commodity_t *, annotation_t");
annotated = true;
}
virtual ~annotated_commodity_t() {
@ -216,7 +216,9 @@ public:
#if defined(HAVE_BOOST_SERIALIZATION)
private:
explicit annotated_commodity_t() : ptr(NULL) {}
explicit annotated_commodity_t() : ptr(NULL) {
TRACE_CTOR(annotated_commodity_t, "");
}
/** Serialization. */

View file

@ -42,7 +42,8 @@
#include "post.h"
#include "xact.h"
#define ARCHIVE_VERSION 0x03000001
#define LEDGER_MAGIC 0x4c454447
#define ARCHIVE_VERSION 0x03000002
//BOOST_IS_ABSTRACT(ledger::scope_t)
BOOST_CLASS_EXPORT(ledger::scope_t)
@ -63,25 +64,64 @@ template void ledger::journal_t::serialize(boost::archive::binary_iarchive&,
const unsigned int);
namespace ledger {
void archive_t::read_header()
namespace {
bool read_header_bits(std::istream& in) {
uint32_t bytes;
assert(sizeof(uint32_t) == 4);
in.read(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
if (bytes != LEDGER_MAGIC) {
DEBUG("archive.journal", "Magic bytes not present");
return false;
}
in.read(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
if (bytes != ARCHIVE_VERSION) {
DEBUG("archive.journal", "Archive version mismatch");
return false;
}
return true;
}
void write_header_bits(std::ostream& out) {
uint32_t bytes;
assert(sizeof(uint32_t) == 4);
bytes = LEDGER_MAGIC;
out.write(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
bytes = ARCHIVE_VERSION;
out.write(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
}
}
bool archive_t::read_header()
{
if (exists(file)) {
// Open the stream, read the version number and the list of sources
ifstream stream(file, std::ios::binary);
boost::archive::binary_iarchive iarchive(stream);
uintmax_t size = file_size(file);
if (size < 8)
return false;
DEBUG("archive.journal", "Reading header from archive");
iarchive >> *this;
// Open the stream, read the version number and the list of sources
ifstream stream(file, std::ios::binary);
if (! read_header_bits(stream))
return false;
DEBUG("archive.journal",
"Version number: " << std::hex << version << std::dec);
DEBUG("archive.journal", "Number of sources: " << sources.size());
boost::archive::binary_iarchive iarchive(stream);
DEBUG("archive.journal", "Reading header from archive");
iarchive >> *this;
DEBUG("archive.journal",
"Version number: " << std::hex << ARCHIVE_VERSION << std::dec);
DEBUG("archive.journal", "Number of sources: " << sources.size());
#if defined(DEBUG_ON)
foreach (const journal_t::fileinfo_t& i, sources)
DEBUG("archive.journal", "Loaded source: " << *i.filename);
foreach (const journal_t::fileinfo_t& i, sources)
DEBUG("archive.journal", "Loaded source: " << *i.filename);
#endif
}
return true;
}
bool archive_t::should_load(const std::list<path>& data_files)
@ -95,8 +135,8 @@ bool archive_t::should_load(const std::list<path>& data_files)
return false;
}
if (version != ARCHIVE_VERSION) {
DEBUG("archive.journal", "No, it fails the version check");
if (! read_header()) {
DEBUG("archive.journal", "No, header failed to read");
return false;
}
@ -205,10 +245,9 @@ void archive_t::save(shared_ptr<journal_t> journal)
{
INFO_START(archive, "Saved journal file cache");
ofstream archive(file, std::ios::binary);
boost::archive::binary_oarchive oa(archive);
ofstream stream(file, std::ios::binary);
version = ARCHIVE_VERSION;
write_header_bits(stream);
sources = journal->sources;
#if defined(DEBUG_ON)
@ -216,8 +255,10 @@ void archive_t::save(shared_ptr<journal_t> journal)
DEBUG("archive.journal", "Saving source: " << *i.filename);
#endif
DEBUG("archive.journal",
"Creating archive with version " << std::hex << version << std::dec);
boost::archive::binary_oarchive oa(stream);
DEBUG("archive.journal", "Creating archive with version "
<< std::hex << ARCHIVE_VERSION << std::dec);
oa << *this;
DEBUG("archive.journal",
@ -232,6 +273,9 @@ bool archive_t::load(shared_ptr<journal_t> journal)
INFO_START(archive, "Read cached journal file");
ifstream stream(file, std::ios::binary);
if (! read_header_bits(stream))
return false;
boost::archive::binary_iarchive iarchive(stream);
// Skip past the archive header, it was already read in before

View file

@ -58,7 +58,6 @@ namespace ledger {
class archive_t
{
path file;
uint32_t version;
std::list<journal_t::fileinfo_t> sources;
@ -66,19 +65,17 @@ public:
archive_t() {
TRACE_CTOR(archive_t, "");
}
archive_t(const path& _file)
: file(_file), version(0) {
archive_t(const path& _file) : file(_file) {
TRACE_CTOR(archive_t, "const path&");
}
archive_t(const archive_t& ar)
: file(ar.file), version(0) {
archive_t(const archive_t& ar) : file(ar.file) {
TRACE_CTOR(archive_t, "copy");
}
~archive_t() {
TRACE_DTOR(archive_t);
}
void read_header();
bool read_header();
bool should_load(const std::list<path>& data_files);
bool should_save(shared_ptr<journal_t> journal);
@ -94,7 +91,6 @@ private:
template<class Archive>
void serialize(Archive & ar, const unsigned int /* version */) {
ar & version;
ar & sources;
}
#endif // HAVE_BOOST_SERIALIZATION

View file

@ -91,7 +91,9 @@ class commodity_t
public:
class base_t : public noncopyable, public supports_flags<uint_least16_t>
{
base_t() {}
base_t() {
TRACE_CTOR(base_t, "");
}
public:
typedef std::map<const datetime_t, amount_t> history_map;
@ -236,7 +238,7 @@ public:
const shared_ptr<base_t>& _base)
: delegates_flags<uint_least16_t>(*_base.get()), base(_base),
parent_(_parent), annotated(false) {
TRACE_CTOR(commodity_t, "");
TRACE_CTOR(commodity_t, "commodity_pool_t *, shared_ptr<base_t>");
}
virtual ~commodity_t() {
TRACE_DTOR(commodity_t);
@ -394,7 +396,9 @@ private:
protected:
explicit commodity_t()
: delegates_flags<uint_least16_t>(temp_flags), parent_(NULL),
annotated(false) {}
annotated(false) {
TRACE_CTOR(commodity_t, "");
}
private:
/** Serialization. */

View file

@ -219,7 +219,9 @@ public:
#if defined(HAVE_BOOST_SERIALIZATION)
private:
explicit call_scope_t() {}
explicit call_scope_t() {
TRACE_CTOR(call_scope_t, "");
}
/** Serialization. */

View file

@ -130,15 +130,17 @@ std::size_t session_t::read_data(const string& master_account)
price_db_path = resolve_path(HANDLER(price_db_).str());
optional<archive_t> cache;
#if 1
// jww (2009-11-01): The binary caching feature is disabled for now.
if (HANDLED(cache_) && master_account.empty()) {
cache = archive_t(HANDLED(cache_).str());
cache->read_header();
if (price_db_path) {
HANDLER(file_).data_files.push_back(*price_db_path);
populated_price_db = true;
}
}
#endif
if (! (cache &&
cache->should_load(HANDLER(file_).data_files) &&

View file

@ -486,6 +486,7 @@ void instance_t::option_directive(char * line)
*p++ = '\0';
}
#if 0
if (! process_option(pathname.string(), line + 2, scope, p, line) &&
! dynamic_cast<session_t *>(&scope)) {
if (std::strlen(line + 2) == 1)
@ -493,6 +494,9 @@ void instance_t::option_directive(char * line)
else
throw_(option_error, _("Illegal option --%1") << line + 2);
}
#else
process_option(pathname.string(), line + 2, scope, p, line);
#endif
}
void instance_t::automated_xact_directive(char * line)
@ -520,6 +524,7 @@ void instance_t::automated_xact_directive(char * line)
journal.auto_xacts.push_back(ae.get());
ae->journal = &journal;
ae->pos = position_t();
ae->pos->pathname = pathname;
ae->pos->beg_pos = pos;
@ -555,6 +560,7 @@ void instance_t::period_xact_directive(char * line)
if (parse_posts(account_stack.front(), *pe.get())) {
reveal_context = true;
pe->journal = &journal;
if (pe->finalize()) {
extend_xact_base(&journal, *pe.get(), true);
@ -570,6 +576,7 @@ void instance_t::period_xact_directive(char * line)
pe.release();
} else {
pe->journal = NULL;
throw parse_error(_("Period transaction failed to balance"));
}
}

View file

@ -457,7 +457,7 @@ bool xact_t::valid() const
DEBUG("ledger.validate", "xact_t: ! _date");
return false;
}
if (! journal) {
if (! has_flags(ITEM_GENERATED | ITEM_TEMP) && ! journal) {
DEBUG("ledger.validate", "xact_t: ! journal");
return false;
}

View file

@ -79,7 +79,9 @@ public:
virtual bool remove_post(post_t * post);
virtual bool finalize();
virtual bool valid() const = 0;
virtual bool valid() const {
return true;
}
#if defined(HAVE_BOOST_SERIALIZATION)
private:
@ -179,9 +181,6 @@ public:
}
virtual void extend_xact(xact_base_t& xact, bool post);
virtual bool valid() const {
return true;
}
#if defined(HAVE_BOOST_SERIALIZATION)
private:
@ -262,14 +261,6 @@ class period_xact_t : public xact_base_t
TRACE_DTOR(period_xact_t);
}
virtual bool valid() const {
if (! period.is_valid()) {
DEBUG("ledger.validate", "period_xact_t: ! period.is_valid()");
return false;
}
return true;
}
#if defined(HAVE_BOOST_SERIALIZATION)
private:
/** Serialization. */

View file

@ -4,8 +4,17 @@ set -e
rm -fr ~/Products/ledger*
if ./acprep -j16 --warn proof 2>&1 | tee ~/Desktop/proof.log; then
echo "Ledger proof build succeeded"
./acprep -j16 --warn proof 2>&1 | tee ~/Desktop/proof.log
if egrep -q '(ERROR|CRITICAL)' ~/Desktop/proof.log; then
if [ "$1" = "--alert" ]; then
notify "Ledger proof build FAILED"
else
echo "Ledger proof build FAILED"
exit 1
fi
else
notify "Ledger proof build failed"
echo "Ledger proof build succeeded"
fi
exit 0