Mercurial:更好的命令行差异?

发布于 2024-10-25 09:15:02 字数 437 浏览 3 评论 0原文

我想知道如何改进 diff 命令作为 hg 的一部分。例如,假设我有以下代码:

line 1 
line 2
lin3 3

我将其更改为:

if($condition) {
   line 1
   line 2
   line 3
}

hg diff 将显示带有“-”的原始三行和带有“+”的新五行。即使我使用 -wbB 运行来忽略空格和行更改。我明白它想告诉我什么,但有没有办法让它“更聪明”并意识到我只添加了两行(并增加了三行的级别)?

编辑: 是否可以让 hg diff 告诉您添加了什么文本以及在哪里添加?与代码的“结构”如何因这些添加而改变相反?

编辑2: 我正在运行 Debian (Linux dev 2.6.26) 和 Mercurial 1.0.1

谢谢

I am wondering how to improve the diff command as part of hg. For example, lets say I have this code:

line 1 
line 2
lin3 3

and I change it to become:

if($condition) {
   line 1
   line 2
   line 3
}

hg diff will show the original three lines with a "-" and the new five lines with a "+". Even when I run with -wbB to ignore whitespace and line changes. I understand what it is trying to tell me, but isn't there way it could be "smarter" and realize that I've only added two lines (and increased level of three lines)?

EDIT:
Is it possible to have hg diff tell you what text was added and where? As opposed to how the "structure" of the code changed because of those additions?

EDIT 2:
I am running Debian (Linux dev 2.6.26) with Mercurial 1.0.1

Thanks

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

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

发布评论

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

评论(2

誰認得朕 2024-11-01 09:15:02

您看到这些更改是因为空格更改很重要。如果你执行hg diff --ignore-space-change,你会看到更像:

+ if($condition) {
   line 1
   line 2
   line 3
+ }

这听起来像你想要的。您还可以使用 ExtDiff 扩展 调用 @sarnold 建议的任何备用 diff 程序。

另外,请考虑更新 Mercurial。您的版本大约有三年历史,当前的软件包是为 Debian 构建的。

You're seeing those changes because whitespace changes count. If you do hg diff --ignore-space-change you'll see something more like:

+ if($condition) {
   line 1
   line 2
   line 3
+ }

which sound like what you want. You can also use the ExtDiff Extension to call any of the alternate diff programs @sarnold suggests.

Also, consider updating Mercurial. Your version is about three years old and current packages are built for Debian.

素染倾城色 2024-11-01 09:15:02

我对类似的东西很感兴趣,但我最终使用 DiffMerge (仅限 Windows,但你可以在 Debian 上尝试 Kdiff3)作为视觉差异来审查这样的更改:

在此处输入图像描述

可悲的是,即使您以您喜欢的形式生成补丁(使用其他工具),在存储库历史记录中,它也会以标准的 Mercurial 格式显示。

I was interested in something similar, but I ended up using DiffMerge (Windows only, but you can try Kdiff3 on Debian) as visual diff for reviewing changes like that:

enter image description here

Sadly, even if you generate the patch in the form you like (using other tools), in the repository history it will be shown in the standard mercurial format.

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