# # # patch "app_state.cc" # from [6bdc0540bb924f98d4e366d0f58f9f95c3e4e4b6] # to [54d9cbe0fd6fbfd4e57ed2e0d2f44bc8b92d2327] # # patch "app_state.hh" # from [e2fa5664051153ade6613f6b6b6f805ef58e2f3f] # to [ca922427ce050a2447701d0c7a82d2cc1dc3d23a] # # patch "automate.cc" # from [84df2e648eb1da3c631f59838fc698189cfb59c7] # to [0db707d4a2b1cc0d326c0792942ae7d5fa626bf0] # # patch "cmd_db.cc" # from [2675e7d8c564ad00fe6d723220acda3b459e4053] # to [a3c511e4cd56d7008155b2c7ea3a4abbfb5207bc] # # patch "cmd_diff_log.cc" # from [37997a5ae177947a4779dc0943726cfebcf0244d] # to [52874bb4df3773c05b53845c8fb50a6397ef3780] # # patch "cmd_files.cc" # from [9ec49f7fd284b014e45e3d3a6054fb4e5ff5b69c] # to [a02b157191ced4630775f0277c26d0e1fbc7c8fb] # # patch "cmd_key_cert.cc" # from [aa0f5995c59032ece0b1ef08acceb51cf4805bde] # to [da995dfc1780f1c4dd6b784ad38ec15a3ecdfa7f] # # patch "cmd_list.cc" # from [a2bf9563613a3aa450b88c29c7228dc2a081f0f0] # to [e140d31952aceb944bbf1a7cbb2f1868ef37514c] # # patch "cmd_merging.cc" # from [329003be23836608a6aad5b8d4479b9c9151e1ca] # to [dae18e35f109905c756e58b8d57c618abaea33e4] # # patch "cmd_netsync.cc" # from [03efee47f588f807007fc1b739d3e1757d2f824b] # to [5579b418d434f397bb517d457681b9eef5451945] # # patch "cmd_othervcs.cc" # from [cad7815967cfa329240476b4264b130912ed8f8d] # to [18f7a7e0ea334d2ff87f461aae8e01f9a778ae76] # # patch "cmd_ws_commit.cc" # from [fcf629639ef904647cb2017e0bd0fe708547851f] # to [e0d1caadfb10955ff6542f86a316bab9a3a70f39] # # patch "lua_hooks.cc" # from [86789686badb6b6104b6753fad7771de9e1c5143] # to [3415778e6c1698847b812b2ad3668e99815c0b91] # # patch "lua_hooks.hh" # from [78afa0b15cb8c96d5569a6d8070111bb588211bb] # to [45e10cd249bab5abd27bf093cf594de14f819607] # # patch "luaext_platform.cc" # from [8fdc0fafb4bd0c497865778b8f9e951a21293376] # to [fa002ab89da3092cb605808772a851049b307b2b] # # patch "project.cc" # from [89c5235c7b7693cdf954b16d594b123fffb970a6] # to [56f1dc381dc621eb41d1d45414f65102667b0742] # # patch "project.hh" # from [a869324a08efe4894c084eb0d6d30d55ef76b7b1] # to [c20d9905b9dae288c4db7641ba9b122df6a24260] # # patch "selectors.cc" # from [363089ff77762398f45398abe931605d142ac06a] # to [20ec3496f3cc8dc085fba0389fbea059c3569e2d] # # patch "std_hooks.lua" # from [432725fc36dde06af213797306121385491fda0c] # to [970a89588a7092507e8c80e8c8f80f0a5b1f12a1] # # patch "tester.cc" # from [c4ddb0b7774c9b6a2a7a97b4fe0cfd65b712bb90] # to [c9338c104c3cadb19e9ff9e6b51e7726eae4a526] # ============================================================ --- app_state.cc 6bdc0540bb924f98d4e366d0f58f9f95c3e4e4b6 +++ app_state.cc 54d9cbe0fd6fbfd4e57ed2e0d2f44bc8b92d2327 @@ -30,6 +30,7 @@ app_state::app_state() app_state::app_state() : db(lua), keys(*this), work(lua), + projects(db), branch_is_sticky(false), mtn_automate_allowed(false) { @@ -58,6 +59,8 @@ app_state::allow_workspace() global_sanity.set_dump_path(system_path(dump_path, false).as_external()); } load_rcfiles(); + + projects.initialize(lua); } void @@ -209,19 +212,6 @@ app_state::make_branch_sticky() } } -project_set & -app_state::get_projects() -{ - // You can't use this until system_path is available, - // which means we need to have the workspace already. - // Need to teach our lua to read directories... - if (!projects) - { - projects.reset(new project_set(db, lua)); - } - return *projects; -} - // rc files are loaded after we've changed to the workspace so that // _MTN/monotonerc can be loaded between ~/.monotone/monotonerc and other // rcfiles. ============================================================ --- app_state.hh e2fa5664051153ade6613f6b6b6f805ef58e2f3f +++ app_state.hh ca922427ce050a2447701d0c7a82d2cc1dc3d23a @@ -38,6 +38,7 @@ public: key_store keys; workspace work; ssh_agent agent; + project_set projects; options opts; @@ -59,11 +60,6 @@ public: void make_branch_sticky(); -private: - boost::shared_ptr projects; -public: - project_set & get_projects(); - void set_database(system_path const & filename); void set_key_dir(system_path const & filename); void set_diff_format(diff_type dtype); ============================================================ --- automate.cc 84df2e648eb1da3c631f59838fc698189cfb59c7 +++ automate.cc 0db707d4a2b1cc0d326c0792942ae7d5fa626bf0 @@ -87,7 +87,7 @@ CMD_AUTOMATE(heads, N_("[BRANCH]"), branch_option = branch_name(idx(args, 0)()); } set heads; - app.get_projects() + app.projects .get_project_of_branch(branch_option) .get_branch_heads(branch_option, heads, app.opts.ignore_suspend_certs); @@ -1423,7 +1423,7 @@ CMD_AUTOMATE(packets_for_certs, N_("REVI N(db.revision_exists(r_id), F("no such revision '%s'") % r_id); - app.get_projects().get_revision_certs(r_id, certs); + app.projects.get_revision_certs(r_id, certs); for (size_t i = 0; i < certs.size(); ++i) pw.consume_revision_cert(idx(certs,i)); } @@ -1590,7 +1590,7 @@ CMD_AUTOMATE(branches, "", set names; - app.get_projects().get_branch_list(names, + app.projects.get_branch_list(names, !app.opts.ignore_suspend_certs); for (set::const_iterator i = names.begin(); @@ -1658,13 +1658,13 @@ CMD_AUTOMATE(tags, N_("[BRANCH_PATTERN]" prt.print_stanza(stz); set tags; - app.get_projects().get_tags(tags); + app.projects.get_tags(tags); for (set::const_iterator tag = tags.begin(); tag != tags.end(); ++tag) { set branches; - app.get_projects().get_revision_branches(tag->ident, branches); + app.projects.get_revision_branches(tag->ident, branches); bool show(!filtering); vector branch_names; ============================================================ --- cmd_db.cc 2675e7d8c564ad00fe6d723220acda3b459e4053 +++ cmd_db.cc a3c511e4cd56d7008155b2c7ea3a4abbfb5207bc @@ -273,7 +273,7 @@ CMD_HIDDEN(clear_epoch, "clear_epoch", " throw usage(execid); branch_name name(idx(args, 0)()); - branch_uid branch = app.get_projects().translate_branch(name); + branch_uid branch = app.projects.translate_branch(name); app.db.clear_epoch(branch); } @@ -289,7 +289,7 @@ CMD(db_set_epoch, "set_epoch", "", CMD_R N(ed.inner()().size() == constants::epochlen, F("The epoch must be %s characters") % constants::epochlen); branch_name name(idx(args, 0)()); - branch_uid branch = app.get_projects().translate_branch(name); + branch_uid branch = app.projects.translate_branch(name); app.db.set_epoch(branch, ed); } @@ -353,7 +353,7 @@ CMD(complete, "complete", "", CMD_REF(in i != completions.end(); ++i) { if (!verbose) cout << i->inner()() << '\n'; - else cout << describe_revision(app.get_projects(), *i) << '\n'; + else cout << describe_revision(app.projects, *i) << '\n'; } } else if (idx(args, 0)() == "file") ============================================================ --- cmd_diff_log.cc 37997a5ae177947a4779dc0943726cfebcf0244d +++ cmd_diff_log.cc 52874bb4df3773c05b53845c8fb50a6397ef3780 @@ -561,7 +561,7 @@ log_certs(ostream & os, app_state & app, if (multiline) newline = true; - app.get_projects().get_revision_certs_by_name(id, name, certs); + app.projects.get_revision_certs_by_name(id, name, certs); for (vector< revision >::const_iterator i = certs.begin(); i != certs.end(); ++i) { ============================================================ --- cmd_files.cc 9ec49f7fd284b014e45e3d3a6054fb4e5ff5b69c +++ cmd_files.cc a02b157191ced4630775f0277c26d0e1fbc7c8fb @@ -181,7 +181,7 @@ CMD(annotate, "annotate", "", CMD_REF(in file_t file_node = downcast_to_file_t(node); L(FL("annotate for file_id %s") % file_node->self); - do_annotate(app.get_projects(), file_node, rid, app.opts.revs_only); + do_annotate(app.projects, file_node, rid, app.opts.revs_only); } CMD(identify, "identify", "", CMD_REF(debug), N_("[PATH]"), ============================================================ --- cmd_key_cert.cc aa0f5995c59032ece0b1ef08acceb51cf4805bde +++ cmd_key_cert.cc da995dfc1780f1c4dd6b784ad38ec15a3ecdfa7f @@ -308,9 +308,9 @@ CMD(approve, "approve", "", CMD_REF(revi revision_id r; complete(app, idx(args, 0)(), r); - guess_branch(r, app.opts, app.get_projects()); + guess_branch(r, app.opts, app.projects); N(app.opts.branchname() != "", F("need --branch argument for approval")); - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .put_revision_in_branch(app.keys, r, app.opts.branchname); } @@ -325,9 +325,9 @@ CMD(suspend, "suspend", "", CMD_REF(revi revision_id r; complete(app, idx(args, 0)(), r); - guess_branch(r, app.opts, app.get_projects()); + guess_branch(r, app.opts, app.projects); N(app.opts.branchname() != "", F("need --branch argument to suspend")); - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .suspend_revision_in_branch(app.keys, r, app.opts.branchname); } ============================================================ --- cmd_list.cc a2bf9563613a3aa450b88c29c7228dc2a081f0f0 +++ cmd_list.cc e140d31952aceb944bbf1a7cbb2f1868ef37514c @@ -66,7 +66,7 @@ CMD(certs, "certs", "", CMD_REF(list), " vector< revision > ts; // FIXME_PROJECTS: after projects are implemented, // use the app.db version instead if no project is specified. - app.get_projects().get_revision_certs(ident, ts); + app.projects.get_revision_certs(ident, ts); for (size_t i = 0; i < ts.size(); ++i) certs.push_back(idx(ts, i).inner()); @@ -281,7 +281,7 @@ CMD(branches, "branches", "", CMD_REF(li globish exc(app.opts.exclude_patterns); set names; - app.get_projects().get_branch_list(inc, names, + app.projects.get_branch_list(inc, names, !app.opts.ignore_suspend_certs); for (set::const_iterator i = names.begin(); @@ -301,7 +301,7 @@ CMD(epochs, "epochs", "", CMD_REF(list), if (args.size() == 0) { std::set branches; - app.get_projects().get_branch_uids(branches); + app.projects.get_branch_uids(branches); for (map::const_iterator i = epochs.begin(); i != epochs.end(); ++i) @@ -312,7 +312,7 @@ CMD(epochs, "epochs", "", CMD_REF(list), } else { - branch_name branch = app.get_projects().translate_branch(i->first); + branch_name branch = app.projects.translate_branch(i->first); cout << i->second << ' ' << branch << '\n'; } } @@ -320,7 +320,7 @@ CMD(epochs, "epochs", "", CMD_REF(list), else { std::set branches; - app.get_projects().get_branch_list(branches, false); + app.projects.get_branch_list(branches, false); for (args_vector::const_iterator i = args.begin(); i != args.end(); ++i) @@ -328,7 +328,7 @@ CMD(epochs, "epochs", "", CMD_REF(list), branch_name branch((*i)()); N(branches.find(branch) != branches.end(), F("Unknown branch %s") % branch); - branch_uid b = app.get_projects().translate_branch(branch); + branch_uid b = app.projects.translate_branch(branch); map::const_iterator j = epochs.find(b); N(j != epochs.end(), F("no epoch for branch %s") % *i); cout << j->second << ' ' << j->first << '\n'; @@ -342,7 +342,7 @@ CMD(tags, "tags", "", CMD_REF(list), "", options::opts::depth | options::opts::exclude) { set tags; - app.get_projects().get_tags(tags); + app.projects.get_tags(tags); for (set::const_iterator i = tags.begin(); i != tags.end(); ++i) { @@ -699,7 +699,7 @@ CMD_AUTOMATE(certs, N_("REV"), vector< revision > ts; // FIXME_PROJECTS: after projects are implemented, // use the db version instead if no project is specified. - app.get_projects().get_revision_certs(rid, ts); + app.projects.get_revision_certs(rid, ts); for (size_t i = 0; i < ts.size(); ++i) certs.push_back(idx(ts, i).inner()); ============================================================ --- cmd_merging.cc 329003be23836608a6aad5b8d4479b9c9151e1ca +++ cmd_merging.cc dae18e35f109905c756e58b8d57c618abaea33e4 @@ -173,7 +173,7 @@ CMD(update, "update", "", CMD_REF(worksp P(F("updating along branch '%s'") % app.opts.branchname); set candidates; pick_update_candidates(candidates, old_rid, app.opts.branchname, - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname), app.opts.ignore_suspend_certs, app.lua); N(!candidates.empty(), @@ -187,7 +187,7 @@ CMD(update, "update", "", CMD_REF(worksp for (set::const_iterator i = candidates.begin(); i != candidates.end(); ++i) P(i18n_format(" %s") - % describe_revision(app.get_projects(), *i)); + % describe_revision(app.projects, *i)); P(F("choose one with '%s update -r'") % ui.prog_name); E(false, F("multiple update candidates remain after selection")); } @@ -202,7 +202,7 @@ CMD(update, "update", "", CMD_REF(worksp // 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.get_projects().get_project_of_branch(app.opts.branchname), + notify_if_multiple_heads(app.projects.get_project_of_branch(app.opts.branchname), app.opts.branchname, app.opts.ignore_suspend_certs); if (old_rid == chosen_rid) @@ -361,7 +361,7 @@ merge_two(revision_id const & left, revi transaction_guard guard(app.db); interactive_merge_and_store(left, right, merged, app.db, app.lua); - app.get_projects() + app.projects .get_project_of_branch(branch) .put_standard_certs_from_options(app.opts, app.lua, app.keys, @@ -394,7 +394,7 @@ CMD(merge, "merge", "", CMD_REF(tree), " F("please specify a branch, with --branch=BRANCH")); set heads; - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -465,7 +465,7 @@ CMD(merge, "merge", "", CMD_REF(tree), " ancestors.clear(); heads_for_ancestor.clear(); - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -539,8 +539,8 @@ CMD(merge_into_dir, "merge_into_dir", "" branch_name src_branch(idx(args, 0)()); branch_name dst_branch(idx(args, 1)()); - project_t & src_project = app.get_projects().get_project_of_branch(src_branch); - project_t & dst_project = app.get_projects().get_project_of_branch(dst_branch); + project_t & src_project = app.projects.get_project_of_branch(src_branch); + project_t & dst_project = app.projects.get_project_of_branch(dst_branch); src_project.get_branch_heads(src_branch, src_heads, app.opts.ignore_suspend_certs); dst_project.get_branch_heads(dst_branch, dst_heads, @@ -1053,7 +1053,7 @@ CMD(heads, "heads", "", CMD_REF(tree), " N(app.opts.branchname() != "", F("please specify a branch, with --branch=BRANCH")); - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -1067,7 +1067,7 @@ CMD(heads, "heads", "", CMD_REF(tree), " for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - cout << describe_revision(app.get_projects(), *i) << '\n'; + cout << describe_revision(app.projects, *i) << '\n'; } CMD(get_roster, "get_roster", "", CMD_REF(debug), N_("[REVID]"), ============================================================ --- cmd_netsync.cc 03efee47f588f807007fc1b739d3e1757d2f824b +++ cmd_netsync.cc 5579b418d434f397bb517d457681b9eef5451945 @@ -165,7 +165,7 @@ CMD(push, "push", "", CMD_REF(network), run_netsync_protocol(client_voice, source_role, uris, include_pattern, exclude_pattern, - app.get_projects(), app.keys, app.lua, app.opts); + app.projects, app.keys, app.lua, app.opts); } CMD(pull, "pull", "", CMD_REF(network), @@ -189,7 +189,7 @@ CMD(pull, "pull", "", CMD_REF(network), run_netsync_protocol(client_voice, sink_role, uris, include_pattern, exclude_pattern, - app.get_projects(), app.keys, app.lua, app.opts); + app.projects, app.keys, app.lua, app.opts); } CMD(sync, "sync", "", CMD_REF(network), @@ -211,7 +211,7 @@ CMD(sync, "sync", "", CMD_REF(network), run_netsync_protocol(client_voice, source_and_sink_role, uris, include_pattern, exclude_pattern, - app.get_projects(), app.keys, app.lua, app.opts); + app.projects, app.keys, app.lua, app.opts); } class dir_cleanup_helper @@ -331,7 +331,7 @@ CMD(clone, "clone", "", CMD_REF(network) run_netsync_protocol(client_voice, sink_role, uris, include_pattern, exclude_pattern, - app.get_projects(), app.keys, app.lua, app.opts); + app.projects, app.keys, app.lua, app.opts); change_current_working_dir(workspace_dir); @@ -344,7 +344,7 @@ CMD(clone, "clone", "", CMD_REF(network) F("use --revision or --branch to specify what to checkout")); set heads; - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -355,7 +355,7 @@ CMD(clone, "clone", "", CMD_REF(network) 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.get_projects(), *i)); + % describe_revision(app.projects, *i)); P(F("choose one with '%s checkout -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.opts.branchname); } @@ -366,10 +366,10 @@ CMD(clone, "clone", "", CMD_REF(network) // use specified revision complete(app, idx(app.opts.revision_selectors, 0)(), ident); - guess_branch(ident, app.opts, app.get_projects()); + guess_branch(ident, app.opts, app.projects); I(!app.opts.branchname().empty()); - N(app.get_projects() + N(app.projects .get_project_of_branch(app.opts.branchname) .revision_is_in_branch(ident, app.opts.branchname), F("revision %s is not a member of branch %s") @@ -459,7 +459,7 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD run_netsync_protocol(server_voice, source_and_sink_role, app.opts.bind_uris, globish("*"), globish(""), - app.get_projects(), app.keys, app.lua, app.opts); + app.projects, app.keys, app.lua, app.opts); } // Local Variables: ============================================================ --- cmd_othervcs.cc cad7815967cfa329240476b4264b130912ed8f8d +++ cmd_othervcs.cc 18f7a7e0ea334d2ff87f461aae8e01f9a778ae76 @@ -56,7 +56,7 @@ CMD(cvs_import, "cvs_import", "", CMD_RE require_password(key, app.keys, app.db); import_cvs_repo(cvsroot, app.keys, - app.get_projects().get_project_of_branch(app.opts.branchname), + app.projects.get_project_of_branch(app.opts.branchname), app.opts.branchname); } ============================================================ --- cmd_ws_commit.cc fcf629639ef904647cb2017e0bd0fe708547851f +++ cmd_ws_commit.cc e0d1caadfb10955ff6542f86a316bab9a3a70f39 @@ -347,7 +347,7 @@ CMD(disapprove, "disapprove", "", CMD_RE N(rev.edges.size() == 1, F("revision %s has %d changesets, cannot invert") % r % rev.edges.size()); - guess_branch(r, app.opts, app.get_projects()); + guess_branch(r, app.opts, app.projects); N(app.opts.branchname() != "", F("need --branch argument for disapproval")); process_commit_message_args(log_message_given, log_message, app, @@ -374,7 +374,7 @@ CMD(disapprove, "disapprove", "", CMD_RE calculate_ident(rdat, inv_id); app.db.put_revision(inv_id, rdat); - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .put_standard_certs_from_options(app.opts, app.lua, app.keys, @@ -596,7 +596,7 @@ CMD(checkout, "checkout", "co", CMD_REF( F("use --revision or --branch to specify what to checkout")); set heads; - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -607,7 +607,7 @@ CMD(checkout, "checkout", "co", CMD_REF( 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.get_projects(), *i)); + % describe_revision(app.projects, *i)); P(F("choose one with '%s checkout -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.opts.branchname); } @@ -618,11 +618,11 @@ CMD(checkout, "checkout", "co", CMD_REF( // use specified revision complete(app, idx(app.opts.revision_selectors, 0)(), revid); - guess_branch(revid, app.opts, app.get_projects()); + guess_branch(revid, app.opts, app.projects); I(!app.opts.branchname().empty()); - N(app.get_projects() + N(app.projects .get_project_of_branch(app.opts.branchname) .revision_is_in_branch(revid, app.opts.branchname), F("revision %s is not a member of branch %s") @@ -1095,7 +1095,7 @@ CMD(commit, "commit", "ci", CMD_REF(work i++) { // this will prefer --branch if it was set - guess_branch(edge_old_revision(i), app.opts, app.get_projects(), + guess_branch(edge_old_revision(i), app.opts, app.projects, bn_candidate); N(branchname() == "" || branchname == bn_candidate, F("parent revisions of this commit are in different branches:\n" @@ -1159,7 +1159,7 @@ CMD(commit, "commit", "ci", CMD_REF(work // for the divergence check, below set heads; - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -1247,7 +1247,7 @@ CMD(commit, "commit", "ci", CMD_REF(work app.db.put_revision(restricted_rev_id, rdat); } - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .put_standard_certs_from_options(app.opts, app.lua, app.keys, @@ -1268,7 +1268,7 @@ CMD(commit, "commit", "ci", CMD_REF(work app.work.blank_user_log(); - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -1289,7 +1289,7 @@ CMD(commit, "commit", "ci", CMD_REF(work // later. map certs; vector< revision > ctmp; - app.get_projects().get_revision_certs(restricted_rev_id, ctmp); + app.projects.get_revision_certs(restricted_rev_id, ctmp); for (vector< revision >::const_iterator i = ctmp.begin(); i != ctmp.end(); ++i) { @@ -1347,11 +1347,11 @@ CMD_NO_WORKSPACE(import, "import", "", C // use specified revision complete(app, idx(app.opts.revision_selectors, 0)(), ident); - guess_branch(ident, app.opts, app.get_projects()); + guess_branch(ident, app.opts, app.projects); I(!app.opts.branchname().empty()); - N(app.get_projects() + N(app.projects .get_project_of_branch(app.opts.branchname) .revision_is_in_branch(ident, app.opts.branchname), F("revision %s is not a member of branch %s") @@ -1364,7 +1364,7 @@ CMD_NO_WORKSPACE(import, "import", "", C F("use --revision or --branch to specify what to checkout")); set heads; - app.get_projects() + app.projects .get_project_of_branch(app.opts.branchname) .get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -1373,7 +1373,7 @@ CMD_NO_WORKSPACE(import, "import", "", C 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.get_projects(), *i)); + % describe_revision(app.projects, *i)); P(F("choose one with '%s checkout -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.opts.branchname); } ============================================================ --- lua_hooks.cc 86789686badb6b6104b6753fad7771de9e1c5143 +++ lua_hooks.cc 3415778e6c1698847b812b2ad3668e99815c0b91 @@ -429,7 +429,7 @@ bool } bool -lua_hooks::hook_get_projects(std::map & project_definitions) +lua_hooks::hook_get_projects(std::map & project_definitions) { project_definitions.clear(); @@ -445,7 +445,7 @@ lua_hooks::hook_get_projects(std::map const & new_results); - bool hook_get_projects(std::map & project_definitions); + bool hook_get_projects(std::map & project_definitions); // network hooks ============================================================ --- luaext_platform.cc 8fdc0fafb4bd0c497865778b8f9e951a21293376 +++ luaext_platform.cc fa002ab89da3092cb605808772a851049b307b2b @@ -6,6 +6,7 @@ #include #include "platform.hh" +#include "sanity.hh" using std::malloc; using std::free; @@ -170,6 +171,69 @@ LUAEXT(get_pid, ) return 1; } +LUAEXT(isdir, ) +{ + try + { + char const * name = luaL_checkstring(L, -1); + switch (get_path_status(name)) + { + case path::nonexistent: + case path::file: lua_pushboolean(L, false); break; + case path::directory: lua_pushboolean(L, true); break; + } + } + catch(informative_failure & e) + { + lua_pushnil(L); + } + return 1; +} + +namespace +{ + struct build_table : public dirent_consumer + { + build_table(lua_State * st) : st(st), n(1) + { + lua_newtable(st); + } + virtual void consume(const char *s) + { + lua_pushstring(st, s); + lua_rawseti(st, -2, n); + n++; + } + private: + lua_State * st; + unsigned int n; + }; +} + +LUAEXT(read_directory, ) +{ + int top = lua_gettop(L); + try + { + std::string path(luaL_checkstring(L, -1)); + build_table tbl(L); + + do_read_directory(path, tbl, tbl, tbl); + } + catch(informative_failure &) + { + // discard the table and any pending path element + lua_settop(L, top); + lua_pushnil(L); + } + catch (...) + { + lua_settop(L, top); + throw; + } + return 1; +} + // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- project.cc 89c5235c7b7693cdf954b16d594b123fffb970a6 +++ project.cc 56f1dc381dc621eb41d1d45414f65102667b0742 @@ -98,18 +98,6 @@ public: { init(spec); } - policy_branch(system_path const & spec_file, - branch_prefix const & prefix, - database & db) - : prefix(prefix), db(db) - { - require_path_is_file(spec_file, - F("policy spec file %s does not exist") % spec_file, - F("policy spec file %s is a directory") % spec_file); - data spec; - read_data(spec_file, spec); - init(spec); - } shared_ptr get_policy(); map branches(); }; @@ -311,10 +299,10 @@ public: public: policy_branch policy; bool passthru; - policy_info(system_path const & spec_file, + policy_info(data const & spec, branch_prefix const & prefix, database & db) - : policy(spec_file, prefix, db), passthru(false) + : policy(spec, prefix, db), passthru(false) { } explicit policy_info(database & db) @@ -324,9 +312,9 @@ project_t::project_t(branch_prefix const }; project_t::project_t(branch_prefix const & project_name, - system_path const & spec_file, + data const & project_spec, database & db) - : db(db), project_policy(new policy_info(spec_file, project_name, db)) + : db(db), project_policy(new policy_info(project_spec, project_name, db)) {} project_t::project_t(database & db) @@ -806,12 +794,17 @@ project_t::put_cert(key_store & keys, //////////////////////////////////////////////////////////////////////// -project_set::project_set(database & db, lua_hooks & lua) +project_set::project_set(database & db) : db(db) { - map project_definitions; +} + +void +project_set::initialize(lua_hooks & lua) +{ + map project_definitions; lua.hook_get_projects(project_definitions); - for (map::const_iterator i = project_definitions.begin(); + for (map::const_iterator i = project_definitions.begin(); i != project_definitions.end(); ++i) { projects.insert(make_pair(branch_prefix(i->first), ============================================================ --- project.hh a869324a08efe4894c084eb0d6d30d55ef76b7b1 +++ project.hh c20d9905b9dae288c4db7641ba9b122df6a24260 @@ -51,7 +51,7 @@ public: public: project_t(branch_prefix const & project_name, - system_path const & spec_file, + data const & project_spec, database & db); explicit project_t(database & db); @@ -128,7 +128,8 @@ public: project_map projects; public: - explicit project_set(database & db, lua_hooks & lua); + explicit project_set(database & db); + void initialize(lua_hooks & lua); // Get a named project. project_t & get_project(branch_prefix const & name); ============================================================ --- selectors.cc 363089ff77762398f45398abe931605d142ac06a +++ selectors.cc 20ec3496f3cc8dc085fba0389fbea059c3569e2d @@ -362,7 +362,7 @@ complete(app_state & app, } P(F("expanding selection '%s'") % str); - complete_selector(sels, completions, app.get_projects()); + complete_selector(sels, completions, app.projects); N(completions.size() != 0, F("no match for selection '%s'") % str); @@ -412,7 +412,7 @@ expand_selector(app_state & app, return; } - complete_selector(sels, completions, app.get_projects()); + complete_selector(sels, completions, app.projects); } void @@ -427,7 +427,7 @@ diagnose_ambiguous_expansion(app_state & % str).str(); for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) - err += ("\n" + describe_revision(app.get_projects(), *i)); + err += ("\n" + describe_revision(app.projects, *i)); N(false, i18n_format(err)); } ============================================================ --- std_hooks.lua 432725fc36dde06af213797306121385491fda0c +++ std_hooks.lua 970a89588a7092507e8c80e8c8f80f0a5b1f12a1 @@ -53,6 +53,46 @@ end return ret end +function write_to_temporary_file(data, namehint) + tmp, filename = temp_file(namehint) + if (tmp == nil) then + return nil + end; + tmp:write(data) + io.close(tmp) + return filename +end + +function copy_text_file(srcname, destname) + src = io.open(srcname, "r") + if (src == nil) then return nil end + dest = io.open(destname, "w") + if (dest == nil) then return nil end + + while true do + local line = src:read() + if line == nil then break end + dest:write(line, "\n") + end + + io.close(dest) + io.close(src) +end + +function read_contents_of_file(filename, mode) + tmp = io.open(filename, mode) + if (tmp == nil) then + return nil + end + local data = tmp:read("*a") + io.close(tmp) + return data +end + +function program_exists_in_path(program) + return existsonpath(program) == 0 +end + -- attributes are persistent metadata about files (such as execute -- bit, ACLs, various special flags) which we want to have set and -- re-set any time the files are modified. the attributes themselves @@ -363,6 +403,18 @@ end return true end +function get_projects() + local project_dir = get_confdir() .. "/projects" + local ret = {} + if isdir(project_dir) then + local projects = read_directory(project_dir) + for i, file in pairs(projects) do + ret[file] = read_contents_of_file(project_dir .. "/" .. file, "r") + end + end + return ret +end + -- merger support -- Fields in the mergers structure: @@ -696,46 +748,6 @@ mergers.opendiff = { wanted = function () return true end } -function write_to_temporary_file(data, namehint) - tmp, filename = temp_file(namehint) - if (tmp == nil) then - return nil - end; - tmp:write(data) - io.close(tmp) - return filename -end - -function copy_text_file(srcname, destname) - src = io.open(srcname, "r") - if (src == nil) then return nil end - dest = io.open(destname, "w") - if (dest == nil) then return nil end - - while true do - local line = src:read() - if line == nil then break end - dest:write(line, "\n") - end - - io.close(dest) - io.close(src) -end - -function read_contents_of_file(filename, mode) - tmp = io.open(filename, mode) - if (tmp == nil) then - return nil - end - local data = tmp:read("*a") - io.close(tmp) - return data -end - -function program_exists_in_path(program) - return existsonpath(program) == 0 -end - function get_preferred_merge3_command (tbl) local default_order = {"kdiff3", "xxdiff", "opendiff", "tortoise", "emacs", "vim", "meld", "diffutils"} local function existmerger(name) ============================================================ --- tester.cc c4ddb0b7774c9b6a2a7a97b4fe0cfd65b712bb90 +++ tester.cc c9338c104c3cadb19e9ff9e6b51e7726eae4a526 @@ -406,69 +406,6 @@ LUAEXT(exists, ) return 1; } -LUAEXT(isdir, ) -{ - try - { - char const * name = luaL_checkstring(L, -1); - switch (get_path_status(name)) - { - case path::nonexistent: - case path::file: lua_pushboolean(L, false); break; - case path::directory: lua_pushboolean(L, true); break; - } - } - catch(informative_failure & e) - { - lua_pushnil(L); - } - return 1; -} - -namespace -{ - struct build_table : public dirent_consumer - { - build_table(lua_State * st) : st(st), n(1) - { - lua_newtable(st); - } - virtual void consume(const char *s) - { - lua_pushstring(st, s); - lua_rawseti(st, -2, n); - n++; - } - private: - lua_State * st; - unsigned int n; - }; -} - -LUAEXT(read_directory, ) -{ - int top = lua_gettop(L); - try - { - string path(luaL_checkstring(L, -1)); - build_table tbl(L); - - do_read_directory(path, tbl, tbl, tbl); - } - catch(informative_failure &) - { - // discard the table and any pending path element - lua_settop(L, top); - lua_pushnil(L); - } - catch (...) - { - lua_settop(L, top); - throw; - } - return 1; -} - LUAEXT(get_source_dir, ) { lua_pushstring(L, source_dir.c_str()); @@ -899,7 +836,7 @@ parse_makeflags(char const * mflags, } } else if (int_int_option(i->c_str(), "--jobserver-fds=", jread, jwrite)) - ; + { } } // do not permit -j in MAKEFLAGS to override -j on the command line.