rails/rails — pull request #15135 by chancancode (2014-05-16 16:57:26+00:00)
Title: Transactions refactor

This is part one of my transaction refactor, I have a slightly bigger piece coming but I'd like to get some feedback on this first.

The main motivation is that I'd like to :scissors: the awkward flow control in https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb#L215-L228. When I was getting back into this part of the code yesterday, I find the conditional dance here very disorienting.

After some fiddling I understood why that was necessary evil (more details in the commit notes, basically the evil `return` inside the yield necessitates the `ensure` dance). This is a best-effort refactor given those constraints. IMO it is still better than what we have, but I'd like some feedback, esp from eyes that haven't looked at this for a while.