[PATCH 1 of 7] localrepo: factor _findtags() out of tags() (affects mq and bookmarks)

Dirkjan Ochtman dirkjan at ochtman.nl
Fri Jul 3 10:10:33 CDT 2009


On Fri, Jul 3, 2009 at 16:48, Greg Ward<greg at gerg.ca> wrote:
> # HG changeset patch
> # User Greg Ward <greg at gerg.ca>
> # Date 1246632310 14400
> # Node ID bc27cc5162749383dbf6852aeb2d8b426e1bf6fd
> # Parent  f46265d17271dc20e5547d26d86de7ac3975dc6c
> localrepo: factor _findtags() out of tags() (affects mq and bookmarks).

Nice...

> @@ -235,6 +235,17 @@
>         '''return a mapping of tag to node'''
>         if self.tagscache:
>             return self.tagscache
> +        else:
> +            return self._findtags()
> +
> +    def _findtags(self):
> +        '''do the hard work of finding tags and populating self.tagscache'''
> +
> +        # XXX bogus: this method has both side effect (update
> +        # self.tagscache) and return value (self.tagscache itself).
> +        # Worse, tags() uses it for side effect, but mqrepo and
> +        # bookmarkrepo both use it for its return value.  Make up your
> +        # mind: return value or side effect -- not both!
>
>         globaltags = {}
>         tagtypes = {}

Just a return value seems nicer to me.

Cheers,

Dirkjan



More information about the Mercurial-devel mailing list