tests/revnamesext.py
author Pulkit Goyal <pulkit@yandex-team.ru>
Mon, 26 Nov 2018 15:36:51 +0300
changeset 40733 9446d5aa0f32
parent 36548 086fc71fbb09
child 43076 2372284d9457
permissions -rw-r--r--
py3: convert strings to bytes in tests/test-remotefilelog-histpack.py Differential Revision: https://phab.mercurial-scm.org/D5303

# 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)