| 1 |
# Import something from Mercurial, so the module loader gets initialized. |
| 2 |
from mercurial import pycompat |
| 3 |
|
| 4 |
del pycompat # unused for now |
| 5 |
|
| 6 |
from hgext.lfs import pointer |
| 7 |
|
| 8 |
|
| 9 |
def tryparse(text): |
| 10 |
r = {} |
| 11 |
try: |
| 12 |
r = pointer.deserialize(text) |
| 13 |
print('ok') |
| 14 |
except Exception as ex: |
| 15 |
print((b'%s' % ex).decode('ascii')) |
| 16 |
if r: |
| 17 |
text2 = r.serialize() |
| 18 |
if text2 != text: |
| 19 |
print('reconstructed text differs') |
| 20 |
return r |
| 21 |
|
| 22 |
|
| 23 |
t = ( |
| 24 |
b'version https://git-lfs.github.com/spec/v1\n' |
| 25 |
b'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1' |
| 26 |
b'258daaa5e2ca24d17e2393\n' |
| 27 |
b'size 12345\n' |
| 28 |
b'x-foo extra-information\n' |
| 29 |
) |
| 30 |
|
| 31 |
tryparse(b'') |
| 32 |
tryparse(t) |
| 33 |
tryparse(t.replace(b'git-lfs', b'unknown')) |
| 34 |
tryparse(t.replace(b'v1\n', b'v1\n\n')) |
| 35 |
tryparse(t.replace(b'sha256', b'ahs256')) |
| 36 |
tryparse(t.replace(b'sha256:', b'')) |
| 37 |
tryparse(t.replace(b'12345', b'0x12345')) |
| 38 |
tryparse(t.replace(b'extra-information', b'extra\0information')) |
| 39 |
tryparse(t.replace(b'extra-information', b'extra\ninformation')) |
| 40 |
tryparse(t.replace(b'x-foo', b'x_foo')) |
| 41 |
tryparse(t.replace(b'oid', b'blobid')) |
| 42 |
tryparse(t.replace(b'size', b'size-bytes').replace(b'oid', b'object-id')) |