changeset 28527:a54afc4475d7

with: use a context manager for transaction in strip
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:50 -0800
parents f1c316fd91f9
children 60ea60fea5f3
files hgext/strip.py
diffstat 1 files changed, 3 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -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)