hgext/narrow/narrowtemplates.py
changeset 43076 2372284d9457
parent 42358 45c18f7345c1
child 43077 687b865b95ad
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
    14 
    14 
    15 keywords = {}
    15 keywords = {}
    16 templatekeyword = registrar.templatekeyword(keywords)
    16 templatekeyword = registrar.templatekeyword(keywords)
    17 revsetpredicate = registrar.revsetpredicate()
    17 revsetpredicate = registrar.revsetpredicate()
    18 
    18 
       
    19 
    19 def _isellipsis(repo, rev):
    20 def _isellipsis(repo, rev):
    20     if repo.changelog.flags(rev) & revlog.REVIDX_ELLIPSIS:
    21     if repo.changelog.flags(rev) & revlog.REVIDX_ELLIPSIS:
    21         return True
    22         return True
    22     return False
    23     return False
       
    24 
    23 
    25 
    24 @templatekeyword('ellipsis', requires={'repo', 'ctx'})
    26 @templatekeyword('ellipsis', requires={'repo', 'ctx'})
    25 def ellipsis(context, mapping):
    27 def ellipsis(context, mapping):
    26     """String. 'ellipsis' if the change is an ellipsis node, else ''."""
    28     """String. 'ellipsis' if the change is an ellipsis node, else ''."""
    27     repo = context.resource(mapping, 'repo')
    29     repo = context.resource(mapping, 'repo')
    28     ctx = context.resource(mapping, 'ctx')
    30     ctx = context.resource(mapping, 'ctx')
    29     if _isellipsis(repo, ctx.rev()):
    31     if _isellipsis(repo, ctx.rev()):
    30         return 'ellipsis'
    32         return 'ellipsis'
    31     return ''
    33     return ''
       
    34 
    32 
    35 
    33 @templatekeyword('outsidenarrow', requires={'repo', 'ctx'})
    36 @templatekeyword('outsidenarrow', requires={'repo', 'ctx'})
    34 def outsidenarrow(context, mapping):
    37 def outsidenarrow(context, mapping):
    35     """String. 'outsidenarrow' if the change affects no tracked files,
    38     """String. 'outsidenarrow' if the change affects no tracked files,
    36     else ''."""
    39     else ''."""
    40     if ctx.files() and not m.always():
    43     if ctx.files() and not m.always():
    41         if not any(m(f) for f in ctx.files()):
    44         if not any(m(f) for f in ctx.files()):
    42             return 'outsidenarrow'
    45             return 'outsidenarrow'
    43     return ''
    46     return ''
    44 
    47 
       
    48 
    45 @revsetpredicate('ellipsis()')
    49 @revsetpredicate('ellipsis()')
    46 def ellipsisrevset(repo, subset, x):
    50 def ellipsisrevset(repo, subset, x):
    47     """Changesets that are ellipsis nodes."""
    51     """Changesets that are ellipsis nodes."""
    48     return subset.filter(lambda r: _isellipsis(repo, r))
    52     return subset.filter(lambda r: _isellipsis(repo, r))