[英]How to keep revision timestamps while converting a repository from Mercurial to Subversion?
Because of work policies, I'm forced to use Subversion. 由于工作策略,我被迫使用Subversion。 Currently I've developed some code using Mercurial, and I have to convert this repository to a new Subversion repository. 目前我已经使用Mercurial开发了一些代码,我必须将此存储库转换为新的Subversion存储库。 The current Mercurial repository also contains legacy code parts that I copied from another SVN repository (a HW driver), and this code contains keywords (like $Id: ...$
) that were expanded while I copied the code. 当前的Mercurial存储库还包含我从另一个SVN存储库(一个HW驱动程序)复制的遗留代码部分,并且此代码包含在复制代码时扩展的关键字(如$Id: ...$
)。
My current approach to do the conversion is: 我目前进行转换的方法是:
hg convert --dest-type svn repository.hg repository.svn
This works, unfortunately it does not preserve the timestamps of Mercurial revisions. 遗憾的是,它不能保留Mercurial修订版的时间戳。 Additionally, it expands tags in some legacy code parts where someone wrote $Id: ...$
stuff. 此外,它扩展了一些遗留代码部分中的标签,其中有人写了$Id: ...$
stuff。
The questions: 问题:
Sorry if this question has been answered already, I've searched intensely with Google and on here, but I cannot find an answer for this problem. 很抱歉,如果这个问题已经得到解答,我已经在谷歌和这里进行了强烈的搜索,但我找不到这个问题的答案。 Especially the timestamp problem must be something that others have already run into. 特别是时间戳问题必须是其他人已经遇到的问题。
Cheers, H. 干杯,H
EDIT: I've since created a script that extracts timestamps from a Mercurial export file and updates a Subversion dumpfile, which is nothing more but a kludge, but it works. 编辑:我已经创建了一个脚本,从Mercurial导出文件中提取时间戳并更新Subversion转储文件,这只是一个kludge,但它的工作原理。 The $Id:
problem is still unsolved, unfortunately. 遗憾的是, $Id:
问题仍未得到解决。
It is a tricky issue. 这是一个棘手的问题。 Why aproaching the solution differently: 为什么不同地解决方案:
https://bitbucket.org/durin42/hgsubversion/wiki/Home https://bitbucket.org/durin42/hgsubversion/wiki/Home
This is an extension to Mercurial which allows you to access it as a SVN Client, could it work for you? 这是Mercurial的扩展,它允许您作为SVN客户端访问它,它可以为您工作吗?
I want to re-suggest hgsubversion as a solution. 我想重新建议将hgsubversion作为解决方案。 In the normal case, it is used to access a Subversion repository using hg
, but you can use it to convert a Mercurial repository to Subversion as well if you are not afraid to work on your history of changesets. 在正常情况下,它用于使用hg
访问Subversion存储库,但是如果您不害怕处理变更集的历史记录,则可以使用它将Mercurial存储库转换为Subversion。 (If you know how to work with changesets, you have quite a bit of control over the process.) (如果您知道如何使用变更集,则可以对该过程进行相当多的控制。)
Essentially, you have to do the following steps: 基本上,您必须执行以下步骤:
hg pull
this SVN path (using hgsubversion) into your Mercurial repository. 创建一个Subversion存储库或目录, hg pull
此SVN路径(使用hgsubversion) hg pull
入Mercurial存储库。 The Subversion path may have to be non-empty for this, but as long as there is no overlap with the files in the Mercurial repository, this should be fine. Subversion路径可能必须非空,但只要Mercurial存储库中的文件没有重叠,这应该没问题。 hg push
to send the result back to Subversion. 使用hg push
将结果发送回Subversion。 The linear set of changes that descend from the former head of the Subversion repository will be added to the Subversion path. 从Subversion存储库的前端开始的线性变化集将添加到Subversion路径中。 Check this blog article for some concrete command-line commands that you can use. 查看此博客文章,了解可以使用的一些具体命令行命令。
I tried the keyword substitution once on SVN and I had to add a svn:keywords
property to the working folder indicating which keyword(s) to be substituted. 我在SVN上尝试了一次关键字替换 ,我不得不在工作文件夹中添加一个svn:keywords
属性,指明要替换的关键字。 So, deleting this property should do the job. 因此,删除此属性应该可以完成这项工作。
This article on Stack Overflow is possibly related to this question. 关于Stack Overflow的这篇文章可能与这个问题有关。
As far as I understand your problem now: You have a Hg repository which was once converted from SVN, where keyword expansion had been used. 据我所知,你现在的问题是:你有一个Hg存储库,它曾经从SVN转换过,其中使用了关键字扩展。 Now the expanded keywords remain unchanged in the Hg repo. 现在,扩展的关键字在Hg仓库中保持不变。 You now want to strip those keywords (or just their expanded values) from the Hg history, preserving author, date/time, commit message and of course changed files. 您现在想要从Hg历史记录中删除这些关键字(或只是它们的扩展值),保留作者,日期/时间,提交消息,当然还有更改的文件。
This is just an idea, I have never done this in practical, but ... Speaking just of mercurial, I think it's possible to do this by a combination of usual mercurial behaviour, just for one branch and without tags and other branches: 这只是一个想法,我从来没有在实践中做到这一点,但是......只是说到mercurial,我认为可以通过常见的mercurial行为,只为一个分支和没有标签和其他分支的组合来做到这一点:
hg log > logfile.txt
over the source repo on that branch you want to change 在要更改的分支上的源存储库上执行hg log > logfile.txt
hg addremove
hg commit -m ... -d ... -u ...
The drawback is that the changesets will get new hash values, so tags and bookmarks need to be updated. 缺点是更改集将获得新的哈希值,因此需要更新标记和书签。
If there are other branches that have to be migrated: 如果还有其他分支需要迁移:
Perhaps there is some more work to be done, but I think this could work. 也许还有一些工作要做,但我认为这可行。 As told before, I've never done this. 如前所述,我从未这样做过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.