fileversionsinlevel.sh

来自「CMVC是IBM和许多跨国公司的缺陷管理工具。这里给出了很多在Linux下用KS」· Shell 代码 · 共 177 行

SH
177
字号
#!/bin/ksh## SAMPLE NAME: fileVersionsInLevel## FUNCTIONS:   This sample shell script shows the file versions#              that are included in a level.## USAGE:       fileVersionsInLevel releaseName levelName## ENVIRONMENT VARIABLE(S): CMVC_FAMILY [CMVC_BECOME]## DESCRIPTION:## It gets all of versions of a given file, using information # in a map file# - This query uses the id of records in the versions and files # tables to identify all of the files in a given committed level.# The Map files contain the following fields for each file in a# committed level:## 1. pathName (same as pathName in ChangeView or FileView)# 2. id of record in the "versions" table (also versionId in ChangeView and#    FileView)# 3. id of record in the "files" table (also fileId in ChangeView and id in#    FileView)# 4. State change in the current level (from last level).  Possible#    values are:##	create	 - created in current level#	delete	 - deleted in the current level.  File will not be#		   extracted, but pathName will be added to .gone file#		   (CMVC.GON in DOS and OS/2 - FAT)#	delta	 - changed since last level#	link	 - linked from another release in current level (first#		   level in current release to contain this file)#	noDelta	 - no changes from last level#	rename	 - renamed in current level (different name in last level)#	recreate - restore a file from deleted to usable## Note:#   This sample uses the DB2/6000 version of this query## 5765-207 (C) COPYRIGHT International Business Machines Corp. 1993,1995# 5765-202 (C) COPYRIGHT International Business Machines Corp. 1993,1995# 5622-063 (C) COPYRIGHT International Business Machines Corp. 1993,1995# 5765-397 (C) COPYRIGHT International Business Machines Corp. 1994,1995## All Rights Reserved# Licensed Materials - Property of IBM## US Government Users Restricted Rights - Use, duplication or# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.###           NOTICE TO USERS OF THE SOURCE CODE EXAMPLES## INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE# EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A# PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE# OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS,# IS WITH YOU.  SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE# DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION# DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR# CORRECTION.## * RISC System/6000 is a trademark of International Business Machines#   Corporation.## /usr/lpp/cmvc/samples/fileVersionsInLevel#### Debug#set -xv# Input:# $1 - Name of release# $2 - Name of level## Installation:# - Put HitComp into $HOME/bin#   (this should be on each user's path)## Error Return:# 1 - Any error### Input check## Check input parameters (must have 2)if [[ $# -ne 2 ]]then   print -u2 ' '   print -u2 "$0 ERROR: Incorrect number of parameters"   print -u2 "$0 syntax:"   print -u2 "	 $0 ReleaseName LevelName"   print -u2 ' '   print -u2 'Notes:'   print -u2 '1. Must be run from family account'   print -u2 '2. This version only supports DB2/6000'   print -u2 '3. It appears that multiple entries for one version of a file'   print -u2 '	 may be included in the case of co-requisites.'   print -u2 ' '   exit 1fimapFile="${HOME}/maps/$1/$2"releaseName=\'$1\'levelName=\'$2\'print ""print "$0: opening map file $mapFile"# Verify file existsif [[ ! -f $mapFile ]]then   print -u2 "$0: Error, could not open map file $mapFile"   exit 1fi# Connect to databasedb2 "connect to `whoami`" 2>&1 > $0.logrc=$?if (( $rc != 0 ))then   print -u2 "$0: Error, could not connect to DB2/6000 family `whoami`."   print -u2 "$0: return code = $rc"   exit 1fi# Setup variables for formatting outputlet lineCount=0let stripTop=0let stripBot=0print ""print "Versions of each file in release $1, level $2"print ""print "Version\t\tFileType\t\tPathName"print "=======\t\t========\t\t========"print ""# Read until end of filewhile read pathName versionId fileId statedo   #look up file in ChangeView   #-get all versions within this level   #-print pathName and versions   # Only process files that have changed in the current release   if [[ $state != "noDelta" ]]   then      # Get versions in level and store to a temporary file      db2 "select versionSID,type,pathName,versionId,fileId from ChangeView \	 where fileId=$fileId and releaseName=${releaseName} and \	 levelName=${levelName} \	 order by versionId"  > ${0}.$$.tmp      # Compute number of lines to remove from top and bottom of tmp file      lineCount=`wc -l ${0}.$$.tmp | awk '{ print $1 }'`      let stripTop=lineCount-6      let stripBot=lineCount-3      # Format output      awk '{ print $1 "\t\t" $2 "\t\t" $3 }' ${0}.$$.tmp | head -${stripBot} \	 | tail -${stripTop}   fidone < $mapFiledb2 "connect reset" 2>&1 >> $0.logrm ${0}.$$.tmpprint ""print "$0: complete"print ""# end of file

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?