On Fri, Jun 24, 2005 at 01:15:10PM -0700, Nathaniel Smith wrote:
> If someone were to fix the b: selector (as described at
> http://venge.net/monotone/quickies.html, last item), then this would
> just be
>   $ for R in `monotone automate select b:badbranch`
>   > do monotone cert $R branch goodbranch; done
> ATM though this will not do what you want if there are any branches
> named badbranchfoo, since b:badbranch will match any branch whose name
> begins with  "badbranch".

Attached is a quick fix for this.  The 'b:' selector is an explicit glob
now - "b:net.venge.monotone" gets only the net.venge.monotone branch,
"b:*net.venge.monotone*" gets the ol behavior.

Behavior for the other selectors shouldn't have changed.  However, their
behavior was not as documented.  Most are doing a '*%s*' glob search
("b:ge.monotone.gu" would find the net.venge.monotone.gui branch), even
though the documentation implied that it was a '%s*' search.

-bcd
--
*** Brian Downing <bdowning at lavos dot net>
# 
# patch "ChangeLog"
#  from [097d8f47e66d6e5bb6a37dd162dcb10f785b8f40]
#    to [0702abf2c4c5342cec4a73e83f5d3f06c1d7de60]
# 
# patch "database.cc"
#  from [1ce26993177acbeb3e3d18aba17f43700372fa3c]
#    to [e0f0e3eee93afac83265188bba8e33ac438b8f59]
# 
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,8 @@
+2005-06-25  Brian Downing <[EMAIL PROTECTED]>
+
+       * database.cc: Makes 'b:' selector be interpreted as a glob
+       instead of as a partial string match.
+
 2005-06-24  Nathaniel Smith  <[EMAIL PROTECTED]>
 
        * unix/process.cc (process_spawn): Format log output correctly.
--- database.cc
+++ database.cc
@@ -2168,14 +2168,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:
@@ -2268,7 +2272,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)
                 {
@@ -2279,7 +2285,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;
                 }
             }
@@ -2298,6 +2305,8 @@
     }
   else 
     {
+      string prefix = "*";
+      string suffix = "*";
       query = "SELECT value FROM revision_certs WHERE";
       if (ty == selectors::sel_unknown)
         {               
@@ -2310,12 +2319,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-devel mailing list
Monotone-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/monotone-devel

Reply via email to