Mercurial > hg-stable
changeset 27052:b9d0b45df7b2
strip: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Before this patch, strip was using repo._bookmarks.write.
This patch replaces this code with the recommended way of saving bookmarks
changes: repo._bookmarks.recordchange.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Fri, 20 Nov 2015 13:46:36 -0800 |
parents | 1168499e5266 |
children | c858945f6969 |
files | hgext/strip.py |
diffstat | 1 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/strip.py Fri Nov 20 13:23:47 2015 -0800 +++ b/hgext/strip.py Fri Nov 20 13:46:36 2015 -0800 @@ -64,13 +64,19 @@ repomarks = repo._bookmarks if bookmarks: - if repo._activebookmark in bookmarks: - bookmarksmod.deactivate(repo) - for bookmark in bookmarks: - del repomarks[bookmark] - repomarks.write() - for bookmark in sorted(bookmarks): - ui.write(_("bookmark '%s' deleted\n") % bookmark) + tr = None + try: + tr = repo.transaction('strip') + 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) finally: release(lock, wlock) @@ -147,11 +153,18 @@ rsrevs = repair.stripbmrevset(repo, marks[0]) revs.update(set(rsrevs)) if not revs: - for bookmark in bookmarks: - del repomarks[bookmark] - repomarks.write() - for bookmark in sorted(bookmarks): - ui.write(_("bookmark '%s' deleted\n") % bookmark) + lock = tr = None + try: + lock = repo.lock() + tr = repo.transaction('bookmark') + 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(lock, tr) if not revs: raise error.Abort(_('empty revision set'))