import: use context manager for lock, dirstateguard, transaction
A tiny side-effect is that the transaction is now closed after saving
the commit message.
Differential Revision: https://phab.mercurial-scm.org/D3748
To run the tests, do:
cd tests/
python run-tests.py
See https://mercurial-scm.org/wiki/WritingTests for
more information on writing tests.