views:

616

answers:

2

I have a very old project that includes the source from another project directly, instead of linking it as a library. Back in the bad days, when I was keeping everything in CVS, I had the external code on a vendor branch and did periodic imports. Now that my project is in git it would make more sense to include the external project as a submodule. But, there's a problem: the external project has migrated to Mercurial. I've found the git-hg and hg-git projects, but I'm not sure if either one handles submodules properly.

Is there a way to create a git submodule that points to an Hg repo instead of a git repo?

+2  A: 

Since the hg-git does mention that submodules are not supported yet, that leaves only a manual option:

  • setup a Git repository somewhere that you have push access to,
  • add it as a Git remote and then
  • run hg gpush from within your project.

For example:

$ cd hg-git # (an Hg repository)
$ hg gremote add origin [email protected]/schacon/hg-git.git
$ hg push

That Git repo will represent your submodule, but if you modify and push that submodule, you will still have to pull from that Git repo to the actual Hg repo.

Other great git-hg commands are listed in this "rosetta stone".

VonC
+1  A: 

There's a typo in the example. "$ hg push" should be "$ hg gpush" as mentioned in the description above. Except that, @VonC's answer was very helpful for me. Thanks! :-)