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.
#header#
<title>Mercurial Error</title>
</head>
<body>
<h2>Mercurial Error</h2>
<p>
An error occured while processing your request:
</p>
<p>
#error|escape#
</p>
#footer#