comparison tests/revnamesext.py @ 33048:46fa46608ca5

namespaces: record and expose whether namespace is built-in Currently, the templating layer tends to treat each namespace as a one-off, with explicit usage of {bookmarks}, {tags}, {branch}, etc instead of using {namespaces}. It would be really useful if we could iterate over namespaces and operate on them generically. However, some consumers may wish to differentiate namespaces by whether they are built-in to core Mercurial or provided by extensions. Expected use cases include ignoring non-built-in namespaces or emitting a generic label for non-built-in namespaces. This commit introduces an attribute on namespace instances that says whether the namespace is "built-in" and then exposes this to the templating layer. As part of this, we implement a reusable extension for defining custom names on each changeset for testing. A second consumer will be introduced in a subsequent commit.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 24 Jun 2017 14:52:15 -0700
parents
children 086fc71fbb09
comparison
equal deleted inserted replaced
33047:de8e3681c402 33048:46fa46608ca5
1 # Dummy extension to define a namespace containing revision names
2
3 from __future__ import absolute_import
4
5 from mercurial import (
6 namespaces,
7 )
8
9 def reposetup(ui, repo):
10 names = {'r%d' % rev: repo[rev].node() for rev in repo}
11 namemap = lambda r, name: names.get(name)
12 nodemap = lambda r, node: ['r%d' % repo[node].rev()]
13
14 ns = namespaces.namespace('revnames', templatename='revname',
15 logname='revname',
16 listnames=lambda r: names.keys(),
17 namemap=namemap, nodemap=nodemap)
18 repo.names.addnamespace(ns)