当您的远程回购商品已经更新时,如何推送本地更改?

时间:2019-07-05 14:50:07

标签: mercurial

在进行一些水银手术时,我遇到了一个问题。

我们执行以下步骤

1) Checkout from the remote repos.
2) we do some build related actions
3) increment the version in version file
4) tag(this includes pull --->update also).This operation takes 10-15 mins because of big/multiple repos.
5) Step 4 takes time and in between someone check-in and when we do push it fails with below error

stdout/stderr: remote has heads on branch 'default' that are not known locally: 5fhfhfhfhfh
stdout/stderr: abort: push creates new remote head fhdhfhdlgjdf!

我们是否可以创建任何解决方案/ bash脚本来告诉我们远程仓库未同步,所以我们需要在推送之前进行拉/更新。我认为下面的命令可以告诉我们有关

hg summary --remote

branch: default
commit: (clean)
update: (current)
remote: (synced)

我也试图在本地创建相同的问题

C:\test\testinoutchanges-clone>hg tag abcedfegh "Build 1.0.0"  **{During this operation someone push the changes}**

C:\test\testinoutchanges-clone>hg push
pushing to https://pro.test.com/next/testinoutchanges
searching for changes
remote has heads on branch 'default' that are not known locally: 5024baaff5d5
abort: push creates new remote head faed8e868739!
(pull and merge or see 'hg help push' for details about pushing new heads)

C:\test\testinoutchanges-clone>hg summary --remote
parent: 2:faed8e868739 tip
 Added tag 175247499ae3, Build 1.0.0 for changeset 175247499ae3
branch: default
commit: (clean)
update: (current)
phases: 1 draft
remote: 1 or more incoming, 1 outgoing


C:\test\testinoutchanges-clone>

现在,如果我运行hg pull -u,那么它将给我一些其他问题

C:\test\testinoutchanges-clone>hg pull -u
pulling from https://pro.test.com/next/testinoutchanges
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to "faed8e868739: Added tag 175247499ae3, Build 1.0.0 for changeset 175247499ae3"
1 other heads for branch "default"

C:\test\testinoutchanges-clone>hg push
pushing to https://pro.test.com/next/testinoutchanges
searching for changes
abort: push creates new remote head faed8e868739!
(merge or see 'hg help push' for details about pushing new heads)

我还试图先拉然后合并。 之后,我使用commit,然后可以推送更改。

我也在考虑是否有任何冲突发生,我们将如何在自动过程中解决这些冲突

1 个答案:

答案 0 :(得分:0)

如果某些尚未同步更改,则可以使用本地存储库中的preoutgoing钩子(检查其中的hg incoming的结果)来阻止推送到远程存储库。 (或仅禁用盲目“提交后推动”)。但要注意hg in的退出代码:

  

如果有传入更改,则返回0,否则返回1

所有控制钩子必须返回0才能允许操作,并且非零阻止