diff hgext3rd/topic/flow.py @ 3158:678a9802c56b

topic: add an option to automatically publish topic-less changeset This new option will help playing with merge based workflow.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 01 Nov 2017 16:26:33 +0100
parents f286eefbd20d
children 90515d0bfb08
line wrap: on
line diff
--- a/hgext3rd/topic/flow.py	Mon Oct 30 19:24:14 2017 +0100
+++ b/hgext3rd/topic/flow.py	Wed Nov 01 16:26:33 2017 +0100
@@ -3,6 +3,7 @@
 from mercurial import (
     error,
     node,
+    phases,
 )
 
 from mercurial.i18n import _
@@ -13,3 +14,14 @@
             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)