我可以克隆Mercurial存储库的一部分吗? [英] Can I clone part of a Mercurial repository?

查看:102
本文介绍了我可以克隆Mercurial存储库的一部分吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以克隆Mercurial存储库的一部分?假设存储库很大,或者包含多个项目或多个分支.我可以只克隆存储库的一部分吗?

Is it possible to clone part of a Mercurial repository? Let's say the repository is quite large, or contains multiple projects, or multiple branches. Can I clone only part of the repository?

例如在Subversion中,您可能具有trunkbranches.如果我只想获取主干(或分支之一),则可以请求[project]/trunk.如果我克隆了hg repo,我将获得主干和所有分支.这可能是我不想要的很多信息.我可以避免得到这个吗?

E.g. in Subversion, you might have trunk and branches. If I only want to get trunk (or one of the branches) I can just request [project]/trunk. If I clone the hg repo I'll get trunk and all of the branches. This might be a lot of information I don't want. Can I avoid getting this?

或者,如果我想在一个hg仓库中包含多个项目,该怎么办? IE.这样我可能只是得到其中一个项目而忽略其他项目.

Alternatively, if I want to have multiple projects in one hg repo, how should I do this? I.e. so that I might just get one of the projects and ignore the others.

推荐答案

可以.我确定您已经继续前进,但是为了以后以后会在这里闲逛的人,我遵循

Yes you can. I'm sure you've moved on, but for the sake of those who will wander here later, I followed the docs at ConvertExtension, and wrote a simple batch script:

@echo off
echo Converting %1
REM Create the file map
echo include %1 > ~myfilemap               
echo rename %1 . >> ~myfilemap 
REM Run the convert process
hg convert --filemap ~myfilemap .\ ..\%1   
REM Delete the file map
del ~myfilemap                             
cd ..\%1
REM update the new repo--to create the files
hg update                                  

将其命名为类似split.cmd的名称,然后将其放在要拆分的存储库的目录中.假设您有C:\repos\ReallyBigProject,而子文件夹为C:\repos\ReallyBigProject\small-project.在命令提示符下,运行:

Name it something like split.cmd, and put it in the directory for the repo you want to split. Say for example you have C:\repos\ReallyBigProject, and a subfolder is C:\repos\ReallyBigProject\small-project. At the command prompt, run:

cd\repos\ReallyBigProject
split.cmd small-project

这将创建C:\repos\small-project,其中包含较大项目的相关修订历史的一部分.

This will create C:\repos\small-project with a slice of the relevant history of revisions from the larger project.

默认情况下未启用convert.您需要确保.hg\hgrc文件中存在以下几行(在我的示例中为c:\repos\ReallyBigProject\.hg\hgrc):

The convert is not enabled by default. You'll need to make sure the following lines exist in your .hg\hgrc file (c:\repos\ReallyBigProject\.hg\hgrc in my example):

[extensions]
hgext.convert=

这篇关于我可以克隆Mercurial存储库的一部分吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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