How to combine several small repositories into separate subdirectories of a single repository?
Chris Green
cl at isbd.net
Tue Apr 28 20:40:12 UTC 2020
On Tue, Apr 28, 2020 at 10:12:22PM +0200, Malcolm Matalka wrote:
>
> 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.
Thank you for the comprehensive instructions and explanation, just
what I needed.
--
Chris Green
More information about the Mercurial
mailing list