hgext3rd/topic/flow.py
changeset 4647 228caeb8b7af
parent 4263 35130e428ebd
child 4743 92e3db149d7d
--- a/hgext3rd/topic/flow.py	Tue Jun 04 10:07:08 2019 +0200
+++ b/hgext3rd/topic/flow.py	Mon May 27 03:42:35 2019 +0200
@@ -55,6 +55,19 @@
         else:
             repo.ui.warn(_("unknown 'topic-mode.server': %s\n" % mode))
 
+def reject_publish(repo, tr):
+    """prevent a transaction to be publish anything"""
+    published = set()
+    for r, (o, n) in tr.changes['phases'].items():
+        if n == phases.public:
+            published.add(r)
+    if published:
+        r = min(published)
+        msg = "rejecting publishing of changeset %s" % repo[r]
+        if len(published) > 1:
+            msg += ' and %d others' % (len(published) - 1)
+        raise error.Abort(msg)
+
 def wrappush(orig, repo, remote, *args, **kwargs):
     """interpret the --publish flag and pass it to the push operation"""
     newargs = kwargs.copy()