On Fri, 23 Nov 2018 13:23:43 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <a...@dwimlabs.net>
> # Date 1541397139 -28800
> #      Mon Nov 05 13:52:19 2018 +0800
> # Node ID ea18d94ac7006faff7148cb2eca3b970655955b9
> # Parent  efd0f79246e3e6633dfd06226464a48584f69b19
> # EXP-Topic push-publish
> push: config option to control behavior when pushing to a publishing server

> `hg push --publish` can be used to make push succeed even when auto-publish is
> set to 'abort'.
> 
> diff --git a/mercurial/configitems.py b/mercurial/configitems.py
> --- a/mercurial/configitems.py
> +++ b/mercurial/configitems.py
> @@ -449,6 +449,9 @@ coreconfigitem('email', 'to',
>  coreconfigitem('experimental', 'archivemetatemplate',
>      default=dynamicdefault,
>  )
> +coreconfigitem('experimental', 'auto-publish',
> +    default='ignore',

auto-publish=ignore sounds like the push operation will never promote the
changesets to public. Perhaps, it can be renamed to 'allow'?

> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -334,6 +334,30 @@ def _computeoutgoing(repo, heads, common
>          heads = cl.heads()
>      return discovery.outgoing(repo, common, heads)
>  
> +def _checkpublish(pushop):
> +    repo = pushop.repo
> +    ui = repo.ui
> +    behavior = ui.config('experimental', 'auto-publish')
> +    if pushop.publish or behavior not in ('warn', 'abort'):
> +        return
> +    remotephases = listkeys(pushop.remote, 'phases')
> +    if not remotephases.get('publishing', False):
> +        return
> +
> +    if pushop.revs is None:
> +        published = repo.filtered('served').revs('not public()')
> +    else:
> +        published = repo.revs('::%ln - public()', pushop.revs)
> +    if published:
> +        if behavior == 'warn':
> +            ui.warn(_('%i changesets about to be published\n')
> +                    % len(published))

I don't think 'warn' is useful unless there's a reliable way to interrupt
the push operation.

> +        elif behavior == 'abort':
> +            msg = _('push would publish %i changesets') % len(published)
> +            hint = _("behavior controlled by 'experimental.auto-publish'"
> +                        " config")

Shouldn't we instead suggest "hg push --publish"?
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to