[PATCH 1 of 5] tags: don't read .hgtags fnodes from tags cache files

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Apr 16 14:13:49 CDT 2015



On 04/16/2015 12:02 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1429193564 14400
> #      Thu Apr 16 10:12:44 2015 -0400
> # Node ID c56d6e53eb5f10b431f4e88b3959e063a0b665b6
> # Parent  d5711c886d0b1acb2d18b92bf6e8ba6d9ad0c4b3
> tags: don't read .hgtags fnodes from tags cache files

I've a couple of comment here. But I got them clarified with greg in 
real life. I've pushed a fixed version to the clowncopter. I'll 
patchbomb a V2 for reference.

> @@ -277,37 +277,34 @@ def _readtagcache(ui, repo):
>           cachelines = iter(cachefile)
>       except IOError:
>           cachefile = None
>
> -    cacherevs = []  # list of headrev
> -    cacheheads = [] # list of headnode
> -    cachefnode = {} # map headnode to filenode
> +    cachetiprev = None
> +    cachetipnode = None
>       if cachefile:
>           try:
> -            for line in cachelines:
> +            for i, line in enumerate(cachelines):
>                   if line == "\n":
>                       break
> +                if i != 0:
> +                    continue

What is this witchcraft about?


>       # Case 1 (common): tip is the same, so nothing has changed.
>       # (Unchanged tip trivially means no changesets have been added.
>       # But, thanks to localrepository.destroyed(), it also means none
>       # have been destroyed by strip or rollback.)
> -    if cacheheads and cacheheads[0] == tipnode and cacherevs[0] == tiprev:
> +    if cachetiprev is not None and cachetiprev == tiprev and \
> +            cachetipnode == tipnode:
>           tags = _readtags(ui, repo, cachelines, cachefile.name)
>           cachefile.close()
>           return (None, None, tags, False)
>       if cachefile:

do not use \ continuation, it makes kitten sad. wrap that in ()

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list