Mercurial:更好的命令行差异?
我想知道如何改进 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您看到这些更改是因为空格更改很重要。如果你执行
hg diff --ignore-space-change
,你会看到更像:这听起来像你想要的。您还可以使用 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: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.
我对类似的东西很感兴趣,但我最终使用 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:
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.