如何让 Mercurial 外部 diff 工具处理文件重命名?

发布于 2024-10-02 19:12:47 字数 314 浏览 1 评论 0原文

如果我提交文件重命名并使用 extdiff 查看 Beyond Compare 或 kdiff3 中的差异,它们会在每一侧显示两个不同的文件。

使用Beyond Compare,我可以手动从每一方选择任意文件进行比较,但是如果我有很多重命名(即更改java包名称以进行重构),这将是一个巨大的痛苦。

我明白为什么会这样:extdiff 只是为 diff 工具创建两个临时快照目录。

所以我的问题是:有什么方法可以将重命名传达给 diff 工具,以便它将旧文件名与新文件名进行比较?

这可能是每个差异工具特有的。因此,如果您知道支持它的工具,请告诉我。

If I commit a file rename and use extdiff to see the diff in Beyond Compare or kdiff3, they show two different files on each side.

With Beyond Compare I can manually pick arbitrary files from each side to compare, but it's a huge pain if I have many renames (i.e. changing a java package name for refactoring).

I understand why it's so: extdiff simply makes two temp snapshot directories for the diff tool.

So my question is: is there any way to convey the rename to the diff tool, such that it will compare the old file name with the new file name?

This is probably specific for each diff tool. So if you know a tool that supports it, please, please let me know.

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

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

发布评论

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

评论(2

从来不烧饼 2024-10-09 19:12:47

注意 这仅适用于与 TortoiseHg 的差异。

我使用 Beyond Compare 3 配置 Mercurial 安装的方式如下:(

注意,这些只是与 diff 和 merging 相关的选项,您在某些相同部分中仍然需要其他选项,因此只需添加或更改,不要清除旧的部分并替换为下面的部分)

[ui]
merge = bc3m

[extensions]
extdiff=

[extdiff]
cmd.bc3d = C:\Program Files (x86)\Beyond Compare 3\bcomp.exe
opts.bc3d = /lro

[merge-tools]
bc3m.executable = C:\Program Files (x86)\Beyond Compare 3\bcomp.exe
bc3m.args = $local $other $base $output /automerge /reviewconflicts /closescript /lro /rro /title1="Left parent" /title2="Right parent" /title3="Common base" /title4="Merged output"
bc3m.priority = 1
bc3m.premerge = True
bc3m.gui = True

[tortoisehg]
vdiff=bc3d

现在:

  • 如果可能的话自动合并,除非存在合并冲突,否则不显示合并 GUI 重
  • 命名文件的差异在左侧显示旧文件名,右侧的新目录(虽然临时目录名称很时髦)

重要说明:不要对合并工具和 diff 工具使用相同的名称(例如两者都使用 bc3)。它混淆了所涉及的工具,并且仅将其转移到 BC 的启动屏幕。这就是合并工具被命名为 bc3m 而 diff 工具被命名为 bc3d 的原因。

另请注意,我已经放弃使用内置的 Beyondcompare 工具,因为它们似乎配置不正确。特别是,使用内置工具时,自动合并部分没有发生,但现在工作得很好。此外,使用内置工具,通过重命名可视化差异会显示目录比较,或者只是将其转至 BC 的启动屏幕,这使您可以选择所需的比较类型。

所以最后我只是进行实验,直到找到正确的选项并自己设置一切。

Note This only works for diffs with TortoiseHg.

The way I've configured my Mercurial installation, with Beyond Compare 3, is as follows:

(note, these are only the options relevant to diff and merging, you still need other options in some of the same sections, so only add or change, don't clear out your old sections and replace with the ones below)

[ui]
merge = bc3m

[extensions]
extdiff=

[extdiff]
cmd.bc3d = C:\Program Files (x86)\Beyond Compare 3\bcomp.exe
opts.bc3d = /lro

[merge-tools]
bc3m.executable = C:\Program Files (x86)\Beyond Compare 3\bcomp.exe
bc3m.args = $local $other $base $output /automerge /reviewconflicts /closescript /lro /rro /title1="Left parent" /title2="Right parent" /title3="Common base" /title4="Merged output"
bc3m.priority = 1
bc3m.premerge = True
bc3m.gui = True

[tortoisehg]
vdiff=bc3d

This now:

  • Auto-merges if possible, not showing a merge-GUI unless there's a merge conflict
  • Diff for a renamed file shows the old filename on the left side and the new one on the right side (funky temporary directory names though)

Important note: Do not use the same name for the merge tool and the diff tool (like bc3 for both). It confuses the tools involved and diffs just punt to the startup screen of BC. That's why the merge tool is named bc3m and the diff tool is named bc3d.

Also note that I've dropped using the built-in beyondcompare tools, as they seem incorrectly configured. In particular, the auto-merge part did not happen when using the built-in tool, but now works nicely. Also, with the built-in tool, visualizing diffs with renames showed the directory comparison or just punted to the startup screen of BC which makes you pick the type of comparison you want.

So in the end I just experimented until I found the right options and set everything up myself.

过度放纵 2024-10-09 19:12:47

处理重命名需要深入研究典型 scm 所具有的历史。特别是像 Mercurial 这样的 dvc。这就是他们可以处理重命名的方式。

有趣的是,Git 不跟踪重命名,而是对内容进行操作,并且重命名并不重要。

Diff 工具可以处理检查更改,但它无法告诉其中的文件。通过先前的历史记录判断文件是否已重命名也会出错。任何外部差异工具通常都会检查内容,因此提供文件的任务将由用户承担。

然而,Mercurial 确实会跟踪重命名。请参阅此扩展,它可用于跟踪重命名的文件。您可以使用它为任何外部差异工具提供正确的文件名进行比较。

Handling renames requires a digging into history which a typical scm has. Specially dvcs like Mercurial. That is how, they can handle renames.

Some thing of interest could be the fact that Git doesn't track renames, operates on content and renames don't matter.

Diff tool can handle examining changes but it can tell nothing about the files within it. It will also be erroneous with a preceding history to tell if the file has been renamed or not. Any external diff tool usually examines contents and hence the task of supplying the files will remain with the user.

How ever, Mercurial does track renames. See this extentsion that can be used to track renamed files. You can use that to supply any external diff tool the right filenames to compare.

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