Thursday, April 12, 2012

Mercurial with Git Subrepository

I recently had some problems creating a Git sub-repository inside my Mercurial main repository using the guide I found here!

Problem

All is well and good up to that point, however when committing the added .hgsub file things started to head south.

From the commandline (cmd) I would get an error:
abort: The system cannot find the file specified
While from TortoiseHg I would not get an error. However, the expected .hgsubstate file did not get created, and thus the repository has in effect no valid sub-repositories if you try to clone it!

Workaround

The workaround is to do the commit of the .hgsub file from the GitBash shell instead of the regular shell or TortoiseHg, since then the .hgsubstate file will be generated. Using the GitBash shell is also mandatory for committing any change to the .hgsub file, or .hgsubstate file, as well as the initial clone of the repository.

Some googling around indicate that the issue is due to either Mercurial or TortoiseHg trying to execute the "git.exe" command (as opposed to just "git") and that this alias does not exist in the regular shell. I have not verified this, so YMMV!

Misc

Potentially relevant software that is installed on the computer:
  • Windows 7 x64
  • TortoiseHg (2.3.1)
  • Mercurial (2.1.1)
  • Git (1.7.6)
  • Python (2.6.6)
Both the "git" and "hg" commands were included in the PATH.