closehead: wrap transaction handling in a context manager
authorMatt Harbison <matt_harbison@yahoo.com>
Mon, 21 Aug 2023 09:50:31 -0400
changeset 50874 f12d53a6e8b8
parent 50873 259213382862
child 50875 00081fa564ed
closehead: wrap transaction handling in a context manager
hgext/closehead.py
--- a/hgext/closehead.py	Sun Aug 20 15:38:35 2023 -0400
+++ b/hgext/closehead.py	Mon Aug 21 09:50:31 2023 -0400
@@ -58,11 +58,10 @@
             date=opts.get('date'),
             extra=extra,
         )
-        tr = repo.transaction(b'commit')
-        ret = repo.commitctx(cctx, True)
-        bookmarks.update(repo, [rev, None], ret)
-        cctx.markcommitted(ret)
-        tr.close()
+        with repo.transaction(b'commit'):
+            ret = repo.commitctx(cctx, True)
+            bookmarks.update(repo, [rev, None], ret)
+            cctx.markcommitted(ret)
 
     revs += tuple(opts.get('rev', []))
     revs = logcmdutil.revrange(repo, revs)