简体   繁体   English

不同文件的Mercurial合并

[英]Mercurial merges of different files

We are using mercurial/tortoisehg with a central repository hosted on kiln. 我们正在将Mercurial / Tortoisehg与托管在窑炉上的中央存储库一起使用。

We have narrowed down what we are doing to the simplest possible scenario. 我们将工作范围缩小到了最简单的情况。 The scenario starts with Bob and Joe having cloned the kiln repository, so they both start with identical sets. 该场景从Bob和Joe克隆了窑库开始,因此他们都从相同的集合开始。

  1. Bob changes file a.txt, commits and pushes it to kiln. 鲍勃更改文件a.txt,提交并推送到窑炉。
  2. Joe changes file b.txt and commits. Joe更改文件b.txt并提交。
  3. Joe tries to push to kiln, but gets these errors: remote has heads on branch 'default' that are not known locally: 503dc02bd36c abort: push creates new remote head dba053a5be68! Joe尝试将其推入窑炉,但出现以下错误:远程在分支“默认”上具有在本地未知的磁头:503dc02bd36c中止:推创建了新的远程磁头dba053a5be68!
  4. This is obviously due to Bob's changes that need to be pulled from kiln first. 显然这是由于鲍勃的变化需要首先从窑炉中取出。 So, Joe pulls the changes from kiln and succeeds 因此,乔从窑炉中取出更改并成功
  5. Joe tries to push to kiln, but gets these errors: abort: push creates new remote head dba053a5be68! Joe尝试推入窑炉,但遇到以下错误:中止:推入会创建新的远程头dba053a5be68!
  6. Joe merges his commits with local and it succeeds 乔将自己的提交与本地合并,并且成功
  7. Joe now tries to push to kiln and succeeds 乔现在尝试推窑并成功

In this scenario, it seems like Mercurial should detect that both users updated different files and not force a merge, which is essentially Joe pulling Bob's changes and having to recommit and push the changes of both users. 在这种情况下,Mercurial似乎应该检测到两个用户都更新了不同的文件而不是强制合并,这实际上是Joe拉动Bob的更改,并且不得不重新提交和推送两个用户的更改。

Thanks everyone. 感谢大家。 To clarify my question: We are curious whether we have missed something or this is just how it works. 为了澄清我的问题:我们很好奇我们是否错过了某些东西,或者这仅仅是它的工作原理。 In this scenario, even though there is no conflict during merge, hg still forces me to have to pull, merge, recommit and re-push my colleague's changes that he has already committed and pushed to the central repository. 在这种情况下,即使在合并过程中没有冲突,hg仍会迫使我不得不拉,合并,重新提交和重新推送同事已经完成并推送到中央存储库的更改。

That's how Mercurial works. 这就是Mercurial的工作方式。

If Joe did not have changes, there would be no need for a merge or merge commit and he could just use hg update tip or hg pull . 如果Joe没有更改,则无需进行合并或合并提交,而只需使用hg update tiphg pull However, since Joe had changes when making the pull request, even though they were not in the same file, a merge is required. 但是,由于Joe在发出拉取请求时进行了更改,即使它们不在同一文件中,也需要进行合并。

This information can be found in Mercurial's guide: https://www.mercurial-scm.org/guide 该信息可以在《 Mercurial指南》中找到: https : //www.mercurial-scm.org/guide

If you didn't do any changes in the project, while you were working on feature1, you can just update to tip (hg update tip), but it is more likely that you'll have done some other changes in between changes. 如果您未在项目中进行任何更改,则在使用feature1时,您可以只更新至小费(hg更新小费),但您很有可能在更改之间进行了一些其他更改。 In that case, it's time for merging. 在这种情况下,是时候合并了。

Merge feature1 into the project code 将feature1合并到项目代码中

$ hg merge $ hg合并

If there are conflicts use hg resolve - that's also what merge tells you to do in case of conflicts. 如果有冲突,请使用hg resolve-这也是merge告诉您在发生冲突时要执行的操作。 After you merge, you have to commit explicitly to make your merge final 合并后,您必须明确地提交才能使合并最终完成

$ hg commit $ hg提交

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM