[PATCH 1 of 1] change tag computation to avoid surprises in case of multiple heads

Benoit Boissinot bboissin at gmail.com
Sun Jan 7 11:59:39 CST 2007


On 1/7/07, Georg-W. Koltermann <gwk.rko at googlemail.com> wrote:
> # HG changeset patch
> # User Georg.Koltermann at mscsoftware.com
> # Date 1168174877 -3600
> # Node ID 82cb2abeddfb1643e68fd2b5bcfac243896a1dc1
> # Parent  27230c29bfec36d5540fbe1c976810aefecfd1d2
> FEATUREFIX: Change tag computation so that obsoleted tag lines (those lines in a tags file that are
> superseded by subsequent lines of the same tag) are ignored.
>
> Previously for any given tag the last entry in the tipmost tags file would win.  This caused
> considerable surprises when a new tip was created off a historic version containing an
> older .tags file.
>
> With this change, lines that are superseded by newer entries in .tags files (called
> obsoleted lines) are ignored in the process of tag computation. So creating a new
> tip off a historic version will only result in exposing a new obsoleted tag entry which
> is ignored, so having no effect on the final tag value.
>
> diff -r 27230c29bfec -r 82cb2abeddfb mercurial/localrepo.py
> --- a/mercurial/localrepo.py    Sun Dec 17 05:00:22 2006 +0100
> +++ b/mercurial/localrepo.py    Sun Jan 07 14:01:17 2007 +0100
> @@ -259,8 +259,18 @@ class localrepository(repo.repository):
>          '''return a mapping of tag to node'''
>          if not self.tagscache:
>              self.tagscache = {}
> -
> -            def parsetag(line, context):
> +            self._obsoletedTagValues = {}
> +
> +            def obsoleteTagValue(key, bin_n):

please do not use CamelCase

> +                if not key in self._obsoletedTagValues:
> +                    self._obsoletedTagValues[key] = {}
> +                self._obsoletedTagValues[key][bin_n] = 1

self._obsoletedTagValues.setdefault(key, {})[bin_n] = 1
but you could probably just use the couple (tag, node) as a key
> +
> +            def isObsoleteTagValue(key, bin_n):
> +                return (key in self._obsoletedTagValues and
> +                        bin_n in self._obsoletedTagValues[key])
> +
>
> [snip]

Otherwise looks ok.

Benoit


More information about the Mercurial-devel mailing list