diff从文件输出所有行

diff从文件输出所有行

本文介绍了SVN diff从文件输出所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了一段时间,但仍然找不到解决此问题的简单方法.我想在文件的两个版本之间产生差异,但我希望输出显示文件的所有行.

I've been searching for a while and still can't find a simple solution to this problem I have. I want to produce a diff between two revisions of a file but I want the output to show all lines of my file.

顺便说一句,我在使用svn 1.6.17的AIX 5.3.

By the way, I'm on an AIX 5.3 using svn 1.6.17.

示例:比较文件"test_file"的21和22版本之间的区别

Example: Comparing difference between revision 21 and 22 of my file "test_file"

% svn cat -r21 test_file
My Test File

line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9

% svn cat -r22 test_file
My Test File

line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9

added after 1
added after 2
added after 3

% svn diff -r21:22 test_file
Index: test_file
===================================================================
--- test_file   (revision 21)
+++ test_file   (revision 22)
@@ -9,3 +9,7 @@
 line 7
 line 8
 line 9
+
+added after 1
+added after 2
+added after 3

现在此输出显示了两个修订版之间的差异,但并非所有文件行都在那里,仅显示了前三个.

Now this output shows the differences in the two revisions, but not all the file's lines are there, it only shows the previous 3.

所以我真正的问题是如何在输出中获得这些行?

So really my question is how do I get these lines in the output??

是否存在某种svn diff配置设置?我知道我可以为svn使用外部diff工具,但是哪一个可以给我我想要的输出?我想避免在公司网络中安装任何差异工具.

Is there some sort of svn diff config settings? I understand I can use external diff tools for svn, but which one gives me the output I would like? I want to try and avoid installing any diff tools as I'm on a corporate network.

其他要点:到目前为止,"sdiff"及其生成的2列似乎是我能得到的最接近的答案,但理想情况下,我希望一个带有"+"和-"的单列文件显示添加/删除的行

Additional point: So far 'sdiff' with its 2 columns generated seems to be the closest I can get to my answer, but I would ideally want a single columned file with '+' and '-' showing added/deleted lines

在此先感谢您的帮助! =)

Thanks in advance for any help! =)

推荐答案

以下内容可能与您想要的内容很接近:

Perhaps the following is close to what you want:

首先,创建一个差异脚本,该脚本将适当地使用从svn接收到的args:

First, create a diff script that will use the args received from svn appropriately:

#!/bin/sh
# file : /usr/local/bin/mydiff

# assumes less that 10,000 lines per file
/usr/bin/diff -U10000 $6 $7

然后与svn进行比较:

And then diff with svn:

svn diff --diff-cmd /usr/local/bin/mydiff

如果要更紧密地自定义diff输出,则只需修改mydiff脚本.

If you want to more closely customize the diff output you need only modify your mydiff script.

这篇关于SVN diff从文件输出所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 15:47