comparison hgext3rd/topic/flow.py @ 5230:8431bb224862

branching: merge with stable
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 07 Apr 2020 19:33:40 +0200
parents d7f87c7cb1f0 af9f40236037
children fe25ec8f0124
comparison
equal deleted inserted replaced
5218:bf37ba1c80ee 5230:8431bb224862
116 _(b'push the changeset as public'))) 116 _(b'push the changeset as public')))
117 extensions.wrapfunction(exchange.pushoperation, '__init__', 117 extensions.wrapfunction(exchange.pushoperation, '__init__',
118 extendpushoperation) 118 extendpushoperation)
119 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) 119 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery)
120 exchange.pushdiscoverymapping[b'phase'] = exchange._pushdiscoveryphase 120 exchange.pushdiscoverymapping[b'phase'] = exchange._pushdiscoveryphase
121
122 def replacecheckpublish(orig, pushop):
123 listkeys = exchange.listkeys
124 repo = pushop.repo
125 ui = repo.ui
126 behavior = ui.config(b'experimental', b'auto-publish')
127 if pushop.publish or behavior not in (b'warn', b'confirm', b'abort'):
128 return
129
130 # possible modes are:
131 #
132 # none -> nothing is published on push
133 # all -> everything is published on push
134 # auto -> only changeset without topic are published on push
135 #
136 # Unknown mode is assumed "all" for safety.
137 #
138 # TODO: do a wider brain storming about mode names.
139
140 mode = b'all'
141 remotephases = listkeys(pushop.remote, b'phases')
142 if not remotephases.get(b'publishing', False):
143 mode = b'none'
144 for c in pushop.remote.capabilities():
145 if c.startswith(b'ext-topics-publish'):
146 mode = c.split(b'=', 1)[1]
147 break
148 if mode == b'none':
149 return
150
151 if pushop.revs is None:
152 published = repo.filtered(b'served').revs(b'not public()')
153 else:
154 published = repo.revs(b'::%ln - public()', pushop.revs)
155 if mode == b'auto':
156 published = repo.revs(b'%ld::(%ld - topic())', published, published)
157 if published:
158 if behavior == b'warn':
159 ui.warn(
160 _(b'%i changesets about to be published\n') % len(published)
161 )
162 elif behavior == b'confirm':
163 if ui.promptchoice(
164 _(b'push and publish %i changesets (yn)?$$ &Yes $$ &No')
165 % len(published)
166 ):
167 raise error.Abort(_(b'user quit'))
168 elif behavior == b'abort':
169 msg = _(b'push would publish %i changesets') % len(published)
170 hint = _(
171 b"use --publish or adjust 'experimental.auto-publish'"
172 b" config"
173 )
174 raise error.Abort(msg, hint=hint)