How to combine several small repositories into separate subdirectories of a single repository?
Malcolm Matalka
mmatalka at gmail.com
Tue Apr 28 20:12:22 UTC 2020
Chris Green <cl at isbd.net> writes:
> On Tue, Apr 28, 2020 at 06:27:32PM +0200, Malcolm Matalka wrote:
>>
>> Chris Green <cl at isbd.net> writes:
>>
>> > I have a number of separate small projects maintained using mercurial,
>> > since they all relate to Dokuwiki and could probably, in the long
>> > term, share some code it would see sensible to combine them into a
>> > single repository.
>> >
>> > So, given a set of separate projects each with its own .hg as follows:-
>> >
>> > ./dokuwiki/plugins/servlog/.hg
>> > ./dokuwiki/plugins/tagentry/.hg
>> > ./dokuwiki/plugins/trip/.hg
>> > ./dokuwiki/plugins/showmail/.hg
>> > ./dokuwiki/tpl/roundbox/.hg
>> > ./dokuwiki/tpl/dokucms/.hg
>> >
>> > How do I combine them into a single mercurial repository with its data
>> > stored in ./dokuwiki/.hg ?
>>
>> You can pick one of those repos or make a new one, and then just do hg
>> pull -f path/to/other/repo
>>
> If I'm in ~/dokuwiki and do 'hg pull -f plugins/blog' then all blog's
> files end up in ~/dokuwiki which isn't what I want. I want the files
> to be in the same sub-directory relative to ~/dokuwiki. Do I have to
> do an 'hg move <all the files>' as well?
>
> I maybe didn't explain my requirement very well, I want exactly the
> directory structure I have now but with a single mercurial repository
> based in ~/dokuwiki.
You can do that but you need an intermediate step:
mkdir /tmp/dokuwiki
cd /tmp/dokuwiki
hg init
hg pull -f ...
hg merge ...
hg pull -f ...
hg merge ...
hg pull -f ...
....
Verify all is good. then nuke ~/dokuwiki and mv /tmp/dokuwiki ~/
Your options to get the directory structure back are to either hg mv
stuff around. Or you could use hg convert to rewrite history in the new
directory names.
see hg convert --help to see how to do that if you want.
I recently did a similar task where I combined into a monorepo and decided
I wanted to rewrite history on all of the combined repos.
More information about the Mercurial
mailing list