# # # patch "automate.cc" # from [cd832ba3447d08ddefc21abc85c3fb8634ac0fac] # to [4b4356adc040a901c42bcb8f0e2c6421e3c7272d] # # patch "cmd.hh" # from [3d37189bd6dad8ad5c6cb7ea72217297f9093b2a] # to [8c23440201398c17660da8dd43dcc93052be1496] # # patch "cmd_automate.cc" # from [fe51ddaaa65d3f62f107adb06274f72e0b69b52a] # to [70adf70cff51acf0add835845ce5f98f367d7fad] # # patch "cmd_db.cc" # from [a85f812934228136d26b01fdfe060db6d434b4e9] # to [e9f3f34803b7dab11dd97d8b813712d3f997bafa] # # patch "cmd_files.cc" # from [f6e514d0a4ef8c6cad2944b7dba9e6f33c687e6f] # to [1d35ebb8c6fafe6f4c263533d1724bf0d53fa216] # # patch "cmd_key_cert.cc" # from [ce343848ec00576228610a9fa45f2f94a468f69d] # to [099c66640452cc08392956c2577af8724e2437d5] # # patch "cmd_ws_commit.cc" # from [c262406337bec4bc2678a0e2e12f84f36f47cc65] # to [873d518fd5f0d334e3f55fbfdb625ac0b974e130] # # patch "database.cc" # from [a0e88769a3b9fa39e1eb991f2550c0e6055be008] # to [3a15e09b1239c818d4b4ae04d98781db308f321a] # # patch "database.hh" # from [ecb4b63d361df3392cb418b1592af75a398e67be] # to [2ce398c2ffc4c225e2584803b80a3aa3d74e8ec3] # # patch "keys.cc" # from [cc509d58838e8a3e117f3b5772cb97b7ff0d2475] # to [cfdec0d03edf3292c10676a4670080ee764ffb22] # # patch "selectors.cc" # from [bc4b72e0a1318f92108b45fd1a5195653c109358] # to [d9da29a608a36462d8f7d76b6ba9f25af6d22692] # ============================================================ --- automate.cc cd832ba3447d08ddefc21abc85c3fb8634ac0fac +++ automate.cc 4b4356adc040a901c42bcb8f0e2c6421e3c7272d @@ -324,7 +324,7 @@ CMD_AUTOMATE_WITH_DATABASE(leaves, "", // Output format: A list of revision ids, in hexadecimal, each followed by a // newline. Revision ids are printed in alphabetically sorted order. // Error conditions: None. -CMD_AUTOMATE(roots, "", +CMD_AUTOMATE_WITH_EVERYTHING(roots, "", N_("Lists the roots of the revision graph"), N_(""), options::opts::none) ============================================================ --- cmd.hh 3d37189bd6dad8ad5c6cb7ea72217297f9093b2a +++ cmd.hh 8c23440201398c17660da8dd43dcc93052be1496 @@ -246,7 +246,7 @@ void commands::cmd_ ## C::exec(app_state // command definition allows the description of input/output format, // error conditions, version when added, etc. 'desc' can later be // automatically built from these. -#define CMD_AUTOMATE(C, params, abstract, desc, opts) \ +#define CMD_AUTOMATE_WITH_EVERYTHING(C, params, abstract, desc, opts)\ namespace commands { \ class automate_ ## C : public automate \ { \ @@ -257,62 +257,64 @@ namespace commands { public: \ automate_ ## C() : automate(#C, params, abstract, desc, \ options::options_type() | opts) \ - public: + {} \ + }; \ + automate_ ## C C ## _automate; \ +} \ +void commands::automate_ ## C :: exec_from_automate \ + (args_vector args, \ + command_id const & execid, \ + app_state & app, \ + std::ostream & output) const +#define CMD_AUTOMATE_WITH_DATABASE(C, params, abstract, desc, opts) \ +namespace commands { \ + class automate_ ## C : public automate \ + { \ + void exec_from_automate(args_vector args, \ + command_id const & execid, \ + app_state & app, \ + std::ostream & output) const; \ + \ + void exec_from_automate(args_vector args, \ + command_id const & execid, \ + database & db, \ + std::ostream & output) const; \ + public: \ + automate_ ## C() : automate(#C, params, abstract, desc, \ + options::options_type() | opts) \ + {} \ + }; \ + automate_ ## C C ## _automate; \ +} \ +void commands::automate_ ## C :: exec_from_automate \ + (args_vector args, \ + command_id const & execid, \ + app_state & app, \ + std::ostream & output) const \ + { exec_from_automate(args, execid, app.db, output); } \ + \ +void commands::automate_ ## C :: exec_from_automate \ + (args_vector args, \ + command_id const & execid, \ + database & db, \ + std::ostream & output) const - struct automate_with_database - : public automate - { - automate_with_database(std::string const & n, std::string const & p, - options::options_type const & o); - - public: - virtual void run(std::vector args, - std::string const & help_name, - database & db, - std::ostream & output) const = 0; - - virtual void run(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) const; - }; - - struct automate_with_workspace - : public automate - { - automate_with_workspace(std::string const & n, std::string const & p, - options::options_type const & o); - - public: - virtual void run(std::vector args, - std::string const & help_name, - workspace & work, - std::ostream & output) const = 0; - - virtual void run(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) const; - }; - - struct automate_with_nothing - : public automate - { - automate_with_nothing(std::string const & n, std::string const & p, - options::options_type const & o); - - public: - virtual void run(std::vector args, - std::string const & help_name, - std::ostream & output) const = 0; - - virtual void run(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) const; - }; - +#define CMD_AUTOMATE_WITH_NOTHING(C, params, abstract, desc, opts) \ +namespace commands { \ + class automate_ ## C : public automate \ + { \ + void exec_from_automate(args_vector args, \ + command_id const & execid, \ + app_state & app, \ + std::ostream & output) const; \ + \ + void exec_from_automate(args_vector args, \ + command_id const & execid, \ + std::ostream & output) const; \ + public: \ + automate_ ## C() : automate(#C, params, abstract, desc, \ + options::options_type() | opts) \ {} \ }; \ automate_ ## C C ## _automate; \ @@ -321,27 +323,15 @@ void commands::automate_ ## C :: exec_fr (args_vector args, \ command_id const & execid, \ app_state & app, \ + std::ostream & output) const \ + { exec_from_automate(args, execid, output); } \ + \ +void commands::automate_ ## C :: exec_from_automate \ + (args_vector args, \ + command_id const & execid, \ std::ostream & output) const CMD_FWD_DECL(__root__); -namespace automation { \ - struct auto_ ## NAME : public automate_with_database \ - { \ - auto_ ## NAME () \ - : automate_with_database(#NAME, PARAMS, \ - options::options_type() | OPTIONS) \ - {} \ - void run(std::vector args, std::string const & help_name, \ - database & db, std::ostream & output) const; \ - virtual ~auto_ ## NAME() {} \ - }; \ - static auto_ ## NAME NAME ## _auto; \ -} \ -void automation::auto_ ## NAME :: run(std::vector args, \ - std::string const & help_name,\ - database & db, \ - std::ostream & output) const - CMD_FWD_DECL(automation); CMD_FWD_DECL(database); CMD_FWD_DECL(debug); @@ -355,43 +345,6 @@ CMD_FWD_DECL(workspace); CMD_FWD_DECL(variables); CMD_FWD_DECL(workspace); -#define AUTOMATE_WITH_WORKSPACE(NAME, PARAMS, OPTIONS) \ -namespace automation { \ - struct auto_ ## NAME : public automate_with_workspace \ - { \ - auto_ ## NAME () \ - : automate_with_workspace(#NAME, PARAMS, \ - options::options_type() | OPTIONS) \ - {} \ - void run(std::vector args, std::string const & help_name, \ - workspace & work, std::ostream & output) const; \ - virtual ~auto_ ## NAME() {} \ - }; \ - static auto_ ## NAME NAME ## _auto; \ -} \ -void automation::auto_ ## NAME :: run(std::vector args, \ - std::string const & help_name,\ - workspace & work, \ - std::ostream & output) const - -#define AUTOMATE_WITH_NOTHING(NAME, PARAMS, OPTIONS) \ -namespace automation { \ - struct auto_ ## NAME : public automate_with_nothing \ - { \ - auto_ ## NAME () \ - : automate_with_nothing(#NAME, PARAMS, \ - options::options_type() | OPTIONS) \ - {} \ - void run(std::vector args, std::string const & help_name, \ - std::ostream & output) const; \ - virtual ~auto_ ## NAME() {} \ - }; \ - static auto_ ## NAME NAME ## _auto; \ -} \ -void automation::auto_ ## NAME :: run(std::vector args, \ - std::string const & help_name,\ - std::ostream & output) const - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- cmd_automate.cc fe51ddaaa65d3f62f107adb06274f72e0b69b52a +++ cmd_automate.cc 70adf70cff51acf0add835845ce5f98f367d7fad @@ -45,46 +45,6 @@ namespace commands { make_io_binary(); exec_from_automate(args, execid, app, std::cout); } - - automate_with_database::automate_with_database(string const &n, - string const &p, options::options_type const & o) - : automate(n, p, o) - { } - - void automate_with_database::run(std::vector args, - string const & help_name, - app_state & app, - std::ostream & output) const - { - run(args, help_name, app.db, output); - } - - - automate_with_workspace::automate_with_workspace(string const &n, - string const &p, options::options_type const & o) - : automate(n, p, o) - { } - void automate_with_workspace::run(std::vector args, - string const & help_name, - app_state & app, - std::ostream & output) const - { - run(args, help_name, app.work, output); - } - - - automate_with_nothing::automate_with_nothing(string const &n, - string const &p, options::options_type const & o) - : automate(n, p, o) - { } - - void automate_with_nothing::run(std::vector args, - string const & help_name, - app_state & app, - std::ostream & output) const - { - run(args, help_name, output); - } } static string const interface_version = "5.0"; @@ -355,7 +315,7 @@ struct automate_ostream : public std::os }; -CMD_AUTOMATE_WITH_NOTHING(stdio, "", +CMD_AUTOMATE_WITH_EVERYTHING(stdio, "", N_("Automates several commands in one run"), N_(""), options::opts::automate_stdio_size) ============================================================ --- cmd_db.cc a85f812934228136d26b01fdfe060db6d434b4e9 +++ cmd_db.cc e9f3f34803b7dab11dd97d8b813712d3f997bafa @@ -186,7 +186,7 @@ CMD(db_changesetify, "changesetify", "", N(args.size() == 0, F("no arguments needed")); - build_changesets_from_manifest_ancestry(app); + build_changesets_from_manifest_ancestry(app.db); } CMD(db_rosterify, "rosterify", "", CMD_REF(db), "", @@ -197,7 +197,7 @@ CMD(db_rosterify, "rosterify", "", CMD_R N(args.size() == 0, F("no arguments needed")); - build_roster_style_revs_from_manifest_style_revs(app); + build_roster_style_revs_from_manifest_style_revs(app.db); } CMD(db_regenerate_caches, "regenerate_caches", "", CMD_REF(db), "", @@ -208,7 +208,7 @@ CMD(db_regenerate_caches, "regenerate_ca N(args.size() == 0, F("no arguments needed")); - regenerate_caches(app); + regenerate_caches(app.db); } CMD_HIDDEN(clear_epoch, "clear_epoch", "", CMD_REF(db), "BRANCH", ============================================================ --- cmd_files.cc f6e514d0a4ef8c6cad2944b7dba9e6f33c687e6f +++ cmd_files.cc 1d35ebb8c6fafe6f4c263533d1724bf0d53fa216 @@ -224,7 +224,7 @@ CMD(identify, "identify", "", CMD_REF(de // // Error conditions: If the file path doesn't point to a valid file prints // an error message to stderr and exits with status 1. -CMD_AUTOMATE(identify, N_("PATH"), +CMD_AUTOMATE_WITH_EVERYTHING(identify, N_("PATH"), N_("Prints the file identifier of a file"), N_(""), options::opts::none) ============================================================ --- cmd_key_cert.cc ce343848ec00576228610a9fa45f2f94a468f69d +++ cmd_key_cert.cc 099c66640452cc08392956c2577af8724e2437d5 @@ -137,7 +137,7 @@ CMD(ssh_agent_export, "ssh_agent_export" app.keys.get_key_pair(id, key); shared_ptr priv = get_private_key(app.keys, id, key.priv); utf8 new_phrase; - get_passphrase(app.lua, id, new_phrase, true, true, "enter new passphrase"); + get_passphrase(app.keys, id, new_phrase, true, true, "enter new passphrase"); Pipe p; p.start_msg(); if (new_phrase().length()) ============================================================ --- cmd_ws_commit.cc c262406337bec4bc2678a0e2e12f84f36f47cc65 +++ cmd_ws_commit.cc 873d518fd5f0d334e3f55fbfdb625ac0b974e130 @@ -776,7 +776,7 @@ CMD(attr_set, "set", "", CMD_REF(attr), // // Error conditions: If the path has no attributes, prints only the // format version, if the file is unknown, escalates -CMD_AUTOMATE(get_attributes, N_("PATH"), +CMD_AUTOMATE_WITH_EVERYTHING(get_attributes, N_("PATH"), N_("Prints all attributes for the specified path"), N_(""), options::opts::none) @@ -891,7 +891,7 @@ CMD_AUTOMATE(get_attributes, N_("PATH"), // // Error conditions: If PATH is unknown in the new roster, prints an error and // exits with status 1. -CMD_AUTOMATE(set_attribute, N_("PATH KEY VALUE"), +CMD_AUTOMATE_WITH_EVERYTHING(set_attribute, N_("PATH KEY VALUE"), N_("Sets an attribute on a certain path"), N_(""), options::opts::none) @@ -937,7 +937,7 @@ CMD_AUTOMATE(set_attribute, N_("PATH KEY // Error conditions: If PATH is unknown in the new roster or the specified // attribute key is unknown, prints an error and exits with // status 1. -CMD_AUTOMATE(drop_attribute, N_("PATH [KEY]"), +CMD_AUTOMATE_WITH_EVERYTHING(drop_attribute, N_("PATH [KEY]"), N_("Drops an attribute or all of them from a certain path"), N_(""), options::opts::none) ============================================================ --- database.cc a0e88769a3b9fa39e1eb991f2550c0e6055be008 +++ database.cc 3a15e09b1239c818d4b4ae04d98781db308f321a @@ -3423,6 +3423,12 @@ bool // FIXME: the quick hack lua link in functions bool +database::hook_exists(std::string const & name) +{ + return __app->lua.hook_exists(name); +} + +bool database::hook_expand_selector(std::string const & sel, std::string & exp) { return __app->lua.hook_expand_selector(sel, exp); ============================================================ --- database.hh ecb4b63d361df3392cb418b1592af75a398e67be +++ database.hh 2ce398c2ffc4c225e2584803b80a3aa3d74e8ec3 @@ -598,6 +598,7 @@ public: revision_t const & rev); // FIXME: quick hack to make these hooks available via the database context + bool hook_exists(std::string const & name); bool hook_expand_selector(std::string const & sel, std::string & exp); bool hook_expand_date(std::string const & sel, std::string & exp); bool hook_get_manifest_cert_trust(std::set const & signers, ============================================================ --- keys.cc cc509d58838e8a3e117f3b5772cb97b7ff0d2475 +++ keys.cc cfdec0d03edf3292c10676a4670080ee764ffb22 @@ -349,7 +349,7 @@ change_key_passphrase(key_store & keys, shared_ptr priv = get_private_key(keys, id, encoded_key, true); utf8 new_phrase; - get_passphrase(lua, id, new_phrase, true, true, "enter new passphrase"); + get_passphrase(keys, id, new_phrase, true, true, "enter new passphrase"); Pipe p; p.start_msg(); ============================================================ --- selectors.cc bc4b72e0a1318f92108b45fd1a5195653c109358 +++ selectors.cc d9da29a608a36462d8f7d76b6ba9f25af6d22692 @@ -87,10 +87,9 @@ namespace selectors /* a selector date-related should be validated */ if (sel_date==type || sel_later==type || sel_earlier==type) { - //FIXME: db.hook_expand_date(...) - if (app.lua.hook_exists("expand_date")) + if (db.hook_exists("expand_date")) { - 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); } else