Clone subdir only from a large repository?

Giorgos Keramidas keramida at ceid.upatras.gr
Thu Jul 17 08:53:59 CDT 2008


On Thu, 17 Jul 2008 03:54:46 +0000 (UTC), rubik <rubik at sina.com> wrote:
> Masklinn <masklinn <at> masklinn.net> writes:
>> As Martin pointed out, this isn't possible at the moment. On the
>> other hand, I'd strongly suggest to check if you couldn't split your
>> "big" project into smaller (and independant) subprojects which you'd
>> link together via a mercurial forest.
>
> hi, is there an easy way to split a subdir into a seperate project ?
>
> I just think of hg cat out every version of files in the subdir and
> commit in turn.

Yes there is.  You don't have to "hg cat" anything, but you can use the
"hg convert" extension to convert from Hg to Hg, with a `file map'.

For example, if you have a source repository at `/hg/foo' and you want
to split the `lib/libexample' part of the `foo' repository, you can
create a filemap like this:

    % cat /tmp/my-filemap
    include lib/libexample
    rename libexample .
    %

THen you can run the "hg convert" extension like this:

    % hg convert --filemap /tmp/my-filemap /hg/foo /hg/libexample

This will convert all the history of `lib/libexample', including any
merges.  Doing the equivalent by repeated "hg cat" or "hg archive" runs
and manually committing in the destination repository is both tedious
and error prone.

There is *one* caveat to converting parts of a repository.  All the
changeset hashes will change in the destination repository.  This is
`normal' but if you have build-processes in place that depend on the
changeset hashes of the source repositry, you should be aware of it
before you run the conversion.



More information about the Mercurial mailing list