The "id" of an item now maps to its UUID
This commit is contained in:
parent
bb0c534414
commit
0efdc0cf6f
6 changed files with 32 additions and 45 deletions
|
|
@ -74,21 +74,21 @@ value_t convert_command(call_scope_t& args)
|
||||||
post->amount.in_place_negate();
|
post->amount.in_place_negate();
|
||||||
}
|
}
|
||||||
|
|
||||||
string ref = (xact->has_tag(_("SHA1")) ?
|
string ref = (xact->has_tag(_("UUID")) ?
|
||||||
xact->get_tag(_("SHA1"))->to_string() :
|
xact->get_tag(_("UUID"))->to_string() :
|
||||||
sha1sum(reader.get_last_line()));
|
sha1sum(reader.get_last_line()));
|
||||||
|
|
||||||
checksum_map_t::const_iterator entry = journal.checksum_map.find(ref);
|
checksum_map_t::const_iterator entry = journal.checksum_map.find(ref);
|
||||||
if (entry != journal.checksum_map.end()) {
|
if (entry != journal.checksum_map.end()) {
|
||||||
INFO(file_context(reader.get_pathname(),
|
INFO(file_context(reader.get_pathname(),
|
||||||
reader.get_linenum())
|
reader.get_linenum())
|
||||||
<< "Ignoring known SHA1 " << ref);
|
<< "Ignoring known UUID " << ref);
|
||||||
checked_delete(xact); // ignore it
|
checked_delete(xact); // ignore it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (report.HANDLED(rich_data) && ! xact->has_tag(_("SHA1")))
|
if (report.HANDLED(rich_data) && ! xact->has_tag(_("UUID")))
|
||||||
xact->set_tag(_("SHA1"), string_value(ref));
|
xact->set_tag(_("UUID"), string_value(ref));
|
||||||
|
|
||||||
if (xact->posts.front()->account == NULL) {
|
if (xact->posts.front()->account == NULL) {
|
||||||
if (account_t * acct =
|
if (account_t * acct =
|
||||||
|
|
|
||||||
10
src/item.cc
10
src/item.cc
|
|
@ -340,6 +340,12 @@ namespace {
|
||||||
value_t get_seq(item_t& item) {
|
value_t get_seq(item_t& item) {
|
||||||
return item.pos ? long(item.pos->sequence) : 0L;
|
return item.pos ? long(item.pos->sequence) : 0L;
|
||||||
}
|
}
|
||||||
|
value_t get_id(item_t& item) {
|
||||||
|
if (optional<value_t> ref = item.get_tag(_("UUID")))
|
||||||
|
return *ref;
|
||||||
|
else
|
||||||
|
return item.pos ? long(item.pos->sequence) : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
value_t get_addr(item_t& item) {
|
value_t get_addr(item_t& item) {
|
||||||
return long(&item);
|
return long(&item);
|
||||||
|
|
@ -447,6 +453,8 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
|
||||||
case 'i':
|
case 'i':
|
||||||
if (name == "is_account")
|
if (name == "is_account")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&ignore>);
|
return WRAP_FUNCTOR(get_wrapper<&ignore>);
|
||||||
|
else if (name == "id")
|
||||||
|
return WRAP_FUNCTOR(get_wrapper<&get_id>);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
|
|
@ -481,6 +489,8 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
|
||||||
case 'u':
|
case 'u':
|
||||||
if (name == "uncleared")
|
if (name == "uncleared")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_uncleared>);
|
return WRAP_FUNCTOR(get_wrapper<&get_uncleared>);
|
||||||
|
else if (name == "uuid")
|
||||||
|
return WRAP_FUNCTOR(get_wrapper<&get_id>);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,23 @@ bool journal_t::add_xact(xact_t * xact)
|
||||||
}
|
}
|
||||||
|
|
||||||
extend_xact(xact);
|
extend_xact(xact);
|
||||||
|
|
||||||
|
// If a transaction with this UUID has already been seen, simply do
|
||||||
|
// not add this one to the journal. However, all automated checks
|
||||||
|
// will have been performed by extend_xact, so asserts can still be
|
||||||
|
// applied to it.
|
||||||
|
if (optional<value_t> ref = xact->get_tag(_("UUID"))) {
|
||||||
|
std::pair<checksum_map_t::iterator, bool> result
|
||||||
|
= checksum_map.insert(checksum_map_t::value_type(ref->to_string(), xact));
|
||||||
|
if (! result.second) {
|
||||||
|
// jww (2012-02-27): Confirm that the xact in
|
||||||
|
// (*result.first).second is exact match in its significant
|
||||||
|
// details to xact.
|
||||||
|
xact->journal = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xacts.push_back(xact);
|
xacts.push_back(xact);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
10
src/post.cc
10
src/post.cc
|
|
@ -186,12 +186,6 @@ namespace {
|
||||||
value_t get_magnitude(post_t& post) {
|
value_t get_magnitude(post_t& post) {
|
||||||
return post.xact->magnitude();
|
return post.xact->magnitude();
|
||||||
}
|
}
|
||||||
value_t get_idstring(post_t& post) {
|
|
||||||
return string_value(post.xact->idstring());
|
|
||||||
}
|
|
||||||
value_t get_id(post_t& post) {
|
|
||||||
return string_value(post.xact->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
value_t get_amount(post_t& post) {
|
value_t get_amount(post_t& post) {
|
||||||
if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND))
|
if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND))
|
||||||
|
|
@ -459,10 +453,6 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
|
||||||
case 'i':
|
case 'i':
|
||||||
if (name == "index")
|
if (name == "index")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_count>);
|
return WRAP_FUNCTOR(get_wrapper<&get_count>);
|
||||||
else if (name == "id")
|
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_id>);
|
|
||||||
else if (name == "idstring")
|
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_idstring>);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
|
|
|
||||||
27
src/xact.cc
27
src/xact.cc
|
|
@ -467,30 +467,10 @@ void xact_t::add_post(post_t * post)
|
||||||
xact_base_t::add_post(post);
|
xact_base_t::add_post(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
string xact_t::idstring() const
|
|
||||||
{
|
|
||||||
std::ostringstream buf;
|
|
||||||
buf << format_date(*_date, FMT_WRITTEN);
|
|
||||||
buf << payee;
|
|
||||||
magnitude().number().print(buf);
|
|
||||||
return buf.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
string xact_t::id() const
|
|
||||||
{
|
|
||||||
return sha1sum(idstring());
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
value_t get_magnitude(xact_t& xact) {
|
value_t get_magnitude(xact_t& xact) {
|
||||||
return xact.magnitude();
|
return xact.magnitude();
|
||||||
}
|
}
|
||||||
value_t get_idstring(xact_t& xact) {
|
|
||||||
return string_value(xact.idstring());
|
|
||||||
}
|
|
||||||
value_t get_id(xact_t& xact) {
|
|
||||||
return string_value(xact.id());
|
|
||||||
}
|
|
||||||
|
|
||||||
value_t get_code(xact_t& xact) {
|
value_t get_code(xact_t& xact) {
|
||||||
if (xact.code)
|
if (xact.code)
|
||||||
|
|
@ -554,13 +534,6 @@ expr_t::ptr_op_t xact_t::lookup(const symbol_t::kind_t kind,
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_code>);
|
return WRAP_FUNCTOR(get_wrapper<&get_code>);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
|
||||||
if (name == "id")
|
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_id>);
|
|
||||||
else if (name == "idstring")
|
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_idstring>);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (name == "magnitude")
|
if (name == "magnitude")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_magnitude>);
|
return WRAP_FUNCTOR(get_wrapper<&get_magnitude>);
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,6 @@ public:
|
||||||
|
|
||||||
virtual void add_post(post_t * post);
|
virtual void add_post(post_t * post);
|
||||||
|
|
||||||
string idstring() const;
|
|
||||||
string id() const;
|
|
||||||
|
|
||||||
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
|
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
|
||||||
const string& name);
|
const string& name);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue