# # # add_dir "tests/p_selector" # # add_file "tests/p_selector/__driver__.lua" # content [db1fd89811f2e462874c0d1559943b816db301e1] # # patch "NEWS" # from [af16495a1be882a92d9ba611b1d835c5008fbb86] # to [bef79302404102a3c375c60857e90043e2f6d887] # # patch "monotone.texi" # from [a198d13bb3365b7d67591144799f5330377aacc6] # to [5fab7072154208ae616663e4579cef644987b6bd] # # patch "selectors.cc" # from [42d6f2ba123ad9887a14ba28d9e6bc0a0bac5148] # to [6ed76563cb3eb25fd04fa557b4a618a8f3b3ce3a] # # patch "work.cc" # from [772e23f689e6523ca680a9dcd5d5889637eeb816] # to [de879cd6058f54689874d6e06b8f23af423193ca] # # patch "work.hh" # from [3a96efd140b80cfafff521c5c99bb187b16faed3] # to [cd117c8295b2bdf48db35e92aaf29842c27a1b7f] # ============================================================ --- tests/p_selector/__driver__.lua db1fd89811f2e462874c0d1559943b816db301e1 +++ tests/p_selector/__driver__.lua db1fd89811f2e462874c0d1559943b816db301e1 @@ -0,0 +1,19 @@ + +include("common/selectors.lua") +mtn_setup() + +addfile("testfile", "blah blah") +commit() +REV1=base_revision() + +writefile("testfile", "stuff stuff") +commit() +REV2=base_revision() + +-- empty parent selector +selmap("p:", {REV1}) +-- standard selection +selmap("p:" .. REV2, {REV1}) +-- parent of a root revision +selmap("p:" .. REV1, {}) + ============================================================ --- NEWS af16495a1be882a92d9ba611b1d835c5008fbb86 +++ NEWS bef79302404102a3c375c60857e90043e2f6d887 @@ -1,13 +1,13 @@ ??? ??? ?? ??:??:?? UTC ???? 0.40 release. Changes - + - The vim merger has been improved and now uses diff3 to merge non-conflict changes automatically before executing vimdiff. - - Values used with the --depth option used to control recursion with + - Values used with the --depth option used to control recursion with node and path restrictions have changed. Using --depth=0 now means exactly the specified directories and *not* their children. Using --depth=1 now means the specified directories and their immediate @@ -25,6 +25,10 @@ New features + - The bare parent selector 'p:' can now be used in a workspace to + query the parent(s) of the workspace' base revision. This is + equivalent to "mtn au select p:`mtn au get_base_workspace_revision`". + Internal - Update Botan to 1.7.4. ============================================================ --- monotone.texi a198d13bb3365b7d67591144799f5330377aacc6 +++ monotone.texi 5fab7072154208ae616663e4579cef644987b6bd @@ -2775,7 +2775,8 @@ @heading Selectors in detail @item Parent selection Uses selector type @code{p}. For example, @code{p:0f3a} matches the revision IDs which are the parent of the revision ID which begins with address@hidden address@hidden If you give a bare @code{p:}, monotone will require you to be in +a workspace, and query the parent of the base workspace revision. @item Tag selection Uses selector type @code{t}. For example, @code{t:monotone-0.11} matches @code{tag} certs where the cert value begins with @code{monotone-0.11}. ============================================================ --- 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,