Mercurial:如何移动项目/模块,但保留修订历史记录
考虑以下多模块项目(在单个存储库中):(
Module A (i.e. parent)
- Module 1 (various core stuff)
- Module i
- Module 2 (non-core, depends on 1)
- Module ii
- Module iii
这样设置的原因是它使一些开发人员能够只处理单个模块(例如 2
及其子模块),同时其他开发人员可以处理整个代码库(例如 A
及其子代)。
然后让我们假设 Module ii
已被重新分类为 core
。 ,并且需要移至 Module 中1
。
我可以通过将Module ii
从Module 2
移动到Module 1
来处理这个问题,但是,mercurial将其视为一个。删除(从 2
中)并添加(在 1
中),因此我们将丢失移动之前的 ii
的修订历史记录 (I)。知道我们实际上不会“失去”这个,因为它在 Mercurial 中仍然可用;但是,在新位置中无法轻松访问文件)。
如何移动文件并让 Mercurial 移动这些文件的修订历史记录?
Consider the following multi-module project (within a single repository):
Module A (i.e. parent)
- Module 1 (various core stuff)
- Module i
- Module 2 (non-core, depends on 1)
- Module ii
- Module iii
(The reason for a set up like this is it enables some developers to just work on individual modules (e.g. 2
and its children), whilst other developers can work on the whole code base (e.g. A
and its children).
Let us then suppose that Module ii
has been reclassified as core
, and needs to be moved into Module 1
.
I could just handle this by moving Module ii
from Module 2
to Module 1
. However, mercurial treats this as a delete (from 2
) and add (in 1
), and thus we would lose the revision history from ii
prior to the move. (I know that we would not actually 'lose' this, as it would still be available in mercurial; however, it would not be readily accessible wrt the files in the new location).
How can I move files and have mercurial move the revision history with those files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以使用 hg mv 将这些添加/删除对转换为“重命名”,只要它们保留在同一存储库中即可。
It is possible to convert these add/remove pairs to "renames" using
hg mv
, as long as they remain in the same repository.信息就在那里并且不会丢失。您只需对 hg 日志使用 -f,--follow 标志即可。
(这就是 @freixo 在帖子 中指出的内容为什么“hg mv”(mercurial)默认不移动文件的历史记录?)
The info is there and is not lost. You just need to use the -f,--follow flag for hg log.
(This is what @freixo points to in post Why 'hg mv' (mercurial) doesn't move a file's history by default?)
你为什么不改变你的〜/.hgrc(或Mercurial.ini)做xanatos在这里所说的:为什么“hg mv”(mercurial)默认不移动文件的历史记录?
Why don't you just change your ~/.hgrc (or Mercurial.ini) doing what xanatos says here: Why 'hg mv' (mercurial) doesn't move a file's history by default?