运行"hg update"后 - >找不到合并MyClass.class的工具:Keep(l)ocal或take(o)ther?

cor*_*nus 2 mercurial

我回过头来看看早期的修订:

hg update -r 10
Run Code Online (Sandbox Code Playgroud)

然后,我想通过以下方式回到提示:

hg update
Run Code Online (Sandbox Code Playgroud)

但我得到了这个消息,我不知道如何回应它:

tool kdiff3 can't handle binary
tool tortoisemerge can't handle binary
tool winmergeu can't handle binary
tool docdiff can't handle binary
no tool found to merge target/classes/com/mypackage/MyClass.class
keep (l)ocal or take (o)ther?
Run Code Online (Sandbox Code Playgroud)

ang*_*son 6

这里的主要问题是.class您的存储库中有文件.

这些是二进制的,并且看到Mercurial认为你已经改变了它,几乎可以肯定是编译你的存储库中的代码的结果.

如果将这些文件视为"来自外部源",例如库或您下载并希望与源代码保持一致的文件,那么将二进制文件保存在存储库中就可以了.

但是,存储库中编译源代码的输出不应保存在存储库中,因为这会导致类似于您现在的问题.

它基本上告诉您,在更新到旧版本后,该特定文件已更改,因此它不再与旧版本的存储库中的文件相同.

然后它会询问您是要保留修改后的副本,还是更新到存储库中的新副本."Local"在这里表示"来自旧存储库版本的修改版本","other"表示"存储库中的新版本".

O在这种情况下我会回答其他问题,但我也会尝试完全从存储库中删除那些.class文件.


发生这种情况的一个例子可能是您有以下场景(请注意,我不是Java开发人员所以我可能会得到Java的确切详细信息):

修订版1,您提交:

  • TestClass.java
  • TestClass.class(编译TestClass.java的结果)

修订版2,您承诺:

  • TestClass.java(修订版1中有一些更改)
  • TestClass.class(再次,编译新的TestClass.java的结果)

然后你更新回修订版1:

  • 从版本1恢复TestClass.java
  • 从版本1恢复TestClass.class

然后你编译:

  • 构建新的TestClass.class,相同的源代码,但可能包含编译的时间戳,使文件二进制文件不同,但在语义上相似

然后,您尝试更新回到修订版2:

  • 由于它是二进制的,因此合并了TestClass.class的冲突

这是一个批处理文件(适用于Windows),它将重现您的案例:

@echo off
setlocal

rd /s /q test
md test
cd test

hg init .

rem ------------------------------------
rem Add .CS file and compile it
rem Producing main.exe
echo class Program { public static void Main() { } }>main.cs
csc /target:exe main.cs

hg addremove
hg commit -m "1"

rem ------------------------------------
rem Change and recompile and commit
echo class Program2 { public static void Main() { } }>main.cs
csc /target:exe main.cs

hg addremove
hg commit -m "2"

rem ------------------------------------
rem Update back to revision 1
hg update 0

rem ------------------------------------
rem Compile
csc /target:exe main.cs

rem ------------------------------------
rem Try to update up to revision 2
hg update 1
Run Code Online (Sandbox Code Playgroud)

输出:

[C:\Temp] :test
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.

adding main.cs
adding main.exe
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.

2 files updated, 0 files merged, 0 files removed, 0 files unresolved
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.

tool beyondcompare3 can't handle binary
tool bcomp can't handle binary
tool beyondcompare3 can't handle binary
tool kdiff3 can't handle binary
tool diffmerge can't handle binary
tool tortoisemerge can't handle binary
tool docdiff can't handle binary
 no tool found to merge main.exe
keep (l)ocal or take (o)ther? interrupted!