Mercurial > evolve
annotate hgext3rd/topic/flow.py @ 6696:e0712a00154e
branching: merge with stable
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 07 Feb 2024 14:57:11 -0300 |
parents | 995c6163e97b |
children | 691a9301b51e |
rev | line source |
---|---|
3157
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 from __future__ import absolute_import |
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 |
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 from mercurial import ( |
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 error, |
3159
90515d0bfb08
push: add a --publish flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3158
diff
changeset
|
5 exchange, |
3157
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 node, |
3158
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
7 phases, |
5204
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
8 util, |
3157
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
9 ) |
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
10 |
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
11 from mercurial.i18n import _ |
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
12 |
4743
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
4647
diff
changeset
|
13 from . import ( |
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
4647
diff
changeset
|
14 compat, |
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
4647
diff
changeset
|
15 ) |
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
4647
diff
changeset
|
16 |
3157
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 def enforcesinglehead(repo, tr): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
18 branchmap = repo.filtered(b'visible').branchmap() |
4743
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
4647
diff
changeset
|
19 for name, heads in compat.branchmapitems(branchmap): |
3157
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 if len(heads) > 1: |
f286eefbd20d
topic: add an option to enforce a single head per name in a repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 hexs = [node.short(n) for n in heads] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
22 raise error.Abort(_(b'%d heads on "%s"') % (len(heads), name), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
23 hint=(b', '.join(hexs))) |
3158
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
24 |
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
25 def publishbarebranch(repo, tr): |
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
26 """Publish changeset without topic""" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
27 if b'node' not in tr.hookargs: # no new node |
3158
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
28 return |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
29 startnode = node.bin(tr.hookargs[b'node']) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
30 topublish = repo.revs(b'not public() and (%n:) - hidden() - topic()', startnode) |
3158
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
31 if topublish: |
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
32 cl = repo.changelog |
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
33 nodes = [cl.node(r) for r in topublish] |
678a9802c56b
topic: add an option to automatically publish topic-less changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3157
diff
changeset
|
34 repo._phasecache.advanceboundary(repo, tr, phases.public, nodes) |
3159
90515d0bfb08
push: add a --publish flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3158
diff
changeset
|
35 |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
36 def rejectuntopicedchangeset(repo, tr): |
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
37 """Reject the push if there are changeset without topic""" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
38 if b'node' not in tr.hookargs: # no new revs |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
39 return |
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
40 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
41 startnode = node.bin(tr.hookargs[b'node']) |
3282
3675fe74521d
topic: use 'hookargs' over 'tr.changes' for flow control
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3235
diff
changeset
|
42 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
43 mode = repo.ui.config(b'experimental', b'topic-mode.server', b'ignore') |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
44 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
45 untopiced = repo.revs(b'not public() and (%n:) - hidden() - topic()', startnode) |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
46 if untopiced: |
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
47 num = len(untopiced) |
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
48 fnode = repo[untopiced.first()].hex()[:10] |
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
49 if num == 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
50 msg = _(b"%s") % fnode |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
51 else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
52 msg = _(b"%s and %d more") % (fnode, num - 1) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
53 if mode == b'warning': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
54 fullmsg = _(b"pushed draft changeset without topic: %s\n") |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
55 repo.ui.warn(fullmsg % msg) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
56 elif mode == b'enforce': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
57 fullmsg = _(b"rejecting draft changesets: %s") |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
58 raise error.Abort(fullmsg % msg) |
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
59 else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
60 repo.ui.warn(_(b"unknown 'topic-mode.server': %s\n" % mode)) |
3235
8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3226
diff
changeset
|
61 |
4647
228caeb8b7af
topic: add a simple option to reject publishing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
62 def reject_publish(repo, tr): |
228caeb8b7af
topic: add a simple option to reject publishing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
63 """prevent a transaction to be publish anything""" |
5204
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
64 if util.safehasattr(tr.changes[b'phases'], 'items'): |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
65 # hg <= 5.3 (fdc802f29b2c) |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
66 published = { |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
67 r for r, (o, n) in tr.changes[b'phases'].items() |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
68 if n == phases.public |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
69 } |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
70 else: |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
71 revranges = [ |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
72 r for r, (o, n) in tr.changes[b'phases'] |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
73 if n == phases.public |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
74 ] |
d7f87c7cb1f0
topic: compat with tr.changes[b'phases'], it's now a list
Anton Shestakov <av6@dwimlabs.net>
parents:
5193
diff
changeset
|
75 published = {r for revrange in revranges for r in revrange} |
4647
228caeb8b7af
topic: add a simple option to reject publishing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
76 if published: |
228caeb8b7af
topic: add a simple option to reject publishing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
77 r = min(published) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
78 msg = b"rejecting publishing of changeset %s" % repo[r] |
4647
228caeb8b7af
topic: add a simple option to reject publishing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
79 if len(published) > 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4808
diff
changeset
|
80 msg += b' and %d others' % (len(published) - 1) |
4647
228caeb8b7af
topic: add a simple option to reject publishing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
81 raise error.Abort(msg) |
228caeb8b7af
topic: add a simple option to reject publishing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4263
diff
changeset
|
82 |
5221
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
83 def replacecheckpublish(orig, pushop): |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
84 listkeys = exchange.listkeys |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
85 repo = pushop.repo |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
86 ui = repo.ui |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
87 behavior = ui.config(b'experimental', b'auto-publish') |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
88 if pushop.publish or behavior not in (b'warn', b'confirm', b'abort'): |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
89 return |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
90 |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
91 # possible modes are: |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
92 # |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
93 # none -> nothing is published on push |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
94 # all -> everything is published on push |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
95 # auto -> only changeset without topic are published on push |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
96 # |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
97 # Unknown mode is assumed "all" for safety. |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
98 # |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
99 # TODO: do a wider brain storming about mode names. |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
100 |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
101 mode = b'all' |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
102 remotephases = listkeys(pushop.remote, b'phases') |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
103 if not remotephases.get(b'publishing', False): |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
104 mode = b'none' |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
105 for c in pushop.remote.capabilities(): |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
106 if c.startswith(b'ext-topics-publish'): |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
107 mode = c.split(b'=', 1)[1] |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
108 break |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
109 if mode == b'none': |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
110 return |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
111 |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
112 if pushop.revs is None: |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
113 published = repo.filtered(b'served').revs(b'not public()') |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
114 else: |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
115 published = repo.revs(b'::%ln - public()', pushop.revs) |
5932
fe25ec8f0124
topic: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
5230
diff
changeset
|
116 # we want to use pushop.revs in the revset even if they themselves are |
fe25ec8f0124
topic: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
5230
diff
changeset
|
117 # secret, but we don't want to have anything that the server won't see |
fe25ec8f0124
topic: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
5230
diff
changeset
|
118 # in the result of this expression |
fe25ec8f0124
topic: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
5230
diff
changeset
|
119 published &= repo.filtered(b'served') |
fe25ec8f0124
topic: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
5230
diff
changeset
|
120 |
5221
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
121 if mode == b'auto': |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
122 published = repo.revs(b'%ld::(%ld - topic())', published, published) |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
123 if published: |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
124 if behavior == b'warn': |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
125 ui.warn( |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
126 _(b'%i changesets about to be published\n') % len(published) |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
127 ) |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
128 elif behavior == b'confirm': |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
129 if ui.promptchoice( |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
130 _(b'push and publish %i changesets (yn)?$$ &Yes $$ &No') |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
131 % len(published) |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
132 ): |
6322
57f9cdbf6a99
topic: use compat.CanceledError for user quit situations
Anton Shestakov <av6@dwimlabs.net>
parents:
5932
diff
changeset
|
133 raise compat.CanceledError(_(b'user quit')) |
5221
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
134 elif behavior == b'abort': |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
135 msg = _(b'push would publish %i changesets') % len(published) |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
136 hint = _( |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
137 b"use --publish or adjust 'experimental.auto-publish'" |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
138 b" config" |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
139 ) |
af9f40236037
topics: fix auto-publish=abort with servers publishing bare branches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4814
diff
changeset
|
140 raise error.Abort(msg, hint=hint) |