106 _(b'push the changeset as public'))) |
106 _(b'push the changeset as public'))) |
107 extensions.wrapfunction(exchange.pushoperation, '__init__', |
107 extensions.wrapfunction(exchange.pushoperation, '__init__', |
108 extendpushoperation) |
108 extendpushoperation) |
109 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) |
109 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) |
110 exchange.pushdiscoverymapping[b'phase'] = exchange._pushdiscoveryphase |
110 exchange.pushdiscoverymapping[b'phase'] = exchange._pushdiscoveryphase |
|
111 |
|
112 def replacecheckpublish(orig, pushop): |
|
113 listkeys = exchange.listkeys |
|
114 repo = pushop.repo |
|
115 ui = repo.ui |
|
116 behavior = ui.config(b'experimental', b'auto-publish') |
|
117 if pushop.publish or behavior not in (b'warn', b'confirm', b'abort'): |
|
118 return |
|
119 |
|
120 # possible modes are: |
|
121 # |
|
122 # none -> nothing is published on push |
|
123 # all -> everything is published on push |
|
124 # auto -> only changeset without topic are published on push |
|
125 # |
|
126 # Unknown mode is assumed "all" for safety. |
|
127 # |
|
128 # TODO: do a wider brain storming about mode names. |
|
129 |
|
130 mode = b'all' |
|
131 remotephases = listkeys(pushop.remote, b'phases') |
|
132 if not remotephases.get(b'publishing', False): |
|
133 mode = b'none' |
|
134 for c in pushop.remote.capabilities(): |
|
135 if c.startswith(b'ext-topics-publish'): |
|
136 mode = c.split(b'=', 1)[1] |
|
137 break |
|
138 if mode == b'none': |
|
139 return |
|
140 |
|
141 if pushop.revs is None: |
|
142 published = repo.filtered(b'served').revs(b'not public()') |
|
143 else: |
|
144 published = repo.revs(b'::%ln - public()', pushop.revs) |
|
145 if mode == b'auto': |
|
146 published = repo.revs(b'%ld::(%ld - topic())', published, published) |
|
147 if published: |
|
148 if behavior == b'warn': |
|
149 ui.warn( |
|
150 _(b'%i changesets about to be published\n') % len(published) |
|
151 ) |
|
152 elif behavior == b'confirm': |
|
153 if ui.promptchoice( |
|
154 _(b'push and publish %i changesets (yn)?$$ &Yes $$ &No') |
|
155 % len(published) |
|
156 ): |
|
157 raise error.Abort(_(b'user quit')) |
|
158 elif behavior == b'abort': |
|
159 msg = _(b'push would publish %i changesets') % len(published) |
|
160 hint = _( |
|
161 b"use --publish or adjust 'experimental.auto-publish'" |
|
162 b" config" |
|
163 ) |
|
164 raise error.Abort(msg, hint=hint) |