src/topic/destination.py
author Pierre-Yves David <pierre-yves.david@fb.com>
Wed, 21 Oct 2015 01:12:32 +0200
changeset 1870 8dd5200b4086
child 1871 58ef5699fb35
permissions -rw-r--r--
topic: introduce a 'ngtip' concept The concept is to be massively used in naming and default destination logic. The name is horrible so that people find a better one.

from mercurial import revset
from mercurial import error
def ngtip(repo, branch, all=False):
    """tip new generation"""
    ## search for untopiced heads of branch
    # could be heads((::branch(x) - topic()))
    # but that is expensive
    #
    # we should write plain code instead
    subquery = '''heads(
                    parents(
                       ancestor(
                         (head() and branch(%s)
                         or (topic() and branch(%s)))))
                   ::(head() and branch(%s))
                   - topic())'''
    if not all:
        subquery = 'max(%s)' % subquery
    return repo.revs(subquery, branch, branch, branch)