问题描述
我们有两个不同的团队,每个团队都在自己的位置上与Mercurial合作,每个位置都有一个参考资料库.每个位置都可以访问企业网络,但是两个网络不能直接连接(请问我,请问我):我们只能交换文件.我们希望能够定期同步这两个位置,以便可以通过各自的参考资料库共享工作.
We have two different teams, each in its own location, working with Mercurial, each location having a reference repository. Each location has a access to an enterprise network, but the two networks cannot be directly connected (trust me, we asked): we can only exchange files. We would like to be able to sync the two locations regularly so that the work can be shared through the respective reference repositories.
要求:
- 必须允许双向交流.
- 即使我们希望大部分时间都在单独的分支上工作,我们也需要能够从双方同时在某些分支上工作,或者至少从发生这种情况的情况中恢复过来.这意味着可能需要采取整合步骤来处理分散的工作.
- 大多数跟踪必须自动进行,以使手动干预和由此带来的操作错误的风险降到最低(不是致命的,但最好避免指责:信任受到限制).我们有许多分支机构,一个接一个地开始处理它们是不可能的.
- 只能通过远程推/拉操作以及在必要时进行轻度管理操作来操作参考存储库,这既是因为它们在IT控制之下,又因为我们希望它们始终保持一致,即先进行集成,然后进行集成另一方的更改以及集成在本地参考资料库中发布.
- 我们不能每次都发送整个存储库(甚至是压缩了tar的文件):它本身不但有点大,而且连续发送的所有软件包也都保存在记录中,因为这是合同承诺的一部分,并且有N份那里的存储库很快将变得不可持续.
- 所有必需的信息必须存储在本地中央位置(与参考存储库相同的约束),以便任何开发人员都可以执行同步步骤,而不必依赖于特定开发人员的本地存储区中存储的信息
非要求:
- 处理两个以上断开连接的站点.两个已经足够具有挑战性了.
- 夜间处理.交易所将被手动触发和处理.
- 有限数量的命令或复杂性.如果需要许多复杂的命令,我们可以随时将这种复杂性隐藏在脚本中.
- 跨脱机同步.就像流一样,这总是意味着麻烦.因此,我们可以假设离线同步操作是完全有序的,而不管它们的方向如何,必要时可以轮流使用.
- 分支机构管理详细信息等.这是我们的内部业务.
- 支持Mercurial书签.在放弃它们之前,我们只是对它们进行了简短的实验.
推荐答案
Mercurial的捆绑包使此操作变得容易;最好通过使存储库的副本处于远程存储库的最后已知状态(存储在$SITE_B_IMAGE_URL
中)来执行跟踪.假设我们的位置称为站点a,而远程位置称为站点b.
Mercurial makes that easy with its bundles; tracking is best performed by having a clone of the repository that is at the last known state of the remote repository, stored at $SITE_B_IMAGE_URL
. Let our location be called site-a and the remote location be called site-b.
-
生成分发包以发送到远程位置:
Generating a bundle to send to the remote location:
-
~/work$> hg clone $LOCAL_REF_URL bundler
-
~/work$> cd bundler
-
~/work/bundler$> hg bundle ../bundle-site-a-$(date +%Y-%m-%d) $SITE_B_IMAGE_URL
~/work$> hg clone $LOCAL_REF_URL bundler
~/work$> cd bundler
~/work/bundler$> hg bundle ../bundle-site-a-$(date +%Y-%m-%d) $SITE_B_IMAGE_URL
捆绑器工作存储库现在可能会被丢弃.
The bundler work repository may now be discarded.
当远程位置已确认能够取消捆绑发送给他们的捆绑包的内容时,更新远程跟踪存储库:
Updating the remote tracking repository, when the remote location has confirmed having been able to unbundle the contents of a bundle sent to them:
-
~/work$> hg clone $SITE_B_IMAGE_URL remote-tracking
-
~/work$> cd remote-tracking
-
~/work/remote-tracking$> hg push -R ../bundle-site-a
~/work$> hg clone $SITE_B_IMAGE_URL remote-tracking
~/work$> cd remote-tracking
~/work/remote-tracking$> hg push -R ../bundle-site-a
现在可以丢弃远程跟踪工作存储库.
The remote-tracking work repository may now be discarded.
从远程位置集成捆绑包:
Integrating a bundle from the remote location:
首先,按照步骤更新远程跟踪存储库,这次使用您收到的捆绑软件,而不是以前发送的捆绑软件.
First, follow the steps to update the remote tracking repository, this time taking the bundle you received, instead of the one you previously sent.
-
~/work$> hg clone $LOCAL_REF_URL bundle-integration
-
~/work$> cd bundle-integration
-
~/work/bundle-integration$> hg unbundle ../bundle-site-b
- 这时
hg heads
会告诉主管,包括给定分支的主管不止一个的情况,因此需要将工作减少到每个分支一个主管的情况,因此请在此处插入合并无关的分支头. - 如果
hg push
完全成功,请返回;否则,返回 - .我们完成了
-
~/work/bundle-integration$> hg pull
- 考虑到您忙于执行前面的步骤时在您的位置上完成的工作
- 转到5
~/work$> hg clone $LOCAL_REF_URL bundle-integration
~/work$> cd bundle-integration
~/work/bundle-integration$> hg unbundle ../bundle-site-b
- At this point
hg heads
will tell the heads, including the cases where there is more than one head for a given branch, and therefore where work in needed to reduce to one head per branch, so insert here the work necessary to merge the extraneous branch heads. - If
hg push
fully succeeds, return; we are done ~/work/bundle-integration$> hg pull
- Take into account work done on your location that happened while you were busy performing the previous steps
- goto 5
bundle集成工作存储库现在可能会被丢弃.
The bundle-integration work repository may now be discarded.
注意:尽管您可以将捆绑软件用作-R
的覆盖,但不会执行集成;只能先进行捆绑才能完成.
Notes: While you can use the bundle as an overlay with -R
, that won't perform the integration; that can only be done by unbundling first.
这篇关于离线同步本地中心的Mercurial存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!