Mercurial > hg
changeset 19440:4a0d0616c47d
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.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 11 Jul 2013 13:11:41 -0400 |
parents | f4148c36f0aa |
children | 8b312c080adb |
files | mercurial/commands.py |
diffstat | 1 files changed, 25 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Jul 17 23:58:04 2013 +0200 +++ b/mercurial/commands.py Thu Jul 11 13:11:41 2013 -0400 @@ -1285,6 +1285,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, _('use the secret phase for committing')), ] + walkopts + commitopts + commitopts2 + subrepoopts, _('[OPTION]... [FILE]...')) def commit(ui, repo, *pats, **opts): @@ -1329,6 +1330,9 @@ # Let --subrepos on the command line override config setting. ui.setconfig('ui', 'commitsubrepos', True) + # Save this for restoring it later + oldcommitphase = ui.config('phases', 'new-commit') + if repo.vfs.exists('graftstate'): raise util.Abort(_('cannot commit an interrupted graft operation'), hint=_('use "hg graft -c" to continue graft')) @@ -1370,12 +1374,18 @@ if not message: message = old.description() editor = cmdutil.commitforceeditor - return repo.commit(message, - opts.get('user') or old.user(), - opts.get('date') or old.date(), - match, - editor=editor, - extra=extra) + try: + if opts.get('secret'): + ui.setconfig('phases', 'new-commit', 'secret') + + return repo.commit(message, + opts.get('user') or old.user(), + opts.get('date') or old.date(), + match, + editor=editor, + extra=extra) + finally: + ui.setconfig('phases', 'new-commit', oldcommitphase) current = repo._bookmarkcurrent marks = old.bookmarks() @@ -1398,8 +1408,15 @@ e = cmdutil.commitforceeditor def commitfunc(ui, repo, message, match, opts): - return repo.commit(message, opts.get('user'), opts.get('date'), - match, editor=e, extra=extra) + try: + if opts.get('secret'): + ui.setconfig('phases', 'new-commit', 'secret') + + return repo.commit(message, opts.get('user'), opts.get('date'), + match, editor=e, extra=extra) + finally: + ui.setconfig('phases', 'new-commit', oldcommitphase) + node = cmdutil.commit(ui, repo, commitfunc, pats, opts)