# HG changeset patch # User Augie Fackler # Date 1475843560 14400 # Node ID 2def3d55b1b9ec2acd53f96ca755d778b5ec865b # Parent 3006d0d26ad37f3e3e5f20559733cedb17688415 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. diff -r 3006d0d26ad3 -r 2def3d55b1b9 mercurial/revset.py --- 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 diff -r 3006d0d26ad3 -r 2def3d55b1b9 tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t Thu Aug 11 15:05:17 2016 +0200 +++ b/tests/test-check-py3-compat.t Fri Oct 07 08:32:40 2016 -0400 @@ -120,35 +120,33 @@ mercurial/httppeer.py: error importing: Can't mix strings and bytes in path components (error at i18n.py:*) mercurial/i18n.py: error importing module: bytes expected, not str (line *) mercurial/keepalive.py: error importing module: module 'mercurial.util' has no attribute 'httplib' (line *) - mercurial/localrepo.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) + mercurial/localrepo.py: error importing: module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*) mercurial/mail.py: error importing module: module 'email' has no attribute 'Header' (line *) - mercurial/manifest.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/merge.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/namespaces.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/patch.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) + mercurial/manifest.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/merge.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/namespaces.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/patch.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) mercurial/pvec.py: error importing module: name 'xrange' is not defined (line *) - mercurial/repair.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/revlog.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/revset.py: error importing module: name 'xrange' is not defined (line *) - mercurial/scmutil.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) + mercurial/repair.py: error importing: module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*) + mercurial/revlog.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/revset.py: error importing module: 'dict' object has no attribute 'iteritems' (line *) mercurial/scmwindows.py: error importing module: No module named 'winreg' (line *) - mercurial/simplemerge.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/sshpeer.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/sshserver.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) + mercurial/sshpeer.py: error importing: module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*) + mercurial/sshserver.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) mercurial/statichttprepo.py: error importing: module 'mercurial.util' has no attribute 'urlerr' (error at byterange.py:*) - mercurial/store.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/streamclone.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/subrepo.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/templatefilters.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/templatekw.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/templater.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/ui.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) - mercurial/unionrepo.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) + mercurial/store.py: error importing module: name 'xrange' is not defined (line *) + mercurial/streamclone.py: error importing: can't concat bytes to str (error at store.py:*) + mercurial/subrepo.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/templatefilters.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/templatekw.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/templater.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/ui.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) + mercurial/unionrepo.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) mercurial/url.py: error importing: module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*) - mercurial/verify.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) + mercurial/verify.py: error importing: module 'email' has no attribute 'Header' (error at mail.py:*) mercurial/win32.py: error importing module: No module named 'msvcrt' (line *) mercurial/windows.py: error importing module: No module named 'msvcrt' (line *) - mercurial/wireproto.py: error importing: a bytes-like object is required, not 'str' (error at revset.py:*) + mercurial/wireproto.py: error importing: %b requires bytes, or an object that implements __bytes__, not 'str' (error at bundle2.py:*) #endif