克隆存储库时如何管理依赖关系?
我正在使用 Mercurial,我想知道如何执行以下操作。 这是我的存储库架构:
./repo/utils/workers/[...]
./repo/utils/tools/[...]
./repo/proj1/file.py
假设在 proj1/file.py 中我需要导入位于工作人员和工具中的一些代码。例如,
from utils.workers import foo
from utils.tools import bar
检查 proj1 及其所有所需依赖项(例如,workers/ 和 tools/)的最佳方法/工具是什么,而无需在 proj1 内克隆 utils/workers 和 utils/tools。
另外 - 执行 sys.path.append(repo/utils/workers) 也不是一个选择。
== 编辑 2011 年 1 月 24 日 ==
感谢您的所有回答。 我一直在想一种方法来真正以不同的方式解释我的问题,看来我们应该对 hg 进行抽象以便更好地理解。 假设在 /utils/
中还有另外一些模块,它们不属于我的项目,但实际上是需要的。例如:http://code.google.com/p/python-gflags/ 当签出 /repo/proj1/
时,我希望所有依赖项(无论它们形成哪个存储库)也被签出 - 但从那时起都是只读的。
因此,如果我执行 hg clone /proj1/
我希望此操作也从 /utils/workers/
克隆所有需要的模块, /utils/tools/
, 和 python-gflags 下 /utils/python-gflags
我希望这有助于澄清我正在尝试做的事情。
干杯,
马丁
I am using mercurial and I am wondering how to do the following.
Here is my repository architecture :
./repo/utils/workers/[...]
./repo/utils/tools/[...]
./repo/proj1/file.py
Let's say that in proj1/file.py I need to import some code located in workers and tools. eg
from utils.workers import foo
from utils.tools import bar
What would be the best way/tool to check out proj1 with all the needed dependencies (eg, workers/ and tools/) without having to clone utils/workers and utils/tools inside of proj1.
Also - doing a sys.path.append(repo/utils/workers)
is not a option.
== Edit 01/24/11 ==
Thanks for all the answers.
I've been thinking of a way to really explain my problem differently, and it seams that we should make abstraction of hg for a better understanding.
Let's say that in /utils/
there also are another few modules in there, that do not belong to my project, but that are actually needed. For example: http://code.google.com/p/python-gflags/
When checking out /repo/proj1/
I want all the dependencies, not matter which repository they're form, to be checked out too - but with read-only since.
So if I do hg clone /proj1/
I want this action to also clone all the needed modules from /utils/workers/
,/utils/tools/
,
and python-gflags under/utils/python-gflags
I hope this helps a little bit to clarify what I am trying to do.
Cheers,
Martin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该查看子存储库(也称为嵌套)
You should look at subrepositories (which also called nested)
我发现对此的最佳解决方案是使用构建。
http://www.buildout.org
这是一个非常有用的管理依赖项的解决方案。
The best solution I've found to to this, is by using buildout.
http://www.buildout.org
It is a really helpful solution to manage dependencies.