Improved usefulness of the "print --anon" output

This commit is contained in:
John Wiegley 2009-06-27 01:45:31 +01:00
parent bf30f989f6
commit 7b05595699
2 changed files with 25 additions and 6 deletions

View file

@ -142,6 +142,7 @@ namespace {
buf.width(8);
buf.fill('0');
buf << std::hex << message_digest[i];
break; // only output the first dword
}
return buf.str();
}
@ -175,13 +176,31 @@ void anonymize_posts::operator()(post_t& post)
post_t& temp = post_temps.back();
temp.xact = &xact;
std::list<string> account_names;
account_t * new_account = NULL;
for (account_t * acct = post.account;
acct;
acct = acct->parent) {
if (! acct->parent) {
new_account = acct;
break;
}
sha.Reset();
sha << post.account->fullname().c_str();
sha << acct->name.c_str();
sha.Result(message_digest);
account_names.push_front(to_hex(message_digest));
}
assert(new_account);
foreach (const string& name, account_names)
new_account = new_account->find_account(name);
temp.copy_details(post);
temp.account = post.xact->journal->find_account(to_hex(message_digest));
temp.account = new_account;
temp.note = none;
temp.add_flags(ITEM_TEMP);

View file

@ -4,8 +4,8 @@ reg --anon
Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
Income:Dividends:Vanguard:VMMXX $-0.35
>>>1
07-Feb-02 6a93dcb30aa7722e967.. ..cfb2807d6a978b431fc7 0.350 VMMXX 0.350 VMMXX
..4fbac0065bfcc300a24e $-0.35 $-0.35
07-Feb-02 6a93dcb3 20:5d:27:988a9c3a 0.350 VMMXX 0.350 VMMXX
1c:b6:27:988a9c3a $-0.35 $-0.35
0.350 VMMXX
>>>2
=== 0