view tests/revnamesext.py @ 45192:509f5b6c0b7e

commitctx: return "touched" status from _filecommit Instead of mutating a list passed in argument, we simply return the information from the `_filecommit` function. This make for a cleaner API and allow for richer information to be returned. That richer information will be used in the next commit to avoid duplicated computation. This is part of a larger refactoring/cleanup of the commitctx code to clarify and augment the logic gathering metadata useful for copy tracing. The current code is a tad too long and entangled to make such update easy. We start with easy and small cleanup. Differential Revision: https://phab.mercurial-scm.org/D8702
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 06 Jul 2020 19:35:53 +0200
parents 2372284d9457
children 6000f5b25c9b
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)