# # # patch "asciik.cc" # from [e52020dbc9cabe05bbca08e996f90b02a0fed7bf] # to [6040a92a6575d0aa05efa8b8892459ecbf0b4fd3] # # patch "automate.cc" # from [0dc786ba3096b88f2c77da34e37283a48effda27] # to [0a3fc4c33d34dd6d2aa20f91283f79aac63929e6] # # patch "commands.cc" # from [b75ca8fe6164c20993fe90c5383ebc888e2eae98] # to [41d9e2d279050a7395f6521c48d6d4069dc6d7e4] # # patch "database.cc" # from [d6ad1937f9623d80391dd07346ab912cf41a437a] # to [bcde36ec95faacf3d986a0d3bc238a7bf8450ac2] # # patch "database.hh" # from [76ff25bd59ccb29cbe31206a9eccfdc9b8ecd5f9] # to [8cf8df8a906ef41ac779b7f1d2f54632ccc37fa4] # # patch "selectors.cc" # from [d56d5fcd51a1f321224be53036bc52e18d536061] # to [6da59b1e019b49a5f65c202bde61bcd745477778] # # patch "selectors.hh" # from [f3f93e168438c3dd49111a2e4aff5a444e01994d] # to [3a20536c5dfbe69829191a1410168e6b7d864473] # ============================================================ --- asciik.cc e52020dbc9cabe05bbca08e996f90b02a0fed7bf +++ asciik.cc 6040a92a6575d0aa05efa8b8892459ecbf0b4fd3 @@ -372,13 +372,13 @@ CMD(asciik, N_("debug"), N_("SELECTOR"), F("wrong argument count")); vector > - sels(selectors::parse_selector(args[0](), app)); + sels(selectors::parse_selector(args[0](), app.db)); // we jam through an "empty" selection on sel_ident type set completions; //set> completions; selectors::selector_type ty = selectors::sel_ident; - selectors::complete_selector("", sels, ty, completions, app); + selectors::complete_selector("", sels, ty, completions, app.db); asciik graph(std::cout, 10); set revs; ============================================================ --- automate.cc 0dc786ba3096b88f2c77da34e37283a48effda27 +++ automate.cc 0a3fc4c33d34dd6d2aa20f91283f79aac63929e6 @@ -534,12 +534,12 @@ AUTOMATE(select, N_("SELECTOR"), options F("wrong argument count")); vector > - sels(selectors::parse_selector(args[0](), app)); + sels(selectors::parse_selector(args[0](), app.db)); // 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); + selectors::complete_selector("", sels, ty, completions, app.db); for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) ============================================================ --- commands.cc b75ca8fe6164c20993fe90c5383ebc888e2eae98 +++ commands.cc 41d9e2d279050a7395f6521c48d6d4069dc6d7e4 @@ -409,14 +409,14 @@ complete(app_state & app, } vector > - sels(selectors::parse_selector(str, app)); + sels(selectors::parse_selector(str, app.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); + selectors::complete_selector("", sels, ty, completions, app.db); N(completions.size() != 0, F("no match for selection '%s'") % str); ============================================================ --- database.cc d6ad1937f9623d80391dd07346ab912cf41a437a +++ database.cc bcde36ec95faacf3d986a0d3bc238a7bf8450ac2 @@ -3469,6 +3469,19 @@ database::close() I(!__sql); } +// FIXME: the quick hack lua link in functions +bool +database::hook_expand_selector(std::string const & sel, std::string & exp) +{ + return __app->lua.hook_expand_selector(sel, exp); +}; + +bool +database::hook_expand_date(std::string const & sel, std::string & exp) +{ + return __app->lua.hook_expand_date(sel, exp); +}; + // transaction guards transaction_guard::transaction_guard(database & d, bool exclusive, ============================================================ --- database.hh 76ff25bd59ccb29cbe31206a9eccfdc9b8ecd5f9 +++ database.hh 8cf8df8a906ef41ac779b7f1d2f54632ccc37fa4 @@ -593,6 +593,10 @@ public: void delete_existing_rosters(); void put_roster_for_revision(revision_id const & new_id, revision_t const & rev); + + // quick hack to make these hooks available via the database context + bool hook_expand_selector(std::string const & sel, std::string & exp); + bool hook_expand_date(std::string const & sel, std::string & exp); }; // Parent maps are used in a number of places to keep track of all the ============================================================ --- selectors.cc d56d5fcd51a1f321224be53036bc52e18d536061 +++ selectors.cc 6da59b1e019b49a5f65c202bde61bcd745477778 @@ -9,8 +9,8 @@ #include "selectors.hh" #include "sanity.hh" -#include "app_state.hh" #include "constants.hh" +#include "database.hh" #include @@ -27,7 +27,7 @@ namespace selectors decode_selector(string const & orig_sel, selector_type & type, string & sel, - app_state & app) + database & db) { sel = orig_sel; @@ -36,7 +36,7 @@ namespace selectors string tmp; if (sel.size() < 2 || sel[1] != ':') { - if (!app.lua.hook_expand_selector(sel, tmp)) + if (!db.hook_expand_selector(sel, tmp)) { L(FL("expansion of selector '%s' failed") % sel); } @@ -87,7 +87,7 @@ namespace selectors /* a selector date-related should be validated */ if (sel_date==type || sel_later==type || sel_earlier==type) { - N (app.lua.hook_expand_date(sel, tmp), + N (db.hook_expand_date(sel, tmp), F ("selector '%s' is not a valid date\n") % sel); if (tmp.size()<8 && (sel_later==type || sel_earlier==type)) @@ -109,16 +109,16 @@ namespace selectors vector > const & limit, selector_type & type, set & completions, - app_state & app) + database & db) { string sel; - decode_selector(orig_sel, type, sel, app); - app.db.complete(type, sel, limit, completions); + decode_selector(orig_sel, type, sel, db); + db.complete(type, sel, limit, completions); } vector > parse_selector(string const & str, - app_state & app) + database & db) { vector > sels; @@ -144,7 +144,7 @@ namespace selectors string sel; selector_type type = sel_unknown; - decode_selector(*i, type, sel, app); + decode_selector(*i, type, sel, db); sels.push_back(make_pair(type, sel)); } } ============================================================ --- selectors.hh f3f93e168438c3dd49111a2e4aff5a444e01994d +++ selectors.hh 3a20536c5dfbe69829191a1410168e6b7d864473 @@ -15,7 +15,7 @@ #include #include -class app_state; +class database; namespace selectors { @@ -40,10 +40,10 @@ namespace selectors std::vector > const & limit, selector_type & type, std::set & completions, - app_state & app); + database & db); std::vector > parse_selector(std::string const & str, - app_state & app); + database & db); }; // namespace selectors