How can I move my Mercurial repository root up one directory?

Viewed 1688

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:

  • Move the contents of src down to a new directory src/src/
  • Move the contents of project_root (other than src/) down to src/
  • Rename src to new_project_root
  • Move new_project_root out of project_root, delete project_root

Is there a better way? I can't be the first person with this problem, and the above solution seems overly involved.

3 Answers
Related