tests/revnamesext.py
author Gregory Szorc <gregory.szorc@gmail.com>
Tue, 28 Aug 2018 18:05:08 -0700
changeset 39446 36f487a332ad
parent 36548 086fc71fbb09
child 43076 2372284d9457
permissions -rw-r--r--
wireprotoframing: use our CBOR module Tests changed because our CBOR encoder appears to sort map keys differently from the vendored CBOR package. The CBOR specification does define canonical sorting rules for keys based on the byte values. I'm guessing our implementation doesn't follow them. But our encoder doesn't guarantee that it conforms with the canonical specification. Right now, we just care that output is deterministic. And our encoder does guarantee that. Differential Revision: https://phab.mercurial-scm.org/D4466

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