with: use a context manager for transaction in strip
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:50 -0800
changeset 27872 a54afc4475d7
parent 27871 f1c316fd91f9
child 27873 60ea60fea5f3
with: use a context manager for transaction in strip
hgext/strip.py
--- a/hgext/strip.py	Fri Jan 15 13:14:49 2016 -0800
+++ b/hgext/strip.py	Fri Jan 15 13:14:50 2016 -0800
@@ -64,19 +64,14 @@
 
         repomarks = repo._bookmarks
         if bookmarks:
-            tr = None
-            try:
-                tr = repo.transaction('strip')
+            with repo.transaction('strip') as tr:
                 if repo._activebookmark in bookmarks:
                     bookmarksmod.deactivate(repo)
                 for bookmark in bookmarks:
                     del repomarks[bookmark]
                 repomarks.recordchange(tr)
-                tr.close()
-                for bookmark in sorted(bookmarks):
-                    ui.write(_("bookmark '%s' deleted\n") % bookmark)
-            finally:
-                release(tr)
+            for bookmark in sorted(bookmarks):
+                ui.write(_("bookmark '%s' deleted\n") % bookmark)
     finally:
         release(lock, wlock)