运行“hg update”后->找不到合并 MyClass.class 的工具:保留 (l)ocal 还是采取 (o)ther?

发布于 2024-09-16 11:34:18 字数 421 浏览 4 评论 0原文

我通过执行以下操作返回查看较早的修订版:

hg update -r 10

然后,我想通过执行以下操作返回提示:

hg update

但我收到此消息,并且不知道如何回应它:

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?

I went back to take a look at an earlier revision by doing:

hg update -r 10

Then, I wanted to go back to the tip by doing:

hg update

But I got this message and am not sure how to respond to it:

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡看悲欢离合 2024-09-23 11:34:18

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

这些是二进制的,并且 Mercurial 认为您已经更改了它,几乎可以肯定是您的存储库中也有编译代码的结果。

如果这些文件被视为“来自外部源”(例如您下载的库或其他文件并希望与源代码一起保存),则将二进制文件保留在存储库中是可以的。

但是,在存储库中编译源代码的输出不应保留在存储库中,因为这会导致像现在这样的问题。

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

然后它会询问您是否要保留修改后的副本,或者更新到存储库中的新副本。这里的“本地”表示“旧存储库版本的修改版本”,“其他”表示“存储库中的新版本”。

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


发生这种情况的一个示例可能是您遇到以下情况(请注意,我不是 Java 开发人员,因此我可能会得到错误的 Java 确切详细信息):

修订版 1,您提交:

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

版本 2,您提交:

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

然后更新回修订版 1:

  • 恢复 TestClass。 java from revision 1
  • Restore TestClass.class from revision 1

然后编译:

  • 构建新的 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

输出:

[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!

The main problem here is that you have .class files in your repository.

These are binary, and seeing as Mercurial thinks that you've changed it, almost certainly the result of compiling code you also have in your repository.

Keeping binary files in the repository is fine if those files are considered "from external sources", like libraries or whatnot that you download and want to keep alongside the source code.

However, the output of compiling source code in the repository should not be kept in the repository, since this will lead to problems like you have now.

It is basically telling you that after you updated to an older version, that particular file has changed, so it is no longer identical to the file you had in your repository for that older version.

And then it asks you whether you want to keep the modified copy, or update to the new one you have in the repository. "Local" here means "modified version from the old repository version", and "other" means "new version in the repository."

I would answer O for other in this case, but I would also try to get rid of those .class files from the repository altogether.


An example of why this happens can be that you have the following scenario (note that I'm no Java developer so I might get the exact details for Java wrong):

Revision 1, you commit:

  • TestClass.java
  • TestClass.class (the result of compiling TestClass.java)

Revision 2, you commit:

  • TestClass.java (with some changes from revision 1)
  • TestClass.class (again, the result of compiling the new TestClass.java)

Then you update back to revision 1:

  • Restore TestClass.java from revision 1
  • Restore TestClass.class from revision 1

Then you compile:

  • Build new TestClass.class, same source code, but probably contains things like timestamps of compilation which makes the file binary different, but semantically similar

Then you try to update back up to revision 2:

  • Merge conflict for TestClass.class due to it being binary

Here's a batch file (for Windows) that will reproduce your case:

@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

Output:

[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!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文