comparison tests/test-lfs-pointer.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents 8a08aefa9273
children 6000f5b25c9b
comparison
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
1 from __future__ import absolute_import, print_function 1 from __future__ import absolute_import, print_function
2 2
3 # Import something from Mercurial, so the module loader gets initialized. 3 # Import something from Mercurial, so the module loader gets initialized.
4 from mercurial import pycompat 4 from mercurial import pycompat
5
5 del pycompat # unused for now 6 del pycompat # unused for now
6 7
7 from hgext.lfs import pointer 8 from hgext.lfs import pointer
9
8 10
9 def tryparse(text): 11 def tryparse(text):
10 r = {} 12 r = {}
11 try: 13 try:
12 r = pointer.deserialize(text) 14 r = pointer.deserialize(text)
17 text2 = r.serialize() 19 text2 = r.serialize()
18 if text2 != text: 20 if text2 != text:
19 print('reconstructed text differs') 21 print('reconstructed text differs')
20 return r 22 return r
21 23
22 t = (b'version https://git-lfs.github.com/spec/v1\n' 24
23 b'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1' 25 t = (
24 b'258daaa5e2ca24d17e2393\n' 26 b'version https://git-lfs.github.com/spec/v1\n'
25 b'size 12345\n' 27 b'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1'
26 b'x-foo extra-information\n') 28 b'258daaa5e2ca24d17e2393\n'
29 b'size 12345\n'
30 b'x-foo extra-information\n'
31 )
27 32
28 tryparse(b'') 33 tryparse(b'')
29 tryparse(t) 34 tryparse(t)
30 tryparse(t.replace(b'git-lfs', b'unknown')) 35 tryparse(t.replace(b'git-lfs', b'unknown'))
31 tryparse(t.replace(b'v1\n', b'v1\n\n')) 36 tryparse(t.replace(b'v1\n', b'v1\n\n'))