transaction: rename lock() to lock_ref()
This leaves space for future expansion to locking other resources
without having to change the API for references.
Introduce reference transactions
A transaction allows you to lock multiple references and set up changes
for them before applying the changes all at once (or as close as the
backend supports).
This can be used for replication purposes, or for making sure some
operations run when the reference is locked and thus cannot be changed.