[PATCH] largefiles: respect config settings in a pristine repo

Na'Tosha Bard natosha at gmail.com
Mon Dec 26 05:35:07 CST 2011


On Sun, Dec 25, 2011 at 11:30 PM, <michalsznajder at gmail.com> wrote:

> # HG changeset patch
> # User Michal Sznajder <michalsznajder at gmail.com>
> # Date 1324852023 -3600
> # Node ID c4130b507277eeccede1b8feef8506f76e552753
> # Parent  3bcfea777efc41c87918c1bb594615ff4fb6a34b
> largefiles: respect config settings in a pristine repo
>
> largefiles config settings (patterns and minsize) are not respected until
> at least one file is added and commited with --large option. it gives
> an impression for newcommers that largefiles are broken.
>

The reason why it works this way is because we don't want the repo turned
into a largefiles repo without the user having explicitly done so by
supplying the --large flag.  There can easily be cases where the user has
to deal with 5 different repos and has largefiles turned on because one of
them is a largefiles repo.  I believe your patch will make it so that any
repo could be turned into a largefiles repo if you supply a file that
matches the patterns or size limits.

So unless I'm misunderstanding what this patch does, I think it's a really
bad idea to change the behavior like this.  Largefiles adds a lot of
overhead, it adds some complexity, and it still las rough edges that need
to be fixed.  It should certainly not be used unless the user is completely
aware of all of these things, and the benefit gained is still worth that
trade-off.  Making it so that users can accidentally turn repos into
largefiles-enabled repos and not really notice it (especially if they are
using GUI tools and not the command-line) seems extremely dangerous.


> this patch solves this by relaxing some checks during add command
> processing
>
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -60,13 +60,12 @@
>  def override_add(orig, ui, repo, *pats, **opts):
>     large = opts.pop('large', None)
>     lfsize = lfutil.getminsize(
> -        ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
> +        ui, True, opts.pop('lfsize', None))
>
>     lfmatcher = None
> -    if os.path.exists(repo.wjoin(lfutil.shortname)):
> -        lfpats = ui.configlist(lfutil.longname, 'patterns', default=[])
> -        if lfpats:
> -            lfmatcher = match_.match(repo.root, '', list(lfpats))
> +    lfpats = ui.configlist(lfutil.longname, 'patterns', default=[])
> +    if lfpats:
> +        lfmatcher = match_.match(repo.root, '', list(lfpats))
>
>     lfnames = []
>     m = scmutil.match(repo[None], pats, opts)
> diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
> --- a/tests/test-largefiles.t
> +++ b/tests/test-largefiles.t
> @@ -11,11 +11,22 @@
>   > patterns=glob:**.dat
>   > EOF
>
> -Create the repo with a couple of revisions of both large and normal
> -files, testing that status correctly shows largefiles.
> +Create the repo and check that config settings (pattern **.dat, minsize 2
> MB)
> +are respected in a pristine repo.
>
>   $ hg init a
>   $ cd a
> +  $ echo testdata > test.dat
> +  $ dd bs=1m count=3 if=/dev/zero of=reallylarge > /dev/null 2> /dev/null
> +  $ hg add
> +  adding reallylarge as a largefile
> +  adding test.dat as a largefile
> +  $ hg forget test.dat reallylarge
> +  $ rm test.dat reallylarge
> +
> +Create couple of revisions of both large and normal
> +files, testing that status correctly shows largefiles.
> +
>   $ mkdir sub
>   $ echo normal1 > normal1
>   $ echo normal2 > sub/normal2
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20111226/a58620c9/attachment.html>


More information about the Mercurial-devel mailing list