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)