Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 38320:eef4668be8a3
backout: use context manager for dirstateguard
Differential Revision: https://phab.mercurial-scm.org/D3743
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 14 Jun 2018 15:28:32 -0700 |
parents | 0d6d0aa3c4bf |
children | 9b1536b02221 |
comparison
equal
deleted
inserted
replaced
38319:0d6d0aa3c4bf | 38320:eef4668be8a3 |
---|---|
615 # the backout should appear on the same branch | 615 # the backout should appear on the same branch |
616 branch = repo.dirstate.branch() | 616 branch = repo.dirstate.branch() |
617 bheads = repo.branchheads(branch) | 617 bheads = repo.branchheads(branch) |
618 rctx = scmutil.revsingle(repo, hex(parent)) | 618 rctx = scmutil.revsingle(repo, hex(parent)) |
619 if not opts.get('merge') and op1 != node: | 619 if not opts.get('merge') and op1 != node: |
620 dsguard = dirstateguard.dirstateguard(repo, 'backout') | 620 with dirstateguard.dirstateguard(repo, 'backout'): |
621 try: | |
622 overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | 621 overrides = {('ui', 'forcemerge'): opts.get('tool', '')} |
623 with ui.configoverride(overrides, 'backout'): | 622 with ui.configoverride(overrides, 'backout'): |
624 stats = mergemod.update(repo, parent, True, True, node, False) | 623 stats = mergemod.update(repo, parent, True, True, node, False) |
625 repo.setparents(op1, op2) | 624 repo.setparents(op1, op2) |
626 dsguard.close() | 625 hg._showstats(repo, stats) |
627 hg._showstats(repo, stats) | 626 if stats.unresolvedcount: |
628 if stats.unresolvedcount: | 627 repo.ui.status(_("use 'hg resolve' to retry unresolved " |
629 repo.ui.status(_("use 'hg resolve' to retry unresolved " | 628 "file merges\n")) |
630 "file merges\n")) | 629 return 1 |
631 return 1 | |
632 finally: | |
633 lockmod.release(dsguard) | |
634 else: | 630 else: |
635 hg.clean(repo, node, show_stats=False) | 631 hg.clean(repo, node, show_stats=False) |
636 repo.dirstate.setbranch(branch) | 632 repo.dirstate.setbranch(branch) |
637 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents()) | 633 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents()) |
638 | 634 |