Patchwork D3743: backout: use context manager for dirstateguard

login
register
mail settings
Submitter phabricator
Date June 15, 2018, 12:49 p.m.
Message ID <aff4e50273d15ffce9f833bcd14e6fa3@localhost.localdomain>
Download mbox | patch
Permalink /patch/32171/
State Not Applicable
Headers show

Comments

phabricator - June 15, 2018, 12:49 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGeef4668be8a3: backout: use context manager for dirstateguard (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3743?vs=9072&id=9087

REVISION DETAIL
  https://phab.mercurial-scm.org/D3743

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -617,20 +617,16 @@ 
     bheads = repo.branchheads(branch)
     rctx = scmutil.revsingle(repo, hex(parent))
     if not opts.get('merge') and op1 != node:
-        dsguard = dirstateguard.dirstateguard(repo, 'backout')
-        try:
+        with dirstateguard.dirstateguard(repo, 'backout'):
             overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
             with ui.configoverride(overrides, 'backout'):
                 stats = mergemod.update(repo, parent, True, True, node, False)
             repo.setparents(op1, op2)
-            dsguard.close()
-            hg._showstats(repo, stats)
-            if stats.unresolvedcount:
-                repo.ui.status(_("use 'hg resolve' to retry unresolved "
-                                 "file merges\n"))
-                return 1
-        finally:
-            lockmod.release(dsguard)
+        hg._showstats(repo, stats)
+        if stats.unresolvedcount:
+            repo.ui.status(_("use 'hg resolve' to retry unresolved "
+                             "file merges\n"))
+            return 1
     else:
         hg.clean(repo, node, show_stats=False)
         repo.dirstate.setbranch(branch)