Submitter | Yuya Nishihara |
---|---|
Date | July 17, 2015, 12:34 p.m. |
Message ID | <c8c61831756e1f0e5c96.1437136447@mimosa> |
Download | mbox | patch |
Permalink | /patch/10028/ |
State | Superseded |
Commit | be29d26e29494847d5460cace50fbd9f4587b98b |
Headers | show |
Comments
On Fri, 2015-07-17 at 21:34 +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1436066154 -32400 > # Sun Jul 05 12:15:54 2015 +0900 > # Node ID c8c61831756e1f0e5c969ae2fd694ebc1ea4f7c9 > # Parent 8836e46ccea8e45da42b0e2eda90cb0e88880353 > revset: parse nullary ":" operator as "0:tip" Very nice. These are queued for default, thanks. Vaguely related: how much trouble will we get in if we try to use ^ as a prefix operator to mean "child of"?
Matt Mackall <mpm@selenic.com> writes: > On Fri, 2015-07-17 at 21:34 +0900, Yuya Nishihara wrote: >> # HG changeset patch >> # User Yuya Nishihara <yuya@tcha.org> >> # Date 1436066154 -32400 >> # Sun Jul 05 12:15:54 2015 +0900 >> # Node ID c8c61831756e1f0e5c969ae2fd694ebc1ea4f7c9 >> # Parent 8836e46ccea8e45da42b0e2eda90cb0e88880353 >> revset: parse nullary ":" operator as "0:tip" > > Very nice. These are queued for default, thanks. > > Vaguely related: how much trouble will we get in if we try to use ^ as a > prefix operator to mean "child of"? You is talking loco and I like it!
On Fri, 17 Jul 2015 15:21:28 -0700, Sean Farley wrote: > Matt Mackall <mpm@selenic.com> writes: > > On Fri, 2015-07-17 at 21:34 +0900, Yuya Nishihara wrote: > >> # HG changeset patch > >> # User Yuya Nishihara <yuya@tcha.org> > >> # Date 1436066154 -32400 > >> # Sun Jul 05 12:15:54 2015 +0900 > >> # Node ID c8c61831756e1f0e5c969ae2fd694ebc1ea4f7c9 > >> # Parent 8836e46ccea8e45da42b0e2eda90cb0e88880353 > >> revset: parse nullary ":" operator as "0:tip" > > > > Very nice. These are queued for default, thanks. > > > > Vaguely related: how much trouble will we get in if we try to use ^ as a > > prefix operator to mean "child of"? > > You is talking loco and I like it! Is the idea like this? ^a 1st child of a ^^a 2nd child of a ^^^...^a nth child of a I can think of two problems: a) prefix "^" shadows suffix "^" because ambiguous suffix operator is taken as infix: a^^ -> (infix^ (infix^ (symbol "a") end)) (actual, parse error) (suffix^ (suffix^ (symbol "a"))) (expected) b) we can't specify <n>-th child as parameter Perhaps (a) can be fixed if ambiguous operators are resolved by binding strengths. It seems the current resolution is awkward: % hg debugrevspec -v 'a^:b' (parent ('symbol', 'a') (rangepre ('symbol', 'b'))) I think it should be taken as '(a^):b' because "^" has higher binding than ":". (range (parentpost ('symbol', 'a')) ('symbol', 'b'))
Patch
diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -123,7 +123,7 @@ elements = { "-": (5, None, ("negate", 19), ("minus", 5), None), "::": (17, None, ("dagrangepre", 17), ("dagrange", 17), "dagrangepost"), "..": (17, None, ("dagrangepre", 17), ("dagrange", 17), "dagrangepost"), - ":": (15, None, ("rangepre", 15), ("range", 15), "rangepost"), + ":": (15, "rangeall", ("rangepre", 15), ("range", 15), "rangepost"), "not": (10, None, ("not", 10), None, None), "!": (10, None, ("not", 10), None, None), "and": (5, None, None, ("and", 5), None), @@ -2225,6 +2225,8 @@ def optimize(x, small): return optimize(('func', ('symbol', 'ancestors'), x[1]), small) elif op == 'dagrangepost': return optimize(('func', ('symbol', 'descendants'), x[1]), small) + elif op == 'rangeall': + return optimize(('range', ('string', '0'), ('string', 'tip')), small) elif op == 'rangepre': return optimize(('range', ('string', '0'), x[1]), small) elif op == 'rangepost': diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -117,6 +117,25 @@ trivial <spanset+ 0:1> 0 1 + $ try --optimize : + (rangeall + None) + * optimized: + (range + ('string', '0') + ('string', 'tip')) + * set: + <spanset+ 0:9> + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 $ try 3::6 (dagrange ('symbol', '3')