view tests/revnamesext.py @ 35577:ac7ee75ee664

bookmarks: use context managers for locks and transaction in pushbookmark() Differential Revision: https://phab.mercurial-scm.org/D1840
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 10 Jan 2018 10:49:12 -0800
parents 46fa46608ca5
children 086fc71fbb09
line wrap: on
line source

# Dummy extension to define a namespace containing revision names

from __future__ import absolute_import

from mercurial import (
    namespaces,
)

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

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