# # # patch "app_state.cc" # from [ab42ce782bb39f6f9895c8d652afe9740d335655] # to [ffe7d555550ba0029a88e3e0fcfdfe99c1a8720b] # # patch "cert.cc" # from [3a9169e5b974a447189069ee3ad9015947540544] # to [a709e1d88c567067dd47f7e4cc0c89e8323a6e84] # # patch "cert.hh" # from [5d8777127b4bf1162d1f82d418e993195624ea68] # to [f9a33063ada94aee63e595e5802d9b1d51edf728] # # patch "cmd_key_cert.cc" # from [63c424ed1af113eb67be7295462111011a648f9d] # to [fb3fe93f13539c29f9c8ef4b2dfad9a84ce3302e] # # patch "cmd_merging.cc" # from [736129e2ea5badc3861399bfe524265558dc1df0] # to [8a04f717c45b70ed6685a8681752d3f977973c29] # # patch "cmd_packet.cc" # from [1e64bf637bd28cda2b019b229fadf93db3b206ee] # to [3812d4cf1a3b051160ffe8aee9a4b3d44834df37] # # patch "cmd_ws_commit.cc" # from [359383aa97f748ce215b8a30ca7eb8a041056078] # to [022a9615a7164baad7f2ad21ea8f6fead608022f] # # patch "key_store.cc" # from [6a656c873482e9ef7920bc787134e825c7e57754] # to [70b97a9e2a06654ec641a1709c2a875cdfa603d5] # # patch "key_store.hh" # from [40ecab081203aedf120cbd0147845222b4176282] # to [8912c391c7e6ea8a925ffb9cd8c9f5b3859bd139] # # patch "merge.cc" # from [6fde96d8dd288134ad3ca24f3d83ec16eae5b593] # to [eefe68a4d7028949498fd89e6014adb343dec991] # # patch "packet.cc" # from [f1c1015d1d9b9d4ff8fc3af5d23a0980444cce47] # to [991e6a99aeb8e43d48d09d64b22e080bb617f08f] # # patch "packet.hh" # from [84f7fdaa2b1fab00d94e08f04e0c2449c415d9c6] # to [e28b0bb77a6505bf4daf75d0f6f655d5b3f28e4d] # # patch "project.cc" # from [7d11e522dbfb1768586b336db41f6749b3597180] # to [f64755c9f3508c82ba5717115171d2ac657b6f5c] # # patch "project.hh" # from [f62f247a889cf9084988628f16e8189c751b64ed] # to [5da24a7e4b1f31ec1e36a351aab0047123aebc2b] # # patch "rcs_import.cc" # from [901a0c2f1ed07d827db3bf85ac7817ecaa0339b5] # to [c4343f5f7eb1a9c2952b9c31ec3c8b88ece5b4b5] # ============================================================ --- app_state.cc ab42ce782bb39f6f9895c8d652afe9740d335655 +++ app_state.cc ffe7d555550ba0029a88e3e0fcfdfe99c1a8720b @@ -36,7 +36,7 @@ app_state::app_state() app_state::app_state() : db(system_path()), - keys(this), work(db, lua), + keys(*this), work(db, lua), // search_root(current_root_path()), // diff_format(unified_diff), branch_is_sticky(false), ============================================================ --- cert.cc 3a9169e5b974a447189069ee3ad9015947540544 +++ cert.cc a709e1d88c567067dd47f7e4cc0c89e8323a6e84 @@ -24,7 +24,6 @@ #include "keys.hh" #include "netio.hh" #include "option.hh" -#include "packet.hh" #include "revision.hh" #include "sanity.hh" #include "simplestring_xform.hh" @@ -442,8 +441,6 @@ check_cert(app_state & app, cert const & // "special certs" -cert_name const branch_cert_name("branch"); - void get_user_key(rsa_keypair_id & key, app_state & app) { @@ -528,60 +525,46 @@ put_simple_revision_cert(revision_id con put_simple_revision_cert(revision_id const & id, cert_name const & nm, cert_value const & val, - app_state & app, - packet_consumer & pc) + app_state & app) { cert t; make_simple_cert(id.inner(), nm, val, app, t); revision cc(t); - pc.consume_revision_cert(cc); + app.db.put_revision_cert(cc); } void cert_revision_in_branch(revision_id const & rev, - cert_value const & branchname, - app_state & app, - packet_consumer & pc) + branch_name const & branch, + app_state & app) { - put_simple_revision_cert (rev, branch_cert_name, - branchname, app, pc); + put_simple_revision_cert (rev, branch_cert_name, cert_value(branch()), + app); } // "standard certs" -cert_name const date_cert_name("date"); -cert_name const author_cert_name("author"); -cert_name const tag_cert_name("tag"); -cert_name const changelog_cert_name("changelog"); -cert_name const comment_cert_name("comment"); -cert_name const testresult_cert_name("testresult"); - - void cert_revision_date_time(revision_id const & m, date_t const & t, - app_state & app, - packet_consumer & pc) + app_state & app) { cert_value val = cert_value(t.as_iso_8601_extended()); - put_simple_revision_cert(m, cert_name(date_cert_name), val, app, pc); + put_simple_revision_cert(m, date_cert_name, val, app); } void cert_revision_author(revision_id const & m, string const & author, - app_state & app, - packet_consumer & pc) + app_state & app) { - put_simple_revision_cert(m, author_cert_name, - cert_value(author), app, pc); + put_simple_revision_cert(m, author_cert_name, cert_value(author), app); } void cert_revision_author_default(revision_id const & m, - app_state & app, - packet_consumer & pc) + app_state & app) { string author; rsa_keypair_id key; @@ -591,45 +574,38 @@ cert_revision_author_default(revision_id { author = key(); } - cert_revision_author(m, author, app, pc); + cert_revision_author(m, author, app); } void cert_revision_tag(revision_id const & m, string const & tagname, - app_state & app, - packet_consumer & pc) + app_state & app) { - put_simple_revision_cert(m, tag_cert_name, - cert_value(tagname), app, pc); + put_simple_revision_cert(m, tag_cert_name, cert_value(tagname), app); } void cert_revision_changelog(revision_id const & m, - utf8 const & changelog, - app_state & app, - packet_consumer & pc) + utf8 const & log, + app_state & app) { - put_simple_revision_cert(m, changelog_cert_name, - cert_value(changelog()), app, pc); + put_simple_revision_cert(m, changelog_cert_name, cert_value(log()), app); } void cert_revision_comment(revision_id const & m, utf8 const & comment, - app_state & app, - packet_consumer & pc) + app_state & app) { - put_simple_revision_cert(m, comment_cert_name, - cert_value(comment()), app, pc); + put_simple_revision_cert(m, comment_cert_name, cert_value(comment()), app); } void cert_revision_testresult(revision_id const & r, string const & results, - app_state & app, - packet_consumer & pc) + app_state & app) { bool passed = false; if (lowercase(results) == "true" || @@ -647,7 +623,8 @@ cert_revision_testresult(revision_id con "tried '0/1' 'yes/no', 'true/false', " "'pass/fail'"); - put_simple_revision_cert(r, testresult_cert_name, cert_value(lexical_cast(passed)), app, pc); + put_simple_revision_cert(r, testresult_cert_name, + cert_value(lexical_cast(passed)), app); } // Local Variables: ============================================================ --- cert.hh 5d8777127b4bf1162d1f82d418e993195624ea68 +++ cert.hh f9a33063ada94aee63e595e5802d9b1d51edf728 @@ -24,7 +24,6 @@ class app_state; // permission. class app_state; -struct packet_consumer; struct cert { @@ -80,8 +79,7 @@ void put_simple_revision_cert(revision_i void put_simple_revision_cert(revision_id const & id, cert_name const & nm, cert_value const & val, - app_state & app, - packet_consumer & pc); + app_state & app); void erase_bogus_certs(std::vector< revision > & certs, app_state & app); @@ -91,13 +89,12 @@ void erase_bogus_certs(std::vector< mani // Special certs -- system won't work without them. -extern cert_name const branch_cert_name; +#define branch_cert_name cert_name("branch") void cert_revision_in_branch(revision_id const & ctx, - cert_value const & branchname, - app_state & app, - packet_consumer & pc); + branch_name const & branchname, + app_state & app); // We also define some common cert types, to help establish useful @@ -113,53 +110,46 @@ guess_branch(revision_id const & id, app void guess_branch(revision_id const & id, app_state & app); -extern cert_name const date_cert_name; -extern cert_name const author_cert_name; -extern cert_name const tag_cert_name; -extern cert_name const changelog_cert_name; -extern cert_name const comment_cert_name; -extern cert_name const testresult_cert_name; +#define date_cert_name cert_name("date") +#define author_cert_name cert_name("author") +#define tag_cert_name cert_name("tag") +#define changelog_cert_name cert_name("changelog") +#define comment_cert_name cert_name("comment") +#define testresult_cert_name cert_name("testresult") void cert_revision_date_time(revision_id const & m, date_t const & t, - app_state & app, - packet_consumer & pc); + app_state & app); void cert_revision_author(revision_id const & m, std::string const & author, - app_state & app, - packet_consumer & pc); + app_state & app); void cert_revision_author_default(revision_id const & m, - app_state & app, - packet_consumer & pc); + app_state & app); void cert_revision_tag(revision_id const & m, std::string const & tagname, - app_state & app, - packet_consumer & pc); + app_state & app); void cert_revision_changelog(revision_id const & m, utf8 const & changelog, - app_state & app, - packet_consumer & pc); + app_state & app); void cert_revision_comment(revision_id const & m, utf8 const & comment, - app_state & app, - packet_consumer & pc); + app_state & app); void cert_revision_testresult(revision_id const & m, std::string const & results, - app_state & app, - packet_consumer & pc); + app_state & app); // Local Variables: ============================================================ --- cmd_key_cert.cc 63c424ed1af113eb67be7295462111011a648f9d +++ cmd_key_cert.cc fb3fe93f13539c29f9c8ef4b2dfad9a84ce3302e @@ -15,7 +15,6 @@ #include "charset.hh" #include "cmd.hh" #include "keys.hh" -#include "packet.hh" #include "transforms.hh" #include "ssh_agent.hh" #include "botan/pipe.h" @@ -198,8 +197,7 @@ CMD(cert, N_("key and cert"), N_("REVISI val = cert_value(dat()); } - packet_db_writer dbw(app); - app.get_project().put_cert(rid, name, val, dbw); + app.get_project().put_cert(rid, name, val); guard.commit(); } @@ -259,8 +257,7 @@ CMD(tag, N_("review"), N_("REVISION TAGN revision_id r; complete(app, idx(args, 0)(), r); - packet_db_writer dbw(app); - cert_revision_tag(r, idx(args, 1)(), app, dbw); + cert_revision_tag(r, idx(args, 1)(), app); } @@ -272,8 +269,7 @@ CMD(testresult, N_("review"), N_("ID (pa revision_id r; complete(app, idx(args, 0)(), r); - packet_db_writer dbw(app); - cert_revision_testresult(r, idx(args, 1)(), app, dbw); + cert_revision_testresult(r, idx(args, 1)(), app); } @@ -286,10 +282,9 @@ CMD(approve, N_("review"), N_("REVISION" revision_id r; complete(app, idx(args, 0)(), r); - packet_db_writer dbw(app); guess_branch(r, app); N(app.opts.branchname() != "", F("need --branch argument for approval")); - app.get_project().put_revision_in_branch(r, app.opts.branchname, dbw); + app.get_project().put_revision_in_branch(r, app.opts.branchname); } CMD(comment, N_("review"), N_("REVISION [COMMENT]"), @@ -314,8 +309,7 @@ CMD(comment, N_("review"), N_("REVISION revision_id r; complete(app, idx(args, 0)(), r); - packet_db_writer dbw(app); - cert_revision_comment(r, comment, app, dbw); + cert_revision_comment(r, comment, app); } // Local Variables: ============================================================ --- cmd_merging.cc 736129e2ea5badc3861399bfe524265558dc1df0 +++ cmd_merging.cc 8a04f717c45b70ed6685a8681752d3f977973c29 @@ -14,7 +14,6 @@ #include "cmd.hh" #include "diff_patch.hh" #include "merge.hh" -#include "packet.hh" #include "restrictions.hh" #include "revision.hh" #include "roster_merge.hh" @@ -317,11 +316,9 @@ merge_two(revision_id const & left, revi transaction_guard guard(app.db); interactive_merge_and_store(left, right, merged, app); - packet_db_writer dbw(app); app.get_project().put_standard_certs_from_options(merged, branch, - utf8(log.str()), - dbw); + utf8(log.str())); guard.commit(); P(F("[merged] %s") % merged); @@ -505,10 +502,8 @@ CMD(merge_into_dir, N_("tree"), N_("SOUR P(F("no merge necessary; putting %s in branch '%s'") % (*src_i) % idx(args, 1)()); transaction_guard guard(app.db); - packet_db_writer dbw(app); app.get_project().put_revision_in_branch(*src_i, - branch_name(idx(args, 1)()), - dbw); + branch_name(idx(args, 1)())); guard.commit(); } else @@ -590,11 +585,9 @@ CMD(merge_into_dir, N_("tree"), N_("SOUR % idx(args, 0) % (*src_i) % idx(args, 1) % (*dst_i)).str()); - packet_db_writer dbw(app); app.get_project().put_standard_certs_from_options(merged, branch_name(idx(args, 1)()), - log_message, - dbw); + log_message); guard.commit(); P(F("[merged] %s") % merged); ============================================================ --- cmd_packet.cc 1e64bf637bd28cda2b019b229fadf93db3b206ee +++ cmd_packet.cc 3812d4cf1a3b051160ffe8aee9a4b3d44834df37 @@ -65,7 +65,68 @@ CMD(privkey, N_("packet i/o"), N_("ID"), pw.consume_key_pair(ident, kp); } +namespace +{ + // this writer injects packets it receives to the database + // and/or keystore. + struct packet_db_writer : public packet_consumer + { + app_state & app; + public: + packet_db_writer(app_state & app) : app(app) {} + virtual ~packet_db_writer() {} + virtual void consume_file_data(file_id const & ident, + file_data const & dat) + { + transaction_guard guard(app.db); + app.db.put_file(ident, dat); + guard.commit(); + } + + virtual void consume_file_delta(file_id const & old_id, + file_id const & new_id, + file_delta const & del) + { + transaction_guard guard(app.db); + app.db.put_file_version(old_id, new_id, del); + guard.commit(); + } + + virtual void consume_revision_data(revision_id const & ident, + revision_data const & dat) + { + transaction_guard guard(app.db); + app.db.put_revision(ident, dat); + guard.commit(); + } + + virtual void consume_revision_cert(revision const & t) + { + transaction_guard guard(app.db); + app.db.put_revision_cert(t); + guard.commit(); + } + + virtual void consume_public_key(rsa_keypair_id const & ident, + base64< rsa_pub_key > const & k) + { + transaction_guard guard(app.db); + app.db.put_key(ident, k); + guard.commit(); + } + + virtual void consume_key_pair(rsa_keypair_id const & ident, + keypair const & kp) + { + transaction_guard guard(app.db); + app.keys.put_key_pair(ident, kp); + guard.commit(); + } + }; +} + + CMD(read, N_("packet i/o"), "[FILE1 [FILE2 [...]]]", N_("read packets from files or stdin"), options::opts::none) ============================================================ --- cmd_ws_commit.cc 359383aa97f748ce215b8a30ca7eb8a041056078 +++ cmd_ws_commit.cc 022a9615a7164baad7f2ad21ea8f6fead608022f @@ -13,7 +13,6 @@ #include "cmd.hh" #include "diff_patch.hh" #include "file_io.hh" -#include "packet.hh" #include "restrictions.hh" #include "revision.hh" #include "transforms.hh" @@ -254,11 +253,9 @@ CMD(disapprove, N_("review"), N_("REVISI calculate_ident(rdat, inv_id); app.db.put_revision(inv_id, rdat); - packet_db_writer dbw(app); app.get_project().put_standard_certs_from_options(inv_id, app.opts.branchname, - log_message, - dbw); + log_message); guard.commit(); } } @@ -861,8 +858,7 @@ CMD(commit, N_("workspace"), N_("[PATH]. file_delta(del)); } else - // If we don't err out here, our packet writer will - // later. + // If we don't err out here, the database will later. E(false, F("Your database is missing version %s of file '%s'") % old_content % path); @@ -893,11 +889,9 @@ CMD(commit, N_("workspace"), N_("[PATH]. app.db.put_revision(restricted_rev_id, rdat); } - packet_db_writer dbw(app); app.get_project().put_standard_certs_from_options(restricted_rev_id, app.opts.branchname, - log_message, - dbw); + log_message); guard.commit(); } ============================================================ --- key_store.cc 6a656c873482e9ef7920bc787134e825c7e57754 +++ key_store.cc 70b97a9e2a06654ec641a1709c2a875cdfa603d5 @@ -15,45 +15,46 @@ using std::vector; using std::string; using std::vector; -struct keyreader : public packet_consumer +namespace { - key_store * ks; + struct keyreader : public packet_consumer + { + key_store & ks; - keyreader(key_store * k): ks(k) {} - virtual void consume_file_data(file_id const & ident, - file_data const & dat) - {E(false, F("Extraneous data in key store."));} - virtual void consume_file_delta(file_id const & id_old, - file_id const & id_new, - file_delta const & del) - {E(false, F("Extraneous data in key store."));} + keyreader(key_store & k): ks(k) {} + virtual void consume_file_data(file_id const & ident, + file_data const & dat) + {E(false, F("Extraneous data in key store."));} + virtual void consume_file_delta(file_id const & id_old, + file_id const & id_new, + file_delta const & del) + {E(false, F("Extraneous data in key store."));} - virtual void consume_revision_data(revision_id const & ident, - revision_data const & dat) - {E(false, F("Extraneous data in key store."));} - virtual void consume_revision_cert(revision const & t) - {E(false, F("Extraneous data in key store."));} + virtual void consume_revision_data(revision_id const & ident, + revision_data const & dat) + {E(false, F("Extraneous data in key store."));} + virtual void consume_revision_cert(revision const & t) + {E(false, F("Extraneous data in key store."));} - virtual void consume_public_key(rsa_keypair_id const & ident, - base64< rsa_pub_key > const & k) - {E(false, F("Extraneous data in key store."));} + virtual void consume_public_key(rsa_keypair_id const & ident, + base64< rsa_pub_key > const & k) + {E(false, F("Extraneous data in key store."));} - virtual void consume_key_pair(rsa_keypair_id const & ident, - keypair const & kp) - { - L(FL("reading key pair '%s' from key store") % ident); - E(!ks->key_pair_exists(ident), - F("Key store has multiple keys with id '%s'.") % ident); - ks->keys.insert(make_pair(ident, kp)); - hexenc hash; - key_hash_code(ident, kp.pub, hash); - ks->hashes.insert(make_pair(hash, ident)); - L(FL("successfully read key pair '%s' from key store") % ident); - } -}; + virtual void consume_key_pair(rsa_keypair_id const & ident, + keypair const & kp) + { + L(FL("reading key pair '%s' from key store") % ident); -key_store::key_store(app_state * a): have_read(false), app(a) + E(ks.put_key_pair_memory(ident, kp), + F("Key store has multiple keys with id '%s'.") % ident); + + L(FL("successfully read key pair '%s' from key store") % ident); + } + }; +} + +key_store::key_store(app_state & a): have_read(false), app(a) { } @@ -80,7 +81,7 @@ key_store::read_key_dir() } else L(FL("key dir '%s' does not exist") % key_dir); - keyreader kr(this); + keyreader kr(*this); for (vector::const_iterator i = key_files.begin(); i != key_files.end(); ++i) { @@ -88,7 +89,7 @@ key_store::read_key_dir() data dat; read_data(key_dir / (*i)(), dat); istringstream is(dat()); - read_packets(is, kr, *app); + read_packets(is, kr, app); } } @@ -110,11 +111,11 @@ key_store::ensure_in_database(rsa_keypai // if this object does not have the key, the database had better. if (i == keys.end()) { - I(app->db.public_key_exists(ident)); + I(app.db.public_key_exists(ident)); return; } - if (app->db.put_key(ident, i->second.pub)) + if (app.db.put_key(ident, i->second.pub)) L(FL("loaded public key '%s' into db") % ident); } @@ -217,6 +218,16 @@ key_store::put_key_pair(rsa_keypair_id c key_store::put_key_pair(rsa_keypair_id const & ident, keypair const & kp) { + bool newkey = put_key_pair_memory(ident, kp); + if (newkey) + write_key(ident); + return newkey; +} + +bool +key_store::put_key_pair_memory(rsa_keypair_id const & ident, + keypair const & kp) +{ maybe_read_key_dir(); L(FL("putting key pair '%s'") % ident); pair::iterator, bool> res; @@ -226,7 +237,6 @@ key_store::put_key_pair(rsa_keypair_id c hexenc hash; key_hash_code(ident, kp.pub, hash); I(hashes.insert(make_pair(hash, ident)).second); - write_key(ident); return true; } else ============================================================ --- key_store.hh 40ecab081203aedf120cbd0147845222b4176282 +++ key_store.hh 8912c391c7e6ea8a925ffb9cd8c9f5b3859bd139 @@ -1,23 +1,18 @@ #ifndef __KEY_STORE_H__ #define __KEY_STORE_H__ #include - #include "vocab.hh" #include "paths.hh" -#include "platform.hh" class app_state; -struct keyreader; - class key_store { private: - friend struct keyreader; system_path key_dir; bool have_read; - app_state * app; + app_state & app; std::map keys; std::map, rsa_keypair_id> hashes; @@ -26,7 +21,7 @@ public: void read_key_dir(); void maybe_read_key_dir(); public: - key_store(app_state * a); + key_store(app_state & a); void set_key_dir(system_path const & kd); system_path const & get_key_dir(); @@ -46,6 +41,12 @@ public: bool put_key_pair(rsa_keypair_id const & ident, keypair const & kp); + // just like put_key_pair except that the key is _not_ written to disk. + // primarily for internal use in reading keys back from disk. + bool put_key_pair_memory(rsa_keypair_id const & ident, + keypair const & kp); + + void delete_key(rsa_keypair_id const & ident); }; ============================================================ --- merge.cc 6fde96d8dd288134ad3ca24f3d83ec16eae5b593 +++ merge.cc eefe68a4d7028949498fd89e6014adb343dec991 @@ -13,7 +13,6 @@ #include "diff_patch.hh" #include "merge.hh" -#include "packet.hh" #include "revision.hh" #include "roster_merge.hh" #include "safe_map.hh" ============================================================ --- packet.cc f1c1015d1d9b9d4ff8fc3af5d23a0980444cce47 +++ packet.cc 991e6a99aeb8e43d48d09d64b22e080bb617f08f @@ -36,69 +36,6 @@ using boost::shared_ptr; using boost::regex; using boost::shared_ptr; -packet_db_writer::packet_db_writer(app_state & app) - : app(app) -{} - -packet_db_writer::~packet_db_writer() -{} - -void -packet_db_writer::consume_file_data(file_id const & ident, - file_data const & dat) -{ - transaction_guard guard(app.db); - app.db.put_file(ident, dat); - guard.commit(); -} - -void -packet_db_writer::consume_file_delta(file_id const & old_id, - file_id const & new_id, - file_delta const & del) -{ - transaction_guard guard(app.db); - app.db.put_file_version(old_id, new_id, del); - guard.commit(); -} - -void -packet_db_writer::consume_revision_data(revision_id const & ident, - revision_data const & dat) -{ - MM(ident); - transaction_guard guard(app.db); - app.db.put_revision(ident, dat); - guard.commit(); -} - -void -packet_db_writer::consume_revision_cert(revision const & t) -{ - transaction_guard guard(app.db); - app.db.put_revision_cert(t); - guard.commit(); -} - - -void -packet_db_writer::consume_public_key(rsa_keypair_id const & ident, - base64< rsa_pub_key > const & k) -{ - transaction_guard guard(app.db); - app.db.put_key(ident, k); - guard.commit(); -} - -void -packet_db_writer::consume_key_pair(rsa_keypair_id const & ident, - keypair const & kp) -{ - transaction_guard guard(app.db); - app.keys.put_key_pair(ident, kp); - guard.commit(); -} - // --- packet writer --- packet_writer::packet_writer(ostream & o) : ost(o) {} ============================================================ --- packet.hh 84f7fdaa2b1fab00d94e08f04e0c2449c415d9c6 +++ packet.hh e28b0bb77a6505bf4daf75d0f6f655d5b3f28e4d @@ -31,9 +31,9 @@ struct cert; // terminal or inclusion in an email / netnews post. they can be edited with // vi, filtered with grep, and concatenated with cat. // -// there are currently 8 types of packets, though this can grow without hurting -// anyone's feelings. if there's a backwards compatibility problem, just introduce -// a new packet type. +// there are currently 8 types of packets, though this can grow without +// hurting anyone's feelings. if there's a backwards compatibility problem, +// just introduce a new packet type. struct packet_consumer { @@ -79,30 +79,6 @@ struct packet_writer : public packet_con keypair const & kp); }; -// this writer injects packets it receives to the database. - -struct packet_db_writer : public packet_consumer -{ - app_state & app; -public: - packet_db_writer(app_state & app); - virtual ~packet_db_writer(); - virtual void consume_file_data(file_id const & ident, - file_data const & dat); - virtual void consume_file_delta(file_id const & id_old, - file_id const & id_new, - file_delta const & del); - - virtual void consume_revision_data(revision_id const & ident, - revision_data const & dat); - virtual void consume_revision_cert(revision const & t); - - virtual void consume_public_key(rsa_keypair_id const & ident, - base64< rsa_pub_key > const & k); - virtual void consume_key_pair(rsa_keypair_id const & ident, - keypair const & kp); -}; - size_t read_packets(std::istream & in, packet_consumer & cons, app_state & app); // Local Variables: ============================================================ --- project.cc 7d11e522dbfb1768586b336db41f6749b3597180 +++ project.cc f64755c9f3508c82ba5717115171d2ac657b6f5c @@ -5,7 +5,6 @@ #include "app_state.hh" #include "cert.hh" -#include "packet.hh" #include "project.hh" #include "revision.hh" #include "transforms.hh" @@ -121,10 +120,9 @@ project_t::put_revision_in_branch(revisi void project_t::put_revision_in_branch(revision_id const & id, - branch_name const & branch, - packet_consumer & pc) + branch_name const & branch) { - cert_revision_in_branch(id, cert_value(branch()), app, pc); + cert_revision_in_branch(id, branch, app); } @@ -222,10 +220,9 @@ project_t::put_tag(revision_id const & i void project_t::put_tag(revision_id const & id, - string const & name, - packet_consumer & pc) + string const & name) { - cert_revision_tag(id, name, app, pc); + cert_revision_tag(id, name, app); } @@ -234,38 +231,34 @@ project_t::put_standard_certs(revision_i branch_name const & branch, utf8 const & changelog, date_t const & time, - utf8 const & author, - packet_consumer & pc) + utf8 const & author) { - cert_revision_in_branch(id, cert_value(branch()), app, pc); - cert_revision_changelog(id, changelog, app, pc); - cert_revision_date_time(id, time, app, pc); + cert_revision_in_branch(id, branch, app); + cert_revision_changelog(id, changelog, app); + cert_revision_date_time(id, time, app); if (!author().empty()) - cert_revision_author(id, author(), app, pc); + cert_revision_author(id, author(), app); else - cert_revision_author_default(id, app, pc); + cert_revision_author_default(id, app); } void project_t::put_standard_certs_from_options(revision_id const & id, branch_name const & branch, - utf8 const & changelog, - packet_consumer & pc) + utf8 const & changelog) { put_standard_certs(id, branch, changelog, app.opts.date_given ? app.opts.date : date_t::now(), - app.opts.author, - pc); + app.opts.author); } void project_t::put_cert(revision_id const & id, cert_name const & name, - cert_value const & value, - packet_consumer & pc) + cert_value const & value) { - put_simple_revision_cert(id, name, value, app, pc); + put_simple_revision_cert(id, name, value, app); } ============================================================ --- project.hh f62f247a889cf9084988628f16e8189c751b64ed +++ project.hh 5da24a7e4b1f31ec1e36a351aab0047123aebc2b @@ -13,7 +13,6 @@ class app_state; #include "vocab.hh" class app_state; -struct packet_consumer; class tag_t { @@ -40,12 +39,11 @@ public: void get_branch_heads(branch_name const & name, std::set & heads); outdated_indicator get_tags(std::set & tags); - void put_tag(revision_id const & id, std::string const & name, packet_consumer & pc); + void put_tag(revision_id const & id, std::string const & name); bool revision_is_in_branch(revision_id const & id, branch_name const & branch); void put_revision_in_branch(revision_id const & id, - branch_name const & branch, - packet_consumer & pc); + branch_name const & branch); outdated_indicator get_revision_cert_hashes(revision_id const & rid, std::vector > & hashes); @@ -63,17 +61,14 @@ public: branch_name const & branch, utf8 const & changelog, date_t const & time, - utf8 const & author, - packet_consumer & pc); + utf8 const & author); void put_standard_certs_from_options(revision_id const & id, branch_name const & branch, - utf8 const & changelog, - packet_consumer & pc); + utf8 const & changelog); void put_cert(revision_id const & id, cert_name const & name, - cert_value const & value, - packet_consumer & pc); + cert_value const & value); }; #endif ============================================================ --- rcs_import.cc 901a0c2f1ed07d827db3bf85ac7817ecaa0339b5 +++ rcs_import.cc c4343f5f7eb1a9c2952b9c31ec3c8b88ece5b4b5 @@ -33,7 +33,6 @@ #include "file_io.hh" #include "interner.hh" #include "keys.hh" -#include "packet.hh" #include "paths.hh" #include "platform-wrapped.hh" #include "project.hh" @@ -1262,14 +1261,13 @@ import_cvs_repo(system_path const & cvsr // now we have a "last" rev for each tag { ticker n_tags(_("tags"), "t", 1); - packet_db_writer dbw(app); transaction_guard guard(app.db); for (map >::const_iterator i = cvs.resolved_tags.begin(); i != cvs.resolved_tags.end(); ++i) { string tag = cvs.tag_interner.lookup(i->first); ui.set_tick_trailer("marking tag " + tag); - app.get_project().put_tag(i->second.second, tag, dbw); + app.get_project().put_tag(i->second.second, tag); ++n_tags; } guard.commit(); @@ -1353,8 +1351,6 @@ cluster_consumer::store_auxiliary_certs( void cluster_consumer::store_auxiliary_certs(prepared_revision const & p) { - packet_db_writer dbw(app); - for (vector::const_iterator i = p.tags.begin(); i != p.tags.end(); ++i) { @@ -1380,8 +1376,7 @@ cluster_consumer::store_auxiliary_certs( branch_name(branchname), utf8(cvs.changelog_interner.lookup(p.changelog)), date_t::from_unix_epoch(p.time), - utf8(cvs.author_interner.lookup(p.author)), - dbw); + utf8(cvs.author_interner.lookup(p.author))); } void