On Sat, Oct 06, 2007, Ralf S. Engelschall wrote: > 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... > [...]
Ok, here is the final patch which includes the documentation update and a little corresponding test for "make check". Any objections for comitting this? Ralf S. Engelschall [EMAIL PROTECTED] 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 ba3e94933926c735fe99c81024701beaaef7203a +++ monotone.texi 9bdc10fe42bccd03dae526214854bc4d08f863b5 @@ -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}. [EMAIL PROTECTED] 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 [EMAIL PROTECTED] @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}. =================================================================== Index: tests/parent_revision_selector/__driver__.lua --- tests/parent_revision_selector/__driver__.lua 9b3fb350caf11956ba9ee62f74e967d83bbd2dc1 +++ tests/parent_revision_selector/__driver__.lua 9b3fb350caf11956ba9ee62f74e967d83bbd2dc1 @@ -0,0 +1,36 @@ + +-- setup workspace +mtn_setup() +revs = {} + +-- commit a revision #1 +addfile("testfile", "this is just a test file") +commit() +revs[1] = base_revision() + +-- commit a revision #2 +writefile("testfile", "now we change the content") +commit() +revs[2] = base_revision() + +-- commit a revision #3 +writefile("testfile", "now we change the content again") +commit() +revs[3] = base_revision() + +-- make sure that revision #3 is the head now +check(mtn("automate", "select", "h:"), 0, true, false) +check(trim(readfile("stdout")) == revs[3]) + +-- select the parent of revision #3 (== revision #2) +check(mtn("automate", "select", "p:" .. revs[3]), 0, true, false) +check(trim(readfile("stdout")) == revs[2]) + +-- select the parent of revision #2 (== revision #1) +check(mtn("automate", "select", "p:" .. revs[2]), 0, true, false) +check(trim(readfile("stdout")) == revs[1]) + +-- select the parent of revision #1 (== none) +check(mtn("automate", "select", "p:" .. revs[1]), 0, true, false) +check(trim(readfile("stdout")) == "") + _______________________________________________ Monotone-devel mailing list Monotone-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/monotone-devel