I asked the question Programmatically swap last two commits. The question got a good answer that gave me the idea I needed to implement my own solution, but that answer is both technically incorrect and not complete (in the sense that I wanted). Nevertheless, I upvoted it and accepted it.
Wanting a solid solution that would work correctly and be resilient to errors, I hacked on it a bit and came up with a suitable script, which I posted as this answer.
Now, my answer technically solves my question, because it works for me (and the poster's doesn't quite). Is it OK to accept my own answer, when the time comes? Or should I just leave it as-is?