view tag_repo.py @ 298:32d3f1716e66

Two minor optimisations/cleanups for svn_swig_wrapper: - 'self' is not used in 'RaCallbacks', so use the @staticmethod decorator syntax introduced in Python 2.4. - Make 'Revision' derive from 'tuple' and use property getters to obtain the individual values. In N+1 years, we can use the NamedRecord introduced in Python 2.6.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 27 Mar 2009 02:50:01 +0100
parents 91c818377703
children 33736e2e25f0
line wrap: on
line source

from mercurial import node

import hg_delta_editor


def tags_from_tag_info(repo):
    hg_editor = hg_delta_editor.HgChangeReceiver(repo=repo)
    for tag, source in hg_editor.tags.iteritems():
        source_ha = hg_editor.get_parent_revision(source[1]+1, source[0])
        yield 'tag/%s'%tag, node.hex(source_ha)


def generate_repo_class(ui, repo):

    class svntagrepo(repo.__class__):
        def tags(self):
            tags = dict((k, node.bin(v))
                        for k,v in tags_from_tag_info(self))
            hg_tags = super(svntagrepo, self).tags()
            tags.update(hg_tags)
            return tags

    return svntagrepo