How to combine a number of small repositories into one?

Dr Rainer Woitok rainer.woitok at gmail.com
Sat Dec 12 15:13:42 UTC 2020


Cris,

On Friday, 2020-12-11 18:55:04 +0100, I myself wrote:

> ...
> $ cd /home/chris/dev/
> $ hg init newwiki
> $ cd newwiki
> $ mkdir plugins tpl
> $ cd plugins
> $ for r in ../../dokuwiki/plugins/* do ; hg pull -f $r ${r##*/} ; done
> $ cd ../tpl
> $ hg pull -f ../../dokuwiki/tpl/roundbox roundbox
> $ cd ../..
> $ mv dokuwiki dokuwiki.orig # Just to still have it around
> $ mv newwiki dokuwiki

Sorry, but the above was utter nonsense!

As far as I can see, you have three options:

1. Turn "dokuwiki/" into a repository which  contains the other reposit-
   ories as sub-repositories.   Then every future  change is first comm-
   itted in the  sub-repository to which  it belongs  and then that sub-
   repository change is committed  in the main  repository  "dokuwiki/".
   Others just clone or pull "dokuwiki/" and get the right thing.

2. To really have everything  in a single repository "dokuwiki/"  with a
   single history and the same directory structure as before you'll have
   to first  move everything  in every  repository  two directory levels
   down.  That is, toplevel file "x" in repository "roundbox/" has to be
   moved to  "roundbox/tpl/roundbox/x".   The other repositories have be
   treated likewise.  I see two ways to achieve this:

   2.1. Use Mercurial's built-in "convert" extension.  I would call this
        the "elegant" method because it is just a sort of transformation
        of each individual repository  into a differently named  new one
        keeping its history intact and not adding any additional change-
        sets documenting this modification.

   2.2. Create a clone of each repository and in this clone insert these
        two directory levels manually  using Mercurial's "hg move" comm-
        and and then committing this change.

   After this is done go into the first of these new repositories,  pull
   in the second repository  using the  "--force" option,  merge the new
   head with the original one, commit this merge and start over with the
   next repository.

I hope this is  a bit more sane  than my previous remarks  and will help
you along reorganizing your repositories.

Sincerely,
  Rainer





More information about the Mercurial mailing list