[PATCH] commit: enable --secret option

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Jul 8 09:26:54 CDT 2013


On 18 juin 2013, at 20:21, Jordi Gutiérrez Hermoso wrote:

> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh at octave.org>
> # Date 1371578523 14400
> #      Tue Jun 18 14:02:03 2013 -0400
> # Node ID 56ee926aeeaded0aedaba4d2097ed6f312568356
> # Parent  401b3ad26e66f6b69937e1aa808da07065c408a6
> commit: enable --secret option
> 
> At the moment, creating secret commits is slightly cumbersome. They
> can either be created by changing the default commit phase to secret
> or by doing `hg phase --secret --force`. Both of these make secret
> commits appear to be like some kind of advanced feature.
> 
> Secret commits, however, should be a convenient feature for people who
> want to work on a private branch without affecting anyone else. There
> should therefore be a prominent and convenient method for creating
> secret commits.
> 
> Since the default phase is draft and there is no need to use --force
> to go from a secret phase to any other phase, this patch
> intentionally does not add --draft and --public options.


I'm in favor of such flag. Creating secret commit is a "common" need and should be eased. There is currently three way to do this:

(1) hg commit --config phase.new-commit=secret
    ugly and unfriendly
(2) hg commit;  hg phase --force --secret .
    Racy and abusive usage of --force that open the way to error
(3) Permanent config change
    Imply a big change in mercurial behavior

Adding a flag for --secret only does not sound a big issue for me. moving to draft -> secret requires force and is racy while moving from secret to draft is safe and does not requires --force. So ensuring people can always create secret commit is enough. (I do not expect people to have new-commit set on public except for very special case)

Here is a summary of what phase are naturally *accessible* without using --force depending of phase easily available at commit time.

commit →    | draft     | draft+secret | secret |
accessible↓ | (default) |              |        |
---------------------------------------------
public      |     x     |       x      |        |
draft       |     x     |       x      |        |
secret      |     x     |       x      |    x   |

We see that adding --secret flag allow natural access to the secret phase. Adding a --draft flag on commit would not have much effect.

> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1286,6 +1286,7 @@
>     ('', 'close-branch', None,
>      _('mark a branch as closed, hiding it from the branch list')),
>     ('', 'amend', None, _('amend the parent of the working dir')),
> +    ('s', 'secret', None, _('commit secret changeset')),

use secret phase for commited changeset ?

>     ] + walkopts + commitopts + commitopts2 + subrepoopts,
>     _('[OPTION]... [FILE]...'))
> def commit(ui, repo, *pats, **opts):
> @@ -1338,6 +1339,9 @@
>     bheads = repo.branchheads(branch)
> 
>     extra = {}
> +    if opts.get('secret'):
> +        ui.setconfig('phases', 'new-commit', 'secret')
> +

You can't just change the config and forget about it. You need to restore it once done. Otherwise you are soaping the road  for people calling commands in the same process.


-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list