向Mercurial添加一个Git子库 [英] Adding a Git subrepository to Mercurial

查看:108
本文介绍了向Mercurial添加一个Git子库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图使用在github上托管项目依赖关系的bitbucket来设置一个项目。使用Hg-Git Mercurial插件,我几乎可以到达那里。



但是当推动时,事情会变得麻烦。



Mercurial subrepositories 的文档指出:


2.4推送

Mercurial会自动尝试先推送所有当您推送时,当前存储库的子目录。这将确保subrepos中的新变更集在被顶级存储库引用时可用。


但是这导致了一个大问题,我想推动所有的子库(为什么我会?) - 我只能读取它们,所以github不会允许它。只有主存储库需要被推送到远程服务器,但我无法弄清楚如何去做。无论是否有变化, hg 都想要控制并推送所有子库。有什么方法绕过这个功能



唯一需要推送的是 .hgsub code>和 .hgsubstate 。一旦通过其他路径推送它们(更新到不存在子库的变更集),就可以更新并从远程存储库中提取更改,但是如果我在变更集因为Mercurial的推动方式,这是不可能的。

这是一个设计错误。



最好的解决方案是更新到以前版本,其中子存储库不存在,然后按。这将绕过Mercurial的限制并上传必要的 .hgsub .hgsubstate 文件。这有点不方便,但是我发现迄今为止最好的方法是让Mercurial和Git能够相互协作。



也许在将来Hg-Git将被更新以自动处理这个用例。


I've been trying to set up a project using bitbucket which has project dependencies hosted on github. Using the Hg-Git Mercurial plugin I am able to almost get there.

But when it comes time to push, things become troublesome.

The documentation for Mercurial subrepositories states:

2.4 Push

Mercurial will automatically attempt to first push all subrepos of the current repository when you push. This will ensure new changesets in subrepos are available when referenced by top-level repositories.

But this causes a big issue since I don't want to push all the subrepositories (why would I?) — I only have read access to them, so github won't allow it. Only the main repository needs to be pushed to the remote server, but I can't figure out how to do it. hg wants to take control and push all subrepositories, regardless of whether or not there are changes. Is there some way to bypass this feature?

The only things which need to be pushed are .hgsub and .hgsubstate. Once they've been pushed via alternative routes (updating to a changeset where the subrepositories don't exist), it's possible to then update and pull the changes from the remote repositories, but if I were to push again whilst on a changeset with the subrepositories, the whole ordeal repeats itself.

解决方案

This isn't possible due to Mercurial's method of pushing. This is a by design error.

The best solution is to update to a previous revision where the subrepositories don't exist, and then push. This will bypass Mercurial's restriction and upload the necessary .hgsub and .hgsubstate files. This is a little inconvenient, but is the best way I've found so far to get Mercurial and Git to work with each other.

Perhaps in the future Hg-Git will be updated to handle this use case automatically.

这篇关于向Mercurial添加一个Git子库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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