Mercurial仓库狭窄的克隆? [英] Mercurial repository narrow clone?

查看:57
本文介绍了Mercurial仓库狭窄的克隆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于有了新的见识而进行了更新:五年后看到此问题后,我意识到这源于试图将版本控制系统用作程序包管理器.当然,这会导致各种意外的问题,我们不应该这样使用它.如果您正在阅读此问题,建议您搜索首选语言的软件包管理器.

Update because of new insights: Upon seeing this question five years later, I realise that this stems from trying to use a version control system as a package manager. This of course leads to all sorts of unexpected issues, and we shouldn't be using it that way. If you're reading this question, I suggest searching for a package manager for your preferred language.

我的原始问题:我目前正处于从Subversion转向Mercurial的过程中,我不得不说我对此决定并不后悔.但是,在尝试转换项目时,遇到了Mercurial问题,但似乎无法解决.我有两个不同的项目:一个是框架,另一个是依赖于该框架的应用程序.这是存储库的样子:

My original question: I'm currently in the process of moving from Subversion to Mercurial, and I have to say I don't regret that decision. However, when trying to convert my project, I ran into a problem of Mercurial, which I can't seem to get fixed. I have two distinct projects: one is a framework, and the other is an application that relies on that framework. Here's what the repositories look like:

框架存储库:

  • docs/
  • 部署/
  • lib/
  • 测试/

应用程序存储库:

  • 应用程序/
  • config/
  • lib/
  • 测试/
  • www/

我想要的是应用程序的lib目录包含框架的lib/目录的副本.我曾经使用svn:externals来做到这一点.现在,我知道Mercurial支持子存储库的概念,但这似乎不像正确"的解决方案,因为它实际上并没有像我想要的那样拉进lib/目录,因为您仍然必须手动拉动和推动更改.这样,再克隆框架存储库,您将获得全部 ,而不仅仅是lib/目录.我只需要lib/目录,而不需要测试或文档.

What I'd like is for the application's lib directory to contain a copy of the frameworks' lib/ directory. I used to do this using svn:externals. Now, I am aware that Mercurial supports the concept of subrepositories, but that doesn't seem like the "correct" solution, as it doesn't actually pull in the lib/ directory like I wanted, as you'll still have to pull and push changes manually. That, plus once you clone the framework repository, you'll get all of it, not just the lib/ directory. I only need the lib/ directory, not the tests, or the docs.

现在,我想出了两种解决此问题的方法,但是我想知道哪种方法最好.第一种解决方案是将框架完全克隆到另一个目录中,并在应用程序的lib/目录中创建符号链接,该链接指向框架的lib/目录.我认为将符号链接放在.hgignore中应该确保一切正常.这意味着您可以编辑框架代码并提交,也可以编辑应用程序的代码并提交.

Now, I thought up two different solutions to this problem, but I wonder which is the best. The first solution would be to clone the framework in a different directory altogether and create symlink in the application's lib/ directory which points to the framework's lib/ directory. Putting the symlink in .hgignore should make sure all is well, I think? That means that you could edit the frameworks code, and commit that, and you could edit the application's code and commit that, too.

另一个选择是拥有多个存储库.该框架作为一个整体被拉出,这意味着您将获得docs/,deploy/,test/等目录,这对于使用 框架是不需要的.我以为纯粹为库创建一个存储库可能是一个解决方案,尽管我对此深表怀疑,因为单元测试非常依赖于库本身.

The other option is to have multiple repositories. The framework gets pulled as a whole, which means you'll get the docs/, deploy/, test/ etc. directories, which are not needed for usage of the framework. I thought maybe creating a repository purely for the library might be a solution, although I sincerely doubt it, as the Unit Tests are very dependant upon the library itself.

有人知道这个问题的解决方案吗?

Does anyone know a decent solution for this problem?

推荐答案

如果仅需要引用库,则应将库分离到单独的存储库中.

You should separate out the libraries into a separate repository if you need to refer to only that.

只要您实际上要做,就只需要引用它即可.引用包含lib目录和其他内容(不是感觉不正确")的存储库有什么问题?

Provided you actually do need to only refer to that. What is the problem with referring to the repository containing the lib directory + other stuff, other than "it doesn't feel right"?

至于仍然必须手动拉动",当您拉动主克隆时,它也会拉动子存储库,但不会将它们更新为较新的修订版,这是一件好事,需要手动执行此操作,就像使用Subversion一样.

As for "still have to pull and push manually", when you pull your main clone, it'll pull the subrepos as well, but it won't update them to a newer revision, which is a good thing, you need to do that manually, just as you should with Subversion.

这篇关于Mercurial仓库狭窄的克隆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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