Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGeef4668be8a3: backout: use context manager for dirstateguard
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/commands.py (16 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Jun 14 2018, 6:28 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
raise error.Abort(_('cannot use --parent on non-merge changeset')) | raise error.Abort(_('cannot use --parent on non-merge changeset')) | ||||
parent = p1 | parent = p1 | ||||
# the backout should appear on the same branch | # the backout should appear on the same branch | ||||
branch = repo.dirstate.branch() | branch = repo.dirstate.branch() | ||||
bheads = repo.branchheads(branch) | bheads = repo.branchheads(branch) | ||||
rctx = scmutil.revsingle(repo, hex(parent)) | rctx = scmutil.revsingle(repo, hex(parent)) | ||||
if not opts.get('merge') and op1 != node: | if not opts.get('merge') and op1 != node: | ||||
dsguard = dirstateguard.dirstateguard(repo, 'backout') | with dirstateguard.dirstateguard(repo, 'backout'): | ||||
try: | |||||
overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | ||||
with ui.configoverride(overrides, 'backout'): | with ui.configoverride(overrides, 'backout'): | ||||
stats = mergemod.update(repo, parent, True, True, node, False) | stats = mergemod.update(repo, parent, True, True, node, False) | ||||
repo.setparents(op1, op2) | repo.setparents(op1, op2) | ||||
dsguard.close() | |||||
hg._showstats(repo, stats) | hg._showstats(repo, stats) | ||||
if stats.unresolvedcount: | if stats.unresolvedcount: | ||||
repo.ui.status(_("use 'hg resolve' to retry unresolved " | repo.ui.status(_("use 'hg resolve' to retry unresolved " | ||||
"file merges\n")) | "file merges\n")) | ||||
return 1 | return 1 | ||||
finally: | |||||
lockmod.release(dsguard) | |||||
else: | else: | ||||
hg.clean(repo, node, show_stats=False) | hg.clean(repo, node, show_stats=False) | ||||
repo.dirstate.setbranch(branch) | repo.dirstate.setbranch(branch) | ||||
cmdutil.revert(ui, repo, rctx, repo.dirstate.parents()) | cmdutil.revert(ui, repo, rctx, repo.dirstate.parents()) | ||||
if opts.get('no_commit'): | if opts.get('no_commit'): | ||||
msg = _("changeset %s backed out, " | msg = _("changeset %s backed out, " | ||||
"don't forget to commit.\n") | "don't forget to commit.\n") |