Reputation: 1509
I been happily using submodules to track all the libraries my project depends from. The thing is I'm using a library called core-plot that only has a public mercurial repository. I can probably mirror it in a readonly Git repository, but is this the best option I got? I had seen there is modules in Mercurial to track things in Git. Someone know if the other way around exists?
Upvotes: 62
Views: 11475
Reputation: 4090
I guess you can use hg-git.
If I understand correctly, you install it with PIP and then:
.hg/hgrc
adding under paths, another line that says, for example:
git = https://github-gitlab.com/your/repo/path
hg push git
(git is because I add git in .hg/hgrc
but you can use the name you want.After you have the repository saved to git, it will suffice to work as you will with any git repository when adding the submodule.
Upvotes: 0
Reputation: 11395
Using git-hg.
First, make sure there is a (non-Mercurial) git submodule under your main repository. If you don't have other submodules yet, just create a dummy submodule for some library other than core-plot
, for instance:
main-repo $ git submodule add https://repo.url.com/repo.git repo
Second, clone the core-plot
library into some directory.
main-repo $ git-hg clone https://code.google.com/p/core-plot/ core-plot
Add the new repo to the submodule list.
main-repo $ git submodule add ./core-plot core-plot
main-repo $ git commit -am "added core-plot submodule"
From now on, any clone from this repo will pull both repositories. (After submodule init and update).
Some problems I found out so far are:
git-hg
will have to git-hg pull
.The converse question git submodule from Hg repo? is also asked on StackOverflow. The best answer mentions projects hg-git and git-hg. Another related converse question is, How to deal with Git submodules on a repo that is converted to Mercurial.
Upvotes: 27
Reputation: 2367
In my experience, most active non-git projects have an up-to-date git mirror floating around on GitHub. It looks like core-plot
has one too:
https://github.com/djw/core-plot
If you're willing to rely on whoever set that mirror up, it seems like it might be the easiest option to get a submodule in place.
Upvotes: 15