comparison mercurial/repair.py @ 26012:d815a5997576 stable

strip: use the 'finally: tr.release' pattern during stripping The previous code, was calling 'abort' in all exception cases. This was wrong when an exception was raised by post-close callback on the transaction. Calling 'abort' on an already closed transaction resulted in a error, shadowing the original error. We now use the same pattern as everywhere else. 'tr.release()' will abort the transaction if we escape the scope without closing it. We add a test to make sure we do not regress.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 08 Aug 2015 14:50:03 -0700
parents 3e84f40232c7
children a5f62af29517
comparison
equal deleted inserted replaced
26000:9ac4e81b9659 26012:d815a5997576
171 file, troffset, ignore = tr.entries[i] 171 file, troffset, ignore = tr.entries[i]
172 repo.svfs(file, 'a').truncate(troffset) 172 repo.svfs(file, 'a').truncate(troffset)
173 if troffset == 0: 173 if troffset == 0:
174 repo.store.markremoved(file) 174 repo.store.markremoved(file)
175 tr.close() 175 tr.close()
176 except: # re-raises 176 finally:
177 tr.abort() 177 tr.release()
178 raise
179 178
180 if saveheads or savebases: 179 if saveheads or savebases:
181 ui.note(_("adding branch\n")) 180 ui.note(_("adding branch\n"))
182 f = vfs.open(chgrpfile, "rb") 181 f = vfs.open(chgrpfile, "rb")
183 gen = exchange.readbundle(ui, f, chgrpfile, vfs) 182 gen = exchange.readbundle(ui, f, chgrpfile, vfs)