##// END OF EJS Templates
pycompat: export queue module instead of symbols in module (API)...
pycompat: export queue module instead of symbols in module (API) Previously, pycompat and util re-exported individual symbols from the queue module. This had the side-effect of forcing the loading of the queue module whenever pycompat/util was imported. These symbols aren't used very often. So importing the module to get a handle on the symbols is wasteful. This commit changes pycompat so it no longer exports the individual symbols in the queue module. Instead, we make the imported module a "public" symbol. We drop the individual symbol aliases from the util module. All consumers are updated to use pycompat.queue.* instead. This change makes 300 invocations of `hg log -r. -T '{rev}\n'` a little faster: before: 18.44s after: 17.87s Differential Revision: https://phab.mercurial-scm.org/D3441

File last commit:

r35097:66c5a8cf default
r38100:8fb99853 @25 default
Show More
test-lfs-pointer.py
41 lines | 1.2 KiB | text/x-python | PythonLexer
from __future__ import absolute_import, print_function
import os
import sys
# make it runnable using python directly without run-tests.py
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
from hgext.lfs import pointer
def tryparse(text):
r = {}
try:
r = pointer.deserialize(text)
print('ok')
except Exception as ex:
print(ex)
if r:
text2 = r.serialize()
if text2 != text:
print('reconstructed text differs')
return r
t = ('version https://git-lfs.github.com/spec/v1\n'
'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1'
'258daaa5e2ca24d17e2393\n'
'size 12345\n'
'x-foo extra-information\n')
tryparse('')
tryparse(t)
tryparse(t.replace('git-lfs', 'unknown'))
tryparse(t.replace('v1\n', 'v1\n\n'))
tryparse(t.replace('sha256', 'ahs256'))
tryparse(t.replace('sha256:', ''))
tryparse(t.replace('12345', '0x12345'))
tryparse(t.replace('extra-information', 'extra\0information'))
tryparse(t.replace('extra-information', 'extra\ninformation'))
tryparse(t.replace('x-foo', 'x_foo'))
tryparse(t.replace('oid', 'blobid'))
tryparse(t.replace('size', 'size-bytes').replace('oid', 'object-id'))