使用 svn 生成 diff 时如何忽略编码约定/风格?
使用 svn 生成 diff 时如何忽略编码约定?
详细来说,我不想区分以下两种编码风格
while (variableIter.hasNext())
{
lModel = variableIter.next();
}
,并且
while (variableIter.hasNext()) {
lModel = variableIter
.next();
}
如果我运行 svn diff,我将得到以下 diff:
- while (variableIter.hasNext())
- {
- lModel = variableIter.next();
+ while (variableIter.hasNext()) {
+ lModel = variableIter
+ .next();
但我不希望它成为 diff 的一部分。我希望 svn 忽略这种编码风格的差异。那么,svn 中有什么选项可以帮助我做到这一点吗? 或者 是否有一个脚本或其他东西我可以在 svn 生成的 diff 上运行以仅吐出真实更改而不是编码风格更改?
TIA
How can we ignore coding convention while generating diff using svn?
To elaborate, I do not want to distinguish between the following two coding styles
while (variableIter.hasNext())
{
lModel = variableIter.next();
}
AND
while (variableIter.hasNext()) {
lModel = variableIter
.next();
}
If I run a svn diff, I'll get the following diff:
- while (variableIter.hasNext())
- {
- lModel = variableIter.next();
+ while (variableIter.hasNext()) {
+ lModel = variableIter
+ .next();
But I do not want this to be part of the diff. I'd like svn to ignore this kind of coding style differences. So, is there any option in svn which can help me do this?
OR
is there a script or something I could run on the svn generated diff to spit out only real changes and not the coding style changes?
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道 svn 是否有内置函数可以做到这一点。不管怎样,你可以在提交之前使用一些工具来统一缩进你的代码,比如 C 语言的缩进工具 (http://www.gnu.org/software/indent/)。
或者您可以尝试使用此选项启动 diff:
svn diff -x -w
I don't know if svn has a builtin function to do that. Anyway you could use some tool to uniformily indent your code before submitting, like the indent tool for C (http://www.gnu.org/software/indent/).
Or you can try to launch the diff with this option:
svn diff -x -w
我无法帮助解决由颠覆直接产生的差异。
但是,一旦您意识到所看到的差异与格式相关,那么您可能会转向替代方案
比较工具。请参阅我们的智能差异器工具。这些工具是特定于语言的。他们的工作方式是解析语言并构建抽象语法树,然后比较这些树。这使得它们对空白(和注释)完全不敏感;重新格式化代码不会显示出差异。差异以语言元素(操作数、表达式、语句、声明、块、方法、类...)和编辑操作(移动、删除、插入、复制、重命名变量在块内)的形式报告,并且精确到开头行/列和结束行/列
我们目前拥有适用于多种语言的 SmartDifferencers,包括 C、C++、C#、Java、JavaScript、PHP。
I can't help with the diff produced directly by subversion.
But once you realize the differences you are seeing are formatting related, then you might swith to an alternative
diff'ing tools. See our Smart Differencer tools. These tools are language-specific. They work by parsing the language and build abstract syntax trees, and then comparing the trees. That makes them completely whitespace (and comment) insenstitive; reformatting the code doesn't show up as a difference. The diffs are reported as language elements (operand, expression, statement, declaration, block, method, class, ...) and editing actions (move, delete, insert, copy, rename-variable-within block and are precise to the start line/column and end line/column.
We presently have SmartDifferencers for many languages, including C, C++, C#, Java, JavaScript, PHP.