8.3. 剖析STARTEAM日志,生成脚本

根据每个文件的Commit Log 文件(*.jxlog),生成相应的脚本文件。

STARTEAM 日志格式如下:


Folder: starteam  (working dir: /home/jiangxin/src/starteam)
History for: st
Description:
Locked by:
Status: Current
----------------------------
Revision: 58 View: compiler Branch Revision: 1.57
Author: nobody_used_for_utility_coci Date: 3/7/03 11:15:03 AM CST
use trap 'rm -f xxxx' EXIT to remove temporary passwd file


----------------------------
Revision: 57 View: compiler Branch Revision: 1.56
Author: nobody_used_for_utility_coci Date: 10/23/02 7:24:38 PM CST
change server ip from 60 to 6


----------------------------
...
...
...
----------------------------
Revision: 2 View: compiler Branch Revision: 1.1
Author: jiangxin(root) Date: 3/10/02 2:12:24 AM CST
jiangxin edition

----------------------------
Revision: 1 View: compiler Branch Revision: 1.0
Author: jiangxin(root) Date: 3/10/02 2:10:17 AM CST
starteam wrapper. by yangzw

=============================================================================

通过程序 steam2cvs 转换之后的脚本示例如下:


st -qq co -lf -r 1 st
cvs add st
cvs ci -m "starteam wrapper. by yangzw (Author:jiangxin(root), Date:3/10/02 2:10:17 AM CST)" st
st -qq co -lf -r 2 st
cvs ci -m "jiangxin edition (Author:jiangxin(root), Date:3/10/02 2:12:24 AM CST)" st
st -qq co -lf -r 3 st
cvs ci -m "ci failed (Author:jiangxin, Date:3/10/02 2:16:25 AM CST)" st
st -qq co -lf -r 4 st
cvs ci -m "cvs style wrapper (Author:jiangxin, Date:3/10/02 2:23:10 AM CST)" st
...
...
...
st -qq co -lf -r 57 st
cvs ci -m "change server ip from 60 to 6 (Author:nobody_used_for_utility_coci, Date:10/23/02 7:24:38 PM CST)" st
st -qq co -lf -r 58 st
cvs ci -m "use trap 'rm -f xxxx' EXIT to remove temporary passwd file (Author:nobody_used_for_utility_coci, Date:3/7/03 11:15:03 AM CST)" st

转换程序 steam2cvs 即完成了上述日志到脚本的转换。源程序参见:

steam2cvs.c,mystring.c, ...

对整个工程的文件执行此操作:

# cd ~jiangxin/work/project
# find . -name "*.jxlog" -o -name ".*.jxlog" -type f -exclude "CVS" -exec steam2cvs {} \;

复杂一些的脚本:


#!/bin/sh

cd <PATH>

xxx=0

while : ; do

for i in `find . -name "*.jxlog" -o -name ".*.jxlog" -type f`; do 
        xxx=`eval "expr $xxx + 1"`
        echo -e "$xxx : proc $i ...     \c"
        steam2cvs $i
        j=${i}.jxsh
        # 运行脚本
        sh $j
        rm -f $i
        echo "done"
done

sleep 60
done