tests/revnamesext.py
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Mon, 15 Apr 2024 16:33:37 +0100
branchstable
changeset 51571 74230abb2504
parent 48875 6000f5b25c9b
permissions -rw-r--r--
match: strengthen visit_children_set invariant, Recursive means "all files" My previous interpretation of "Recursive" was too relaxed: I thought it instructed the caller to do something like this: > you can stop calling `visit_children_set` because you'll need to descend into > every directory recursively, but you should still check every file if it > matches or not Whereas the real instruction seems to be: > I guarantee that everything in this subtree matches, you can stop > querying the matcher for all files and dirs altogether. The evidence to support this: - the test actually passes with the stronger invariant, revealing no exceptions from this rule - the implementation of `visit_children_set` for `DifferenceMatcher` clearly relies on this requirement, so it must hold for that not to lead to bugs.

# Dummy extension to define a namespace containing revision names


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)