topic: add an option to automatically publish topic-less changeset
This new option will help playing with merge based workflow.
from __future__ import absolute_import
from mercurial import (
error,
node,
phases,
)
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)))
def publishbarebranch(repo, tr):
"""Publish changeset without topic"""
if 'node' not in tr.hookargs: # no new node
return
startnode = node.bin(tr.hookargs['node'])
topublish = repo.revs('not public() and (%n:) - hidden() - topic()', startnode)
if topublish:
cl = repo.changelog
nodes = [cl.node(r) for r in topublish]
repo._phasecache.advanceboundary(repo, tr, phases.public, nodes)