##// END OF EJS Templates
with: use context manager for transaction in strip
Bryan O'Sullivan -
r27873:60ea60fe default
parent child Browse files
Show More
@@ -160,10 +160,10 b' def strip(ui, repo, nodelist, backup=Tru'
160 msg = _('programming error: cannot strip from inside a transaction')
160 msg = _('programming error: cannot strip from inside a transaction')
161 raise error.Abort(msg, hint=_('contact your extension maintainer'))
161 raise error.Abort(msg, hint=_('contact your extension maintainer'))
162
162
163 tr = repo.transaction("strip")
163 try:
164 with repo.transaction("strip") as tr:
164 offset = len(tr.entries)
165 offset = len(tr.entries)
165
166
166 try:
167 tr.startgroup()
167 tr.startgroup()
168 cl.strip(striprev, tr)
168 cl.strip(striprev, tr)
169 mfst.strip(striprev, tr)
169 mfst.strip(striprev, tr)
@@ -171,15 +171,11 b' def strip(ui, repo, nodelist, backup=Tru'
171 repo.file(fn).strip(striprev, tr)
171 repo.file(fn).strip(striprev, tr)
172 tr.endgroup()
172 tr.endgroup()
173
173
174 try:
175 for i in xrange(offset, len(tr.entries)):
174 for i in xrange(offset, len(tr.entries)):
176 file, troffset, ignore = tr.entries[i]
175 file, troffset, ignore = tr.entries[i]
177 repo.svfs(file, 'a').truncate(troffset)
176 repo.svfs(file, 'a').truncate(troffset)
178 if troffset == 0:
177 if troffset == 0:
179 repo.store.markremoved(file)
178 repo.store.markremoved(file)
180 tr.close()
181 finally:
182 tr.release()
183
179
184 if saveheads or savebases:
180 if saveheads or savebases:
185 ui.note(_("adding branch\n"))
181 ui.note(_("adding branch\n"))
General Comments 0
You need to be logged in to leave comments. Login now