touch: use context manager for locks
authorSushil khanchi <sushilkhanchi97@gmail.com>
Mon, 13 May 2019 18:45:00 +0530
changeset 4639 c4cab1dd31b7
parent 4638 7978db1dda3e
child 4640 c720d09c2366
touch: use context manager for locks
hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py	Mon May 13 18:39:43 2019 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Mon May 13 18:45:00 2019 +0530
@@ -1362,15 +1362,8 @@
         rewriteutil.precheck(repo, revs, 'touch')
     tmpl = utility.shorttemplate
     displayer = compat.changesetdisplayer(ui, repo, {'template': tmpl})
-    wlock = lock = tr = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
-        tr = repo.transaction('touch')
+    with repo.wlock(), repo.lock(), repo.transaction('touch'):
         touchnodes(ui, repo, revs, displayer, **opts)
-        tr.close()
-    finally:
-        lockmod.release(tr, lock, wlock)
 
 def touchnodes(ui, repo, revs, displayer, **opts):
     duplicate = opts['duplicate']