merging / integrating a subrepo into its parent
Matt Harbison
mharbison72 at gmail.com
Fri Jul 6 02:40:34 UTC 2018
On Thu, 05 Jul 2018 05:46:59 -0400, Benoit Fouletier <benblo at gmail.com>
wrote:
> I have the following structure:
> * main
> * sub
>
> sub is currently stored in a subrepo: now I would like to have it as a
> regular subfolder of main, with its history stored in main.
>
> I know I could use hg pull --force to add it as a parallel branch, then
> merge the heads, and the end result would look like this:
> o-main1-main2-main2------------------o
> /
> o-sub1-sub2-sub3
That's not quite the same either, because the 'sub' part of the path isn't
actually stored in the subrepo, so you'd lose it on pull. If you then try
to rename those files to add 'sub' back in, you will run into problems
when you update between a revision with a subrepo and a revision without
the subrepo.
> ... but it feels like a shame to lose the main <-> sub relationship
> tracked
> by .hgsubstate, so basically I would like to rewrite it to:
> o-main1-sub1-main2-sub2-main2-sub3-o
> --> is there a way to achieve that? perhaps using hg convert?
Convert will work, but not out of the box. If your subrepo is 1:1 with
the parent (i.e. you used commit -S), then it should be relatively trivial
to hack up the mercurial_source class to return all of the files,
including from the subrepo. I had a repo/subrepo pair that was pretty
close to that, but there were a handful of subrepo commits that I piled up
and then committed to the parent as a group. I hacked the convert code to
notice that a parent commit jumped more than one subrepo revision, and had
the source class (and the main convert code) crawl the subrepo and create
an equivalent commit so I didn't lose any commit messages. But it was too
tied to the repo I was converting to submit upstream.
> I am fine with rewriting history, changing hashes and recloning
> everything.
More information about the Mercurial
mailing list