comparison hgext/histedit.py @ 31459:f84fbd27b6d3

histedit: get rid of ui.backupconfig
author Jun Wu <quark@fb.com>
date Thu, 16 Mar 2017 14:36:35 -0700
parents 6ce67d3941fc
children fa8aaff2001a
comparison
equal deleted inserted replaced
31458:2017b5a5685b 31459:f84fbd27b6d3
500 Note that fold has its own separated logic because its handling is a bit 500 Note that fold has its own separated logic because its handling is a bit
501 different and not easily factored out of the fold method. 501 different and not easily factored out of the fold method.
502 """ 502 """
503 phasemin = src.phase() 503 phasemin = src.phase()
504 def commitfunc(**kwargs): 504 def commitfunc(**kwargs):
505 phasebackup = repo.ui.backupconfig('phases', 'new-commit') 505 overrides = {('phases', 'new-commit'): phasemin}
506 try: 506 with repo.ui.configoverride(overrides, 'histedit'):
507 repo.ui.setconfig('phases', 'new-commit', phasemin,
508 'histedit')
509 extra = kwargs.get('extra', {}).copy() 507 extra = kwargs.get('extra', {}).copy()
510 extra['histedit_source'] = src.hex() 508 extra['histedit_source'] = src.hex()
511 kwargs['extra'] = extra 509 kwargs['extra'] = extra
512 return repo.commit(**kwargs) 510 return repo.commit(**kwargs)
513 finally:
514 repo.ui.restoreconfig(phasebackup)
515 return commitfunc 511 return commitfunc
516 512
517 def applychanges(ui, repo, ctx, opts): 513 def applychanges(ui, repo, ctx, opts):
518 """Merge changeset from ctx (only) in the current working directory""" 514 """Merge changeset from ctx (only) in the current working directory"""
519 wcpar = repo.dirstate.parents()[0] 515 wcpar = repo.dirstate.parents()[0]
760 # histedit_source 756 # histedit_source
761 # note: ctx is likely a temporary commit but that the best we can do 757 # note: ctx is likely a temporary commit but that the best we can do
762 # here. This is sufficient to solve issue3681 anyway. 758 # here. This is sufficient to solve issue3681 anyway.
763 extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex()) 759 extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
764 commitopts['extra'] = extra 760 commitopts['extra'] = extra
765 phasebackup = repo.ui.backupconfig('phases', 'new-commit') 761 phasemin = max(ctx.phase(), oldctx.phase())
766 try: 762 overrides = {('phases', 'new-commit'): phasemin}
767 phasemin = max(ctx.phase(), oldctx.phase()) 763 with repo.ui.configoverride(overrides, 'histedit'):
768 repo.ui.setconfig('phases', 'new-commit', phasemin, 'histedit')
769 n = collapse(repo, ctx, repo[newnode], commitopts, 764 n = collapse(repo, ctx, repo[newnode], commitopts,
770 skipprompt=self.skipprompt()) 765 skipprompt=self.skipprompt())
771 finally:
772 repo.ui.restoreconfig(phasebackup)
773 if n is None: 766 if n is None:
774 return ctx, [] 767 return ctx, []
775 repo.ui.pushbuffer() 768 repo.ui.pushbuffer()
776 hg.update(repo, n) 769 hg.update(repo, n)
777 repo.ui.popbuffer() 770 repo.ui.popbuffer()