with: use context manager for wlock in branch
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27804 aa41199a74e2
parent 27803 a8e8950ebd4d
child 27805 bdaf433192f0
with: use context manager for wlock in branch
mercurial/commands.py
--- a/mercurial/commands.py	Fri Jan 15 13:14:46 2016 -0800
+++ b/mercurial/commands.py	Fri Jan 15 13:14:46 2016 -0800
@@ -1197,8 +1197,7 @@
         ui.write("%s\n" % repo.dirstate.branch())
         return
 
-    wlock = repo.wlock()
-    try:
+    with repo.wlock():
         if opts.get('clean'):
             label = repo[None].p1().branch()
             repo.dirstate.setbranch(label)
@@ -1220,8 +1219,6 @@
             if not others:
                 ui.status(_('(branches are permanent and global, '
                             'did you want a bookmark?)\n'))
-    finally:
-        wlock.release()
 
 @command('branches',
     [('a', 'active', False,