comparison mercurial/commands.py @ 22039:0aa2cb965f4c

commit: update the --secret code to use backupconfig and restoreconfig Those dedicated methods also preserve all associated data (eg: sources, lack of value).
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 05 Aug 2014 18:53:05 -0700
parents 41e969cb9468
children 56ccd95b49c6
comparison
equal deleted inserted replaced
22038:021becbf024a 22039:0aa2cb965f4c
1384 if opts.get('amend'): 1384 if opts.get('amend'):
1385 raise util.Abort(_('cannot amend with --subrepos')) 1385 raise util.Abort(_('cannot amend with --subrepos'))
1386 # Let --subrepos on the command line override config setting. 1386 # Let --subrepos on the command line override config setting.
1387 ui.setconfig('ui', 'commitsubrepos', True, 'commit') 1387 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1388 1388
1389 # Save this for restoring it later
1390 oldcommitphase = ui.config('phases', 'new-commit')
1391
1392 cmdutil.checkunfinished(repo, commit=True) 1389 cmdutil.checkunfinished(repo, commit=True)
1393 1390
1394 branch = repo[None].branch() 1391 branch = repo[None].branch()
1395 bheads = repo.branchheads(branch) 1392 bheads = repo.branchheads(branch)
1396 1393
1440 if bm == current: 1437 if bm == current:
1441 bookmarks.setcurrent(repo, bm) 1438 bookmarks.setcurrent(repo, bm)
1442 newmarks.write() 1439 newmarks.write()
1443 else: 1440 else:
1444 def commitfunc(ui, repo, message, match, opts): 1441 def commitfunc(ui, repo, message, match, opts):
1442 backup = ui.backupconfig('phases', 'new-commit')
1443 baseui = repo.baseui
1444 basebackup = baseui.backupconfig('phases', 'new-commit')
1445 try: 1445 try:
1446 if opts.get('secret'): 1446 if opts.get('secret'):
1447 ui.setconfig('phases', 'new-commit', 'secret', 'commit') 1447 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1448 # Propagate to subrepos 1448 # Propagate to subrepos
1449 repo.baseui.setconfig('phases', 'new-commit', 'secret', 1449 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1450 'commit')
1451 1450
1452 editform = 'commit.normal' 1451 editform = 'commit.normal'
1453 editor = cmdutil.getcommiteditor(editform=editform, **opts) 1452 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1454 return repo.commit(message, opts.get('user'), opts.get('date'), 1453 return repo.commit(message, opts.get('user'), opts.get('date'),
1455 match, 1454 match,
1456 editor=editor, 1455 editor=editor,
1457 extra=extra) 1456 extra=extra)
1458 finally: 1457 finally:
1459 ui.setconfig('phases', 'new-commit', oldcommitphase, 'commit') 1458 ui.restoreconfig(backup)
1460 repo.baseui.setconfig('phases', 'new-commit', oldcommitphase, 1459 repo.baseui.restoreconfig(basebackup)
1461 'commit')
1462 1460
1463 1461
1464 node = cmdutil.commit(ui, repo, commitfunc, pats, opts) 1462 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1465 1463
1466 if not node: 1464 if not node: