[PATCH V2] lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'

Yuya Nishihara yuya at tcha.org
Fri Jan 19 07:21:30 EST 2018


On Fri, 19 Jan 2018 00:05:42 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1515967224 18000
> #      Sun Jan 14 17:00:24 2018 -0500
> # Node ID fccf09e44f5124abf18ae898fab553ea6d91e951
> # Parent  45b678bf3a787085d56fad5bee494e0c160aa120
> lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'

Queued updated version, thanks.

> I liked {pointer} better, but couldn't make it work with the singular/plural
> forms.

I think {pointer} is okay here since its singular form is ({key}, {value}).

> @@ -303,6 +304,8 @@
>      # when writing a bundle via "hg bundle" command, upload related LFS blobs
>      wrapfunction(bundle2, 'writenewbundle', wrapper.writenewbundle)
>  
> +    templatekw.defaulttempl['lfsattr'] = '{key}={value}'

This isn't needed. Dropped.

> @@ -311,9 +314,16 @@
>      pointers = wrapper.pointersfromctx(ctx) # {path: pointer}
>      files = sorted(pointers.keys())
>  
> +    def lfsattrs(v):
> +        # In the file spec, version is first and the other keys are sorted.
> +        sortkeyfunc = lambda x: (x[0] != 'version', x)
> +        items = sorted(pointers[v].iteritems(), key=sortkeyfunc)
> +        return util.sortdict(kv for kv in items)

s/kv for kv in//

> diff --git a/tests/test-lfs.t b/tests/test-lfs.t
> --- a/tests/test-lfs.t
> +++ b/tests/test-lfs.t
> @@ -865,6 +865,17 @@
>    oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
>    size 29
>    x-is-binary 0
> +  $ hg --cwd convert_lfs log -r 0 -T "{lfs_files % '{lfsattrs % \"{lfsattr}\n\"}'}"

This example just applies defaulttempl['lfsattr']. Inlined '{key}={value}'.


More information about the Mercurial-devel mailing list