view hgext3rd/topic/flow.py @ 3157:f286eefbd20d

topic: add an option to enforce a single head per name in a repository
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 30 Oct 2017 19:24:14 +0100
parents
children 678a9802c56b
line wrap: on
line source

from __future__ import absolute_import

from mercurial import (
    error,
    node,
)

from mercurial.i18n import _

def enforcesinglehead(repo, tr):
    for name, heads in repo.filtered('visible').branchmap().iteritems():
        if len(heads) > 1:
            hexs = [node.short(n) for n in heads]
            raise error.Abort(_('%d heads on "%s"') % (len(heads), name),
                              hint=(', '.join(hexs)))