[PATCH STABLE] store: remove zero size files from fncache

Adrian Buehlmann adrian at cadifra.com
Wed Mar 3 14:22:10 CST 2010


On 03.03.2010 20:46, Adrian Buehlmann wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1267641462 -3600
> # Branch stable
> # Node ID 5e8f1e8fc98af12d7f16082c8992c90d2d5623fc
> # Parent  d5bd1beff794461611bb37999a79bd110c88d008
> store: remove zero size files from fncache
> 
> 'hg strip' truncates files in the store to zero if those files were added in a
> stripped changeset.
> 
> These zero-size files should be treated the same as nonexistent fncache entries,
> i.e. not be yielded by store.fncachestore.datafiles and removed from the fncache
> file.
> 
> diff --git a/mercurial/store.py b/mercurial/store.py
> --- a/mercurial/store.py
> +++ b/mercurial/store.py
> @@ -309,8 +309,12 @@ class fncachestore(basicstore):
>              ef = hybridencode(f)
>              try:
>                  st = os.stat(pjoin(spath, ef))
> -                yield f, ef, st.st_size
> -                existing.append(f)
> +                if st.st_size != 0:
> +                    yield f, ef, st.st_size
> +                    existing.append(f)
> +                else:
> +                    # stripped by mq, remove entry from fncache
> +                    rewrite = True
>              except OSError:
>                  # nonexistent entry
>                  rewrite = True
> diff --git a/mercurial/verify.py b/mercurial/verify.py
> --- a/mercurial/verify.py
> +++ b/mercurial/verify.py
> @@ -197,7 +197,7 @@ def _verify(repo):
>      for f, f2, size in repo.store.datafiles():
>          if not f:
>              err(None, _("cannot decode filename '%s'") % f2)
> -        elif size > 0:
> +        else:
>              storefiles.add(f)

This has the problem that the other store kinds still return zero size
files (as tonfa pointed out on IRC).

So, zero size files should be filtered out in all variants of datafiles.




More information about the Mercurial-devel mailing list