在中央服务器上保持子存储库同步
我一直认为我了解子存储库以及如何使它们适合我的团队工作流程,但显然我不了解,因为每次我尝试实现一些基本工作流程时,有些东西最终都无法正常工作。
我已经阅读了几乎所有有关在线子存储库的内容,并且我遵循了人们发布的所有琐碎示例,但是当我尝试做一些更复杂的事情时。或者也许我确实完全理解它,而我想做的事情只是效果不佳。
让我们先了解一下基础知识。可以说我有一个远程“祝福”的存储库集合。
http://acme.com/BlessedRepos/ProjA
/LibA
/LibB
因此,我将 /ProjA
克隆到 C:\ProjA
并将 /LibA
克隆到 C:\ProjA\LibA
code> 和 /LibB
到 C:\ProjA\LibB
。我创建我的 .hgsub
文件并
LibA = http://acme.com/BlessedRepos/LibA
LibB = http://acme.com/BlessedRepos/LibB
提交所有内容。然后我可以推送 ProjA
,一切都很好。
因此,现在我团队中的某人可以将 /PrjoA
克隆到 C:\dev\ProjA
,它将关闭 LibA
和 LibB
也作为子存储库。这个人可以像我一样轻松地从“blessed repo”中推/拉。到目前为止一切都很好。
现在,我说:好的,ProjA 团队,停止推送受祝福的存储库,这是我在审查您的工作后要做的事情。从现在开始,我希望大家将更改推送到位于以下位置的 ProjA dev 和 ProjA QA 远程存储库:
http://acme.com/Dev/ProjA
http://acme.com/QA/ProjA
这是我们停止的地方。尝试推送到 http://acme.com/Dev/ProjA
只会推送 /ProjA
,而 /ProjA/LibA
和 /ProjA/LibB
被推回其在受祝福的存储库中的原始位置,而不是 http://acme.com/Dev/ProjA
的所需位置。
现在,我可以将 .hgsub
文件设置为 LibA = ../LibA
。这最初是可行的,但如果我要从受祝福的存储库克隆 ProjA
,它无法获取 LibA
或 LibB
,我之所以相信,是因为它期望找到本地存储库 LibA
和 LibB
作为我正在克隆的 ProjA
存储库的兄弟。我的意思是,如果我将 http://acme.com/BlessedRepos/ProjA
克隆到 C:\Test\ProjA
,它将失败,因为它希望找到位于 C:\Test\LibA
的现有存储库。
我还可以将 hgsub 设置为 LibA = LibA 。但是,当您尝试推送到受祝福的存储库时,此操作会失败,因为 LibA
不是受祝福空间中 ProjA
的嵌套。我可以创建它们,但我永远不会退回到 http://acme.com/BlessedRepos/LibA
,而只会退回到 http://acme.com/BlessedRepos/ProjA/ LibA
,然后似乎就已经违背了子存储库的目的。
我很确定我的第一个方法可以工作,如果我还有一些我要运行的脚本,它会遍历并将 .hgsub
文件中的所有值从“有福的”远程位置更改为“dev”和“QA”位置,但这似乎不太理想。
所以。如果有人真正理解这些东西,你能否向我解释一下我哪里出了问题,或者我如何使用子存储库实现我的原始工作流程,或者只是确认我正在追求一些不属于的东西非常适合子存储库。如果有助于了解情况,我们可能有 15-20 个“产品/解决方案”和 50 个“共享”项目。 15-20 个产品中的任何一个都可以使用其解决方案中 50 个共享项目中的 N 个。
I keep thinking I understand subrepos and how I can make them work for my teams workflow, but clearly I don't, because every time I try to implement some basic workflow, something doesn't end up working right.
I've read pretty much everything there is to read about subrepos online, and I follow all of the trivial examples people post, but when I try to do something more complicated. Or maybe I do understand it perfectly well, and what I'm trying to do is just not something that works well.
Lets get the basics out of the way. Lets say I have a remote "blessed" collection of repos.
http://acme.com/BlessedRepos/ProjA
/LibA
/LibB
So I do a clone of /ProjA
to C:\ProjA
and clone /LibA
to C:\ProjA\LibA
and /LibB
to C:\ProjA\LibB
. I create my .hgsub
file with
LibA = http://acme.com/BlessedRepos/LibA
LibB = http://acme.com/BlessedRepos/LibB
I commit everything. I can then push ProjA
and all is well.
So now someone on my team can go clone /PrjoA
to C:\dev\ProjA
and it will bring down LibA
and LibB
too as subrepos. This person can easily push/pull from the "blessed repo" just like I can. So good so far.
Now, I say: Ok, ProjA Team, stop pushing to the blessed repo, that's for me to do after reviewing your work. Starting now, I want you all to push your changes to the ProjA dev and ProjA QA remote repos located at:
http://acme.com/Dev/ProjA
http://acme.com/QA/ProjA
This is where we stop. Trying to push to http://acme.com/Dev/ProjA
will only push /ProjA
, while /ProjA/LibA
and /ProjA/LibB
get pushed back to their original location in the blessed repo and not the desired location of http://acme.com/Dev/ProjA
.
Now, I could have setup my .hgsub
file as LibA = ../LibA
. This would work initially, but if I were to do a clone of ProjA
from the blessed repo, it fails to get LibA
or LibB
, I believe because it's expecting to find local repos LibA
and LibB
as siblings to the ProjA
repo I'm cloning. What I mean is if I'm cloning to http://acme.com/BlessedRepos/ProjA
to C:\Test\ProjA
it will fail because it expect to find an existing repo at C:\Test\LibA
.
I could also have setup my hgsub as LibA = LibA
. But doing this fails when you try to push to the blessed repo as LibA
is not a nested of ProjA
in the blessed space. I could create them, but then I'm never pushing back to http://acme.com/BlessedRepos/LibA
, only to http://acme.com/BlessedRepos/ProjA/LibA
, and then it seems that has defeated the purpose of the subrepo to begin with.
I'm pretty sure my first method could work if I also had some script that I would run that would go through and change out all the values in the .hgsub
file from "blessed" remote locations to the "dev" and "QA" locations, but this seems less than ideal.
So. If there is anyone out there that really groks this stuff, could you either explain to me where I've gone wrong, or how I could achieve my original workflow using subrepos, or maybe just confirm that I am going after something that isn't really suited for subrepos. If it helps to understand the situation, we have probably something like 15-20 "products/solutions" and 50 "shared" projects. Any of the 15-20 products can make use of N number of the 50 shared projects in it's solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少的关键部分是您可以在服务器上多次公开 LibA 和 LibB 存储库,而无需在服务器上拥有多个副本。请请参阅我对有关子存储库的另一个问题的回答以了解详细信息。
另外,如果您遇到此类问题,请通过 #mercurial 与我们联系 - 就是这样这比在 StackOverflow 上写长篇文章要好得多,因为这不是 Mercurial 社区所在的地方。您还可以使用我们的邮件列表。
The key part you are missing is that you can expose the
LibA
andLibB
repositories multiple times on the server without having multiple copies on the server. Please see my answer to another question about subrepos for the details.Also, just come talk to us at #mercurial if you have problems like that -- that's much better than writing long posts on StackOverflow since that's not where the Mercurial community is anyway. You can also use the mailinglists we have.