Patchwork D3777: debugbuilddag: use context manager for progress, locks, transaction

login
register
mail settings
Submitter phabricator
Date June 18, 2018, 2:24 p.m.
Message ID <17a898d96d5f3f66a06c1808cd164642@localhost.localdomain>
Download mbox | patch
Permalink /patch/32285/
State Not Applicable
Headers show

Comments

phabricator - June 18, 2018, 2:24 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0d7ec620faef: debugbuilddag: use context manager for progress, locks, transaction (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3777?vs=9148&id=9181

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -181,15 +181,9 @@ 
         initialmergedlines.append("")
 
     tags = []
-
-    wlock = lock = tr = None
     progress = ui.makeprogress(_('building'), unit=_('revisions'),
                                total=total)
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
-        tr = repo.transaction("builddag")
-
+    with progress, repo.wlock(), repo.lock(), repo.transaction("builddag"):
         at = -1
         atbranch = 'default'
         nodeids = []
@@ -268,13 +262,9 @@ 
                 ui.note(('branch %s\n' % data))
                 atbranch = data
             progress.update(id)
-        tr.close()
 
         if tags:
             repo.vfs.write("localtags", "".join(tags))
-    finally:
-        progress.complete()
-        release(tr, lock, wlock)
 
 def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
     indent_string = ' ' * indent