view hgext/narrow/narrowtemplates.py @ 41801:9f53a4e2e193

tests: increase timeout for slow test Test case `test-sparse-revlog.t` need some artifact (a bundle) build before it can run. The artifact is expensive to build, but can be reused from one run to the other. We are about to update that test to make the artifact building automatic if `--allow-slow-tests` is passed. However, we need a bump the timeout a bit to make sure the artifact building as time to finish. We could maybe teach run-tests.py how to directly handle such artifacts. However since there is only one of them for now, this seems premature. There are also some room to speed up the bundle creation for test-sparse-revlog.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 24 Feb 2019 19:56:40 +0100
parents 05ded838c997
children 45c18f7345c1
line wrap: on
line source

# narrowtemplates.py - added template keywords for narrow clones
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

from __future__ import absolute_import

from mercurial import (
    registrar,
    revlog,
)

keywords = {}
templatekeyword = registrar.templatekeyword(keywords)
revsetpredicate = registrar.revsetpredicate()

def _isellipsis(repo, rev):
    if repo.changelog.flags(rev) & revlog.REVIDX_ELLIPSIS:
        return True
    return False

@templatekeyword('ellipsis', requires={'repo', 'ctx'})
def ellipsis(context, mapping):
    """String. 'ellipsis' if the change is an ellipsis node, else ''."""
    repo = context.resource(mapping, 'repo')
    ctx = context.resource(mapping, 'ctx')
    if _isellipsis(repo, ctx.rev()):
        return 'ellipsis'
    return ''

@templatekeyword('outsidenarrow', requires={'repo', 'ctx'})
def outsidenarrow(context, mapping):
    """String. 'outsidenarrow' if the change affects no tracked files,
    else ''."""
    repo = context.resource(mapping, 'repo')
    ctx = context.resource(mapping, 'ctx')
    m = repo.narrowmatch()
    if not m.always():
        if not any(m(f) for f in ctx.files()):
            return 'outsidenarrow'
    return ''

@revsetpredicate('ellipsis()')
def ellipsisrevset(repo, subset, x):
    """Changesets that are ellipsis nodes."""
    return subset.filter(lambda r: _isellipsis(repo, r))