tests/revnamesext.py
author Manuel Jacob <me@manueljacob.de>
Fri, 17 Jul 2020 14:58:22 +0200
changeset 45157 74b486226480
parent 43076 2372284d9457
child 48966 6000f5b25c9b
permissions -rw-r--r--
windows: handle file-like objects without isatty() method Copying the function is not nice, but moving around stuff to avoid the circular import didn’t seem to be worth the effort.

# Dummy extension to define a namespace containing revision names

from __future__ import absolute_import

from mercurial import namespaces


def reposetup(ui, repo):
    names = {b'r%d' % rev: repo[rev].node() for rev in repo}
    namemap = lambda r, name: names.get(name)
    nodemap = lambda r, node: [b'r%d' % repo[node].rev()]

    ns = namespaces.namespace(
        b'revnames',
        templatename=b'revname',
        logname=b'revname',
        listnames=lambda r: names.keys(),
        namemap=namemap,
        nodemap=nodemap,
    )
    repo.names.addnamespace(ns)