Mercurial > evolve
comparison hgext3rd/topic/flow.py @ 3235:8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
This patch adds a new config option experimental.topic-mode.server which if
sets to True, the server won't accept any draft changeset without topic on it.
In case both `experimental.topic-mode.server` and
`experimental.topic.publish-bare-branch` are set to True, the enforce-topic one
is respected.
Tests are added for it. The CHANGELOG file is also updated mentioning about the
config option.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 09 Dec 2017 06:13:28 +0100 |
parents | 5dfe4e5cf9e4 |
children | 3675fe74521d |
comparison
equal
deleted
inserted
replaced
3234:a18ca224e812 | 3235:8a772f0c54d9 |
---|---|
27 topublish = repo.revs('not public() and (%n:) - hidden() - topic()', startnode) | 27 topublish = repo.revs('not public() and (%n:) - hidden() - topic()', startnode) |
28 if topublish: | 28 if topublish: |
29 cl = repo.changelog | 29 cl = repo.changelog |
30 nodes = [cl.node(r) for r in topublish] | 30 nodes = [cl.node(r) for r in topublish] |
31 repo._phasecache.advanceboundary(repo, tr, phases.public, nodes) | 31 repo._phasecache.advanceboundary(repo, tr, phases.public, nodes) |
32 | |
33 def rejectuntopicedchangeset(repo, tr): | |
34 """Reject the push if there are changeset without topic""" | |
35 if not tr.changes['revs']: # no new revs | |
36 return | |
37 | |
38 mode = repo.ui.config('experimental', 'topic-mode.server', 'ignore') | |
39 | |
40 revs = list(tr.changes['revs']) | |
41 untopiced = repo.revs('not public() and (%ld:) - hidden() - topic()', revs) | |
42 if untopiced: | |
43 num = len(untopiced) | |
44 fnode = repo[untopiced.first()].hex()[:10] | |
45 if num == 1: | |
46 msg = _("%s") % fnode | |
47 else: | |
48 msg = _("%s and %d more") % (fnode, num - 1) | |
49 if mode == 'warning': | |
50 fullmsg = _("pushed draft changeset without topic: %s\n") | |
51 repo.ui.warn(fullmsg % msg) | |
52 elif mode == 'enforce': | |
53 fullmsg = _("rejecting draft changesets: %s") | |
54 raise error.Abort(fullmsg % msg) | |
55 else: | |
56 repo.ui.warn(_("unknown 'topic-mode.server': %s\n" % mode)) | |
32 | 57 |
33 def wrappush(orig, repo, remote, *args, **kwargs): | 58 def wrappush(orig, repo, remote, *args, **kwargs): |
34 """interpret the --publish flag and pass it to the push operation""" | 59 """interpret the --publish flag and pass it to the push operation""" |
35 newargs = kwargs.copy() | 60 newargs = kwargs.copy() |
36 if kwargs.pop('publish', False): | 61 if kwargs.pop('publish', False): |