[PATCH 4 of 9 V3] localrepo: use _findlocaltags in _findtags

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Apr 1 03:13:25 UTC 2014



On 03/28/2014 03:06 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1395964989 18000
> #      Thu Mar 27 19:03:09 2014 -0500
> # Node ID ee90b9a274e93bf091e9c00f9bfc916eb98e2408
> # Parent  ccf260976f55dd32cc8d5158d9f164c365275ee4
> localrepo: use _findlocaltags in _findtags
>
> This makes the only caller of tags.readlocaltags localrepo._findlocaltags now.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -611,13 +611,21 @@ class localrepository(object):
>
>           alltags = {}                    # map tag name to (node, hist)
>           tagtypes = {}
>
>           tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
> -        tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
> +        tags, tagtypes = self._encodetags(alltags, tagtypes)
>
> -        tags, tagtypes = self._encodetags(alltags, tagtypes)
> +        ltags, ltagtypes = self._findlocaltags()
> +        # global tags take precedence, so we only update distinct local tags
> +        ltags = dict([(name, node) for name, node in ltags.iteritems()
> +                      if name not in tags])
> +        ltagtypes = dict([(name, type) for name, type in ltagtypes.iteritems()
> +                          if name not in tagtypes])
> +        tags.update(ltags)
> +        tagtypes.update(ltagtypes)
> +

If global tags overwrite local ones. Why don't you "simply do"

   alltags, alltagtypes = self._findlocaltags()
   gtabs, gtypes = {}, {}
   tagsmod.findglobaltags(self.ui, self, gtags, gtypes)
   gtags, gtypes = self._encodetags(gtags, gtypes)
   alltags.update(gtags)
   alltagtypes.update(gtypes)

(or even better, moving the encoding part in the findglobaltags logic 
and drop the intermediate dict.


(also consider moving the logic into the tag module for humanity goods)

-- 
Pierre-Yves


More information about the Mercurial-devel mailing list