Made transaction.managed a no-op and deprecated it.

enter_transaction_management() was nearly always followed by managed().

In three places it wasn't, but they will all be refactored eventually.
The "forced" keyword argument avoids introducing behavior changes until
then.

This is mostly backwards-compatible, except, of course, for managed
itself. There's a minor difference in _enter_transaction_management:
the top self.transaction_state now contains the new 'managed' state
rather than the previous one. Django doesn't access
self.transaction_state in _enter_transaction_management.
Added an API to control database-level autocommit.
Separated autocommit and isolation level handling for PostgreSQL.

Autocommit cannot be manipulated independently from an open connection.
This commit introduces a minor change in behavior: entering transaction
management forces opening a databasse connection. This shouldn't be
backwards incompatible in any practical use case.
Enabled autocommit for PostgreSQL in all circumstances.

For users who didn't activate autocommit in their database options, this
is backwards-incompatible in "non-managed" aka "auto" transaction state.
This state now uses database-level autocommit instead of ORM-level
autocommit.

Also removed the uses_autocommit which lost its purpose.
Stopped flipping the uses_savepoints feature at runtime.
Added BaseDatabaseWrapper.ensure_connection.

This API is useful because autocommit cannot be managed without an open
connection.
Removed _enter/_leave_transaction_management.

The goal is to make all databases share a common, autocommit-based,
implementation.
Enabled database-level autocommit for all backends.

This has the same backwards-incompatibility consequences as those
described for PostgreSQL in the previous email.
Deprecated transaction.commit/rollback_unless_managed.

Since "unless managed" now means "if database-level autocommit",
committing or rolling back doesn't have any effect.

Restored transactional integrity in a few places that relied on
automatically-started transactions with a transitory API.
Documented database-level autocommit.
Deprecated transaction.is_managed().

It's synchronized with the autocommit flag.
Moved standard SQL for savepoints in the base backend.

These methods are only called when uses_savepoints = True anyway.
Refactored implementation of savepoints.

Prepared for using savepoints within transactions in autocommit mode.
Added support for savepoints in SQLite.

Technically speaking they aren't usable yet.
Implemented an 'atomic' decorator and context manager.

Currently it only works in autocommit mode.

Based on @xact by Christophe Pettus.
Made atomic usable inside the legacy transaction management.
Added some assertions to enforce the atomicity of atomic.
Deprecated the old transaction management APIs.
Removed superfluous code now that connections use autocommit by default.
Made atomic work even before the first SQL query.

Thanks Florian for reporting this bug.