# HG changeset patch # User Bryan O'Sullivan # Date 1452892486 28800 # Node ID aa41199a74e2568afcd44f5932f63d60ffcb5c62 # Parent a8e8950ebd4d8e6e78346d261453d2bdf9a87887 with: use context manager for wlock in branch diff -r a8e8950ebd4d -r aa41199a74e2 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,