diff 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
line wrap: on
line diff
--- a/mercurial/repair.py	Thu Aug 06 21:00:16 2015 -0400
+++ b/mercurial/repair.py	Sat Aug 08 14:50:03 2015 -0700
@@ -173,9 +173,8 @@
                 if troffset == 0:
                     repo.store.markremoved(file)
             tr.close()
-        except: # re-raises
-            tr.abort()
-            raise
+        finally:
+            tr.release()
 
         if saveheads or savebases:
             ui.note(_("adding branch\n"))