I have a directory structure like:
project_root
data/
src/
.hg/
utils/
math/
graphics/
...
README.txt
LICENCE.txt
As you can see from the location of .hg/, only src/ is under Hg control. I'd like to move the repository root up from src/ to its parent directory project_root, so I can track data/, README.txt, and LICENCE.txt as well.
A hacky way to do this would be to move everything down a directory rather than moving .hg up:
Is there a better way? I can't be the first person with this problem, and the above solution seems overly involved.
You should try hg convert
. You will be "converting" your existing Mercurial repo into a new one. You specify rules for the conversion, which in your case will be that all files from the original repo go to a src
directory in the new repo. Then you can manually copy and hg add
the other files to the new repo.
This has the advantage that it won't be reflected as separate changes in your history. The possible disadvantage is that it will cause your changeset IDs to be regenerated, and existing clones will no longer be able to pull from the new repo.
Your plan is fine. It may seem involved, but it should take less than 20 minutes (worst case) and only happens once.
In the first step when you move the files that are tracked, you should use hg rename
(alias hg move
) to move them, as Mercurial will remember what each file was before and after the move. This will help with merging changes on file prior to the move with the new files after the move. Works best when renaming/copying is not accompanied by changes to the contents in the same changeset.
I recommend cloning the actual repo (or copying the entire project directory) before proceeding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With