Johan Råde
Johan Råde

Reputation: 21368

Reorganize directory structure with Mercurial

I have a project with directory structure

Foo/
    .hg
    Bar1/
        ...
    Bar2/
        ...
    Zope/
        ...

I want to change this to

Foo/
    .hg
    Source/
        Bar1/
            ...
        Bar2/
            ...
    Zope/
        ...

What is the easiest way? (There are too many files to move them one-by-one. And there are several files with identical content, so if I just move the files and ask Mercurial to figure things out afterwards, then things get a little messy.)

Upvotes: 4

Views: 510

Answers (2)

Christian Specht
Christian Specht

Reputation: 36421

Mercurial has a special command to move stuff: hg mv
When you move your folders like this, it knows in the history that Foo/Source/Bar/SomeFile was previously Foo/Bar/SomeFile.
So when you look at the history of Foo/Source/Bar/SomeFile now, you also see the changes that were made when the file was still Foo/Bar/SomeFile.

Here's an example how to move the Bar1 folder into the Source folder and commit:

hg mv Bar1 Source
hg commit -m "moved to Source folder"

Upvotes: 7

Tyler Smith
Tyler Smith

Reputation: 1279

Drag the 2 Bar folders into the new Source folder and commit.

Upvotes: 0

Related Questions