I have two Mercurial repositories. Both repos have their own unrelated history. Let's call them:
- "Main" (contains the project itself)
- "Lab" (contains some related content)
I would now like to "import" the Lab
repo into the Main
repo with the following constraints:
- Both repos shall keep their history.
Lab
shall be stored as a subfolder inMain
.- The changes from
Lab
shall be be located in a branch which gets merged intoMain
.
Following https://www.mercurial-scm.org/wiki/MergingUnrelatedRepositories basically works but doesn't create a branch.
Given a repository
Main
andLab
, you can merge theLab
repository into the Main repository and rename its default branch to some other name by doing the following with theconvert
extension:default Lab
. Using this branchmap, the Lab changesets in the "default" branch will be named "Lab". If you have other branches in your Lab repository, you may want additional entries.hg convert Lab Main --branchmap branchmap.txt
. This assumes the Lab and Main repository directories, and the branchmap.txt file, are in the current directory. Adjust paths accordingly. The Lab changesets will be added to the Main repository.a.
hg update Lab
b.
mkdir Lab
c.
hg move * Lab
d.hg ci -m "Moved Lab files to Lab subdirectory"
e.
hg update default
f.
hg merge Lab
g.
hg ci -m Merge
Now you can continue to modify the Lab branch in the future and merge to default as needed.