我使用Mercurial已经有一段时间了,有一个“事实”被给出了很多次。
事实上,我在看FogCreek昨天制作的视频时被它击中了,
this video: Fog Creek Kiln: Unlock the power of DVCS for your company
这里似乎有些东西对我不起作用。
在这段视频中大约1:39的时候,它强调了当其他版本控制系统跟踪修订(即快照)时,dvc像mercurial track changeset(即快照之间发生的情况)。
这给了他们在合并场景中的优势,然后它显示了一个示例。如果您在一个分支中移动一个函数,并在另一个分支中更改相同的函数,那么Mercurial可以合并该函数。
我在其他地方也看到过,尽管我现在找不到任何直接的联系。
这似乎对我不起作用。
编辑:这是TortoiseHg的默认“BeyondCompare3”合并工具配置的问题。我在mercurial.ini文件中添加了下面的配置,现在它可以正常工作了。当然,如果它不能自动合并的话,它会跳到GUI工具上,但是现在这个问题中描述的合并在没有任何提示的情况下运行,只是在开箱即用的情况下做正确的事情。
[ui]
merge = bc3
[merge-tools]
bc3.executable = C:\Program Files (x86)\Beyond Compare 3\bcomp.exe
bc3.args = $local $other $base $output /automerge /reviewconflicts /closescript
bc3.priority = 1
bc3.premerge = True
bc3.gui = True
为了测试这个,我将这个文件提交到一个存储库:
void Main()
{
Function1();
Function2();
}
public void Function1()
{
Debug.WriteLine("Function 1");
for (int index = 0; index < 10; index++)
Debug.WriteLine("f1: " + index);
}
public void Function2()
{
Debug.WriteLine("Function 1");
}
然后,在从这一个分支出来的两个不同的并行变更集中,我做了以下两个更改:
-
我把函数1移到了文件的底部
-
我更改了功能1中的消息
然后我尝试合并,Mercurial给了我一个合并冲突窗口,试图弄清楚我做了什么。
基本上,它尝试更改函数2中的文本,该文本现在处于函数1移动前的位置。
这是不应该发生的!
以下是复制示例的源文件:
用于生成存储库的批处理文件:
@echo off
setlocal
if exist repo rd /s /q repo
hg init repo
cd repo
copy ..\example1.linq example.linq
hg commit -m "initial commit" --addremove --user "Bob" --date "2010-01-01 18:00:00"
copy ..\example2.linq example.linq
hg commit -m "moved function" --user "Bob" --date "2010-01-01 19:00:00"
hg update 0
copy ..\example3.linq example.linq
hg commit -m "moved function" --user "Alice" --date "2010-01-01 20:00:00"
文件的3个版本:example1.linq、example2.linq和example3.linq:
实例1.LIQ:
<Query Kind="Program" />
void Main()
{
Function1();
Function2();
}
public void Function1()
{
Debug.WriteLine("Function 1");
for (int index = 0; index < 10; index++)
Debug.WriteLine("f1: " + index);
}
public void Function2()
{
Debug.WriteLine("Function 1");
}
实例2.LIQ:
<Query Kind="Program" />
void Main()
{
Function1();
Function2();
}
public void Function2()
{
Debug.WriteLine("Function 1");
}
public void Function1()
{
Debug.WriteLine("Function 1");
for (int index = 0; index < 10; index++)
Debug.WriteLine("f1: " + index);
}
LIQ:
<Query Kind="Program" />
void Main()
{
Function1();
Function2();
}
public void Function1()
{
Debug.WriteLine("Function 1b");
for (int index = 0; index < 10; index++)
Debug.WriteLine("f1: " + index);
}
public void Function2()
{
Debug.WriteLine("Function 1");
}