如何使“svn log"忽略属性更改? [英] How to make 'svn log' ignore property changes?

查看:57
本文介绍了如何使“svn log"忽略属性更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'svn log' 显示以下日志:1) 内容已更改的文件和/或2) 属性改变的文件.

'svn log' shows the log of: 1) files whose content has changed AND/OR 2) files whose properties have changed.

有没有办法只显示适用于情况 1 的文件?

Is there a way to show only files for which case 1 applies?

推荐答案

'svn log' 显示:1) 文件的日志其内容已更改和/或 2)属性已更改的文件.

'svn log' shows the log of: 1) files whose content has changed AND/OR 2) files whose properties have changed.

如您所知,svn log 的输出是按提交日志消息而不是按文件组织的.如果您使用详细模式 (-v),它将显示与每个日志条目关联的文件(路径").然而,其中一些路径可能在请求的目标之外(默认:您的当前目录).您是否希望结果也包括这些外部路径?我想从表面上看你的问题,你只是要求过滤,所以是的,如果它们代表文件的内容更改,你会想要这些外部路径.

As you know, svn log's output is organized by commit log messages rather than by files. If you use verbose mode (-v), it will show the files ("paths") associated with each log entry. However some of those paths can be outside of the requested target (default: your current directory). Do you want the results to include those external paths as well? I guess taking your question at face value, you're just asking for filtering, so yes you would want those external paths if they represent a content change to files.

这是一个解决方案.它可能很慢,但我测试过它并且它在 Windows 7 上的 cygwin 中工作.(不要忘记,确保你的脚本有 unixy 行尾!如有必要,使用 dos2unix)

Here is a solution. It may be slow, but I tested it and it works in cygwin on Windows 7. (Don't forget, make sure your scripts have unixy line endings! with dos2unix if necessary)

除了一个外部 sed 脚本(真正的黑客可以把它放在命令行上,但用命令行转义搞乱生命是短暂的)之外,它实际上只有一个长行:

It's really only one long line, except for an external sed script (which a real hacker could put on the command line but life is short to be messing with command-line escaping):

#!/bin/sh

# These paths are set up for cygwin
SED=/bin/sed
SORT=/bin/sort
UNIQ=/bin/uniq
XARGS=/bin/xargs
GREP=/bin/grep
SVN=svn

# Add desired log options here
LOG_OPTIONS=-v
SINCE_REV=10800
SED_SCRIPT=/cygdrive/c/temp/get-paths.sed
# Make sure you edit the sed script referenced above
# to set the base URL of your repository.

# 1) generate the list of log messages, including affected paths (svn log -v)
# 2) process out those paths (sed)
# 3) eliminate duplicates (sort | uniq)
# 4) get the change history for each of those paths (svn diff)
# 5) filter out the ones that involve only property changes (sed)
# 6) eliminate duplicates again (sort | uniq)
$SVN log $LOG_OPTIONS | $SED -n -f $SED_SCRIPT | $SORT | $UNIQ \
 | $XARGS -n20 -I PATHS $SVN diff -r $SINCE_REV --summarize PATHS 2> error.log \
 | $SED -n 's/^[^ ].... *//p' | $SORT | $UNIQ

这里是外部 sed 脚本.确保将 svn 存储库基 URL 更改为存储库的正确基 URL.IE.svn log -v 没有输出的 svn URL 的开始部分.

Here is the external sed script. Be sure to change the svn repository base URL to the right base URL for your repository. I.e. the beginning part of the svn URL that is not output by svn log -v.

 # sed script to output all lines between
 # /^Changed paths:$/ and /^$/, exclusive.
 # Also removes first 5 columns (status) and replaces them with svn repository base url.

 /^Changed paths:$/,/^$/ {
   /^Changed paths:$/b
   /^$/b
   s|^.....|https://svn.myrepo.org/prefix|
   s/ (from .*)$//
   p
}

该脚本将向 error.log 输出一些错误消息,主要是找不到路径",我认为这是针对曾经存在于存储库中但已被移动(重命名)或删除的文件.

The script will output some error messages to error.log, primarily "path not found", which I believe is for files that used to be present in the repository but have been moved (renamed) or deleted.

这是否符合您的要求?

感谢 Michael Augustin 在 此页面 关于 grep svn diff 的输出以删除仅属性更改的想法.

Credit to Michael Augustin at this page for ideas about grepping the output of svn diff to remove property-only changes.

附言这个其他页面似乎问了同样的问题问题,但没有完整的答案.

P.S. This other page seems to ask the same question, but there's no full answer there.

P.P.S.编辑上面的 bash 脚本以添加额外的 |排序 |uniq 到管道的末尾,因为我看到重复出现在那里.虽然我不明白它们为什么会发生.

P.P.S. Edited the above bash script to add an extra | sort | uniq to the end of the pipeline, since I have seen duplicates come out there. Though I don't see why they would occur.

这篇关于如何使“svn log"忽略属性更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆