tests/revnamesext.py
author Yuya Nishihara <yuya@tcha.org>
Thu, 23 Nov 2017 22:04:53 +0900
branchstable
changeset 35169 898c6f812a51
parent 33048 46fa46608ca5
child 36548 086fc71fbb09
permissions -rw-r--r--
fancyopts: add early-options parser compatible with getopt() The next patch will add a flag for strict parsing of early options, where we'll have to parse all early options at once instead of processing them one-by-one by dispatch._earlygetopt(). That's why I decided to hook fancyopts(). All dispatch._early*opt() functions is planned to be replaced with this function. But in this stable series, only the strict mode will be handled by fancyopts.earlygetopt().

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