将Mercurial存储库转换为具有完整历史记录的子存储库(例如hg log -f) [英] Convert mercurial repository to subrepositories with full history (like hg log -f)

查看:68
本文介绍了将Mercurial存储库转换为具有完整历史记录的子存储库(例如hg log -f)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我将Mercurial存储库中的一些文件移到了子目录(作为模块)中,以使所有内容保持整洁.几天后,我发现我需要在另一个项目中使用该模块,因此我试图将其转换为自己的Mercurial存储库.

Recently I moved some files in my mercurial repository to a subdirectory (as a module) to keep everything tidy. Some days later I found out I needed that module in another project, so I'm trying to convert it to its own mercurial repository.

我面临的问题是新的存储库历史记录不完整,重命名后仅包含文件的历史记录.我得到的历史记录与执行hg log filename相同,我想要的是拥有文件的完整历史记录,例如hg log -f filename的输出.

The problem I'm facing is that the new repository history isn't complete, it only includes file's history after the rename. The history I'm getting is the same as executing hg log filename, and what I want is to have the full history of the file, like the output of hg log -f filename.

我想念什么?

谢谢.

推荐答案

我假设您具有以下结构:

I assume that you had something like this structure:

main.c
lib1.c
lib2.c

您重命名了文件,并得到了这样的内容:

You renamed the files and got something like this:

main.c
lib/lib1.c
lib/lib2.c

现在您在lib存储库中需要这样的东西:

You now want something like this as you lib repository:

lib1.c
lib2.c

我假设这是最后一部分,因为当您将其作为子存储库包含时,它看起来就像您的原始存储库在重命名后一样.

I assume this last part because, when you include it as a sub-repository, it will look like the your original repository did after the rename.

我将分几个阶段进行.

第一步是像您可能已经做的那样做.使用命令行hg convert --filemap LibTempMap.txt Main LibTempLibTempMap.txt的以下内容转换存储库:

The first stage would be to do as you probably already did. Convert the repository with the command line hg convert --filemap LibTempMap.txt Main LibTemp and the following contents of LibTempMap.txt:

exclude *
include lib
rename lib .

这为您提供了一个存储库,其中包含重命名后的历史记录.

This gives you a repository with the history after the rename.

第二阶段是使用命令行hg convert --rev X --filemap LibMap.txt Main Lib(其中X是重命名之前的修订)和LibMap.txt的以下内容来转换重命名之前的存储库:

The second stage would be to convert the repository before the rename with the command line hg convert --rev X --filemap LibMap.txt Main Lib (where X is the revision before the rename) and the following contents of LibMap.txt:

exclude *
include lib1.c
include lib2.c

这将为您提供一个存储库,其中包含重命名之前的历史记录.

This gives you a repository with the history from before the rename.

然后,我将使用hg transplant -s ..\LibTemp Y:tipLib文件夹(其中Y是在LibTemp存储库中重命名之后的修订版本).通过在转换过程中进行重命名来确保临时存储库中的文件结构相同,这应该可以干净地移植.

I would then transplant the later changes from LibTemp to Lib using hg transplant -s ..\LibTemp Y:tip from within the Lib folder (where Y is the revision after the rename in the LibTemp repository). This should transplant cleanly as you made sure that the file structures were the same in the temporary repository by doing the rename during the convert.

然后剩下的是Lib存储库,其中包含所需的历史记录和文件,并且可以删除LibTemp存储库.

You're then left with the Lib repository containing the history and files that you want and can delete the LibTemp repository.

这篇关于将Mercurial存储库转换为具有完整历史记录的子存储库(例如hg log -f)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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