Another nerd post! Turns out I’m using my blog as more of a script repository. Oh well!
If you’ve ever imported an svn repository into hg, then you may have discovered you need to keep the *exact* repo around… unless you know some magic! (thanks bos!)
The secret comes in knowing that hg convert uses a hidden, unversioned file to do its thang, .hg/shamap. The bigger secret is revealed when you run hg tip --debug – the same information is versioned, you just need to squeeze that metadata format back into a file. Because this involves string manipulation, and because I’m old school like that, I used perl to do this.
poppy@host:~/project$ hg log –debug | perl -e ‘my (@x,$l); while(){if(/extra: convert_revision=(.*)/){$l=$1.” $l”;push(@x,$l);}if(/changeset: \d+:(.*)/){$l=$1} }; print join(“\n”,reverse(@x)).”\n”;’ > .hg/new-shamap
poppy@host:~/project$ mv .hg/shamap .hg/old-shamap # if you have one…
poppy@host:~/project$ mv .hg/new-shamap .hg/shamap
BAM! Now you can clone and re-sync your code anywhere, and push it around however you like. It may be dirty but it’s expedient and works for me! Let me know if it works for you.