Take the 2-minute tour ×

I'm working on an Android game with the folder structure:

\data (contains game graphics)
\libs (libgdx engine jars)
                 (*.class files)

Foolishly, I created a mercurial repository (hg init) in the \src directory. Thus, if I update any of the graphics (small file sizes), they aren't added to the repo when I commit. My question is: how can I change the root of the repo to include the \data directory as well as the \src directory, but without including the \libs directory as that includes 10-20mb jars?

share|improve this question
possible duplicate of Changing a directory structure in Mercurial –  Martin Geisler Feb 24 '12 at 11:18
add comment

2 Answers

up vote 2 down vote accepted

There are two ways to do this.

1) Start a new repo. It's quick and easy but you'll lose your history.

2) Use hg rename. This is effectively a move command.

Rename the src directory to be something meaningful and then do this.

  1. hg rename MyProject/com MyProject/src/com
  2. Copy all the files/folders into the MyProject/ directory.
  3. Mark bin and libs as ignorable and
  4. Add everything else.
  5. hg commit
share|improve this answer
add comment

If you don't want to just do an hg rename, you can do it with the convert extension (which comes by default with Mercurial, you just need to enable it in your .hgrc).

Run it with the --filemap parameter and a filemap file that has something like:

rename com src/com

You will end up with a new repository with all of your history, but with your com directory moved into src/com. You can then copy you bin, data and libs folders in there, run hg addremove and you should be all good to go.

Warning: the new repo is completely different than the old one -- changeset IDs and such will be different, so anybody you worked with in the past will have to get on the new repo.

share|improve this answer
add comment

Your Answer


