comparison hgext3rd/topic/flow.py @ 4647:228caeb8b7af

topic: add a simple option to reject publishing The option is pretty basic but it can be used as base to build larger feature. The main target for going in this direction is to be able to distinct between user that are "simple contributors" pushing topic for review and the "maintainers" or "automation" that can publish changesets.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 27 May 2019 03:42:35 +0200
parents 35130e428ebd
children 92e3db149d7d
comparison
equal deleted inserted replaced
4646:7b986968700b 4647:228caeb8b7af
53 fullmsg = _("rejecting draft changesets: %s") 53 fullmsg = _("rejecting draft changesets: %s")
54 raise error.Abort(fullmsg % msg) 54 raise error.Abort(fullmsg % msg)
55 else: 55 else:
56 repo.ui.warn(_("unknown 'topic-mode.server': %s\n" % mode)) 56 repo.ui.warn(_("unknown 'topic-mode.server': %s\n" % mode))
57 57
58 def reject_publish(repo, tr):
59 """prevent a transaction to be publish anything"""
60 published = set()
61 for r, (o, n) in tr.changes['phases'].items():
62 if n == phases.public:
63 published.add(r)
64 if published:
65 r = min(published)
66 msg = "rejecting publishing of changeset %s" % repo[r]
67 if len(published) > 1:
68 msg += ' and %d others' % (len(published) - 1)
69 raise error.Abort(msg)
70
58 def wrappush(orig, repo, remote, *args, **kwargs): 71 def wrappush(orig, repo, remote, *args, **kwargs):
59 """interpret the --publish flag and pass it to the push operation""" 72 """interpret the --publish flag and pass it to the push operation"""
60 newargs = kwargs.copy() 73 newargs = kwargs.copy()
61 if kwargs.pop('publish', False): 74 if kwargs.pop('publish', False):
62 opargs = kwargs.get('opargs') 75 opargs = kwargs.get('opargs')