Mercurial 子存​​储库和相对路径

发布于 2024-10-19 05:23:20 字数 780 浏览 2 评论 0原文

我有一个项目,我有一个 bitbucket 存储库,它依赖于我合并为子存储库的另一个项目。现在,我没有对子存储库的推送访问权限,我也不想或不需要——这是一种仅拉的关系。

我意识到,当您推送主存储库时,它也会尝试推送子存储库。由于我无法做到这一点,因此我提取了依赖项目的本地副本,与主存储库目录处于同一级别。本质上,我有以下布局:

Main/           ; pushes to https://mine.org/Main
  .hg/
  .hgsub
  Lib/
    SubRepo/    ; clone of Main/../SubRepo/
      .hg/

SubRepo/        ; local copy of https://forbidden.org/SubRepo
  .hg/

.hgsub 的内容类似于,

Lib/SubRepo = ../SubRepo

然后我克隆,

~/path/to/Main $ hg clone ../SubRepo/ Lib/SubRepo

到目前为止,一切都很好。问题是,在我设置完这一切并提交更改后,当我尝试推送 Main Mercurial 时,它会尝试将 SubRepo 推送到 https ://mine.org/SubRepo,它不存在,从而导致整个推送操作失败。

我有什么遗漏的吗?

I have a project, which I have a bitbucket repository for, and it is dependent on another project that I incorporate as a subrepo. Now, I don't have push access to the subrepository, nor do I want or need to--it's a pull-only relationship.

I realize that when you push the main repository, it will try to push the subrepositories, as well. Since I cannot do that, I pulled a local copy of the dependent project, at the same level as the main repository's directory. In essence, I have the following layout:

Main/           ; pushes to https://mine.org/Main
  .hg/
  .hgsub
  Lib/
    SubRepo/    ; clone of Main/../SubRepo/
      .hg/

SubRepo/        ; local copy of https://forbidden.org/SubRepo
  .hg/

The content of .hgsub is something like,

Lib/SubRepo = ../SubRepo

Then I cloned,

~/path/to/Main $ hg clone ../SubRepo/ Lib/SubRepo

So far, so good. The problem is, after I set this all up and committed the changes, when I try to push Main Mercurial will try to push SubRepo to https://mine.org/SubRepo, which does not exist, thereby failing the whole push operation.

Is there something I'm missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帝王念 2024-10-26 05:23:20

如果您不想做广告,为什么不直接创建一个 https://mine.org/SubRepo您始终可以在其 .hg/hgrc 文件的 [web] 部分为其打开隐藏。这是我习惯的模式,您可以在每个要使用它们的地方以相同的布局克隆主存储库和所有子存储库:您的开发盒和面向网络的 hgweb 安装。

或者,您可以使用 Main/.hg/hgrc 中的 [subpaths] 部分,其中包含类似以下内容:

[subpaths]
https://mine.org/SubRepo = https://forbidden.org/SubRepo

这应该让您拦截推送的派生目标并将它指向一个不允许你推送的地方,会让你看到没有任何变化,这样推送就可以继续。

Why not just create a https://mine.org/SubRepo -- if you don't want to advertise it you can always turn on hide for it in the [web] section in its .hg/hgrc file. This is the pattern I'm used to, where you clone down the main repo and all the subrepos in the same layout at each place you'll use them: both your development box and your web-facing hgweb install.

Alternately, you could use a [subpaths] section in Main/.hg/hgrc with something like this in it:

[subpaths]
https://mine.org/SubRepo = https://forbidden.org/SubRepo

which should let you intercept the derrived target for the push and point it at a place that which it won't let you push, will let you see nothing has changed so push can continue.

懷念過去 2024-10-26 05:23:20

Mercurial 所做的事情似乎是合法的:使用 .hgsub 中列出的路径,它试图推送到一个名为“SubRepo”的目录,该目录位于 Main 的上一级目录。这显然不是您想要的,因此您可能需要在这里施展一些魔法。我可以想到两个选项:

  1. 如果您可以支持这一点,请将forbidden.org存储库的本地副本放在C:/Forbidden/Subrepo或类似的位置,并在中使用这个绝对路径你的.hgsub。 Mercurial 能够推动这一点并且它应该可以工作。

  2. 如果您不对这个存储库进行任何修改,那么将实际的forbidden.org url 作为您的子存储库地址是没有问题的。如果子存储库没有更改,您的推送应该会成功。当然,这是一个相当手动的选项,在较大的团队中不可能强制执行。如果您不小心对子存储库进行了一些修改,则必须仔细检查并使用 histeditMQueues 将其拉出,这对于子存储库来说可能很棘手。

It seems like what Mercurial is doing is legitimate: using the paths listed in your .hgsub it's attempting to push to a directory called 'SubRepo' that exists one level up from Main. This is obviously not what you want, so you'll probably have to work some magic here. I can think of two options:

  1. If you can support this, place the local copy of forbidden.org's repository at C:/Forbidden/Subrepo or something like that, and use this absolute path in your .hgsub. Mercurial will be able to push to this and it should work.

  2. There's no problem including the actual forbidden.org url as your subrepo address if you don't make any modifications to this repo. If there are no changes to the subrepo, your push should succeed. Of course, this is a fairly manual option and on a larger team it would be impossible to enforce. If you did accidentally commit some modification to the subrepo, you'd have to go through and use histedit or MQueues to pull it out, and that can be tricky with subrepos.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文