Mercurial > public > mercurial-scm > hg
diff mercurial/revset.py @ 30071:2def3d55b1b9
revset: build _syminitletters from a saner source: the string module
For now, these sets will be unicode characters in Python 3, which is
probably wrong, but it un-blocks importing the module so we can get
further along. In the future we'll have to come up with a reasonable
encoding strategy for revsets in Python 3.
This patch was originally pair-programmed with Martijn.
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 07 Oct 2016 08:32:40 -0400 |
parents | 3eb4df6d15f8 |
children | d61c42c1a35c |
line wrap: on
line diff
--- a/mercurial/revset.py Thu Aug 11 15:05:17 2016 +0200 +++ b/mercurial/revset.py Fri Oct 07 08:32:40 2016 -0400 @@ -9,6 +9,7 @@ import heapq import re +import string from .i18n import _ from . import ( @@ -22,6 +23,7 @@ parser, pathutil, phases, + pycompat, registrar, repoview, util, @@ -173,11 +175,12 @@ keywords = set(['and', 'or', 'not']) # default set of valid characters for the initial letter of symbols -_syminitletters = set(c for c in [chr(i) for i in xrange(256)] - if c.isalnum() or c in '._@' or ord(c) > 127) +_syminitletters = set( + string.ascii_letters + + string.digits + pycompat.sysstr('._@')) | set(map(chr, xrange(128, 256))) # default set of valid characters for non-initial letters of symbols -_symletters = _syminitletters | set('-/') +_symletters = _syminitletters | set(pycompat.sysstr('-/')) def tokenize(program, lookup=None, syminitletters=None, symletters=None): ''' @@ -2619,8 +2622,7 @@ # the set of valid characters for the initial letter of symbols in # alias declarations and definitions -_aliassyminitletters = set(c for c in [chr(i) for i in xrange(256)] - if c.isalnum() or c in '._@$' or ord(c) > 127) +_aliassyminitletters = _syminitletters | set(pycompat.sysstr('$')) def _parsewith(spec, lookup=None, syminitletters=None): """Generate a parse tree of given spec with given tokenizing options