# # old_revision [00862d40b30f11d972198ffb53e61986d3ce7aac] # # patch "selectors.cc" # from [42d6f2ba123ad9887a14ba28d9e6bc0a0bac5148] # to [6ed76563cb3eb25fd04fa557b4a618a8f3b3ce3a] # # patch "work.cc" # from [772e23f689e6523ca680a9dcd5d5889637eeb816] # to [de879cd6058f54689874d6e06b8f23af423193ca] # # patch "work.hh" # from [3a96efd140b80cfafff521c5c99bb187b16faed3] # to [cd117c8295b2bdf48db35e92aaf29842c27a1b7f] # ============================================================ --- selectors.cc 42d6f2ba123ad9887a14ba28d9e6bc0a0bac5148 +++ selectors.cc 6ed76563cb3eb25fd04fa557b4a618a8f3b3ce3a @@ -48,7 +48,8 @@ static void typedef vector > selector_list; static void -decode_selector(options const & opts, +decode_selector(project_t & project, + options const & opts, lua_hooks & lua, string const & orig_sel, selector_type & type, @@ -140,7 +141,7 @@ decode_selector(options const & opts, tmp += "T00:00:00"; N(tmp.size()==19 || sel_date==type, F("selector '%s' is not a valid date (%s)") % sel % tmp); - + if (sel != tmp) { P (F ("expanded date '%s' -> '%s'\n") % sel % tmp); @@ -170,13 +171,35 @@ decode_selector(options const & opts, F("the cert selector c: may not be empty")); break; + case sel_parent: + if (sel.empty()) + { + workspace work(opts, lua, F("the empty parent selector p: refers to" + "the base revision of the workspace")); + + parent_map parents; + set parent_ids; + + work.get_parent_rosters(project.db, parents); + + for (parent_map::const_iterator i = parents.begin(); + i != parents.end(); ++i) + { + parent_ids.insert(i->first); + } + + diagnose_ambiguous_expansion(project, "p:", parent_ids); + sel = (* parent_ids.begin()).inner()(); + } + break; default: break; } } } static void -parse_selector(options const & opts, +parse_selector(project_t & project, + options const & opts, lua_hooks & lua, string const & str, selector_list & sels) { @@ -204,7 +227,7 @@ parse_selector(options const & opts, string sel; selector_type type = sel_unknown; - decode_selector(opts, lua, *i, type, sel); + decode_selector(project, opts, lua, *i, type, sel); sels.push_back(make_pair(type, sel)); } } @@ -338,7 +361,7 @@ complete(options const & opts, lua_hooks set & completions) { selector_list sels; - parse_selector(opts, lua, str, sels); + parse_selector(project, opts, lua, str, sels); // avoid logging if there's no expansion to be done if (sels.size() == 1 @@ -393,7 +416,7 @@ expand_selector(options const & opts, lu set & completions) { selector_list sels; - parse_selector(opts, lua, str, sels); + parse_selector(project, opts, lua, str, sels); // avoid logging if there's no expansion to be done if (sels.size() == 1 ============================================================ --- work.cc 772e23f689e6523ca680a9dcd5d5889637eeb816 +++ work.cc de879cd6058f54689874d6e06b8f23af423193ca @@ -179,6 +179,14 @@ workspace::workspace(app_state & app, i1 set_ws_options(app.opts, false); } +workspace::workspace(options const & opts, lua_hooks & lua, + i18n_format const & explanation, bool writeback_options) + : lua(lua) +{ + require_workspace(explanation); + if (writeback_options) + set_ws_options(opts, false); +} // routines for manipulating the bookkeeping directory ============================================================ --- work.hh 3a96efd140b80cfafff521c5c99bb187b16faed3 +++ work.hh cd117c8295b2bdf48db35e92aaf29842c27a1b7f @@ -110,6 +110,8 @@ public: explicit workspace(app_state & app, bool writeback_options = true); explicit workspace(app_state & app, i18n_format const & explanation, bool writeback_options = true); + explicit workspace(options const & opts, lua_hooks & lua, + i18n_format const & explanation, bool writeback_options = true); // Methods for manipulating the workspace's content. void find_missing(roster_t const & new_roster_shape,