我正在使用 SVN 提交注释将一些关键字与提交的文件相关联。我现在正在尝试查找所有提交的文件 - 在任何修订版中 - 在评论中具有特定关键字。可能吗?
提前致谢!
编辑以获取更多信息:我可以使用 TortoiseSVN(来 self 本地的 Windows Seven 64 位)或命令行(来 self 们的集成服务器,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'
现在,唯一要做的就是 cd 进入我的版本化网站根目录,然后调用
./path/to/scripts/ExportAllRevisionsFromKeyword.sh PROJECT-XXX
它将搜索任何包含“PROJECT-XXX”关键字的注释提交的修订,并将该修订修改的文件的 HEAD 修订导出到一个新文件夹中:path/to/scripts/sorties/svnExports/PROJECT -XXX
我需要说 Nishant 对他给我的链接很有帮助。太感谢了 ! :)
最佳答案
使用 Tortoise SVN,您可以轻松找到您的提交:
右键单击 => SVN Checkout => 显示日志
将打开一个新窗口,在那里,您会找到一个文本区域,输入您的关键字,乌龟将自动找到您的提交。
现在,如果您不使用 Tortoise,请为这个无用的答案感到抱歉。
关于SVN : Export modified files of revisions committed with specific comment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9631205/