revnamesext.py
21 lines
| 576 B
| text/x-python
|
PythonLexer
/ tests / revnamesext.py
Gregory Szorc
|
r33048 | # Dummy extension to define a namespace containing revision names | ||
from __future__ import absolute_import | ||||
Augie Fackler
|
r43346 | from mercurial import namespaces | ||
Gregory Szorc
|
r33048 | |||
def reposetup(ui, repo): | ||||
Yuya Nishihara
|
r36566 | names = {b'r%d' % rev: repo[rev].node() for rev in repo} | ||
Gregory Szorc
|
r33048 | namemap = lambda r, name: names.get(name) | ||
Yuya Nishihara
|
r36566 | nodemap = lambda r, node: [b'r%d' % repo[node].rev()] | ||
Gregory Szorc
|
r33048 | |||
Augie Fackler
|
r43346 | ns = namespaces.namespace( | ||
b'revnames', | ||||
templatename=b'revname', | ||||
logname=b'revname', | ||||
listnames=lambda r: names.keys(), | ||||
namemap=namemap, | ||||
nodemap=nodemap, | ||||
) | ||||
Gregory Szorc
|
r33048 | repo.names.addnamespace(ns) | ||