view tests/revnamesext.py @ 40036:acf5dbe39478

showstack: also handle SIGALRM This is looking *very* handy when debugging mysterious hangs in a test: you can wrap a hanging invocation in `perl -e 'alarm shift @ARGV; exec @ARGV' 1` for example, a hanging `hg pull` becomes `perl -e 'alarm shift @ARGV; exec @ARGV' 1 hg pull` where the `1` is the timeout in seconds before the process will be hit with SIGALRM. After making that edit to the test file, you can then use --extra-config-opt on run-tests.py to globaly enable showstack during the test run, so you'll get full stack traces as you force your hg to exit. I wonder (but only a little, not enough to take action just yet) if we should wire up some scaffolding in run-tests itself to automatically wrap all commands in alarm(3) somehow to avoid hangs in the future? Differential Revision: https://phab.mercurial-scm.org/D4870
author Augie Fackler <augie@google.com>
date Wed, 03 Oct 2018 16:03:16 -0400
parents 086fc71fbb09
children 2372284d9457
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)