我正在使用SVN提交注释将一些关键字与提交的文件相关联。我现在正在尝试查找所有提交的文件 - 在任何修订版中 - 在评论中都有一个特定的关键字。有可能吗?
先谢谢!
编辑更多信息:我可以使用TortoiseSVN(来自我的本地,Windows 7 64位)或命令行(来自我们的集成服务器,linux)
再次编辑:乌龟中的“显示日志”不允许我从任何日期搜索。现在我无法从去年开始搜索......但仅限于2012年2月15日......有什么方法可以解决这个问题吗?
=============================================== ==============================
最终答案: 我终于按照我的意愿使它工作了。我想让所有这些日志用于svn导出。最终脚本名为ExportAllRevisionsFromKeyword.sh:
#!/bin/sh
if [ ! $1 ];then echo "No keyword specified. Needs for example a ticket number : PROJECT-XXX. The command will be : ./SearchCommitsFromComment.sh PROJECT-XXX";exit;fi
cd /root/PROJETS/myproject/
SEARCH=$1
echo "Searching revisions committed with keyword "$SEARCH
svn log | awk '{
if ( $1 == "------------------------------------------------------------------------") {
getline
REVISION = $1
}
else {
if (match($0, SEARCH)) {
print "Keyword found in " REVISION ". Export coming..."
system("./var/batchesFolder/svnxport.sh . " substr(REVISION,2) " var/batchesFolder/sorties/svnExports/" SEARCH)
}
}
}' SEARCH="$SEARCH"
如你所见,我正在调用另一个脚本。它的灵感来自于Julien Falconet's tutorial,名为svnxport.sh:
#!/bin/sh
# svnxport.sh
# Export only modified files in SVN
#
# Copyright (C) 2009 by Julien Falconnet
# http://www.falconnet.fr
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
#
#BEWARE : This script does not operate correctly with files whose filename contains spaces
# tests for parameters
if [ ! $1 ];then echo "svnxport : No source specified. Needs : source revision target_directory";exit;fi
if [ ! $2 ];then echo "svnxport : No revision specified. Needs : source revision target_directory";exit;fi
if [ ! $3 ];then echo "svnxport : No target_directory specified. Needs : source revision target_directory";exit;fi
# check if the target_directory allready exists
#if [ -d $3 ];then echo "svnxport : target_directory '$3' allready exists. Remove it or change target_directory parameter.";exit;fi
# we use svn diff to select changed files between $2-1 and $2 revisions and only keep those updated or added.
sourceDir=$1
revision=$2
previous=$(($revision - 1))
targetDir=$3
escapedSourceDir=$1
if [ $escapedSourceDir == '.' ]
then
escapedSourceDir='\\.'
fi
echo "Processing : source($sourceDir), revision($revision), target_directory($targetDir)"
# Then the 'for' separate status from filename (here is the problem with file with blanks)
for myfile in `svn diff -r $previous:$revision --summarize $sourceDir | grep -e '^M ' -e '^A '`
do
if [ "$myfile" = "M" -o "$myfile" = "AM" -o "$myfile" = "A" -o "$myfile" = "." -o -d $myfile ]
then
# we ignore the status, and the directory to update
continue
else
#we focus on true changed files
#first we create needed directories for the current file
#note that we use a relative directory system
outfile=`echo $myfile |sed "s|$escapedSourceDir||g"`
dir="$targetDir/$outfile"
mkdir -p $(dirname $dir)
#then we export the file
svn export --force $myfile $targetDir/$outfile >> /dev/null
echo "export $targetDir/$outfile "
fi
done
# List other files. Changed but not exported. Mainly the deleted ones.
# Usefull to know which files should be removed and follow weird comportment
#echo "Watch for : "
#svn diff -r $previous:$revision --summarize $sourceDir | grep -v -e 'M ' -e 'A ' |sed "s|$sourceDir||g"
echo $'\n'
现在,唯一要做的就是进入我的版本化网站root,然后打电话
./path/to/scripts/ExportAllRevisionsFromKeyword.sh PROJECT-XXX
它将搜索通过包含“PROJECT-XXX”关键字的评论提交的任何修订,并将该修订修改的文件的HEAD修订版导出到新文件夹中:path/to/scripts/sorties/svnExports/PROJECT-XXX
我需要说Nishant对他给我的联系非常有帮助。非常感谢 ! :)
答案 0 :(得分:8)
使用Tortoise SVN,您可以轻松找到您的提交:
右键单击=> SVN Checkout =>显示日志
将打开一个新窗口,你会找到一个文本aera,输入你的关键字,乌龟会自动找到你的提交。
现在,如果你不使用Tortoise,抱歉这个无用的答案。
答案 1 :(得分:3)
答案 2 :(得分:1)
关于好笑话权利的提案:
为了对SVN-repo使用执行复杂查询:
在您的情况下(带有关键字的修订版文件),您将获得类似
的内容 hg log --templates "{files}\n" -r "keyword(word)"
或者,甚至可能
hg log --template "{join(files, '\n')}" -r "keyword(word)" | sort -u
(最新模板必须有效,但现在对我不起作用)
答案 3 :(得分:0)
尝试使用它的显示日志窗口,该窗口将显示所有提交的内容。现在只需要使用上面文本框中的特定注释对其进行过滤。