hgext3rd/topic/flow.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Mon, 30 Oct 2017 19:24:14 +0100
changeset 3157 f286eefbd20d
child 3158 678a9802c56b
permissions -rw-r--r--
topic: add an option to enforce a single head per name in a repository

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)))