[issue2623] repo tag cache not invalidated after prechangegroup hook

Tom Karzes bugs at mercurial.selenic.com
Fri Feb 4 02:57:48 UTC 2011


New submission from Tom Karzes <Tom.Karzes at magnumsemi.com>:

This is an old problem which is still present in the 1.7.5 release.

Accessing repo.tags() in a prechangegroup hook can cause side effects when a
pretxnchangegroup hook is later called.  Specifically, if repo.tags() is
called in the prechangegroup hook, then the tags are cached.  If repo.tags()
is later called in the pretxnchangegroup, then any newly added tags from the
push will not appear, because it re-uses the cached tags from the first
hook.  In other words, the set of tags seen in the second hook changes if
the first hook accesses the original tags.

The repo cache should be automatically invalidated after invoking a
prechangegroup hook function.  That would avoid this problem.

As an experiment, I found that I could avoid the problem by calling
repo.invalidate() after checking the tags in the prechangegroup hook.  For
example:

    def hook_prechangegroup(ui, repo, hooktype, ...):
        check_old_tags(repo.tags())
        repo.invalidate()
        return False

    def hook_pretxnchangegroup(ui, repo, hooktype, ...):
        return check_new_tags(repo.tags())

Is this a safe workaround while waiting for a fix?  Do I need to invalidate
the repo cache after the pretxnchangegroup as well?

----------
messages: 15118
nosy: tkarzes
priority: bug
status: unread
title: repo tag cache not invalidated after prechangegroup hook

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2623>
____________________________________________________


More information about the Mercurial-devel mailing list