# HG changeset patch # User Pierre-Yves David # Date 1407289985 25200 # Node ID 0aa2cb965f4c3b958eeedaa8a8f88a2e8a6cea35 # Parent 021becbf024a5ef6469eebcd18e7929c0d63d2f3 commit: update the --secret code to use backupconfig and restoreconfig Those dedicated methods also preserve all associated data (eg: sources, lack of value). diff -r 021becbf024a -r 0aa2cb965f4c mercurial/commands.py --- a/mercurial/commands.py Tue Aug 05 13:22:44 2014 -0700 +++ b/mercurial/commands.py Tue Aug 05 18:53:05 2014 -0700 @@ -1386,9 +1386,6 @@ # 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() @@ -1442,12 +1439,14 @@ 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') editform = 'commit.normal' editor = cmdutil.getcommiteditor(editform=editform, **opts) @@ -1456,9 +1455,8 @@ editor=editor, 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)