想做一个带有 hgignore 模式过滤器的善变克隆
随着时间的推移,许多开发人员提交了文件,然后将其添加到 .hgignore 中。据我所知,没有办法从 Mercurial 的历史中删除项目,这没关系。但我也听说有一种方法可以进行克隆,我认为使用转换插件来克隆/导出存储库,同时指定哪些文件不包含在转换中。
我忍不住认为有人有一个脚本可以使用 .hgignore 文件中的模式进行导出/过滤/转换。
有人创造过这样的野兽吗?
Over time a number of the developers have committed files that were then added to the .hgignore. From what I hear there is no way to remove items from the history of mercurial, which is ok. But I also heard that there is a way to do a clone, I think using the convert plugin, to clone/export a repo while specifying which files to not include in the conversion.
I can't help but think that someone out there has a script that does this export/filter/convert using the patterns from the .hgignore file.
Has anyone created such a beast?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以从 .hgignore 创建一个文件映射,执行如下操作:
这将为您提供一个文件映射,您可以将其传递到
hg Convert
中,该文件映射将删除所有添加的文件,这些文件将在您的 .hgignore 中被忽略。但请理解,运行 Convert 会创建一个与您之前的存储库无关的全新存储库。所有现有克隆都将无法与新克隆一起使用。通常不值得。
You could create a filemap from .hgignore doing something like this:
that will get you a filemap you can pass into
hg convert
that removes all the added files that would be ignored given your .hgignore.Do understand though, that running convert creates a whole new repo that is unrelated to your previous repo. All existing clones will be unusable with the new one. It's not normally worth it.
hg Convert 确实是您想要使用的东西。
您将需要创建一个文件映射(只是一个文本文件),其中将列出您想要包含、排除或重命名的所有内容:
阅读以下内容以获取更具体的示例:
https://www.mercurial-scm.org/wiki/ConvertExtension#A --filemap
创建此文件后,您只需使用以下命令:
$ hg 转换 --filemap my_file_map /path/to/source/repo /path/to/dest/repo
源存储库不会被修改,并且目标存储库将被创建。我不想只是逐字复制文档已经说明的内容,所以这里是链接:
如何仅保留子目录(或在 Mercurial 存储库上运行):
https://www.mercurial-scm.org/wiki/ConvertExtension#Converting_from_Mercurial
hg convert is indeed the thing you want to use.
You will want to create a file map (just a text file) which will list all of the things you either want to include, exclude, or rename:
Read the following for a more concrete example:
https://www.mercurial-scm.org/wiki/ConvertExtension#A--filemap
Once you have created this file you will just use the following command:
$ hg convert --filemap my_file_map /path/to/source/repo /path/to/dest/repo
The source repo will not be modified and a dest repo will be created. I don't want to just copy verbatim what the documentation already says so here is the link:
How to keep just a subdirectory (or run on the mercurial repo):
https://www.mercurial-scm.org/wiki/ConvertExtension#Converting_from_Mercurial