1 # How to convert Mercurial Repositories with subrepos
5 Subrepositories must first be converted in order for the conversion of
6 the super repository to know how hg commits map to git commits in the
7 sub repositories. When all subrepositories have been converted, a
8 mapping file that maps the mercurial subrepository path to a converted
9 git submodule path must be created. The format for this file is:
11 "<mercurial subrepo path>"="<git submodule path>"
12 "<mercurial subrepo path2>"="<git submodule path2>"
15 The path of this mapping file is then provided with the --subrepo-map
20 Example mercurial repo folder structure (~/mercurial):
26 Create an empty new folder where all the converted git modules will be imported:
30 ### Convert all submodules to git:
34 hg-fast-export.sh -r ~/mercurial/subrepo1
39 hg-fast-export.sh -r ~/mercurial/subrepo2
41 ### Create mapping file
43 cat > submodule-mappings << EOF
44 "subrepo/subrepo1"="../submodule1"
45 "subrepo/subrepo2"="../submodule2"
48 ### Convert main repository
53 hg-fast-export.sh -r ~/mercurial --subrepo-map=../submodule-mappings
56 The resulting repository will now contain the subrepo/subrepo1 and
57 subrepo/subrepo1 submodules. The created .gitmodules file will look
60 [submodule "subrepo/subrepo1"]
61 path = subrepo/subrepo1
63 [submodule "subrepo/subrepo2"]
64 path = subrepo/subrepo2