fix backtrace printed when cannot get lock.
change lock error handling code so exceptions have useful info and
exception handling in one place.
add test case for when cannot get lock.
1:016807e6fdaf0:eb43f19ff115016807e6fdaf tipeb43f19ff115eb43f19ff115+eb43f19ff115016807e6fdaf tipmerging file1016807e6fdaf tip016807e6fdaf tip016807e6fdaf tip016807e6fdaf tip