function setVars()
{
#验证配置文件是否存在,如果不存在则退出
if ( -not (& test-path ${VAR_FILE}))
{
echo " "
echo "please make sure that config.txt file exists!"
exit 1
}
#读取配置文件
$result=$(cat ${VAR_FILE})
foreach( $i in $result)
{
#遍历每一行,分割变量名和变量值
if (("$i" -ne " ") -and $($i -match "^[^#]"))
{
${varname}=$(${i} -split "=")[0]
${varvalue}=$(${i} -split "=")[1]
}
#如果变量名不为为空,则将设置变量,并输出
if (${varname})
{
& set-variable -name ${varname} -value ${varvalue} -scope "script"
echo "+ ${varname}=${varvalue} "
}
}
}
#验证参数是否都已经定义
function checkVariable()
{
if(${rStart} -and ${rEnd} -and ${CheckPath})
{
# echo "OK!"
}
else
{
echo "variable error! please check variables in config.txt"
}
}
$VAR_FILE = "config.txt"
#调用函数:设置参数
setVars
#列出snv目录的信息,相当于shell 中的list
$info_result = ((& svn list $CheckPath))
#根据返回的错误代码,验证SVN url 是否正确
if ($LastExitCode -eq 1)
{
echo " "
echo "error! please check SVN URL"
exit 1
}
elseif($LastExitCode -eq 0)
{
# echo "SVN OK!"
}
#调用函数:验证参数
checkVariable
<# echo "------"
echo $LastExitCode
echo $info_result > error.txt
echo "------"
foreach($line in $info_result)
{
echo $line
echo "------"
if ($line -match "http*")
{
"URL error"
}
else {
"NG"
}
}
if ($LastExitCode -eq 1)
{
exit 1
}
echo "hello"
#>
#$rStart = 16586
#$rEnd = 17850
#$file_path = "http://svn.fnst.cn.fujitsu.com/Pfsoft/esf/2_V15_1/4_web_practise_project/esfv15/app/views"
$rStart = "${rStart}".replace(" ","")
$rEnd = "${rEnd}".replace(" ","")
$all_log = (& svn log -v -r "${rStart}:${rEnd}" $CheckPath)
$all_log > svn.log
#$all_log= (cat svn.log)
$num = 0
$a = @{
}
foreach ($line in $all_log)
{
$num += 1
if ($line -match "^\s\s\s[MAD]\s")
{
if( ($line[3] -eq "M") -or ($line[3] -eq "A"))
{
echo $line.Substring(5) >> "modify.txt"
$filename = $line
$filename2=( -split $filename)
# echo $filename2[1]
$filename = $filename2[1]
if($a."$filename" -eq "")
{
$a=$a+ @{"$filename"=0}
$a.totalNum += 1
}
else
{
$a."$filename" += 1
}
}
# elseif ($line[3] -eq "A")
# {
# echo $line.Substring(5) >> "add.txt"
# }
elseif ($line[3] -eq "D")
{
# $filename = $line
$filename2=( -split $line)
$filename = $filename2[1]
echo $line.Substring(5) >> "delete.txt"
if($a."$filename" -eq "")
{
# $a=$a+ @{"$filename"=0}
# $a.totalNum += 1
}
else {
$a.remove("$filename")
}
}
}
}
#echo $a > "hash_M.txt"
#echo $num
foreach($obj in ($a.Keys.GetEnumerator()| sort-object))
{
"file: "+$obj >>"hash_M.txt"
"num: "+$a[$obj] >>"hash_M.txt"
}
<#
$filename = " M /2_V15_1/4_web_practise_project/esfv15/app/controllers/advanced_copy_groups_screen_controller.rb"
$filename2=( -split $filename)
echo $filename2[1]
$filename = $filename2[1]
$a = @{
"totalNum"=0;
"/2_V15_1/4_web_practise_project/esfv15/app/controllers/advanced_copy_groups_screen_controller.rb"=1
}
if(-not $a."$filename")
{
echo "not exist"
$a=$a+ @{"$filename"=0}
$a.totalNum += 1
}
else {
echo "exist"
$a."$filename" += 1
}
echo $a
#>
<#
$a = @{
"esfv15/app/controllers/affinity_groups_screen_controller.rb"=0;
"esfv15/spec/controllers/advanced_copy_groups_screen_controller_spec.rb"=1;
"esfv15/app/views/backup_operations_screen/index.html.erb"=2;
"esfv15/app/views/thin_provisionings_screen/create_tpp_wizard.html.erb"=3;
}
foreach($obj in ($a.Keys.GetEnumerator()| sort-object))
{
"file: "+$obj
"num: "+$a[$obj]
}
$a.getenumerator() | sort-object -property key
#>
{
#验证配置文件是否存在,如果不存在则退出
if ( -not (& test-path ${VAR_FILE}))
{
echo " "
echo "please make sure that config.txt file exists!"
exit 1
}
#读取配置文件
$result=$(cat ${VAR_FILE})
foreach( $i in $result)
{
#遍历每一行,分割变量名和变量值
if (("$i" -ne " ") -and $($i -match "^[^#]"))
{
${varname}=$(${i} -split "=")[0]
${varvalue}=$(${i} -split "=")[1]
}
#如果变量名不为为空,则将设置变量,并输出
if (${varname})
{
& set-variable -name ${varname} -value ${varvalue} -scope "script"
echo "+ ${varname}=${varvalue} "
}
}
}
#验证参数是否都已经定义
function checkVariable()
{
if(${rStart} -and ${rEnd} -and ${CheckPath})
{
# echo "OK!"
}
else
{
echo "variable error! please check variables in config.txt"
}
}
$VAR_FILE = "config.txt"
#调用函数:设置参数
setVars
#列出snv目录的信息,相当于shell 中的list
$info_result = ((& svn list $CheckPath))
#根据返回的错误代码,验证SVN url 是否正确
if ($LastExitCode -eq 1)
{
echo " "
echo "error! please check SVN URL"
exit 1
}
elseif($LastExitCode -eq 0)
{
# echo "SVN OK!"
}
#调用函数:验证参数
checkVariable
<# echo "------"
echo $LastExitCode
echo $info_result > error.txt
echo "------"
foreach($line in $info_result)
{
echo $line
echo "------"
if ($line -match "http*")
{
"URL error"
}
else {
"NG"
}
}
if ($LastExitCode -eq 1)
{
exit 1
}
echo "hello"
#>
#$rStart = 16586
#$rEnd = 17850
#$file_path = "http://svn.fnst.cn.fujitsu.com/Pfsoft/esf/2_V15_1/4_web_practise_project/esfv15/app/views"
$rStart = "${rStart}".replace(" ","")
$rEnd = "${rEnd}".replace(" ","")
$all_log = (& svn log -v -r "${rStart}:${rEnd}" $CheckPath)
$all_log > svn.log
#$all_log= (cat svn.log)
$num = 0
$a = @{
}
foreach ($line in $all_log)
{
$num += 1
if ($line -match "^\s\s\s[MAD]\s")
{
if( ($line[3] -eq "M") -or ($line[3] -eq "A"))
{
echo $line.Substring(5) >> "modify.txt"
$filename = $line
$filename2=( -split $filename)
# echo $filename2[1]
$filename = $filename2[1]
if($a."$filename" -eq "")
{
$a=$a+ @{"$filename"=0}
$a.totalNum += 1
}
else
{
$a."$filename" += 1
}
}
# elseif ($line[3] -eq "A")
# {
# echo $line.Substring(5) >> "add.txt"
# }
elseif ($line[3] -eq "D")
{
# $filename = $line
$filename2=( -split $line)
$filename = $filename2[1]
echo $line.Substring(5) >> "delete.txt"
if($a."$filename" -eq "")
{
# $a=$a+ @{"$filename"=0}
# $a.totalNum += 1
}
else {
$a.remove("$filename")
}
}
}
}
#echo $a > "hash_M.txt"
#echo $num
foreach($obj in ($a.Keys.GetEnumerator()| sort-object))
{
"file: "+$obj >>"hash_M.txt"
"num: "+$a[$obj] >>"hash_M.txt"
}
<#
$filename = " M /2_V15_1/4_web_practise_project/esfv15/app/controllers/advanced_copy_groups_screen_controller.rb"
$filename2=( -split $filename)
echo $filename2[1]
$filename = $filename2[1]
$a = @{
"totalNum"=0;
"/2_V15_1/4_web_practise_project/esfv15/app/controllers/advanced_copy_groups_screen_controller.rb"=1
}
if(-not $a."$filename")
{
echo "not exist"
$a=$a+ @{"$filename"=0}
$a.totalNum += 1
}
else {
echo "exist"
$a."$filename" += 1
}
echo $a
#>
<#
$a = @{
"esfv15/app/controllers/affinity_groups_screen_controller.rb"=0;
"esfv15/spec/controllers/advanced_copy_groups_screen_controller_spec.rb"=1;
"esfv15/app/views/backup_operations_screen/index.html.erb"=2;
"esfv15/app/views/thin_provisionings_screen/create_tpp_wizard.html.erb"=3;
}
foreach($obj in ($a.Keys.GetEnumerator()| sort-object))
{
"file: "+$obj
"num: "+$a[$obj]
}
$a.getenumerator() | sort-object -property key
#>