Many editors clean up trailing white space on save. By removing it all
in one go, it helps keep future diffs cleaner by avoiding spurious white
space changes on unrelated lines.
Add `atomic_if_using_transaction` context manager and use it instead of
if/else statements.
Wrap `before_import`, `import_row`, `after_import` calls into
`atomic_if_using_transaction`.
Add tests.
Refs: #609, #399, #610