We came across this error recently in one of our mercurial hg repositories. This particular repository holds several subrepositories. The problem is pretty easy to fix, once you know what’s going on.
In our case, the problem was caused by a mismatch between our .hgsubstate file and one of the subrepositories it was pointing to. A mistake was made when the subrepositories were originally defined in the .hgsub file. Here’s what we had in .hgsub:
sites/2=sites/3 #problem line
And here’s what we should have had in .hgsub:
We committed this incorrect .hgsub and continued with our work. Several commits later, we noticed the error in .hgsub and fixed it there.
A few days after that, we got the “abort: unknown revision” error, and were unable to commit the main repository. Googling for an answer wasn’t very productive. Fortunately, a mercurial ninja over at stackoverflow.com was able to point us in the right direction.
All we needed to do was find the correct, complete changeset id for the tip revision of the subrepository that had been previously incorrectly linked, and paste it into the corresponding line in .hgsubstate. To get the complete changeset id for a repository, execute the following command in that repository:
hg --debug tags. Take the tip changeset id and paste it into the parent repository’s .hgsubstate, replacing the incorrect changeset id.
Commit your changes and you should be good to go again.
No related posts.