新手 - Mercurial 合并问题
在文件 X.java 中进行了更改 - 通过 hg repo explorer,我看到了我的更改。
将 X.java 中的更改提交到本地存储库
我从中央存储库中提取了更改,其中还包括其他开发人员在 X.java 中进行的非冲突更改 - 我看到其他开发人员在 X.java 中所做的更改。
我在本地合并了两个版本,
合并后我看到的是其他开发人员所做的更改仅针对此文件丢失(!),并且合并后文件与我在合并之前提交的文件相同。所有其他仅被其他人更改的文件都完好无损。
我不确定为什么合并会覆盖其他开发人员的更改,我发现这两个开发人员更改、合并和提交的所有文件都发生了这种情况。
我正在使用 tortoise hg 来完成所有反复无常的任务。
谁能帮助我了解发生了什么事?
另外,我是否可以搜索因先前合并而被覆盖并已提交到中央存储库的此类文件,以便我可以修复它们?
非常感谢,
**从评论中添加更新**
我认为由于此文件中所做的更改不冲突,我认为 Mercurial 没有启动任何工具或 Kdiff 或要求我手动选择。我认为它自动合并了。如果我不是 100% 确定,mercurial 可能已将文件标记为“U”(未解决),在检查非冲突更改后,我可能会选择“将冲突标记为已解决”选项。我记得我对几个文件这样做了,不确定在这种情况下我是否这样做了。所以只有两种可能性: 1. Mercurial 可能在没有我干预的情况下自动合并 2. 我可能选择了“标记为已解决”选项。 – 永远学习
Made Changes in file X.java – through hg repo explorer, I see my changes.
Committed changes in X.java to local repository
I pulled changes from central repo which also included non-conflicting changes by other developer in X.java – I see chages made in X.java by other developer.
I merged two versions locally,
After merge what I am seeing is that changes made by other developer are lost (!) only for this file, and post-merge file is same as what I had committed before merge. All other files which were only changed by others are intact.
I am not sure why merge overwrote other developer’s changes, I found out that this has happened to all files which both developers have changed, merged and committed.
I am using tortoise hg for all mercurial tasks.
Can anyone help me understand what’s going on?
Also, is there anyway I can search such files which are overwritten as a result of previous merges and already committed to central repo so that I can fix them?
Thanks a lot,
**Update Added From A Comment **
I think since changes made in this file were non-conflicting i don't think mercurial launched any tool or Kdiff or asked me to manually select. I think it automerged itself. If at all which I am not 100% sure, mercurial might have marked file as "U" (Unresolved) which after checking non-conflicting changes, I might have chosen "Mark conflict as resolved" option. I remember me doing that for couple of files not sure if I did that in this case. so only two possibilities are 1. Mercurial might have auto-merged without my intervention 2. I might have chosen "Mark as resolved" option. – alwaysLearning
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您要求合并时,Mercurial 会进行预合并,但这样做非常保守,并且肯定不会将代码留在地板上,因此它不会“自动合并”为你。
您的第二个操作“标记为已解决”将完美描述您所得到的结果。使用标记作为解析(从命令行使用
hg resolve --mark
)告诉 Mercurial:“磁盘上的工作副本是这两个文件的完美结合,并且应该是提升到合并变更集的内容”。如果您在实际合并这些文件之前执行此操作,则结果文件中除了合并的左父文件之外什么都没有,这听起来又像您所拥有的那样。幸运的是,您始终可以重新进行合并:
不幸的是,如果人们已经根据您之前推出的不完整合并完成了进一步的工作,您也需要将该工作移过去。
一般来说,请记住,合并与打字一样是编码的一部分。这是一种有意识的人类行为,值得关注和代码审查。
Mercurial will do a pre-merge when you ask it to merge, but it is very conservative in doing so and certainly won't leave code on the floor, so it didn't "auto merge" this for you.
Your second action 'mark as resolved' would perfectly describe the results you have. Using mark as resolve (
hg resolve --mark
from the command line) tell's mercurial: "The working copy on disk is the perfect marriage of those two files, and should be what's promoted on to the merge changeset". If you do that before actually merging those files, you'll have nothing but the left parent of the merge in the resulting file, which again sounds like what you have.Fortunately you can always re-do a merge:
Unfortunately, if people have already done further work based on the incomplete merges you've previously pushed out you'll need to move that work over too.
In general remember that merging is just as much a part of coding as typing. It's a conscious human action and deserves care and code-review.