mercurial/__init__.py
changeset 31159 76a64c1e5439
parent 30166 102e6ef5bb3a
child 31160 7c54917b31f6
equal deleted inserted replaced
31158:3eaff87a0a89 31159:76a64c1e5439
   278                 if fullname == 'mercurial.pycompat':
   278                 if fullname == 'mercurial.pycompat':
   279                     yield t
   279                     yield t
   280                     continue
   280                     continue
   281                 r, c = t.start
   281                 r, c = t.start
   282                 l = (b'; from mercurial.pycompat import '
   282                 l = (b'; from mercurial.pycompat import '
   283                      b'delattr, getattr, hasattr, setattr, xrange\n')
   283                      b'delattr, getattr, hasattr, setattr, xrange, open\n')
   284                 for u in tokenize.tokenize(io.BytesIO(l).readline):
   284                 for u in tokenize.tokenize(io.BytesIO(l).readline):
   285                     if u.type in (tokenize.ENCODING, token.ENDMARKER):
   285                     if u.type in (tokenize.ENCODING, token.ENDMARKER):
   286                         continue
   286                         continue
   287                     yield u._replace(
   287                     yield u._replace(
   288                         start=(r, c + u.start[1]), end=(r, c + u.end[1]))
   288                         start=(r, c + u.start[1]), end=(r, c + u.end[1]))
   325 
   325 
   326     # Header to add to bytecode files. This MUST be changed when
   326     # Header to add to bytecode files. This MUST be changed when
   327     # ``replacetoken`` or any mechanism that changes semantics of module
   327     # ``replacetoken`` or any mechanism that changes semantics of module
   328     # loading is changed. Otherwise cached bytecode may get loaded without
   328     # loading is changed. Otherwise cached bytecode may get loaded without
   329     # the new transformation mechanisms applied.
   329     # the new transformation mechanisms applied.
   330     BYTECODEHEADER = b'HG\x00\x06'
   330     BYTECODEHEADER = b'HG\x00\x07'
   331 
   331 
   332     class hgloader(importlib.machinery.SourceFileLoader):
   332     class hgloader(importlib.machinery.SourceFileLoader):
   333         """Custom module loader that transforms source code.
   333         """Custom module loader that transforms source code.
   334 
   334 
   335         When the source code is converted to a code object, we transform
   335         When the source code is converted to a code object, we transform