Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Mercurial: Waiting for Lock

📅 2011-Jan-20 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Problem

Mercurial repositories can sometimes be left in a locked state. A lock is created whenever a client is connected to a repository. But, this lock is not removed if the client got disconnected, say over the network. If any client now tries to change the repository (say push changes), Mercurial complains that it is waiting for the lock.

Here is an example:

P:\Foobar>hg push
pushing to Q:\FoobarRep
waiting for lock on repository Q:\FoobarRep held by 'Computer42:9999'

In this example, Mercurial is complaining that a lock is still being held by a client from the computer named Computer42 over port 9999.

Solution

Delete the lock file in the .hg\store directory of the repository. In the example above, delete the file Q:\FoobarRep\.hg\store\lock