Mercurial > hg
view tests/test-lfs-pointer.py @ 41595:8785188d1915
scmutil: introduce a new backuppath() to replace origpath()
Unlike most functions in our codebase, origpath() takes a path that is
relative to cwd. This commit introduces a replacement for
origpath(). The new function takes a path that is relative to the repo
root. There is a lot of duplication between the two, but I intend to
remove origpath() within the next few commits, so it won't be a
maintenance burden.
origpath() is also a little weird in that it returns either a a
cwd-relative path or an absolute path. It needs to be able to return a
path outside the repo, so it makes sense that it can return an
absolute path. However, it would be simpler to always return an
absolute path. The new function does that.
Differential Revision: https://phab.mercurial-scm.org/D5851
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 04 Feb 2019 20:46:33 -0800 |
parents | 8a08aefa9273 |
children | 2372284d9457 |
line wrap: on
line source
from __future__ import absolute_import, print_function # 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'))