Mercurial > hg
changeset 27873:60ea60fea5f3
with: use context manager for transaction in strip
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Fri, 15 Jan 2016 13:14:49 -0800 |
parents | a54afc4475d7 |
children | 4ff0e2347ae6 |
files | mercurial/repair.py |
diffstat | 1 files changed, 9 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/repair.py Fri Jan 15 13:14:50 2016 -0800 +++ b/mercurial/repair.py Fri Jan 15 13:14:49 2016 -0800 @@ -160,26 +160,22 @@ msg = _('programming error: cannot strip from inside a transaction') raise error.Abort(msg, hint=_('contact your extension maintainer')) - tr = repo.transaction("strip") - offset = len(tr.entries) + try: + with repo.transaction("strip") as tr: + offset = len(tr.entries) - try: - tr.startgroup() - cl.strip(striprev, tr) - mfst.strip(striprev, tr) - for fn in files: - repo.file(fn).strip(striprev, tr) - tr.endgroup() + tr.startgroup() + cl.strip(striprev, tr) + mfst.strip(striprev, tr) + for fn in files: + repo.file(fn).strip(striprev, tr) + tr.endgroup() - try: for i in xrange(offset, len(tr.entries)): file, troffset, ignore = tr.entries[i] repo.svfs(file, 'a').truncate(troffset) if troffset == 0: repo.store.markremoved(file) - tr.close() - finally: - tr.release() if saveheads or savebases: ui.note(_("adding branch\n"))