HowTo: Fix Mercurial hg Error – “abort: unknown revision”

by Kurt Milam on March 12, 2010
http://xioup.com/s/437

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/1=sites/1
sites/2=sites/2
sites/2=sites/3 #problem line

And here’s what we should have had in .hgsub:
sites/1=sites/1
sites/2=sites/2
sites/3=sites/3

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.

Share this page:
  • Facebook
  • Twitter
  • LinkedIn
  • Identi.ca
  • del.icio.us
  • Faves
  • Google Bookmarks
  • Diigo
  • Add to favorites
  • Technorati
  • Ping.fm
  • Reddit
  • Digg
  • StumbleUpon
  • Posterous
  • Tumblr
  • Live
  • email

No related posts.

Leave a Comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Previous post:

Next post: