view tests/revnamesext.py @ 41091:d9b6b9ed96d8

vfs: add a `_auditpath` to abstract vfs We are about to make `rename` audit path. Since rename lives in the `abstractvfs` layer, we need it to be aware of auditing to some extent. The default implementation is no-op because multiple existing vfs are not using auditing at all right now (eg: fncachevfs).
author Boris Feld <boris.feld@octobus.net>
date Wed, 26 Dec 2018 13:44:23 +0100
parents 086fc71fbb09
children 2372284d9457
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 = {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)