# # # patch "cert.cc" # from [d72920719f062aa2ba1e0a1694c4a1387cde1017] # to [de57eef79d80980042168a581f6e85cbb9e3f147] # # patch "cert.hh" # from [b2f4de53a290497a08a5185d382aa980ea291f09] # to [3d0773d6995e74025a81c0bbf79947ee956ef081] # # patch "cmd_key_cert.cc" # from [41060424a1f24888e53b762d83bda91837170b30] # to [3241526b563ed572a5abcd9a3304ae8f37ec33b0] # # patch "cmd_merging.cc" # from [05e6bf5e0085944554606888374a7f38c0e360ec] # to [112d08ea9d7d3e72e37be28a29f6382e9b7614d4] # # patch "cmd_ws_commit.cc" # from [62fbf1f8c008b60488a6c4f63fe990bb452d1fda] # to [c6fe07700cef1c3e60c176f504fad622958eceba] # # patch "merge.cc" # from [a0d49fda137f4c89ed813a95aed5dadca9947572] # to [6fde96d8dd288134ad3ca24f3d83ec16eae5b593] # # patch "project.cc" # from [50538ea67357a522ab5a74bfcefebe2f842de40d] # to [d97bc10fd9ebe24fea6563717e975339765b1e35] # # patch "project.hh" # from [4370fd8dda1fcc27de319de6d53388c648dce201] # to [4ef8072510d9791ce001e03e641ab01f83f042c3] # # patch "rcs_import.cc" # from [138e5d7da50a1726b2ba9737d0692041987671be] # to [ec31df86841d31110bb1ac9e55face801ad7446f] # ============================================================ --- cert.cc d72920719f062aa2ba1e0a1694c4a1387cde1017 +++ cert.cc de57eef79d80980042168a581f6e85cbb9e3f147 @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -519,7 +518,7 @@ make_simple_cert(hexenc const & id, c = t; } -static void +void put_simple_revision_cert(revision_id const & id, cert_name const & nm, cert_value const & val, ============================================================ --- cert.hh b2f4de53a290497a08a5185d382aa980ea291f09 +++ cert.hh 3d0773d6995e74025a81c0bbf79947ee956ef081 @@ -66,13 +66,21 @@ void load_key_pair(app_state & app, void load_key_pair(app_state & app, rsa_keypair_id const & id, keypair & kp); -void calculate_cert(app_state & app, cert & t); + +// Only used in cert.cc, and in revision.cc in what looks +// like migration code. void make_simple_cert(hexenc const & id, cert_name const & nm, cert_value const & cv, app_state & app, cert & c); +void put_simple_revision_cert(revision_id const & id, + cert_name const & nm, + cert_value const & val, + app_state & app, + packet_consumer & pc); + void erase_bogus_certs(std::vector< revision > & certs, app_state & app); ============================================================ --- cmd_key_cert.cc 41060424a1f24888e53b762d83bda91837170b30 +++ cmd_key_cert.cc 3241526b563ed572a5abcd9a3304ae8f37ec33b0 @@ -135,14 +135,8 @@ CMD(cert, N_("key and cert"), N_("REVISI else val = cert_value(get_stdin()); - base64 val_encoded; - encode_base64(val, val_encoded); - - cert t(ident, name, val_encoded, key); - packet_db_writer dbw(app); - calculate_cert(app, t); - dbw.consume_revision_cert(revision(t)); + app.project.put_cert(ident, name, val, dbw); guard.commit(); } ============================================================ --- cmd_merging.cc 05e6bf5e0085944554606888374a7f38c0e360ec +++ cmd_merging.cc 112d08ea9d7d3e72e37be28a29f6382e9b7614d4 @@ -296,8 +296,10 @@ merge_two(revision_id const & left, revi interactive_merge_and_store(left, right, merged, app); packet_db_writer dbw(app); - cert_revision_in_branch(merged, branch, app, dbw); - cert_revision_changelog(merged, log.str(), app, dbw); + app.project.put_standard_certs_from_options(merged, + branch, + log.str(), + dbw); guard.commit(); P(F("[merged] %s") % merged); @@ -482,7 +484,7 @@ CMD(merge_into_dir, N_("tree"), N_("SOUR % (*src_i) % idx(args, 1)()); transaction_guard guard(app.db); packet_db_writer dbw(app); - cert_revision_in_branch(*src_i, idx(args, 1)(), app, dbw); + app.project.put_revision_in_branch(*src_i, idx(args, 1), dbw); guard.commit(); } else @@ -555,10 +557,6 @@ CMD(merge_into_dir, N_("tree"), N_("SOUR app); } - packet_db_writer dbw(app); - - cert_revision_in_branch(merged, idx(args, 1)(), app, dbw); - bool log_message_given; utf8 log_message; process_commit_message_args(log_message_given, log_message, app); @@ -568,7 +566,11 @@ CMD(merge_into_dir, N_("tree"), N_("SOUR % idx(args, 0) % (*src_i) % idx(args, 1) % (*dst_i)).str(); - cert_revision_changelog(merged, log_message, app, dbw); + packet_db_writer dbw(app); + app.project.put_standard_certs_from_options(merged, + idx(args, 1), + log_message(), + dbw); guard.commit(); P(F("[merged] %s") % merged); ============================================================ --- cmd_ws_commit.cc 62fbf1f8c008b60488a6c4f63fe990bb452d1fda +++ cmd_ws_commit.cc c6fe07700cef1c3e60c176f504fad622958eceba @@ -247,16 +247,10 @@ CMD(disapprove, N_("review"), N_("REVISI calculate_ident(rdat, inv_id); dbw.consume_revision_data(inv_id, rdat); - cert_revision_in_branch(inv_id, branchname, app, dbw); - if (app.opts.date_given) - cert_revision_date_time(inv_id, app.opts.date, app, dbw); - else - cert_revision_date_now(inv_id, app, dbw); - if (app.opts.author().length() > 0) - cert_revision_author(inv_id, app.opts.author(), app, dbw); - else - cert_revision_author_default(inv_id, app, dbw); - cert_revision_changelog(inv_id, log_message, app, dbw); + app.project.put_standard_certs_from_options(inv_id, + branchname(), + log_message(), + dbw); guard.commit(); } } @@ -895,18 +889,10 @@ CMD(commit, N_("workspace"), N_("[PATH]. write_revision(restricted_rev, rdat); dbw.consume_revision_data(restricted_rev_id, rdat); - cert_revision_in_branch(restricted_rev_id, branchname, app, dbw); - if (app.opts.date_given) - cert_revision_date_time(restricted_rev_id, app.opts.date, app, dbw); - else - cert_revision_date_now(restricted_rev_id, app, dbw); - - if (app.opts.author_given > 0) - cert_revision_author(restricted_rev_id, app.opts.author(), app, dbw); - else - cert_revision_author_default(restricted_rev_id, app, dbw); - - cert_revision_changelog(restricted_rev_id, log_message, app, dbw); + app.project.put_standard_certs_from_options(restricted_rev_id, + branchname(), + log_message(), + dbw); guard.commit(); } ============================================================ --- merge.cc a0d49fda137f4c89ed813a95aed5dadca9947572 +++ merge.cc 6fde96d8dd288134ad3ca24f3d83ec16eae5b593 @@ -196,15 +196,6 @@ store_roster_merge_result(roster_t const transaction_guard guard(app.db); app.db.put_revision(merged_rid, merged_rev); - packet_db_writer dbw(app); - if (app.opts.date_given) - cert_revision_date_time(merged_rid, app.opts.date, app, dbw); - else - cert_revision_date_now(merged_rid, app, dbw); - if (app.opts.author().length() > 0) - cert_revision_author(merged_rid, app.opts.author(), app, dbw); - else - cert_revision_author_default(merged_rid, app, dbw); guard.commit(); } ============================================================ --- project.cc 50538ea67357a522ab5a74bfcefebe2f842de40d +++ project.cc d97bc10fd9ebe24fea6563717e975339765b1e35 @@ -5,14 +5,25 @@ #include "app_state.hh" #include "cert.hh" +#include "packet.hh" #include "project.hh" #include "revision.hh" #include "transforms.hh" +#include + + using std::set; using std::vector; +boost::posix_time::ptime time_from_time_t(time_t time) +{ + boost::gregorian::date the_epoch(1970, 1, 1); + boost::posix_time::seconds seconds(static_cast(time)); + return boost::posix_time::ptime(the_epoch, seconds); +} + project_t::project_t(app_state & app) : app(app) {} @@ -118,6 +129,15 @@ project_t::revision_is_in_branch(revisio return !certs.empty(); } +void +project_t::put_revision_in_branch(revision_id const & id, + utf8 const & branch, + packet_consumer & pc) +{ + cert_revision_in_branch(id, cert_value(branch()), app, pc); +} + + outdated_indicator project_t::get_revision_cert_hashes(revision_id const & id, std::vector > & hashes) @@ -209,3 +229,51 @@ project_t::get_tags(set & tags) } return i; } + +void +project_t::put_tag(revision_id const & id, + string const & name, + packet_consumer & pc) +{ + cert_revision_tag(id, name, app, pc); +} + + +void +project_t::put_standard_certs(revision_id const & id, + utf8 const & branch, + string const & changelog, + boost::posix_time::ptime const & time, + utf8 const & author, + packet_consumer & pc) +{ + 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); + if (!author().empty()) + cert_revision_author(id, author(), app, pc); + else + cert_revision_author_default(id, app, pc); +} + +void +project_t::put_standard_certs_from_options(revision_id const & id, + utf8 const & branch, + string const & changelog, + packet_consumer & pc) +{ + put_standard_certs(id, + branch, + changelog, + app.opts.date_given?app.opts.date:now(), + app.opts.author, + pc); +} +void +project_t::put_cert(revision_id const & id, + cert_name const & name, + cert_value const & value, + packet_consumer & pc) +{ + put_simple_revision_cert(id, name, value, app, pc); +} ============================================================ --- project.hh 4370fd8dda1fcc27de319de6d53388c648dce201 +++ project.hh 4ef8072510d9791ce001e03e641ab01f83f042c3 @@ -11,7 +11,11 @@ #include "outdated_indicator.hh" #include "vocab.hh" +#include + + class app_state; +class packet_consumer; class tag_t { @@ -23,6 +27,13 @@ bool operator < (tag_t const & a, tag_t }; bool operator < (tag_t const & a, tag_t const & b); +inline boost::posix_time::ptime now() +{ + return boost::posix_time::second_clock::universal_time(); +} + +boost::posix_time::ptime time_from_time_t(time_t time); + class project_t { app_state & app; @@ -38,8 +49,13 @@ public: void get_branch_heads(utf8 const & name, std::set & heads); outdated_indicator get_tags(std::set & tags); + void put_tag(revision_id const & id, string const & name, packet_consumer & pc); bool revision_is_in_branch(revision_id const & id, utf8 const & branch); + void put_revision_in_branch(revision_id const & id, + utf8 const & branch, + packet_consumer & pc); + outdated_indicator get_revision_cert_hashes(revision_id const & id, std::vector > & hashes); outdated_indicator get_revision_certs(revision_id const & id, @@ -51,6 +67,22 @@ public: std::set & branches); outdated_indicator get_branch_certs(utf8 const & branch, std::vector > & certs); + + void put_standard_certs(revision_id const & id, + utf8 const & branch, + string const & changelog, + boost::posix_time::ptime const & time, + utf8 const & author, + packet_consumer & pc); + void put_standard_certs_from_options(revision_id const & id, + utf8 const & branch, + string const & changelog, + packet_consumer & pc); + + void put_cert(revision_id const & id, + cert_name const & name, + cert_value const & value, + packet_consumer & pc); }; #endif ============================================================ --- rcs_import.cc 138e5d7da50a1726b2ba9737d0692041987671be +++ rcs_import.cc ec31df86841d31110bb1ac9e55face801ad7446f @@ -38,6 +38,7 @@ #include "packet.hh" #include "paths.hh" #include "platform-wrapped.hh" +#include "project.hh" #include "rcs_file.hh" #include "revision.hh" #include "safe_map.hh" @@ -1274,7 +1275,7 @@ import_cvs_repo(system_path const & cvsr { string tag = cvs.tag_interner.lookup(i->first); ui.set_tick_trailer("marking tag " + tag); - cert_revision_tag(i->second.second, tag, app, dbw); + app.project.put_tag(i->second.second, tag, dbw); ++n_tags; } guard.commit(); @@ -1386,10 +1387,12 @@ cluster_consumer::store_auxiliary_certs( } } - cert_revision_in_branch(p.rid, cert_value(branchname), app, dbw); - cert_revision_author(p.rid, cvs.author_interner.lookup(p.author), app, dbw); - cert_revision_changelog(p.rid, cvs.changelog_interner.lookup(p.changelog), app, dbw); - cert_revision_date_time(p.rid, p.time, app, dbw); + app.project.put_standard_certs(p.rid, + branchname, + cvs.changelog_interner.lookup(p.changelog), + time_from_time_t(p.time), + cvs.author_interner.lookup(p.author), + dbw); } void