From patchwork Wed Aug 6 04:27:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 6] commit: update the --secret code to use backupconfig and restoreconfig From: Pierre-Yves David X-Patchwork-Id: 5285 Message-Id: To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Tue, 05 Aug 2014 21:27:31 -0700 # HG changeset patch # User Pierre-Yves David # Date 1407289985 25200 # Tue Aug 05 18:53:05 2014 -0700 # Node ID e55c90663515bf11cce9fdf6459c7d6b6789015e # Parent 78b7329fcb845f6c2603104a688ead6ef4f88c77 commit: update the --secret code to use backupconfig and restoreconfig Those dedicated methods also preserver all associated data (eg: as sources, lack of value). diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1383,13 +1383,10 @@ def commit(ui, repo, *pats, **opts): if opts.get('amend'): raise util.Abort(_('cannot amend with --subrepos')) # Let --subrepos on the command line override config setting. ui.setconfig('ui', 'commitsubrepos', True, 'commit') - # Save this for restoring it later - oldcommitphase = ui.config('phases', 'new-commit') - cmdutil.checkunfinished(repo, commit=True) branch = repo[None].branch() bheads = repo.branchheads(branch) @@ -1439,25 +1436,26 @@ def commit(ui, repo, *pats, **opts): if bm == current: bookmarks.setcurrent(repo, bm) newmarks.write() else: def commitfunc(ui, repo, message, match, opts): + backup = ui.backupconfig('phases', 'new-commit') + baseui = repo.baseui + basebackup = baseui.backupconfig('phases', 'new-commit') try: if opts.get('secret'): ui.setconfig('phases', 'new-commit', 'secret', 'commit') # Propagate to subrepos - repo.baseui.setconfig('phases', 'new-commit', 'secret', - 'commit') + baseui.setconfig('phases', 'new-commit', 'secret', 'commit') return repo.commit(message, opts.get('user'), opts.get('date'), match, editor=cmdutil.getcommiteditor(**opts), extra=extra) finally: - ui.setconfig('phases', 'new-commit', oldcommitphase, 'commit') - repo.baseui.setconfig('phases', 'new-commit', oldcommitphase, - 'commit') + ui.restoreconfig(backup) + repo.baseui.restoreconfig(basebackup) node = cmdutil.commit(ui, repo, commitfunc, pats, opts) if not node: