Recovering from a Bad Mercurial Subrepo State

Earlier today I was checking out a Mercurial repository I setup a while back as a blank template for projects. Unfortunately, my last commit to it was a merge that broke the subrepo state. It also suffered from a typo in the .hgsub file. In short, the repository was hosed because I couldn't update to any of the previous revisions. I kept getting errors like:

cloning subrepo vendor/_src/twig.js from git://
fatal: unable to connect to Servname not supported for ai_socktype

abort: git clone error 128 in vendor/_src/twig.js (in subrepo vendor/_src/twig.js)


abort: invalid subrepository revision specifier in .hgsubstate line 5

It took me a lot of searching to find a solution to these problems, so I'm documenting it here in the hope that someone else finds it useful.

Read More