monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] [PATCH] parent selector 'p:xxx'


From: Ralf S. Engelschall
Subject: [Monotone-devel] [PATCH] parent selector 'p:xxx'
Date: Sat, 6 Oct 2007 19:09:03 +0200
User-agent: Mutt/1.5.16 OpenPKG/CURRENT (2007-06-09)

This afternoon I finally got really nerved having to type

    $ mtn diff -r `mtn automate parent <rev>` -r <rev>

or the rather ugly, unhandy and partly unrecognizeable

    $ mtn log --diffs --no-graph --brief --from <rev> --to <rev>

just to get the diff output which has lead to a particular revision
<rev> (which in turn I usually figure out via "mtn annotate"
beforehand).

I don't know whether it is just me, but I rather often need the _parent_
of a revision (if more parents exists, I'm out of luck doing an easy
diff anyway) and especially -- even if a command can figure it out --
want to avoid even having to copy & paste it more revision ids than
necessary.

So, find appended a small patch against h:n.v.m which implements a
"p:<rev>" selector. With this I now can finally use short commands like:

    $ mtn diff -r p:<rev> -r <rev>

The <rev> here can be an appreviated revision, too.

In case others find this additional selector also handy, are there any
objections if I commit this to n.v.m? Else I will include this stuff
just into the patchset I maintain for OpenPKG's "monotone" package...

                                       Ralf S. Engelschall
                                       address@hidden
                                       www.engelschall.com

Index: selectors.hh
--- selectors.hh        a580067010375b01e72094ebc255e26da4894384
+++ selectors.hh        04a1e8390e95624c89c100fd14de9157f5309dc1
@@ -30,6 +30,7 @@ namespace selectors
       sel_cert,
       sel_earlier,
       sel_later,
+      sel_parent,
       sel_unknown
     }
   selector_type;
Index: selectors.cc
--- selectors.cc        87df1393159bdc637059d9dfa9dfc52d50236326
+++ selectors.cc        1f5468137482871fb0c6b418357caa93eed01201
@@ -79,6 +79,9 @@ namespace selectors
           case 'e':
             type = sel_earlier;
             break;
+          case 'p':
+            type = sel_parent;
+            break;
           default:
             W(F("unknown selector type: %c") % sel[0]);
             break;
Index: database.cc
--- database.cc 4ae4c79a2a7fba4f39b072de6edc52625e1f69c0
+++ database.cc b37f89c9d264b674728fda144360e30d5d3b6397
@@ -2874,6 +2874,7 @@ static void selector_to_certname(selecto
     case selectors::sel_ident:
     case selectors::sel_cert:
     case selectors::sel_unknown:
+    case selectors::sel_parent:
       I(false); // don't do this.
       break;
     }
@@ -2914,6 +2915,11 @@ void database::complete(selector_type ty
               lim.sql_cmd += "SELECT id FROM revision_certs WHERE id GLOB ?";
               lim % text(i->second + "*");
             }
+          else if (i->first == selectors::sel_parent)
+            {
+              lim.sql_cmd += "SELECT parent AS id FROM revision_ancestry WHERE 
child GLOB ?";
+              lim % text(i->second + "*");
+            }
           else if (i->first == selectors::sel_cert)
             {
               if (i->second.length() > 0)
@@ -3033,7 +3039,7 @@ void database::complete(selector_type ty
   // will complete either some idents, or cert values, or "unknown"
   // which generally means "author, tag or branch"

-  if (ty == selectors::sel_ident)
+  if (ty == selectors::sel_ident || ty == selectors::sel_parent)
     {
       lim.sql_cmd = "SELECT id FROM " + lim.sql_cmd;
     }
Index: monotone.texi
--- monotone.texi       11dbcb7685ca2369e9131eb7a4c2194f6b5619ae
+++ monotone.texi       cb9220003751300efd0953226bac5db97cddbbf6
@@ -2765,6 +2765,10 @@ @heading Selectors in detail
 @item Identifier selection
 Uses selector type @code{i}. For example, @code{i:0f3a} matches
 revision IDs which begin with @code{0f3a}.
address@hidden 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
 @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}.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]