Mercurial > hg
view tests/test-lfs-pointer.py @ 39811:ae20f52437e9
wireprotov2: advertise recognized path filter prefixes
While the wire protocol doesn't yet support it, we'll eventually
have commands that accept narrow patterns to specify the set of
files relevant to a command.
For security and performance reasons, only specific filter types
are allowed.
This commit teaches the server to advertise the set of allowed
filter types. By doing so, clients can e.g. validate user-specified
patterns against the server's abilities without having to send
a command to retrieve data.
Having the data in the capabilities data structure will also serve
as a check against unwanted BC.
Differential Revision: https://phab.mercurial-scm.org/D4616
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 17 Sep 2018 09:49:28 -0700 |
parents | 7cd1e1adc471 |
children | 8a08aefa9273 |
line wrap: on
line source
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__), '..')] # Import something from Mercurial, so the module loader gets initialized. from mercurial import pycompat del pycompat # unused for now from hgext.lfs import pointer def tryparse(text): r = {} try: r = pointer.deserialize(text) print('ok') except Exception as ex: print((b'%s' % ex).decode('ascii')) if r: text2 = r.serialize() if text2 != text: print('reconstructed text differs') return r t = (b'version https://git-lfs.github.com/spec/v1\n' b'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1' b'258daaa5e2ca24d17e2393\n' b'size 12345\n' b'x-foo extra-information\n') tryparse(b'') tryparse(t) tryparse(t.replace(b'git-lfs', b'unknown')) tryparse(t.replace(b'v1\n', b'v1\n\n')) tryparse(t.replace(b'sha256', b'ahs256')) tryparse(t.replace(b'sha256:', b'')) tryparse(t.replace(b'12345', b'0x12345')) tryparse(t.replace(b'extra-information', b'extra\0information')) tryparse(t.replace(b'extra-information', b'extra\ninformation')) tryparse(t.replace(b'x-foo', b'x_foo')) tryparse(t.replace(b'oid', b'blobid')) tryparse(t.replace(b'size', b'size-bytes').replace(b'oid', b'object-id'))