本文介绍了Mercurial移除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有办法从数据库中删除旧的变更集?我有一个60GB的存储库,这使得进行克隆非常痛苦.我想在某个日期之前修剪掉所有内容,并丢弃庞大的数据库以收集灰尘.

解决方案

您可以这样做,但是这样做会使所有克隆无效化,因此除非您完全独自工作,否则这样做通常是不明智的. /p>

每个变数集均由哈希码唯一标识,该哈希码是(除其他事项外)源代码变更,元数据以及其一两个父代的哈希值的组合.那些父母需要一直存在于仓库中,直到项目开始. (没有该限制的话,将拥有浅克隆,但尚无可用.)

如果您可以更改较新的变更集的哈希值(这又再次打破了所有克隆的散列),则可以使用以下命令;

hg export -o 'changeset-%r.patch' 400:tip   # changesets 400 through the end for example
cd /elsewhere
hg init newrepo
cd newrepo
hg import /path/to/the/patches/*.patch

您可能需要做一些工作来处理合并变更集,但这是一般的想法.

还可以使用类型为hghg convert作为源类型和目标类型,并使用splicemap来完成此操作,但这可能还涉及更多.

更大的问题是,如何输入60GB的源代码,或者您是否根据所有建议添加了生成的文件. :)

Is there a way in mercurial to remove old changesets from a database? I have a repository that is 60GB and that makes it pretty painful to do a clone. I would like to trim off everything before a certain date and put the huge database away to collect dust.

解决方案

You can do it, but in doing so you invalidate all the clones out there, so it's generally not wise to do unless you're working entirely alone.

Every changeset in mercurial is uniquely identified by a hashcode, which is a combination of (among other things) the source code changes, metadata, and the hashes of its one or two parents. Those parents need to exist in the repo all the way back to the start of the project. (Not having that restriction would be having shallow-clones, which aren't available (yet)).

If you're okay with changing the hashes of the newer changesets (which again breaks all the clones out there in the wild) you can do so with the commands;

hg export -o 'changeset-%r.patch' 400:tip   # changesets 400 through the end for example
cd /elsewhere
hg init newrepo
cd newrepo
hg import /path/to/the/patches/*.patch

You'll probably have to do a little work to handle merge changesets, but that's the general idea.

One could also do it using hg convert with type hg as both the source and the destination types, and using a splicemap, but that's probably more involved yet.

The larger question is, how do you type up 60GB of source code, or were you adding generated files against all advice. :)

这篇关于Mercurial移除记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 19:54