Patchwork D3746: tag: use context manager for locks

login
register
mail settings
Submitter phabricator
Date June 15, 2018, 12:49 p.m.
Message ID <07547f6be0ad57326d775c733dc8727f@localhost.localdomain>
Download mbox | patch
Permalink /patch/32174/
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 rHG48c52385e062: tag: use context manager for locks (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3746?vs=9075&id=9090

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

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
@@ -5356,10 +5356,7 @@ 
     Returns 0 on success.
     """
     opts = pycompat.byteskwargs(opts)
-    wlock = lock = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
+    with repo.wlock(), repo.lock():
         rev_ = "."
         names = [t.strip() for t in (name1,) + names]
         if len(names) != len(set(names)):
@@ -5430,8 +5427,6 @@ 
 
         tagsmod.tag(repo, names, node, message, opts.get('local'),
                     opts.get('user'), date, editor=editor)
-    finally:
-        release(lock, wlock)
 
 @command('tags', formatteropts, '', intents={INTENT_READONLY})
 def tags(ui, repo, **opts):