如何从SVN差异中删除SVN属性
时间:2020-02-23 14:38:57 来源:igfitidea点击:
我将SVN用于我的项目版本控制系统。
有时,我需要查看两个标签或者两个分支之间的区别,但是当我运行" svn diff"命令时,它会在输出中提供大量的SVN属性更改。
我一直在寻找删除这些内容的方法,但是内置的svn diff选项不提供此功能。
因此,我写了一个shell脚本来为我完成这项工作,其想法是首先将SVN Diff summary选项与grep和awk一起使用,以找出存在文本更改的文件名,然后遍历此列表以生成SVN diff并追加到文件以生成最终差异。
#!/bin/bash # Call this script to generate clean svn diff url1= url2= #If URLs don't end with /, add them if [ "${url1#${url1%?}}" != "/" ]; then url1=$url1"/" fi if [ "${url2#${url2%?}}" != "/" ]; then url2=$url2"/" fi echo $url1 echo $url2 #Get the length of url1, will be used later on length1=${#url1} # Below command will get all the files with text changes and store them in files variable files=$(svn diff $url1 $url2 --summarize | grep -v '^ ' | awk '{print substr({代码},9)}') #Generate diff for each of the files and save it in a new file for f in $files do f2=${url2}${f:${length1}} $(svn diff $f $f2 >> svn_diff_clean.txt) echo "processed $f and $f2" done echo "done"
当我通过传递两个URL执行上述脚本时,它将生成具有全文差异的svn_diff_clean.txt。
我使用此脚本在项目中生成差异,并且输出的行数减少了近50%。
但是,这取决于项目结构和元数据使用情况。
提示:如果每次运行SVN命令时需要输入密码,请尝试从主目录中删除.subversion文件夹,然后再运行它,它只会第一次询问密码,然后使用缓存的密码。