[PATCH 2 of 2 V2] lfs: control tracked file selection via a tracked file

Yuya Nishihara yuya at tcha.org
Wed Jan 17 09:07:50 EST 2018


On Wed, 17 Jan 2018 01:02:27 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1515971571 18000
> #      Sun Jan 14 18:12:51 2018 -0500
> # Node ID 074417bc25368171950f0e8e292b151f9641b5a0
> # Parent  03d737594660bb74823317e02a6ad2e91456c12d
> lfs: control tracked file selection via a tracked file

Looks generally good, and there was no comment for the previous version.
Queued, thanks.

>  Configs::
>  
>      [lfs]
> @@ -35,6 +59,9 @@
>      # - (**.php & size(">2MB")) | (**.js & size(">5MB")) | **.tar.gz
>      #     | ("path:bin" & !"path:/bin/README") | size(">1GB")
>      # (default: none())
> +    #
> +    # This is ignored if there is a tracked '.hglfs' file, and this setting
> +    # will eventually be deprecated and removed.

[...]

> @@ -149,18 +185,58 @@
>          ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs')
>          ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs')
>  
> -def _trackedmatcher(repo):
> +def _trackedmatcher(repo, ctx):
>      """Return a function (path, size) -> bool indicating whether or not to
>      track a given file with lfs."""
> -    trackspec = repo.ui.config('lfs', 'track')
> +    data = ''
> +
> +    if '.hglfs' in ctx.added() or '.hglfs' in ctx.modified():
> +        data = ctx['.hglfs'].data()
> +    elif '.hglfs' not in ctx.removed():
> +        p1 = repo['.']
> +
> +        if '.hglfs' not in p1:
> +            # No '.hglfs' in wdir or in parent.  Fallback to config
> +            # for now.
> +            trackspec = repo.ui.config('lfs', 'track')
> +
> +            # deprecated config: lfs.threshold
> +            threshold = repo.ui.configbytes('lfs', 'threshold')
> +            if threshold:
> +                fileset.parse(trackspec)  # make sure syntax errors are confined
> +                trackspec = "(%s) | size('>%d')" % (trackspec, threshold)

This seems okay if we'll drop the support for lfs.threshold. If we won't,
I think lfs.threshold should be OR-ed with the .hglfs rules.


More information about the Mercurial-devel mailing list