From patchwork Tue Aug 4 15:10:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 4] revset: port parsing rule of old-style ranges from scmutil.revrange() From: Yuya Nishihara X-Patchwork-Id: 10101 Message-Id: To: mercurial-devel@selenic.com Date: Wed, 05 Aug 2015 00:10:28 +0900 # HG changeset patch # User Yuya Nishihara # Date 1437229817 -32400 # Sat Jul 18 23:30:17 2015 +0900 # Node ID fb330f1901e39f450b5aec93e590df1a247c2bfc # Parent d31439b19ed278f05b0c1e113fc9b48bb1627f7e revset: port parsing rule of old-style ranges from scmutil.revrange() The old-style parser will be removed soon. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -178,6 +178,21 @@ def tokenize(program, lookup=None, symin if symletters is None: symletters = _symletters + if program and lookup: + # attempt to parse old-style ranges first to deal with + # things like old-tag which contain query metacharacters + parts = program.split(':', 1) + if all(lookup(sym) for sym in parts if sym): + if parts[0]: + yield ('symbol', parts[0], 0) + if len(parts) > 1: + s = len(parts[0]) + yield (':', None, s) + if parts[1]: + yield ('symbol', parts[1], s + 1) + yield ('end', None, len(program)) + return + pos, l = 0, len(program) while pos < l: c = program[pos] diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -201,13 +201,49 @@ names that should work without quoting names that should be caught by fallback mechanism $ try -- '-a-b-c-' - (negate - ('symbol', 'a-b-c-')) + ('symbol', '-a-b-c-') * set: 4 $ log -a-b-c- 4 + $ try '+a+b+c+' + ('symbol', '+a+b+c+') + * set: + + 3 + $ try '+a+b+c+:' + (rangepost + ('symbol', '+a+b+c+')) + * set: + + 3 + 4 + 5 + 6 + 7 + 8 + 9 + $ try ':+a+b+c+' + (rangepre + ('symbol', '+a+b+c+')) + * set: + + 0 + 1 + 2 + 3 + $ try -- '-a-b-c-:+a+b+c+' + (range + ('symbol', '-a-b-c-') + ('symbol', '+a+b+c+')) + * set: + + 4 + 3 + $ log '-a-b-c-:+a+b+c+' + 4 + 3 $ try -- -a-b-c--a # complains (minus