Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
116 views
in Technique[技术] by (71.8m points)

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

I decided to rename some directories in my home/hobby Python package (doc to docs, test to tests, util to utils) because, now that I've thought more about it, I think the new names are more appropriate. My general thinking now is that if containers are named after their contents their names should be plural nouns.

Now that I'm ready for my next hg commit I'm wondering how to tell Mercurial about these directory name changes. I am new to RCS software in general and have only been using Mercurial for a couple months. When I run hg status it shows all the the files in these directories being removed and added, so I'm afraid if I just do a hg addremove I will loose all the change history for the files in these directories, or at the very least the change history will become fragmented and untraceable. I've come across the hg rename command, but the docs only discuss its use for individual files, not directories.

After further reading in Bryan O'Sullivan's 'Definitive Guide' it appears that maybe rename can refer to directories.

So here's what I've decided to try:

hg rename --after doc docs
hg rename --after test tests
hg rename --after util utils
hg status
hg addremove

Can anyone tell me if this is the accepted and preferred method for renaming directories in Mercurial, and if not, how should I do it.

question from:https://stackoverflow.com/questions/3535676/how-to-rename-a-directory-in-mercurial-and-continue-to-track-all-file-changes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...