# # # patch "README.encapsulation" # from [d63c17db209a20f78658c05b8603b3442e1e9f44] # to [effe875fa4dde44dedfcc89434df5f56333690d8] # # patch "annotate.cc" # from [5b24ddee7d5cb461f3697a6ea2717f995298f268] # to [592ed7bc428468ecf3d9ba80188b416b42c9d168] # # patch "annotate.hh" # from [0f72356a416fc60ea888a71d59dc55d391d272dd] # to [bb1f437d65a043cb2aa763835632551d7041fbb3] # # patch "automate.cc" # from [0a6a4f9410e74cf608a272948dc110b56a903d5e] # to [267419c83457db95e512cf5288ef4983759884cf] # # patch "cert.cc" # from [200f1c04f4b359ae1640ea2e1c66b666319de40b] # to [22c2196e794574ca0da8d7e00aef73b431773b82] # # patch "cert.hh" # from [5e4120f4f615b11a298cea86dfee0e27c4a32b67] # to [a6ff0e38c31434662f9eeeda958d2d8921beceb6] # # patch "cmd.hh" # from [5c6809b9a65951b6e69d3bb80ff2d6d42781c511] # to [a8110165eb56760ccba3f7d90c96f9b51d1129bd] # # patch "cmd_db.cc" # from [f0b71653f074699006a36446e744966d68a65b4b] # to [2924b40e2a9a6b4065a47639253249e30f7174a9] # # patch "cmd_diff_log.cc" # from [489b808e2b1944053769838376b50c4ee6377c72] # to [f4ac10d6cef7225e8977e1a3a75cfd811709d4c2] # # patch "cmd_files.cc" # from [17de5623905f507598b21286d65d96870096e086] # to [af49f7e6f0d8ccc50a5ff9717d7bb9f1b329587b] # # patch "cmd_key_cert.cc" # from [543558de324168a743c957aba995dac76b185b13] # to [722d39318846376c6df7c9ee00ef9526e8675b5a] # # patch "cmd_list.cc" # from [187e20a29daae3301b12ff85f217743d3f713444] # to [744b63656850bc2337d009044053fc80872c3849] # # patch "cmd_merging.cc" # from [b7558ceaad02dad729e56876b3df0952a587e4ad] # to [2fad601cedd05771feaa79e4e4a92aa876e470c3] # # patch "cmd_netsync.cc" # from [4f08638b197e1ffecf48f3241f261b83db89d1a0] # to [842310ca1ba1f2c840158f5047eee6bbc57322ea] # # patch "cmd_ws_commit.cc" # from [f11a3f1a5a4514f555f694ad8a6900d22a74ea5d] # to [7bc0f28aa1439e4fde3514abd1e844c54c3c4409] # # patch "commands.cc" # from [41d9e2d279050a7395f6521c48d6d4069dc6d7e4] # to [4dfc2850b357792750c9dcccf42ae2f3d672ef0c] # # patch "database.cc" # from [47aae9a254bc67828dceb1bc9be193d3f5532af8] # to [2aa1b86c0ba93f75e254e33b785a334f78ed0b4b] # # patch "database.hh" # from [92d2d29ac6ed71da95852b9eeea7603311596456] # to [30245ff17a9001e4a57e5a8100d5cb1238dbd26f] # # patch "netsync.cc" # from [f10df3d7b9ad02b7ef9e55fe8d0aca9219302ff4] # to [ff78d7fa7e234847134eac0d0c8bbfeee55cc560] # # patch "rcs_import.cc" # from [bda5c49ca2c4cfea9e2d04d7ff8f6ac6da320e84] # to [2e1fa18ef746b3f57ec102f045dd5284ba325cc6] # ============================================================ --- README.encapsulation d63c17db209a20f78658c05b8603b3442e1e9f44 +++ README.encapsulation effe875fa4dde44dedfcc89434df5f56333690d8 @@ -1,23 +1,8 @@ -annotate.cc: - - annotate_context::build_revisions_to_annotations(): - - # Why does this go via the project? It only calls - # db.get_revision_certs()... - app.get_project().get_revision_certs(*i, certs); - app.db.. - revision.cc: only a CMD(rev_height is left using the app_state -cert.cc: - guess_branch(): - app.opts.branch_given + app.opts.branchname - app.get_project().get_revision_branches() - - database.cc: __app is a member variable of class database, it's needed for the @@ -27,9 +12,7 @@ database.cc: test_migration_step() database::complete() - needs: __app->get_project().get_branch_list() needs: __app->require_workspace() - needs: __app->get_project().get_branch_heads() needs: __app->opts.branchname @@ -65,14 +48,12 @@ netsync.cc: app.db... app.opts.use_transport_auth app.opts.signing_key - app.get_project().get_branch_list() app.lua.hook_note_netsync_start session::process_anonymous_cmd(): app.db... app.opts.use_transport_auth app.opts.signing_key - app.get_project().get_branch_list() app.lua.hook_get_netsync_read_permitted needs: rebuild_merkle_trees() @@ -82,7 +63,6 @@ netsync.cc: app.lua.hook_note_netsync_start() app.lua.hook_get_netsync_read_permitted() app.lua.hook_get_netsync_write_permitted() - app.get_project().get_branch_list() needs: rebuild_merkle_trees() session::begin_service(): @@ -105,7 +85,6 @@ netsync.cc: session::rebuild_merkle_trees() (huh? takes another app_state, even if the session already has one?) - app.get_project().get_branch_certs() app.db... app.opts.keys_to_push() app.keys.key_pair_exists() ============================================================ --- annotate.cc 5b24ddee7d5cb461f3697a6ea2717f995298f268 +++ annotate.cc 592ed7bc428468ecf3d9ba80188b416b42c9d168 @@ -17,13 +17,14 @@ #include #include "annotate.hh" -#include "app_state.hh" #include "cert.hh" #include "constants.hh" #include "cset.hh" +#include "database.hh" #include "interner.hh" #include "lcs.hh" #include "platform.hh" +#include "project.hh" #include "revision.hh" #include "sanity.hh" #include "simplestring_xform.hh" @@ -74,7 +75,7 @@ public: /// return true if we have no more unassigned lines bool is_complete() const; - void dump(app_state & app, bool just_revs) const; + void dump(database & db, bool just_revs) const; string get_line(int line_index) const { @@ -82,7 +83,7 @@ private: } private: - void build_revisions_to_annotations(app_state & app, + void build_revisions_to_annotations(database & db, map & r2a) const; vector file_lines; @@ -371,7 +372,7 @@ annotate_context::build_revisions_to_ann void annotate_context::build_revisions_to_annotations -(app_state & app, +(database & db, map & revs_to_notations) const { I(annotations.size() == file_lines.size()); @@ -391,8 +392,8 @@ annotate_context::build_revisions_to_ann i != seen.end(); i++) { vector< revision > certs; - app.get_project().get_revision_certs(*i, certs); - erase_bogus_certs(certs, app.db); + db.get_project().get_revision_certs(*i, certs); + erase_bogus_certs(certs, db); string author(cert_string_value(certs, author_cert_name, true, false, "@< ")); @@ -424,7 +425,7 @@ void } void -annotate_context::dump(app_state & app, bool just_revs) const +annotate_context::dump(database & db, bool just_revs) const { revision_id nullid; I(annotations.size() == file_lines.size()); @@ -433,7 +434,7 @@ annotate_context::dump(app_state & app, string empty_note; if (!just_revs) { - build_revisions_to_annotations(app, revs_to_notations); + build_revisions_to_annotations(db, revs_to_notations); size_t max_note_length = revs_to_notations.begin()->second.size(); empty_note.insert(string::size_type(0), max_note_length - 2, ' '); } @@ -815,13 +816,13 @@ void } void -do_annotate (app_state &app, file_t file_node, revision_id rid, bool just_revs) +do_annotate (database & db, file_t file_node, revision_id rid, bool just_revs) { L(FL("annotating file %s with content %s in revision %s") % file_node->self % file_node->content % rid); shared_ptr - acp(new annotate_context(file_node->content, app.db)); + acp(new annotate_context(file_node->content, db)); shared_ptr lineage = acp->initial_lineage(); @@ -830,13 +831,13 @@ do_annotate (app_state &app, file_t file { // prepare the first work_unit rev_height height; - app.db.get_rev_height(rid, height); + db.get_rev_height(rid, height); set rids_interesting_ancestors; - get_file_content_marks(app.db, rid, file_node->self, rids_interesting_ancestors); + get_file_content_marks(db, rid, file_node->self, rids_interesting_ancestors); bool rid_marked = (rids_interesting_ancestors.size() == 1 && *(rids_interesting_ancestors.begin()) == rid); if (rid_marked) - app.db.get_revision_parents(rid, rids_interesting_ancestors); + db.get_revision_parents(rid, rids_interesting_ancestors); annotate_node_work workunit(acp, lineage, rid, file_node->self, height, rids_interesting_ancestors, file_node->content, rid_marked); @@ -854,13 +855,13 @@ do_annotate (app_state &app, file_t file annotate_node_work work = *w; work_units.erase(w); - do_annotate_node(work, app.db, work_units); + do_annotate_node(work, db, work_units); } acp->annotate_equivalent_lines(); I(acp->is_complete()); - acp->dump(app, just_revs); + acp->dump(db, just_revs); } // Local Variables: ============================================================ --- annotate.hh 0f72356a416fc60ea888a71d59dc55d391d272dd +++ annotate.hh bb1f437d65a043cb2aa763835632551d7041fbb3 @@ -12,10 +12,10 @@ #include "vocab.hh" #include "roster.hh" -class app_state; +class database; void -do_annotate(app_state &app, file_t file_node, revision_id rid, bool just_revs); +do_annotate(database & db, file_t file_node, revision_id rid, bool just_revs); // Local Variables: // mode: C++ ============================================================ --- automate.cc 0a6a4f9410e74cf608a272948dc110b56a903d5e +++ automate.cc 267419c83457db95e512cf5288ef4983759884cf @@ -71,7 +71,7 @@ AUTOMATE(heads, N_("[BRANCH]"), options: app.opts.branchname = branch_name(idx(args, 0)()); } set heads; - app.get_project().get_branch_heads(app.opts.branchname, heads); + app.db.get_project().get_branch_heads(app.opts.branchname, heads); for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) output << (*i).inner()() << '\n'; } @@ -1124,7 +1124,7 @@ AUTOMATE(packets_for_certs, N_("REVID"), N(app.db.revision_exists(r_id), F("no such revision '%s'") % r_id); - app.get_project().get_revision_certs(r_id, certs); + app.db.get_project().get_revision_certs(r_id, certs); for (size_t i = 0; i < certs.size(); ++i) pw.consume_revision_cert(idx(certs,i)); } @@ -1270,7 +1270,7 @@ AUTOMATE(branches, "", options::opts::no set names; - app.get_project().get_branch_list(names); + app.db.get_project().get_branch_list(names); for (set::const_iterator i = names.begin(); i != names.end(); ++i) @@ -1332,13 +1332,13 @@ AUTOMATE(tags, N_("[BRANCH_PATTERN]"), o prt.print_stanza(stz); set tags; - app.get_project().get_tags(tags); + app.db.get_project().get_tags(tags); for (set::const_iterator tag = tags.begin(); tag != tags.end(); ++tag) { set branches; - app.get_project().get_revision_branches(tag->ident, branches); + app.db.get_project().get_revision_branches(tag->ident, branches); bool show(!filtering); vector branch_names; ============================================================ --- cert.cc 200f1c04f4b359ae1640ea2e1c66b666319de40b +++ cert.cc 22c2196e794574ca0da8d7e00aef73b431773b82 @@ -17,13 +17,15 @@ #include #include -#include "app_state.hh" #include "cert.hh" #include "constants.hh" +#include "database.hh" #include "interner.hh" #include "keys.hh" +#include "key_store.hh" #include "netio.hh" #include "option.hh" +#include "project.hh" #include "revision.hh" #include "sanity.hh" #include "simplestring_xform.hh" @@ -467,10 +469,11 @@ void // APP may override. Branch name is returned in BRANCHNAME. // Does not modify branch state in APP. void -guess_branch(revision_id const & ident, app_state & app, branch_name & branchname) +guess_branch(revision_id const & ident, database & db, + branch_name & branchname) { - if (app.opts.branch_given && !app.opts.branchname().empty()) - branchname = app.opts.branchname; + if (db.has_opt_branch() && !db.get_opt_branchname()().empty()) + branchname = db.get_opt_branchname(); else { N(!ident.inner()().empty(), @@ -478,7 +481,7 @@ guess_branch(revision_id const & ident, "please provide a branch name")); set branches; - app.get_project().get_revision_branches(ident, branches); + db.get_project().get_revision_branches(ident, branches); N(branches.size() != 0, F("no branch certs found for revision %s, " @@ -496,11 +499,11 @@ void // As above, but set the branch name in the app state. void -guess_branch(revision_id const & ident, app_state & app) +guess_branch(revision_id const & ident, database & db) { branch_name branchname; - guess_branch(ident, app, branchname); - app.opts.branchname = branchname; + guess_branch(ident, db, branchname); + db.set_opt_branchname(branchname); } void ============================================================ --- cert.hh 5e4120f4f615b11a298cea86dfee0e27c4a32b67 +++ cert.hh a6ff0e38c31434662f9eeeda958d2d8921beceb6 @@ -23,7 +23,6 @@ // about revisions, using certs, without needing anyone's special // permission. -class app_state; class key_store; class database; @@ -108,9 +107,9 @@ void get_user_key(rsa_keypair_id & key, key_store & keys); void -guess_branch(revision_id const & id, app_state & app, branch_name & branchname); +guess_branch(revision_id const & id, database & db, branch_name & branchname); void -guess_branch(revision_id const & id, app_state & app); +guess_branch(revision_id const & id, database & db); #define date_cert_name cert_name("date") #define author_cert_name cert_name("author") ============================================================ --- cmd.hh 5c6809b9a65951b6e69d3bb80ff2d6d42781c511 +++ cmd.hh a8110165eb56760ccba3f7d90c96f9b51d1129bd @@ -15,6 +15,7 @@ class app_state; #include "sanity.hh" class app_state; +class database; namespace commands { @@ -68,23 +69,23 @@ std::string } std::string -describe_revision(app_state & app, +describe_revision(database & db, revision_id const & id); void -complete(app_state & app, +complete(database & db, std::string const & str, revision_id & completion, bool must_exist=true); void -complete(app_state & app, +complete(database & db, std::string const & str, std::set & completion, bool must_exist=true); void -notify_if_multiple_heads(app_state & app); +notify_if_multiple_heads(database & db); void process_commit_message_args(bool & given, ============================================================ --- cmd_db.cc f0b71653f074699006a36446e744966d68a65b4b +++ cmd_db.cc 2924b40e2a9a6b4065a47639253249e30f7174a9 @@ -32,7 +32,7 @@ kill_rev_locally(app_state& app, string kill_rev_locally(app_state& app, string const& id) { revision_id ident; - complete(app, id, ident); + complete(app.db, id, ident); N(app.db.revision_exists(ident), F("no such revision '%s'") % ident); @@ -174,7 +174,7 @@ CMD(complete, N_("informative"), N_("(re i != completions.end(); ++i) { if (!verbose) cout << i->inner()() << '\n'; - else cout << describe_revision(app, *i) << '\n'; + else cout << describe_revision(app.db, *i) << '\n'; } } else if (idx(args, 0)() == "file") ============================================================ --- cmd_diff_log.cc 489b808e2b1944053769838376b50c4ee6377c72 +++ cmd_diff_log.cc f4ac10d6cef7225e8977e1a3a75cfd811709d4c2 @@ -391,7 +391,7 @@ prepare_diff(cset & included, roster_t new_roster, old_roster; revision_id r_old_id; - complete(app, idx(app.opts.revision_selectors, 0)(), r_old_id); + complete(app.db, idx(app.opts.revision_selectors, 0)(), r_old_id); N(app.db.revision_exists(r_old_id), F("no such revision '%s'") % r_old_id); @@ -416,8 +416,8 @@ prepare_diff(cset & included, roster_t new_roster, old_roster; revision_id r_old_id, r_new_id; - complete(app, idx(app.opts.revision_selectors, 0)(), r_old_id); - complete(app, idx(app.opts.revision_selectors, 1)(), r_new_id); + complete(app.db, idx(app.opts.revision_selectors, 0)(), r_old_id); + complete(app.db, idx(app.opts.revision_selectors, 1)(), r_new_id); N(app.db.revision_exists(r_old_id), F("no such revision '%s'") % r_old_id); @@ -636,7 +636,7 @@ CMD(log, N_("informative"), N_("[FILE] . i != app.opts.from.end(); i++) { set rids; - complete(app, (*i)(), rids); + complete(app.db, (*i)(), rids); for (set::const_iterator j = rids.begin(); j != rids.end(); ++j) { @@ -691,7 +691,7 @@ CMD(log, N_("informative"), N_("[FILE] . { MM(*i); set rids; - complete(app, (*i)(), rids); + complete(app.db, (*i)(), rids); for (set::const_iterator j = rids.begin(); j != rids.end(); ++j) { ============================================================ --- cmd_files.cc 17de5623905f507598b21286d65d96870096e086 +++ cmd_files.cc af49f7e6f0d8ccc50a5ff9717d7bb9f1b329587b @@ -161,7 +161,7 @@ CMD(annotate, N_("informative"), N_("PAT } else { - complete(app, idx(app.opts.revision_selectors, 0)(), rid); + complete(app.db, idx(app.opts.revision_selectors, 0)(), rid); N(!null_id(rid), F("no revision for file '%s' in database") % file); N(app.db.revision_exists(rid), @@ -179,7 +179,7 @@ CMD(annotate, N_("informative"), N_("PAT file_t file_node = downcast_to_file_t(node); L(FL("annotate for file_id %s") % file_node->self); - do_annotate(app, file_node, rid, app.opts.brief); + do_annotate(app.db, file_node, rid, app.opts.brief); } CMD(identify, N_("debug"), N_("[PATH]"), @@ -264,7 +264,7 @@ CMD(cat, N_("informative"), rid = parent_id(parents.begin()); } else - complete(app, idx(app.opts.revision_selectors, 0)(), rid); + complete(app.db, idx(app.opts.revision_selectors, 0)(), rid); dump_file(cout, app, rid, idx(args, 0)); } @@ -319,7 +319,7 @@ AUTOMATE(get_file_of, N_("FILENAME"), op rid = parent_id(parents.begin()); } else - complete(app, idx(app.opts.revision_selectors, 0)(), rid); + complete(app.db, idx(app.opts.revision_selectors, 0)(), rid); dump_file(output, app, rid, idx(args, 0)); } ============================================================ --- cmd_key_cert.cc 543558de324168a743c957aba995dac76b185b13 +++ cmd_key_cert.cc 722d39318846376c6df7c9ee00ef9526e8675b5a @@ -180,7 +180,7 @@ CMD(cert, N_("key and cert"), N_("REVISI transaction_guard guard(app.db); revision_id rid; - complete(app, idx(args, 0)(), rid); + complete(app.db, idx(args, 0)(), rid); cert_name name; internalize_cert_name(idx(args, 1), name); @@ -212,7 +212,7 @@ CMD(trusted, N_("key and cert"), throw usage(name); revision_id rid; - complete(app, idx(args, 0)(), rid, false); + complete(app.db, idx(args, 0)(), rid, false); hexenc ident(rid.inner()); cert_name name; @@ -257,7 +257,7 @@ CMD(tag, N_("review"), N_("REVISION TAGN throw usage(name); revision_id r; - complete(app, idx(args, 0)(), r); + complete(app.db, idx(args, 0)(), r); cert_revision_tag(r, idx(args, 1)(), app.db); } @@ -269,7 +269,7 @@ CMD(testresult, N_("review"), N_("ID (pa throw usage(name); revision_id r; - complete(app, idx(args, 0)(), r); + complete(app.db, idx(args, 0)(), r); cert_revision_testresult(r, idx(args, 1)(), app.db); } @@ -282,8 +282,8 @@ CMD(approve, N_("review"), N_("REVISION" throw usage(name); revision_id r; - complete(app, idx(args, 0)(), r); - guess_branch(r, app); + complete(app.db, idx(args, 0)(), r); + guess_branch(r, app.db); N(app.opts.branchname() != "", F("need --branch argument for approval")); app.get_project().put_revision_in_branch(r, app.opts.branchname); } @@ -309,7 +309,7 @@ CMD(comment, N_("review"), N_("REVISION F("empty comment")); revision_id r; - complete(app, idx(args, 0)(), r); + complete(app.db, idx(args, 0)(), r); cert_revision_comment(r, comment, app.db); } ============================================================ --- cmd_list.cc 187e20a29daae3301b12ff85f217743d3f713444 +++ cmd_list.cc 744b63656850bc2337d009044053fc80872c3849 @@ -50,7 +50,7 @@ ls_certs(string const & name, app_state transaction_guard guard(app.db, false); revision_id ident; - complete(app, idx(args, 0)(), ident); + complete(app.db, idx(args, 0)(), ident); vector< revision > ts; // FIXME_PROJECTS: after projects are implemented, // use the app.db version instead if no project is specified. ============================================================ --- cmd_merging.cc b7558ceaad02dad729e56876b3df0952a587e4ad +++ cmd_merging.cc 2fad601cedd05771feaa79e4e4a92aa876e470c3 @@ -171,7 +171,7 @@ CMD(update, N_("workspace"), "", P(F("multiple update candidates:")); for (set::const_iterator i = candidates.begin(); i != candidates.end(); ++i) - P(i18n_format(" %s") % describe_revision(app, *i)); + P(i18n_format(" %s") % describe_revision(app.db, *i)); P(F("choose one with '%s update -r'") % ui.prog_name); E(false, F("multiple update candidates remain after selection")); } @@ -179,7 +179,7 @@ CMD(update, N_("workspace"), "", } else { - complete(app, app.opts.revision_selectors[0](), chosen_rid); + complete(app.db, app.opts.revision_selectors[0](), chosen_rid); N(app.db.revision_exists(chosen_rid), F("no such revision '%s'") % chosen_rid); } @@ -188,7 +188,7 @@ CMD(update, N_("workspace"), "", // do this notification before checking to see if we can bail out early, // because when you are at one of several heads, and you hit update, you // want to know that merging would let you update further. - notify_if_multiple_heads(app); + notify_if_multiple_heads(app.db); if (old_rid == chosen_rid) { @@ -634,7 +634,7 @@ CMD(merge_into_workspace, N_("tree"), left = parent_cached_roster(parents.begin()); } - complete(app, idx(args, 0)(), right_id); + complete(app.db, idx(args, 0)(), right_id); app.db.get_roster(right_id, right); N(!(left_id == right_id), F("workspace is already at revision %s") % left_id); @@ -700,8 +700,8 @@ CMD(explicit_merge, N_("tree"), if (args.size() != 3) throw usage(name); - complete(app, idx(args, 0)(), left); - complete(app, idx(args, 1)(), right); + complete(app.db, idx(args, 0)(), left); + complete(app.db, idx(args, 1)(), right); branch = branch_name(idx(args, 2)()); N(!(left == right), @@ -722,8 +722,8 @@ CMD(show_conflicts, N_("informative"), N if (args.size() != 2) throw usage(name); revision_id l_id, r_id; - complete(app, idx(args,0)(), l_id); - complete(app, idx(args,1)(), r_id); + complete(app.db, idx(args,0)(), l_id); + complete(app.db, idx(args,1)(), r_id); N(!is_ancestor(l_id, r_id, app.db), F("%s is an ancestor of %s; no merge is needed.") % l_id % r_id); N(!is_ancestor(r_id, l_id, app.db), @@ -775,7 +775,7 @@ CMD(pluck, N_("workspace"), N_("[-r FROM if (app.opts.revision_selectors.size() == 1) { - complete(app, idx(app.opts.revision_selectors, 0)(), to_rid); + complete(app.db, idx(app.opts.revision_selectors, 0)(), to_rid); N(app.db.revision_exists(to_rid), F("no such revision '%s'") % to_rid); std::set parents; @@ -790,10 +790,10 @@ CMD(pluck, N_("workspace"), N_("[-r FROM } else if (app.opts.revision_selectors.size() == 2) { - complete(app, idx(app.opts.revision_selectors, 0)(), from_rid); + complete(app.db, idx(app.opts.revision_selectors, 0)(), from_rid); N(app.db.revision_exists(from_rid), F("no such revision '%s'") % from_rid); - complete(app, idx(app.opts.revision_selectors, 1)(), to_rid); + complete(app.db, idx(app.opts.revision_selectors, 1)(), to_rid); N(app.db.revision_exists(to_rid), F("no such revision '%s'") % to_rid); } @@ -945,7 +945,7 @@ CMD(heads, N_("tree"), "", N_("show unme for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - cout << describe_revision(app, *i) << '\n'; + cout << describe_revision(app.db, *i) << '\n'; } CMD(get_roster, N_("debug"), N_("[REVID]"), @@ -1006,7 +1006,7 @@ CMD(get_roster, N_("debug"), N_("[REVID] else if (args.size() == 1) { revision_id rid; - complete(app, idx(args, 0)(), rid); + complete(app.db, idx(args, 0)(), rid); I(!null_id(rid)); app.db.get_roster(rid, roster, mm); } ============================================================ --- cmd_netsync.cc 4f08638b197e1ffecf48f3241f261b83db89d1a0 +++ cmd_netsync.cc 842310ca1ba1f2c840158f5047eee6bbc57322ea @@ -302,7 +302,7 @@ CMD(clone, N_("network"), N_("ADDRESS[:P { P(F("branch %s has multiple heads:") % app.opts.branchname); for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - P(i18n_format(" %s") % describe_revision(app, *i)); + P(i18n_format(" %s") % describe_revision(app.db, *i)); P(F("choose one with '%s checkout -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.opts.branchname); } @@ -311,11 +311,11 @@ CMD(clone, N_("network"), N_("ADDRESS[:P else if (app.opts.revision_selectors.size() == 1) { // use specified revision - complete(app, idx(app.opts.revision_selectors, 0)(), ident); + complete(app.db, idx(app.opts.revision_selectors, 0)(), ident); N(app.db.revision_exists(ident), F("no such revision '%s'") % ident); - guess_branch(ident, app); + guess_branch(ident, app.db); I(!app.opts.branchname().empty()); ============================================================ --- cmd_ws_commit.cc f11a3f1a5a4514f555f694ad8a6900d22a74ea5d +++ cmd_ws_commit.cc 7bc0f28aa1439e4fde3514abd1e844c54c3c4409 @@ -221,13 +221,13 @@ CMD(disapprove, N_("review"), N_("REVISI revision_id r; revision_t rev, rev_inverse; shared_ptr cs_inverse(new cset()); - complete(app, idx(args, 0)(), r); + complete(app.db, idx(args, 0)(), r); app.db.get_revision(r, rev); N(rev.edges.size() == 1, F("revision %s has %d changesets, cannot invert") % r % rev.edges.size()); - guess_branch(r, app); + guess_branch(r, app.db); N(app.opts.branchname() != "", F("need --branch argument for disapproval")); process_commit_message_args(log_message_given, log_message, app, @@ -513,7 +513,7 @@ CMD(checkout, N_("tree"), N_("[DIRECTORY { P(F("branch %s has multiple heads:") % app.opts.branchname); for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - P(i18n_format(" %s") % describe_revision(app, *i)); + P(i18n_format(" %s") % describe_revision(app.db, *i)); P(F("choose one with '%s checkout -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.opts.branchname); } @@ -522,11 +522,11 @@ CMD(checkout, N_("tree"), N_("[DIRECTORY else if (app.opts.revision_selectors.size() == 1) { // use specified revision - complete(app, idx(app.opts.revision_selectors, 0)(), ident); + complete(app.db, idx(app.opts.revision_selectors, 0)(), ident); N(app.db.revision_exists(ident), F("no such revision '%s'") % ident); - guess_branch(ident, app); + guess_branch(ident, app.db); I(!app.opts.branchname().empty()); @@ -743,7 +743,7 @@ CMD(commit, N_("workspace"), N_("[PATH]. i++) { // this will prefer --branch if it was set - guess_branch(edge_old_revision(i), app, bn_candidate); + guess_branch(edge_old_revision(i), app.db, bn_candidate); N(branchname() == "" || branchname == bn_candidate, F("parent revisions of this commit are in different branches:\n" "'%s' and '%s'.\n" @@ -982,11 +982,11 @@ CMD_NO_WORKSPACE(import, N_("tree"), N_( if (app.opts.revision_selectors.size() == 1) { // use specified revision - complete(app, idx(app.opts.revision_selectors, 0)(), ident); + complete(app.db, idx(app.opts.revision_selectors, 0)(), ident); N(app.db.revision_exists(ident), F("no such revision '%s'") % ident); - guess_branch(ident, app); + guess_branch(ident, app.db); I(!app.opts.branchname().empty()); @@ -1006,7 +1006,7 @@ CMD_NO_WORKSPACE(import, N_("tree"), N_( { P(F("branch %s has multiple heads:") % app.opts.branchname); for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - P(i18n_format(" %s") % describe_revision(app, *i)); + P(i18n_format(" %s") % describe_revision(app.db, *i)); P(F("choose one with '%s checkout -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.opts.branchname); } ============================================================ --- commands.cc 41d9e2d279050a7395f6521c48d6d4069dc6d7e4 +++ commands.cc 4dfc2850b357792750c9dcccf42ae2f3d672ef0c @@ -352,7 +352,7 @@ string } string -describe_revision(app_state & app, +describe_revision(database & db, revision_id const & id) { cert_name author_name(author_cert_name); @@ -364,7 +364,7 @@ describe_revision(app_state & app, // append authors and date of this revision vector< revision > tmp; - app.get_project().get_revision_certs_by_name(id, author_name, tmp); + db.get_project().get_revision_certs_by_name(id, author_name, tmp); for (vector< revision >::const_iterator i = tmp.begin(); i != tmp.end(); ++i) { @@ -373,7 +373,7 @@ describe_revision(app_state & app, description += " "; description += tv(); } - app.get_project().get_revision_certs_by_name(id, date_name, tmp); + db.get_project().get_revision_certs_by_name(id, date_name, tmp); for (vector< revision >::const_iterator i = tmp.begin(); i != tmp.end(); ++i) { @@ -388,7 +388,7 @@ void void -complete(app_state & app, +complete(database & db, string const & str, set & completion, bool must_exist) @@ -403,20 +403,20 @@ complete(app_state & app, { completion.insert(revision_id(hexenc(id(str)))); if (must_exist) - N(app.db.revision_exists(*completion.begin()), + N(db.revision_exists(*completion.begin()), F("no such revision '%s'") % *completion.begin()); return; } vector > - sels(selectors::parse_selector(str, app.db)); + sels(selectors::parse_selector(str, db)); P(F("expanding selection '%s'") % str); // we jam through an "empty" selection on sel_ident type set completions; selectors::selector_type ty = selectors::sel_ident; - selectors::complete_selector("", sels, ty, completions, app.db); + selectors::complete_selector("", sels, ty, completions, db); N(completions.size() != 0, F("no match for selection '%s'") % str); @@ -432,21 +432,21 @@ void void -complete(app_state & app, +complete(database & db, string const & str, revision_id & completion, bool must_exist) { set completions; - complete(app, str, completions, must_exist); + complete(db, str, completions, must_exist); if (completions.size() > 1) { string err = (F("selection '%s' has multiple ambiguous expansions:") % str).str(); for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) - err += ("\n" + describe_revision(app, *i)); + err += ("\n" + describe_revision(db, *i)); N(completions.size() == 1, i18n_format(err)); } @@ -454,17 +454,17 @@ void } void -notify_if_multiple_heads(app_state & app) +notify_if_multiple_heads(database & db) { set heads; - app.get_project().get_branch_heads(app.opts.branchname, heads); + db.get_project().get_branch_heads(db.get_opt_branchname(), heads); if (heads.size() > 1) { string prefixedline; prefix_lines_with(_("note: "), _("branch '%s' has multiple heads\n" "perhaps consider '%s merge'"), prefixedline); - P(i18n_format(prefixedline) % app.opts.branchname % ui.prog_name); + P(i18n_format(prefixedline) % db.get_opt_branchname() % ui.prog_name); } } ============================================================ --- database.cc 47aae9a254bc67828dceb1bc9be193d3f5532af8 +++ database.cc 2aa1b86c0ba93f75e254e33b785a334f78ed0b4b @@ -3440,6 +3440,12 @@ database::get_key_store() return __app->keys; } +project_t & +database::get_project() +{ + return __app->get_project(); +} + bool database::must_drop_attr(string const & key) { @@ -3462,7 +3468,26 @@ database::get_opt_date_or_cur_date() return date_t::now(); } +bool +database::has_opt_branch() +{ + return __app->opts.branch_given; +} +branch_name const & +database::get_opt_branchname() +{ + return __app->opts.branchname; +} + +void +database::set_opt_branchname(branch_name const & branchname) +{ + __app->opts.branchname = branchname; +} + + + // transaction guards transaction_guard::transaction_guard(database & d, bool exclusive, ============================================================ --- database.hh 92d2d29ac6ed71da95852b9eeea7603311596456 +++ database.hh 30245ff17a9001e4a57e5a8100d5cb1238dbd26f @@ -78,6 +78,7 @@ struct date_t; struct query; class rev_height; struct date_t; +struct project_t; class database { @@ -604,8 +605,12 @@ public: utf8 const & get_opt_author(); date_t const get_opt_date_or_cur_date(); + bool has_opt_branch(); + branch_name const & get_opt_branchname(); + void set_opt_branchname(branch_name const & branchname); key_store & get_key_store(); + project_t & get_project(); }; // Parent maps are used in a number of places to keep track of all the ============================================================ --- netsync.cc f10df3d7b9ad02b7ef9e55fe8d0aca9219302ff4 +++ netsync.cc ff78d7fa7e234847134eac0d0c8bbfeee55cc560 @@ -1304,7 +1304,7 @@ session::process_hello_cmd(rsa_keypair_i // clients always include in the synchronization set, every branch that the // user requested set all_branches, ok_branches; - app.get_project().get_branch_list(all_branches); + app.db.get_project().get_branch_list(all_branches); for (set::const_iterator i = all_branches.begin(); i != all_branches.end(); i++) { @@ -1397,7 +1397,7 @@ session::process_anonymous_cmd(protocol_ } set all_branches, ok_branches; - app.get_project().get_branch_list(all_branches); + app.db.get_project().get_branch_list(all_branches); globish_matcher their_matcher(their_include_pattern, their_exclude_pattern); for (set::const_iterator i = all_branches.begin(); i != all_branches.end(); i++) @@ -1530,7 +1530,7 @@ session::process_auth_cmd(protocol_role } set all_branches, ok_branches; - app.get_project().get_branch_list(all_branches); + app.db.get_project().get_branch_list(all_branches); for (set::const_iterator i = all_branches.begin(); i != all_branches.end(); i++) { @@ -3036,7 +3036,7 @@ session::rebuild_merkle_trees(app_state // FIXME_PROJECTS: probably something like // app.get_project(i->project).get_branch_certs(i->branch) // or so. - app.get_project().get_branch_certs(*i, certs); + app.db.get_project().get_branch_certs(*i, certs); for (vector< revision >::const_iterator j = certs.begin(); j != certs.end(); j++) { ============================================================ --- rcs_import.cc bda5c49ca2c4cfea9e2d04d7ff8f6ac6da320e84 +++ rcs_import.cc 2e1fa18ef746b3f57ec102f045dd5284ba325cc6 @@ -1267,7 +1267,7 @@ import_cvs_repo(system_path const & cvsr { string tag = cvs.tag_interner.lookup(i->first); ui.set_tick_trailer("marking tag " + tag); - app.get_project().put_tag(i->second.second, tag); + app.db.get_project().put_tag(i->second.second, tag); ++n_tags; } guard.commit(); @@ -1372,11 +1372,11 @@ cluster_consumer::store_auxiliary_certs( } } - app.get_project().put_standard_certs(p.rid, - branch_name(branchname), - utf8(cvs.changelog_interner.lookup(p.changelog)), - date_t::from_unix_epoch(p.time), - utf8(cvs.author_interner.lookup(p.author))); + app.db.get_project().put_standard_certs(p.rid, + branch_name(branchname), + utf8(cvs.changelog_interner.lookup(p.changelog)), + date_t::from_unix_epoch(p.time), + utf8(cvs.author_interner.lookup(p.author))); } void