# # add_file "tests/t_selector_globbing.at" # # patch "ChangeLog" # from [4bfc7aa2da954cb72f968520af66b8b4a64bd5f7] # to [c4e55823786489afbc98d8f36fe206279537d3a8] # # patch "database.cc" # from [0a9b7e64e78688aa04d6f92347f8d3fa737b975f] # to [a860ce3c2fff23bc6d4f96e25d3babf73e8dc87d] # # patch "monotone.texi" # from [b19c0f2cedcd918ffe81dae204ec6ce7e2b924a7] # to [e2f9f59600765157a478a7914ad6bbca7bf4c7f8] # # patch "tests/t_selector_globbing.at" # from [] # to [ddb658e8f3a3bdbf8a8c10e0d2a8e90bd2b1565e] # # patch "testsuite.at" # from [ab14f67b36bdae6519026513aac992bb0d6e9e2c] # to [4aa4dfcf4f81601bb0894fcdca7a7e76913010b4] # --- ChangeLog +++ ChangeLog @@ -1,5 +1,22 @@ 2005-07-16 Nathaniel Smith + * monotone.texi (Selectors): Document use of globs. + * tests/t_selector_globbing.at: New test. + * testsuite.at: Add it. + +2005-07-16 Jordan Breeding + + * database.cc (selector_to_certname): Make 't:' selector match + exactly by default as well. + +2005-06-25 Brian Downing + + * database.cc (selector_to_certname, complete): Makes 'b:' + selector be interpreted as a glob instead of as a partial string + match. + +2005-07-16 Nathaniel Smith + * netsync.cc: Revert accidentally committed changes. 2005-07-16 Nathaniel Smith --- database.cc +++ database.cc @@ -2248,14 +2248,18 @@ using selectors::selector_type; static void selector_to_certname(selector_type ty, - string & s) + string & s, + string & prefix, + string & suffix) { + prefix = suffix = "*"; switch (ty) { case selectors::sel_author: s = author_cert_name; break; case selectors::sel_branch: + prefix = suffix = ""; s = branch_cert_name; break; case selectors::sel_date: @@ -2264,6 +2268,7 @@ s = date_cert_name; break; case selectors::sel_tag: + prefix = suffix = ""; s = tag_cert_name; break; case selectors::sel_ident: @@ -2348,7 +2353,9 @@ else { string certname; - selector_to_certname(i->first, certname); + string prefix; + string suffix; + selector_to_certname(i->first, certname, prefix, suffix); lim += (F("SELECT id FROM revision_certs WHERE name='%s' AND ") % certname).str(); switch (i->first) { @@ -2359,7 +2366,8 @@ lim += (F("unbase64(value) > X'%s'") % encode_hexenc(i->second)).str(); break; default: - lim += (F("unbase64(value) glob '*%s*'") % i->second).str(); + lim += (F("unbase64(value) glob '%s%s%s'") + % prefix % i->second % suffix).str(); break; } } @@ -2378,6 +2386,8 @@ } else { + string prefix = "*"; + string suffix = "*"; query = "SELECT value FROM revision_certs WHERE"; if (ty == selectors::sel_unknown) { @@ -2390,12 +2400,13 @@ else { string certname; - selector_to_certname(ty, certname); + selector_to_certname(ty, certname, prefix, suffix); query += (F(" (name='%s')") % certname).str(); } - query += (F(" AND (unbase64(value) GLOB '*%s*')") % partial).str(); + query += (F(" AND (unbase64(value) GLOB '%s%s%s')") + % prefix % partial % suffix).str(); query += (F(" AND (id IN %s)") % lim).str(); } --- monotone.texi +++ monotone.texi @@ -2277,7 +2277,7 @@ @heading Selectors in detail A selector is a combination of a selector type, which is a single -ASCII character, followed by a @code{:} character and a selector +xoASCII character, followed by a @code{:} character and a selector string. All selectors strings except for selector type @code{c} are just values. The value is matched against identifiers or certs, depending on its type, in an attempt to match a single revision. @@ -2290,13 +2290,14 @@ @var{name} or @address@hidden@var{value}. The former syntax will select any revision that has a cert with that name, regardless of value; the latter will match any revision that has a cert with that -name and value. Values to match for can have wildcards. +name and value. Values to match for can have shell wildcards. @item Author selection Uses selector type @code{a}. For example, @code{a:graydon} matches address@hidden certs where the cert value begins with @code{graydon}. address@hidden certs where the cert value contains @code{graydon}. @item Branch selection -Uses selector type @code{b}. For example, @code{b:net.venge} matches address@hidden certs where the cert value begins with @code{net.venge}. +Uses selector type @code{b}. For example, @code{b:net.venge.monotone} matches address@hidden certs where the cert value is @code{net.venge.monotone}. +Values to match for can have shell wildcards. @item Date selection Uses selector type @code{d}. For example, @code{d:2004-04} matches @code{date} certs where the cert value begins with @@ -2317,9 +2318,9 @@ Uses selector type @code{i}. For example, @code{i:0f3a} matches revision IDs which begin with @code{0f3a}. @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 address@hidden +Uses selector type @code{t}. For example, @code{t:monotone-0.11} matches address@hidden certs where the cert value begins with @code{monotone-0.11}. +Values to match for can have shell wildcards. @end table Further selector types may be added in the future. --- tests/t_selector_globbing.at +++ tests/t_selector_globbing.at @@ -0,0 +1,35 @@ +AT_SETUP([b: and t: selector globbing]) +MONOTONE_SETUP + +ADD_FILE(testfile, [blah blah +]) +COMMIT(testbranch) +R1=`BASE_REVISION` + +SET_FILE(testfile, [stuff stuff +]) +COMMIT(otherbranch) +R2=`BASE_REVISION` + +SET_FILE(testfile, [thing thing +]) +COMMIT(branch) +R3=`BASE_REVISION` + +AT_CHECK(MONOTONE tag $R1 foo, [], [ignore], [ignore]) +AT_CHECK(MONOTONE tag $R2 bar, [], [ignore], [ignore]) +AT_CHECK(MONOTONE tag $R3 foobarbaz, [], [ignore], [ignore]) + +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select b:testbranch, echo $R1) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select b:otherbranch, echo $R2) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select b:branch, echo $R3) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select b:test*, echo $R1) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select b:*branch*, (echo $R1; echo $R2; echo $R3) | sort) + +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select t:foo, echo $R1) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select t:bar, echo $R2) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select t:foobarbaz, echo $R3) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select t:*bar, echo $R2) +CHECK_SAME_CANONICALISED_STDOUT(MONOTONE automate select t:*bar*, (echo $R2; echo $R3) | sort) + +AT_CLEANUP --- testsuite.at +++ testsuite.at @@ -672,3 +672,4 @@ m4_include(tests/t_ambiguous_tags.at) m4_include(tests/t_kill_tag_locally.at) m4_include(tests/t_restricted_diff_unchanged.at) +m4_include(tests/t_selector_globbing.at)