Combining repos

Steve Greenland steveg at moregruel.net
Sat Jun 23 19:04:34 UTC 2007


According to Paul Moore <p.f.moore at gmail.com>:
> On 22/06/07, Daniel Holth <dholth at fastmail.fm> wrote:
> > Haven't you heard of the coolest merge ever?
> >
> > Just use "hg mv" to move everything in the old repository into the
> > desired subdirectory name, "cd new ; hg pull -f old"; "hg merge". The
> > combined repository will have two root revisions.
> 
> I'm having a bit of trouble following this. Could you give a step by
> step example? To get the OP's setup, I did:
> 
> >mkdir foo
> >mkdir foo\bar
> >mkdir foo\bar\baz
> >cd foo\bar\baz
> >hg init
> >echo Hello >a
> >hg add a
> >hg commit -m "Added a"
> >cd ..\..
> >hg init
> 
> Now I have
> 
> >hg status bar\baz\a
> ? bar\baz\a

Yes, except I also did 'hg add' in the 'foo' repo, which add everything
except the foo/bar/baz directory and contents, presumably because it
detected the existing repo.

> 
> Is the following what you meant?
> 
> >hg mv bar\baz\a bar\baz
> bar\baz\a: not copying - file is not managed
> abort: no files to copy
> >hg add bar\baz\a
> >hg status bar\baz\a
> A bar\baz\a

No, now you have 'a' in two repos.

Instead, I did this:

(Create sample situation of two repos, one "inside" the other:)
~/tmp$ mkdir -p foo/bar/baz
~/tmp$ cd foo/bar/baz
~/tmp/foo/bar/baz$ hg init
~/tmp/foo/bar/baz$ echo 'This is a' > a
~/tmp/foo/bar/baz$ hg add
adding a
~/tmp/foo/bar/baz$ hg ci -m"Initial a"
~/tmp/foo/bar/baz$ cd ../.. 
~/tmp/foo$ hg init
~/tmp/foo$ touch x
~/tmp/foo$ touch bar/y
~/tmp/foo$ hg add
adding bar/y
adding x
~/tmp/foo$ hg ci -m "Initial foo"

(Now merge the first, interior repo as a subdir of the new one:)
~/tmp/foo$ cd ..
~/tmp$ mv foo/bar/baz trepo
~/tmp$ cd trepo
~/tmp/trepo$ mkdir bar
~/tmp/trepo$ mkdir bar/baz
~/tmp/trepo$ hg mv a bar/baz/
~/tmp/trepo$ hg status
A bar/baz/a
R a
~/tmp/trepo$ hg ci -m"Moved a to bar/baz for repo merge"
~/tmp/trepo$ cd ../foo
~/tmp/foo$ hg pull -f ~/tmp/trepo
pulling from /home/steveg/tmp/trepo
searching for changes
warning: repository is unrelated
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
~/tmp/foo$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
~/tmp/foo$ hg ci -m"Merged old baz repo"


Regards
Steve
-- 
Steve Greenland
    The irony is that Bill Gates claims to be making a stable operating
    system and Linus Torvalds claims to be trying to take over the
    world.       -- seen on the net




More information about the Mercurial mailing list