with: use context manager in rename
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:49 -0800
changeset 29799 b0b98e0a12f8148df78a3d05d44614b913087872
parent 29798 2b3a21052be978860ac7000688883589a08328fc
child 29800 7575c048482db03478121bfa9058d09a71498004
push id172
push usergszorc@mozilla.com
push dateMon, 18 Jan 2016 03:58:21 +0000
with: use context manager in rename
mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5813,21 +5813,18 @@ def rename(ui, repo, *pats, **opts):
     exist in the working directory. If invoked with -A/--after, the
     operation is recorded, but no copying is performed.
 
     This command takes effect at the next commit. To undo a rename
     before that, see :hg:`revert`.
 
     Returns 0 on success, 1 if errors are encountered.
     """
-    wlock = repo.wlock(False)
-    try:
+    with repo.wlock(False):
         return cmdutil.copy(ui, repo, pats, opts, rename=True)
-    finally:
-        wlock.release()
 
 @command('resolve',
     [('a', 'all', None, _('select all unresolved files')),
     ('l', 'list', None, _('list state of files needing merge')),
     ('m', 'mark', None, _('mark files as resolved')),
     ('u', 'unmark', None, _('mark files as unresolved')),
     ('n', 'no-status', None, _('hide status prefix'))]
     + mergetoolopts + walkopts + formatteropts,