简体   繁体   English

如何仅从Mercurial存储库中检索子目录?

[英]How can I retrieve only a subdirectory from a Mercurial Repository?

I'm trying to sell our group on using Mercurial as a source repository rather than VSS. 我正在尝试出售使用Mercurial作为源存储库而不是VSS的小组。 In the process of updating our build scripts, I'm running into an issue trying to retrieve files from the Hg repository. 在更新构建脚本的过程中,我遇到了一个尝试从Hg存储库检索文件的问题。

Our builds are automated with NAnt and currently work for local builds or builds from VSS (ie, pull the source as needed from VSS). 我们的构建使用NAnt进行自动化,并且当前可用于本地构建或从VSS构建(即,根据需要从VSS提取源代码)。 I'm trying to update them to work with Mercurial as well. 我正在尝试更新它们以使其与Mercurial一起使用。

Basically, when I'm working with single files, I don't have any issues since I can just use NAnt's 'get' task (after getting the appropriate revision hash) to retrieve the individual file. 基本上,当我使用单个文件时,我没有任何问题,因为我可以使用NAnt的“ get”任务(在获取适当的修订哈希之后)来检索单个文件。

The problem that I'm having is when I need to work with a directory (and subdirectories) of files that aren't at the root of the repository. 我遇到的问题是当我需要使用不在存储库根目录中的文件的目录(和子目录)时。 I can't seem to figure out the proper commands to retrieve/copy a subdirectory from the repository to my 'working' directory for the builds. 我似乎无法找出适当的命令来将子目录从存储库检索/复制到构建的“工作”目录。 I've spent basically the whole afternoon trying to figure out how to do this with the mercurial executables (so I can use a NAnt 'exec' task), and have basically hit a wall so I figured I'd try posting here. 我整个下午基本上都在花时间试图弄清楚如何使用可执行的可执行文件(这样我就可以使用NAnt'exec'任务)了,并且基本上已经碰壁了,所以我想尝试在此处发布。

Can someone confirm whether this is possible, and provide some suggestions as to how I might be able to do this? 有人可以确认这是否可行,并提供一些有关我如何能够做到这一点的建议吗? I realize that Mercurial tracks changes by files and not directories, but it seems odd to me that this isn't available out of the box (from what I can tell). 我意识到Mercurial跟踪文件而不是目录的更改,但是让我觉得奇怪的是,这并不是开箱即用的(据我所知)。

If it's just not possible, the only workarounds I see are either maintaining NAnt fileset lists of expected files to work with (ugh!), or cloning the entire repository to a temporary directory and then just copying the files from that source as needed (this feels like a cludge to me). 如果不可能,我看到的唯一解决方法是要么维护要使用的预期文件的NAnt文件集列表(ugh!),要么将整个存储库克隆到一个临时目录,然后根据需要从该源复制文件(这对我来说就像个笨蛋)。

I realize that I could simply create another repository for the directory that I want to work with, but I'd prefer to not go that route since I think that would increase the complexity of what I'm trying to do by a significant amount (I would have to apply this a large number of times for all of the different libraries that we build..). 我意识到我可以为要使用的目录简单地创建另一个存储库,但是我宁愿不要走那条路,因为我认为这会大大增加我尝试执行的操作的复杂性(对于我们构建的所有不同库,我将不得不多次应用。

Mercurial doesn't let you get only part of a repository. Mercurial不允许您仅获取存储库的一部分。 You have to get the whole tree. 您必须得到整棵树。 It's much more whole-repo focused than svn is. 它比svn更注重整体回购。

You could try and segment your repository into multiple repos and manage them using the subrepos feature. 您可以尝试将存储库细分为多个存储库,并使用subrepos功能对其进行管理。 Then you can pull the subdirectories independently. 然后,您可以独立拉出子目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mercurial:如何从存储库中仅导入一些更改集? - Mercurial: How can I import only some changesets from a repository? 如何从mercurial存储库中检出OpenJDK? - How can I checkout the OpenJDK from the mercurial repository? 如何完全从Mercurial存储库中删除某些内容? - How can I completely remove something from a Mercurial repository? 如何拆分商品库? - how can I split a mercurial repository? 如何将带分支的Git存储库转换为可行的Mercurial存储库? - How can I convert a Git repository with branches to a workable Mercurial repository? 如何在不使用子存储库的情况下将一个商业存储库(包括历史记录)作为子目录导入另一个商业存储库? - How can I import a mercurial repo (including history) into another mercurial repo as a subdirectory, without using subrepos? 我可以拆分Mercurial存储库吗? - Can I split a Mercurial repository? 在Mercurial存储库中,如何查找子目录中最后提交的10个文件? - In a Mercurial repository, how to find lastly committed 10 files contained in a subdirectory? 我可以在本地使用Mercurial,并从/ push更新到Subversion存储库吗? - Can I use Mercurial locally, and update from/push to a Subversion repository? 如何在没有hg命令的情况下从Mercurial存储库下载文件? - How can I download a file from mercurial repository without hg command?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM