如何在Mercurial中重命名目录并继续跟踪所有文件更改 [英] How to rename a directory in Mercurial and continue to track all file changes

查看:108
本文介绍了如何在Mercurial中重命名目录并继续跟踪所有文件更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定重命名我的家庭/业余Python包中的某些目录(docdocstesttestsutilutils),因为现在我已经考虑了更多关于这一点,我认为新名称更合适.我现在的一般想法是,如果容器以其内容命名,则其名称应为复数名词.

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.

现在我已经准备好下一个hg commit了,我想知道如何将这些目录名称更改告知Mercurial.我是RCS软件的新手,仅使用Mercurial已有几个月.当我运行hg status时,它会显示这些目录中的所有文件都已删除和添加,因此,如果我只是执行hg addremove,恐怕我会丢失这些目录中或目录中文件的所有更改历史记录.至少,变更历史记录将变得零散且无法追踪.我遇到过hg rename命令,但是文档仅讨论了它用于单个文件的用途,而不是目录.

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.

在进一步阅读Bryan O'Sullivan的权威指南"之后,看来rename可以引用目录.

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

谁能告诉我这是否是Mercurial中重命名目录的公认方法,如果不是,我该怎么做.

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.

推荐答案

由于您已经重命名了目录,因此完全可以. (如果您让Mercurial为您重命名它们:hg rename doc docs等,而不是自己做然后让Mercurial知道,那将为您节省一个手动步骤.)

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).

如果没有其他文件要签入,则hg addremove是多余的.查看hg stat的输出,您应该只看到以'R'开头的行(对于doc/*test/*util/*)和'A'开头的行(对于docs/*等)

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.

编辑:忘了说...使用hg log --follow来跟踪整个重命名中的更改.

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

这篇关于如何在Mercurial中重命名目录并继续跟踪所有文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆