How to rename a directory in Mercurial and continue to track all file changes

后端 未结 3 1070
旧巷少年郎
旧巷少年郎 2021-02-01 14:18

I decided to rename some directories in my home/hobby Python package (doc to docs, test to tests, util to

相关标签:
3条回答
  • 2021-02-01 15:07

    Since you've already renamed the directories, this is perfectly OK. (It would have saved you a manual step if you'd let Mercurial rename them for you: hg rename doc docs, etc. instead of doing it yourself then letting Mercurial know about it).

    If you don't have any other files to check in, the hg addremove is superfluous. Look in the output of hg stat and you should only see lines beginning with 'R' (for doc/*, test/* and util/*) and 'A' (for docs/*, etc.)

    Finally, don't forget to commit the changes.

    EDIT: Forgot to say... use hg log --follow to track changes across the rename.

    0 讨论(0)
  • 2021-02-01 15:11

    Mercurial has no concept of directories; it treats everything (files and directories) as files. Also, I usually never rename files or directories manually; I just use

    hg rename old-name new-name

    I suggest you do that too.

    Mercurial offers a rename-tracking feature, which means that mercurial can trace the complete history of a file which has been renamed. If you manually rename this, its not possible.

    However, as you have already renamed them manually, you need to use the --follow argument along with hg log to track the file changes through the history.

    Personally I'd just go with hg rename and it should be the preferred method.

    0 讨论(0)
  • 2021-02-01 15:12

    One reason to use --after instead of renaming with hg is if you are using a refactoring tool that does more than just rename e.g. also fixes references.

    0 讨论(0)
提交回复
热议问题