--- a/mercurial/revset.py Sat Oct 01 20:11:48 2016 +0900
+++ b/mercurial/revset.py Sat Oct 01 20:20:11 2016 +0900
@@ -368,6 +368,13 @@
return baseset()
return _makerangeset(repo, subset, m.first(), n.last(), order)
+def rangepre(repo, subset, y, order):
+ # ':y' can't be rewritten to '0:y' since '0' may be hidden
+ n = getset(repo, fullreposet(repo), y)
+ if not n:
+ return baseset()
+ return _makerangeset(repo, subset, 0, n.last(), order)
+
def _makerangeset(repo, subset, m, n, order):
if m == n:
r = baseset([m])
@@ -2329,6 +2336,7 @@
methods = {
"range": rangeset,
+ "rangepre": rangepre,
"dagrange": dagrange,
"string": stringset,
"symbol": stringset,
@@ -2444,9 +2452,7 @@
elif op == 'dagrangepost':
return _analyze(('func', ('symbol', 'descendants'), x[1]), order)
elif op == 'rangeall':
- return _analyze(('range', ('string', '0'), ('string', 'tip')), order)
- elif op == 'rangepre':
- return _analyze(('range', ('string', '0'), x[1]), order)
+ return _analyze(('rangepre', ('string', 'tip')), order)
elif op == 'rangepost':
return _analyze(('range', x[1], ('string', 'tip')), order)
elif op == 'negate':
@@ -2462,7 +2468,7 @@
return (op, _analyze(x[1], order), order)
elif op == 'not':
return (op, _analyze(x[1], anyorder), order)
- elif op == 'parentpost':
+ elif op in ('rangepre', 'parentpost'):
return (op, _analyze(x[1], defineorder), order)
elif op == 'group':
return _analyze(x[1], order)
@@ -2567,7 +2573,7 @@
o = _optimize(x[1], not small)
order = x[2]
return o[0], (op, o[1], order)
- elif op == 'parentpost':
+ elif op in ('rangepre', 'parentpost'):
o = _optimize(x[1], small)
order = x[2]
return o[0], (op, o[1], order)
--- a/tests/test-revset.t Sat Oct 01 20:11:48 2016 +0900
+++ b/tests/test-revset.t Sat Oct 01 20:20:11 2016 +0900
@@ -161,8 +161,7 @@
(rangeall
None)
* optimized:
- (range
- ('string', '0')
+ (rangepre
('string', 'tip')
define)
* set:
@@ -612,6 +611,63 @@
8
9
+':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
+may be hidden (issue5385)
+
+ $ try -p parsed -p analyzed ':'
+ * parsed:
+ (rangeall
+ None)
+ * analyzed:
+ (rangepre
+ ('string', 'tip')
+ define)
+ * set:
+ <spanset+ 0:9>
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ $ try -p analyzed ':1'
+ * analyzed:
+ (rangepre
+ ('symbol', '1')
+ define)
+ * set:
+ <spanset+ 0:1>
+ 0
+ 1
+ $ try -p analyzed ':(1|2)'
+ * analyzed:
+ (rangepre
+ (or
+ (list
+ ('symbol', '1')
+ ('symbol', '2'))
+ define)
+ define)
+ * set:
+ <spanset+ 0:2>
+ 0
+ 1
+ 2
+ $ try -p analyzed ':(1&2)'
+ * analyzed:
+ (rangepre
+ (and
+ ('symbol', '1')
+ ('symbol', '2')
+ define)
+ define)
+ * set:
+ <baseset []>
+
infix/suffix resolution of ^ operator (issue2884):
x^:y means (x^):y