wx.sh revision daaffb314aae330855b7faea7a653244767ed744
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "@(#)wx 1.12 98/11/09 SMI" (from bonwick)
#ident "@(#)wxx 1.26 03/01/23 SMI" (from fiveash)
#ident "%Z%%M% %I% %E% SMI"
#
# wx -- workspace extensions. Jeff Bonwick, December 1992.
# The bugster cat/subcat = consolidation/os-net-tools
echo "%Z%%M% %I% %E% SMI"
}
# Sound bell to stderr, no newline
print -u2 "\007\c"
}
# output error message to stderr
exit 1
}
typeset question=$1 default_answer=$2
echo "$question \c"
else
echo "$question [$default_answer]: \c"
fi
read answer
}
typeset question="$1"
*) answer=;;
esac
done
}
yesno "$*"
echo "Exiting, no action performed"
exit 1
fi
}
# Escape the . so they are treated as literals in greps.
}
# remove entries in local nt cache
[[ ! -f $wxtmp/local_nametable ]] && \
}
# remove entries in renamed list
# assuming arg is the new filename to remove
}
# Add workspace nametable entry to local nt cache for better perf.
# add entries from workspace nt to local nt cache
[[ ! -f $wxdir/local_nametable ]] && \
fi
return 0
}
# Remove entry from active list
# $1 is the filepath to remove
nawk '
$1 == target {
# Get past filepath line
while(NF > 0)
getline;
# Get past blank lines
while(NF == 0)
getline;
# Get past comments
while(NF > 0)
getline;
# Get past ending blank lines
while(NF == 0) {
if (getline) {
continue;
} else {
next;
}
}
}
# print the other active list entries
{ print $0; } ' target=$1 $wxdir/active >$wxtmp/tmp_active ||
if mv -f $wxtmp/tmp_active $wxdir/active; then
echo "$1 removed from active list."
else
cat >&2 <<-EOF
An error occured trying to remove $1 from the active list.
The active list may be corrupt. You should check it out and
possibly run '$ME update' to fix.
EOF
fi
}
# renamed $1 to $2 filepath in active list
}
# Return 0 if filepath arg is found in active list.
}
#
# Will not remove entries that differ from parent or are new.
#
# if an arg is passed in then this is assumed to be the filepath
# otherwise we assume the variables were set properly by the caller
if [[ $# -eq 1 ]]; then
filepath=$1
if [[ ! -f $file ]]; then
echo "Cannot find $file"
return 1
fi
fi
if wx_pnt_filepath $filepath; then
if ! cmp -s $file $parentfilepath; then
cat <<-EOF
The file $filepath
differs from parent file:
$parentfilepath
and will remain in the active list.
EOF
return
fi
else
# New file, leave in active list.
cat <<-EOF
$filepath
is new and will remain in active list. Use:
'$ME uncreate $filepath'
to remove from active list.
EOF
return
fi
# Remove entry from active list because it is the same as
# the parent.
echo "There is no difference between $filepath and the parent"
echo "$parentfilepath"
fi
fi
}
# Refresh the parent nametable cache if necessary.
# Note, this is a cache for the parent nametable entries that
# have the same hash as the local active and renamed files.
# no parent so nothing to update.
[[ -z $parent ]] && return 0
if [[ ! -r $parent/Codemgr_wsdata/nametable ]]; then
fail "Error: cannot read $parent/Codemgr_wsdata/nametable"
fi
if [[ ! -f $wxtmp/parent_nametable ||
$wxdir/local_nametable -nt $wxtmp/parent_nametable ]]; then
fi
# Use hash list to get only the parent files
# we're interested in.
[[ ! -f $wxtmp/parent_nametable ]] && \
else
# There aren't any files to search for so just
# update the timestamp.
fi
fi
}
# add an active file to the new list
# update new file list
fi
fi
}
# remove a file from the new list
# remove entries in new list
fi
}
# Try to add an entry to the active list
if ! is_active $1; then
# Use sed to remove any empty lines from comment file.
fail "Could not update active list."
else
fail "Could not update active list."
echo "Remember to edit the comment in the active list "\
"(use '$ME ea')."
fi
fi # End if not in active list
}
# Note must use filepath for wx_show_comment
done > $wxtmp/active_sort || \
mv -f $wxtmp/active_sort $wxdir/active || \
}
sort $wxdir/renamed > $wxtmp/renamed_sort || \
mv -f $wxtmp/renamed_sort $wxdir/renamed || \
}
# replace comment in active list entry with contents of $comment_file
nawk '
# find active list entry to modify
$1 == filepath {
# print filepath line
while(NF > 0){
print $1;
getline;
}
#print 1 blank (delimit)
print "";
# Get past blank lines
while(NF == 0){
getline;
}
# Get past active entry comments
# append to or replace comment
if (comment_mode == "append"){
while(NF > 0) {
# output existing comments
print $0;
getline;
}
} else {
# get past existing comments
while(NF > 0) getline;
}
# output new comments
while (getline < comments){
# do not print blank lines
if (NF > 0)
print $0
}
close comments
# print delimiting blank line
printf "\n"
# Get past ending blank lines in active entry
NF=0
while(NF == 0) {
if (getline) {
continue;
} else {
next;
}
}
}
# print the other active list entries
{ print $0; } ' filepath=$1 comment_mode=$comment_mode \
if [[ $? -eq 0 ]]; then
echo "$1 comment(s) updated in active list."
else
cat <<-EOF
An error occured trying to update comments for $1 in the active list.
The active list ($wxdir/active) may be corrupt. You should check it out
and possilbly run '$ME ea' to fix.
EOF
fi
}
# Find a local file's parent filepath.
# Returns 1 if not found (local file is new)
# Sets env var. parentfilepath and parenthash if found
# Requires a file arg.
# Updates local and parent nt caches.
if [[ -z $parent ]]; then
cat >&2 <<-EOF
Warning: there is no parent for the current workspace so local file:
$1
is assumed to be new.
EOF
return 1
fi
# Nothing has been brought over so assuming new file.
cat >&2 <<-EOF
Warning: the $wsdata/nametable
doesn't exist so
$1
is assumed to be new.
EOF
return 1
fi
if [[ ! -r $parent/Codemgr_wsdata/nametable ]]; then
fail "Error: cannot read $parent/Codemgr_wsdata/nametable."
fi
if [[ ! -f $wxtmp/parent_nametable ]] || $need_pnt_refresh; then
need_pnt_refresh=false
fi
if [[ ! -f $wxdir/local_nametable ]]; then
fi
# May be multiple entries in nametable, see if one
# matches parent.
for pnt_nt in $wxtmp/parent_nametable \
# get current parent nt entry
parententry=$(grep \
# found parent entry
# Update the local nt
# hash cache if parent
# found and local
# workspace nt used.
fi
if [[ $pnt_nt == \
then
# Update the parent nt
# hash cache if actual
# parent nt used.
echo $parententry >>\
fi
# break out of all the loops if
# parent found
break 3
fi
done # for pnt_nt
done # while read active file
done # for local_nt
# parent filepath not found.
return 1
else
# parent filepath found.
return 0
fi
}
#
# Detect if a file was locally renamed
#
# Return 0 if renamed, 1 if not locally renamed
# parentfile and parenthash set as side effect
# Must be used by commands that set filepath (like wx_eval)
fi
# new is the new filename in the current ws, old is the previous
# filename that should exist in parent ws.
if lookup_parent $filepath; then
return 0
else
# parent is a problem
"file in $parent"
fi
else
# not locally renamed
return 1
fi
}
# return 0 if parent file found. Side effect: sets parentfilepath
# and parentsdot. parentfile and parenthash are set via lookup_parent.
# if an arg is passed in then this is assumed to be the filepath
# otherwise we assume the variables were set properly by the caller
if [[ $# -eq 1 ]]; then
filepath=$1
fi
# Find the parent filename
if lookup_parent $filepath; then
if [[ -f $parentfilepath && -s $parentsdot ]]; then
# found
return 0
else
"but file does not exist or SCCS file is empty."
fi
fi
# wasn't found
return 1
}
# Get output of putback -n (useful for parsing to find diffs between
# workspaces). Creates $wxtmp/putback.err and $wxtmp/putback.out
typeset -i rc=0
typeset origdir=$(pwd)
# clean up if interrupted.
cat <<-EOF
Doing a '$PUTBACK -n $*' to find diffs between workspaces.
Please be patient as this can take several minutes.
EOF
cd $workspace
$PUTBACK -n $* 2>$wxtmp/putback.err >$wxtmp/putback.out
rc=$?
# Note a blocked putback returns a 2 but is not a problem.
"for details."
fi
cd $origdir
return 0
}
cat << EOF
See <http://onnv.eng/wx.html> for usage tips.
Usage: $ME command [-D] [args]
-D turn on debugging for any command (output to stderr)
===================== Initialization and Update Commands ====================
$ME init [-f(t|q|n) [-s]] [src-root-dir]
initialize workspace for $ME usage
-f(t|q|n): non-interactive mode of update. Use this
to keep init from asking questions.
-ft: thorough update (update both active and
renamed lists with all diffs between parent
and current workspace).
-fq: quick update (update active list with files
currently checked out in current workspace).
-fn: no update (just create empty active and
renamed lists if they don't exist already).
-s: keep active list sorted by default. Must
follow a -f(t|q|n) flag.
src-root-dir: optional path relative to top of
workspace where wx will search for files.
Use "." to set src-root to top of
workspace. Default is usr.
$ME update [-q|-r] [-s]
Update the active and renamed file lists by
appending names of all files that have been
checked out, changed, created or renamed as
compared to the parent workspace. This is the
most accurate way of updating but it is slow.
All files in the workspace must be under SCCS
control in order for update to find them. Note,
this operation can be sped up in some cases by
setting the PUTBACK env. variable to use
"cm_env -g -o putback". (See
http://webhome.holland.sun.com/casper/ for more
info about the turbo def.dir.flp tool).
-q: quick update (only updates active list with
files currently checked out in workspace). This
is faster but will not find renames or files that
have been checked-in/delget'ed.
-r: only update the renamed list. Does not update
the active list.
-s: sort the active list.
======================== Information Commands ===========================
$ME list [-r|-p|-w] list active files (the ones you are working on)
-r: list only renamed active files.
-p: output list of both active and renamed files
suitable for input to putback.
-w: output list of both active and renamed files
suitable for input to webrev (see $ME webrev
subcommand below).
$ME active alias for list
$ME pblist alias for list -p (see above).
$ME renamed [-a|-d|-p]
list locally renamed files. The output format is:
"new_name previous_name". Note, deleted files are
a special case of rename.
-a: list only renamed active files (same as list -r)
-d: list only deleted files
-p: show "new_name parent_name" (Note, parent_name
may not be the same as previous_name)
$ME new [-t] List new active files (files that exist in child only)
Note, should be run before reedit (see reedit below).
-t: thorough, does not use new cache (slower but more
accurate if new cache isn't current).
$ME out find all checked-out files in workspace
$ME info [file ...] show all info about active files
$ME diffs [file ...]
show sccs diffs for files (current vs previous
local version). Will show diffs for all active
files if no files given on command line. Will
use WXDIFFCMD environment variable if set. Hint,
try: export WXDIFFCMD="diff -bwU5"
$ME tdiffs [file ...]
Similar to diffs but new files are also displayed.
New files are those listed by '$ME new'.
$ME pdiffs [file ...] show diffs against parent files
Will show diffs between local file and it's
parent for all active files if no files given on
command line. Will use WXDIFFCMD environment
variable if set.
$ME tpdiffs [file ...] show diffs against parent files
Similar to pdiffs but new files are also displayed.
A file is considered new if it does not exist in
the parent.
$ME prt [-y] show sccs history for all active files
$ME comments display check-in comments for active files
$ME bugs [-u] display all bugids in check-in comments
$ME arcs [-u] display all ARC cases in check-in comments
$ME pbcom [-v] [-u] [-N] display summarized comments suitable for putback
Default is to display only bugs and arc cases. Will
display warnings about non-bug comments to stderr.
-v: display all comments verbatim including non-bug/arc
-u: prevent sorting, order determined by active list
-N: don't check bug synopsis against bug database
======================== File Manipulation Commands ======================
$ME edit [-s] [file ...]
check out either file(s) on command line or
all active files if no file args.
(Updates the active list.)
-s: silent, less sccs diagnostic output. This is
true for the other commands that accept the
-s flag.
$ME checkout Alias for edit command.
$ME co Alias for edit command.
$ME unedit [-s][-f] [file ...]
Returns file(s) to state prior to edit/checkout
Note, files will be unlocked and any changes made
when file was last checked out will be lost.
Unedit all active files if no files listed on
command line. Removes active list entry if there
are no diffs between local and parent file.
(Updates active list)
-f: force unedit, non-interactive. Will backup
if wx files newer than last backup.
$ME uncheckout Alias for unedit command.
$ME unco Alias for unedit command.
$ME delget [-(c|C) comment_file][-s][-f] [file ...]
Check in all active files or files on command
line. Check in comments will be those in active
file. See '$ME comments' for more info.
-c comment_file: use comment(s) in specified comment
file when checking in file(s). Note,
each comment should be on new line,
blank lines not allowed. Existing
comments in active list will be
replaced by contents of comment_file.
-C comment_file: Similar to -c but comments are
appended to current active list
comments.
-f: force checkin, no checks, non-interactive.
Use this if your sure the files okay to checkin
otherwise this command will check for
keyword problems. Will backup if wx files
newer than last backup.
NOTE: use redelget to reset new file's version to 1.1.
$ME checkin Alias for delget command.
$ME ci Alias for delget command.
$ME create [-(c|C) comment_file] [-f] [-o] file [file ...]
Creates one or more files in the workspace.
(Updates active list)
-(c|C) comment_file: see delget
-f: force create regardless of warnings,
(non-interactive).
-o: also check out file for further editing.
$ME uncreate [-f] [file ...]
Undoes the create of a new file. The file's
active list entry, its SCCS history and the
entry in the workspace nametable will be removed
but the file will stay in the workspace.
Will uncreate all new files in active list if
no file argument is specified.
-f: force uncreate, non-interactive. Will backup
if wx files newer than last backup.
$ME get [-k][-r #][-p] [file ...]
Get a copy of all active files or files on command
line. By default this is a read only version of
the file.
-r #: get specified version #
-p: output to stdout
-k: don't expand the sccs ID string
$ME extract Alias for get command.
$ME reedit [-m] [-s] [file ...]
Collapse the sccs delta (file history) such that
all changes made to the file in the current
workspace are now in one delta. If no files are
given on command line then all the active files
are processed. The files are left in a checked
out state so you can make further changes if a
resolve to make all your changes look like a
single delta. This eliminates the uninteresting
leaf deltas that arise from resolving conflicts,
so your putbacks do not contain a bunch of noise
about every bringover/resolve you did in the
interim. Accepts the same compression flags as
$ME backup. If [file ...] given, wx only
reedits files passed on command line. This adds
files to active list if not already there.
NOTE: reedit is appropriate for leaf workspaces
ONLY -- applying reedit to an interior-node
workspace would delete all childrens comments
and confuse Teamware tools in general.
NOTE: if files are listed as new that are not
then DO NOT use the reedit as it will destroy
the file history.
NOTE: if a file is new reedit will leave the
file checked out so in order to keep the delta
version at 1.1 redelget must be used for
checkin.
-m: only reedit files that have more that one
delta as compared to parent file. New files
will be recreated with comment found in
active list.
-s: silent checkin
$ME recheckout Alias for reedit command.
$ME reco Alias for reedit command.
$ME redelget [-m][-s] [file ...]
Similar to reedit but the file is checked in
when the command is done. This is the command to
use to collapse new files to their initial
1.1 delta (will assign comment in active list).
$ME recheckin Alias for redelget command.
$ME reci Alias for redelget command.
$ME delete [-f] [file ...]
Delete one or more files from the workspace.
Will delete all files in active list if no file
args. Note, for files brought over from parent,
this command actually moves the file under the
deleted_files/ subdir so it can be recovered.
For new files this command can remove the file
and file history completely.
(Updates active list if file is in there.)
-f : force delete regardless of warnings
(non-interactive)
Warning, this will completely remove new
files from the workspace. Will backup
if wx files newer than last backup.
$ME rm Alias for delete command.
$ME mv file newfile
Rename file to newfile
(Updates active list with new file name)
$ME mv file newdir
$ME mv dir newdir
Renames dir or file to newdir. If newdir exists
then dir will be subdir under newdir. Note,
this renames all files in dir and can take a
while if there are a lot of files affected by
the rename. (Updates active list)
$ME reset [-f] [file ...]
Resets file contents and history to that of
parent file. If the file was renamed locally it
will be renamed to that of the parent. It does not
work on new files (see uncreate or delete).
NOTE: use with care. If something goes wrong,
do a wx restore from the last backup and copy
wx/tmp/nametable.orig to Codemgr_wsdata/nametable.
======================== Teamware Commands ======================
$ME putback [-v][-f][-N][Teamware putback flags, see below][file ...]
Use Teamware putback command to putback either
file(s) specified or *all* active and renamed
files if no file(s) specified. Will use pbcom
output as the putback comments.
-f: force non-interactive mode (will not prompt)
-v: pass comments verbatim to putback(see pbcom)
-N: don't check bug synopsis against bug database
Accepts -n, -p pws, -q putback flags ('man putback'
for more info).
$ME pb alias for putback.
$ME resolve [Teamware resolve args]
resolve bringover conflicts and reedit merged
files. See 'man resolve' for args.
======================== ON Rules checking Commands ======================
$ME cstyle run cstyle over all active .c and .h files
skips files in wx/cstyle.NOT
$ME jstyle run jstyle over all active .java files
skips files in wx/jstyle.NOT
$ME hdrchk run 'hdrchk -a' over all active .h files
skips files in wx/hdrchk.NOT
$ME makestyle run makestyle over all active Makefiles
$ME keywords run keywords over all active files
skips files in wx/keywords.NOT
$ME copyright make sure there is a correct copyright message
that contains the current year
skips files in wx/copyright.NOT
$ME cddlchk make sure there is a current CDDL block in
active files
skips files in wx/cddlchk.NOT
$ME rmdelchk make sure sccs rmdel was not run on active files
(This causes Teamware problems.)
$ME deltachk make sure only 1 sccs delta in active files
(more than 1 breaks gate putback rules unless > 1
bug in putback.)
$ME comchk make sure comments are okay
$ME rtichk make sure RTI is approved for bugs/rfe's listed
in active list comments. Will skip rtichk if
wx/rtichk.NOT exists.
$ME outchk warn if there are files checked out that aren't in
active list.
$ME nits [file ...]
nits checking. Run cstyle, jstyle, hdrchk, copyright,
cddlchk, and keywords over files to which they are
applicable (makestyle is not currently run
because it seems to be quite broken -- more
noise than data). This is a subset of pbchk checks
suitable for checking files during development.
Use pbchk before doing the final putback.
Will run checks on all active files if no file args.
Will skip checks for files listed in wx/nits.NOT.
$ME pbchk [file ...]
putback check. Run cstyle, jstyle, hdrchk, copyright,
cddlchk, keywords, rmdelchk, deltachk, comchk, rtichk
and outchk over files to which they are
applicable (makestyle is not currently run
because it seems to be quite broken -- more
noise than data). Good command to run before
doing a putback.
Will run checks on all active files if no file args.
Will skip checks for files listed in wx/pbchk.NOT.
======================== Code Review Commands ======================
$ME webrev [webrev-args]
generate webrev for active and renamed/deleted files.
Note, uses comments in the active list. This is the
preferred way of reviewing code. Arguments to webrev
may also be specified.
Will skip files listed in wx/webrev.NOT
$ME codereview [-N] [codereview options]
generate environmentally friendly codereview diffs
for all active files. -N indicates that delta
comments should not be included.
$ME fullreview [-N] [codereview options]
generate full codereview diffs for all active files.
-N indicates that delta comments should not be
included.
======================== Backup and Restore Commands ======================
$ME backup [-i|-n|-z|-b|-t]
make backup copies of all active and renamed files.
-i: info about backups (backup dir and contents)
-n: no compression
-z: use gzip, faster than bzip2 but less compression.
-b: use bzip2, slower but better compression.
-t: backup if wx files are newer than last backup.
Defaults to the compression of the previous backup.
$ME bu Alias for backup command.
$ME restore [-f] [backup_dir]
restore a backup in a workspace (restores both
active files and performs file renames). A path
to the directory containing the backup to
restore from can be optionally specified.
-f: non-interactive. Will restore from last backup.
======================== Misc Commands ============================
$ME apply <cmd> apply cmd to all active files; for example,
"$ME apply cat" cats every file
$ME eval <cmd> like apply, but more general. In fact,
"$ME apply cmd" is implemented internally as
"$ME eval 'cmd \$file'". When using eval,
you can refer to \$dir, \$file, \$filepath,
\$parent, and \$workspace. For example:
$ME eval 'echo \$dir; sccs prt \$file | more'
will show the sccs history for each active file,
preceded by its directory.
$ME grep search all active files for pattern; equivalent to
"$ME eval 'echo \$filepath; grep pattern \$file'"
$ME egrep see $ME grep
$ME sed see $ME grep
$ME nawk see $ME grep
$ME dir echo the $ME directory path (\$workspace/$ME)
$ME e <file> edit the named $ME control file, e.g. "$ME e active".
The editor is \$EDITOR if set, else vi.
$ME ea shorthand for "$ME e active" (edit active list).
Note, the format for each entry in the active
list is:
filepath
<empty line> # no spaces allowed
one or more comment lines # no blank lines between.
<empty line> # no spaces allowed, ends the entry.
In general, it is best to only edit the active
list to update comments. Use the other $ME
commands like edit or create to update the
active list when possible.
$ME ws <file> cat the named workspace control file, i.e.
\$workspace/Codemgr_wsdata/file
$ME args shorthand for "$ME ws args"
$ME access shorthand for "$ME ws access_control"
$ME help print this usage message
$ME version print current version of this program
EOF
exit 1
}
}
# list new files (not found in parent ws)
typeset new
if [[ $1 == '-t' ]]; then
while read new; do
# thorough, skip new cache
if ! lookup_parent $new; then
# no parent, new file
echo "$new"
fi
done
else
while read new; do
# use new cache
if ! lookup_parent $new; then
# no parent, new file
echo "$new"
fi
fi
}
if [[ $# -eq 0 ]]; then
elif [[ $1 == '-d' ]]; then
# Only list only deleted file renames
elif [[ $1 == '-n' ]]; then
# Only list only current filenames
elif [[ $1 == '-p' ]]; then
# list parent for current instead of local previous name
if lookup_parent $current; then
print "$current $parentfile"
else
"for $current"
fi
elif [[ $1 == '-a' ]]; then
# Just list active renamed files
done
elif [[ $1 == '-r' ]]; then
# Just list non-active renamed files (just current name)
echo $current
else
fail "Invalid flag $i. Run 'wx help' for info."
fi
}
# Output a list of active and renamed files suitable for webrev
if renamed; then
echo "$filepath $parentfile"
else
echo "$filepath"
fi
done
}
cd $workspace
# skip files listed in .NOT files
( # do the loops in a subshell so there is only one file open
continue
fi
if renamed; then
echo "$filepath $parentfile"
else
echo "$filepath"
fi
done
# Do non-active renamed files
continue
fi
if [[ $filepath != $parentfile ]]; then
echo "$filepath $parentfile"
# output empty line, comment, empty line
echo "\nRenamed only (webrev comment generated by "\
"$ME, not an sccs comment)\n"
else
echo "$filepath"
echo "\nWarning, file in renamed list but has same "\
"name as parent (not an sccs comment)\n"
fi
done
# End of subshell
) > $wxdir/tmp/webrev.list
# Note that the file list must come last.
cd $origdir
}
#
# list all active files
#
# do not print hash by default
typeset rc hash=0
case $1 in
# list only renamed active files
-r) list_renamed -a; return 0;;
# list suitable for putback (both active and renamed)
-p) list_putback; return 0;;
# list suitable for webrev (both active and renamed)
-w) list_webrev; return 0;;
esac
fi
nawk '
{
# skip blank lines
while (NF == 0) {
if (getline == 0)
next;
}
if (NF > 0){
# print the active filepath
print $1;
getline;
}
# skip blank lines
while (NF == 0) {
if (getline == 0){
# Error, corrupt active list (missing comment)
exit 1
}
}
# skip comment
while (NF > 0) {
if (getline == 0){
# Error, blank line after comment missing
exit 2
}
}
rc=$?
fail "Corrupt active list (missing comment)."
fail "Corrupt active list (blank line needed after comment)."
fi
}
#
# show the comment for $filepath
#
nawk '
{
filename=$1
getline
while (getline) {
if (length == 0)
next
if (filename == target) {
if ($0 == "NO_COMMENT") {
found = 0
exit 1
}
found = 1
print
}
}
}
END {
if (found == 0)
print "NO_COMMENT"
exit 1 - found
return $?
else
echo "NO_COMMENT"
fi
}
typeset buglist=$1
if [[ ! -x $monaco ]]; then
return 1
fi
set What =
substr(cr.cr_number, 1, 7), synopsis
set Which =
cr.cr_number in ($buglist)
set FinalClauses =
order by cr.cr_number
do query/CR
EOF
}
BEGIN {
}
# If the synopsis doesn't match the bug database
# and the synopsis isn't what's in the database
# with " (something)" appended, spew a warning.
print "Bug " $1 " is not in the database"
/ \([^)]*\)$/)) {
print "Synopsis of " $1 " is wrong:"
}
}
}
}
#
# Summarize all comments listing, in order:
# - free-form comments
# - ARC case comments
# - Bug comments
#
# -a will suppress ARC case comments
# -b will suppress bug comments
# -n will do pbchk processing (give all warnings, no error exit)
# -o will suppress free-form (other) comments
# -p will do pbcom checking and exit if it finds problems unless -v is given
# -u will prevent sorting of the ARC case comments and bug comments
# -v will output all comments verbatim (no sorting)
# -N will prevent bug lookup, which may take a while.
#
# Note, be careful when modifying this function as sometimes the output
# should go to stdout, as in the case of being called via pbchk and
# sometimes the output should go to stderr. Think about this when
# making changes in here.
#
show_arcs=true \
show_bugs=true \
show_others=true \
verbatim=false \
pbchk=false \
pbcom=false \
nolookup=false
while getopts :abnopuvN i; do
case $i in
a) show_arcs=false;;
b) show_bugs=false;;
n) pbchk=true;;
o) show_others=false;;
p) pbcom=true;;
v) verbatim=true;;
N) nolookup=true;;
"info.";;
esac
done
# Store all the comments in a tmp file
for filepath in $file_list; do
"comments."
if $pbcom; then
# Don't want to output anything to stdout for a pbcom
# if there is an error.
return 1
fi
fi
# All comments output verbatim. Note, is hacky because
# of the wx_summary interface. pbcom calls wx_summary
# with -po assuming other comments shouldn't be output.
show_others=true
fi
# Note, hard tab in the arc R.E.
arc='[A-Z][A-Z]*ARC[/ ][12][0-9][0-9][0-9]/[0-9][0-9][0-9][^0-9]'
# bug ID must followed by single space
bug='[0-9][0-9][0-9][0-9][0-9][0-9][0-9] '
bugnospc='[0-9][0-9][0-9][0-9][0-9][0-9][0-9][^ ]'
if $show_arcs; then
then
if $pbchk; then
print -n "Inconsistent ARC summaries for: "
else
print -nu2 "Inconsistent ARC summaries for: "
fi
# Don't want to output anything to
# stdout for a pbcom if there is an
# error.
return 1
fi
fi
fi
if $show_bugs; then
# Treating bug comments with "(nit comment)" at the end as the
# same as the original bug hence the sed and nawk below
# Note hard tabs in sed arg.
if $pbchk; then
print -n "Inconsistent bug summaries for: "
else
print -nu2 "Inconsistent bug summaries for: "
fi
# Don't want to output anything to
# stdout for a pbcom if there is an
# error.
return 1
fi
fi
# Compare bug synopsis in active comments with the bug database.
# If we've been passed -N, then we just never set buglist, thus
# skipping the lookup.
if ! $nolookup; then
cat $wxtmp/buglist.active | while read bugid synopsis; do
done
else
if $pbchk; then
print "Not performing bug synopsis check (be careful)"
else
print -u2 "Not performing bug synopsis check (be careful)"
fi
fi
if [[ -n $buglist ]]; then
if [[ -s $wxtmp/buglist.bugdb && $? -eq 0 ]]; then
if $pbchk; then
else
fi
# Don't want to output anything
# to stdout for a pbcom if there
# is an error.
return 1
fi
fi
else
if $pbchk; then
print "Could not perform bug synopsis check"
else
print -u2 "Could not perform bug synopsis check"
if $pbcom; then
print -u2 "Use -N to skip bug synopsis check (be careful)"
fi
fi
# Don't want to output anything
# to stdout for a pbcom if there
# is an error.
return 1
fi
fi
fi
# must have single space following bug ID
if $pbchk; then
print "\nThese bugs are missing single space following the bug ID"
print "(output prefaced by active file line number ':'):"
while read comment
do
else
print -u2 "\nThese bugs are missing single space following the bug ID"
print -u2 "(output prefaced by active file line number ':'):"
while read comment
do
fi
# Don't want to output anything to
# stdout for a pbcom if there is an
# error.
return 1
fi
fi
fi
# Create warning for pbchk or pbcom.
> $wxtmp/other_comments; then
cat <<-EOF
Warning, the following comments are found in your active list
that are neither bug or arc cases:
EOF
print -- "\n---- End of active list comment warnings ----"
fi > $wxtmp/comment_warning
if [[ -s $wxtmp/comment_warning ]]; then
if $pbchk; then
# output to stdout, don't exist in case there are more
# warnings.
# Don't want to output anything to stdout for a pbcom
# if there is an error.
cat $wxtmp/comment_warning >&2
return 1
fi
fi
if $pbchk; then
cd $workspace
# See if sccs delta comment is the same as active list comment
for filepath in $file_list; do
# extract most recent delta comment
# Add blank line to active comments so following cmp will
# work properly.
print "\n$filepath"
print "Warning: current sccs comment does not"\
"match active list comment"
print "(< sccs comment, > active list comment):"
fi
done
# Just output warnings for pbchk
return 0
fi
if $show_others; then
if ! $verbatim; then
# The non-verbatim check should have produced the
# other_comments file.
else
# just output comments verbatim then return
return 0
fi
fi
if $show_arcs; then
fi
if $show_bugs; then
fi
return 0
}
# Try to add a entry to the renamed list. Note, this stores the new
# name and previous name, not the parent name as this is more useful in
# detecting cyclic renames.
# ofp: old filepath, nfp: new filepath
# remove old and new entries from renamed
# remove old entries from local nt cache
# Do not update renamed list if the filepath is the same as
# the parent or the file is new.
if lookup_parent $nfp; then
if [[ $parentfile != $nfp ]]; then
[[ $ACTSORT == sort ]] && do_renamed_sort=true
fi
fi
return 0
}
typeset -i rc
if [[ $# -eq 0 ]]; then
# No args so we need to create the renamed list from
# the source root.
append=false
if [ -r $wxdir/srcroot_dir ]; then
else
fi
else
# Assuming one or more filepaths as args
append=true
pb_files="$*"
fi
echo "Updating $ME renamed list... this may take several minutes."
# Get output of putback -n to detect renames elsewhere in
# this script.
nawk '
/^rename from:/{orig_file=$3}
$1 == "to:" {print $2 " " orig_file}' \
$wxtmp/putback.out >$wxtmp/pb_renames || \
fail "Error: cannot create $wxdir/renamed.old."
if $append; then
else
mv -f $wxtmp/pb_renames $wxdir/renamed ||
fi
[[ $ACTSORT == sort ]] && do_renamed_sort=true
}
# returns 0 if a pattern in patternfile matches input path arg
typeset pattern path=$1 patternfile=$2
while read pattern; do
return 0 # pattern matched path
fi
done < $patternfile
return 1 # file path not matched by pattern
}
#
# Evaluate a command for all listed files. This is the basic building
# block for most wx functionality.
#
typeset -i changedir=1
shift
fi
pre_eval=$*
# skip files listed in .NOT files
for filepath in $file_list; do
print "$filepath (skipping)"
else
cd $workspace
[[ $changedir -eq 1 ]] && cd $dir
eval $pre_eval
fi
done
}
#
# Initialize a workspace for wx.
#
typeset srcroot_dir force=false
# check that srcroot is relative to top of workspace
if cd $workspace/$1; then
# normalize the srcroot dir for test below
srcroot_dir=$(/bin/pwd)
srcroot_dir="${srcroot_dir#$workspace/}"
if [[ $srcroot_dir == $workspace ]]; then
# Special case need to set srcroot_dir to
# a relative path but we're at the top of the
# workspace.
srcroot_dir="."
fi
else
"($workspace)."
fi
if [ -d $wxtmp ]; then
if [[ $2 != -f[nqt] ]]; then
echo "This workspace has already been initialized."
ok_to_proceed 'Do you really want to re-initialize?'
fi
else
fi
#
# Make sure to save $srcroot_dir as a path relative to the workspace
# root; an absolute path would break if the workspace name changed.
#
rm -f $wxdir/srcroot_dir
echo $srcroot_dir >$wxdir/srcroot_dir
[[ -d $backup_dir ]] || mkdir -p $backup_dir ||
fail "mkdir -p $backup_dir failed."
cd $backup_dir
rm -f $wxdir/backup_dir
if [[ -z "$2" ]]; then
# Interactive mode
cat << EOF
Pick one of the following update methods:
1) Thorough: Detect any differences between the current workspace
and its parent and update the active, new and renamed lists. Use
this in workspaces where files have been renamed or deleted or
there are files that are different from the parent that are not
checked out. Note, files must be under SCCS control in order for
this method to compare them to the parent workspace.
2) Quick: Only update the active list with files that are currently
checked out. Will not update the renamed list.
3) None: Use this on workspaces where there are no changes between
the workspace and its parent. This is very quick but will not
update the active, new or renamed lists.
EOF
read answer?"Which update method? [1|2|3]: "
1) wx_update;;
2) wx_update -q;;
3) ;;
"again";;
esac
yesno "Keep active list sorted by default?"
else
fi
else
# non-interactive mode
case $2 in
# forced thorough update
# forced quick update
# forced no update
# invalid arg
esac
if [[ $3 == -s ]]; then
else
fi
fi
print
if $force; then
# only backup if necessary
print "Will backup wx and active files if necessary"
wx_backup -t
else
print "Making backup copies of all wx and active files"
fi
else
echo "Active list empty, not doing backup."
echo
fi
echo "$ME initialization complete"
}
#
# Find all checked out files
#
typeset origdir=$(pwd)
cd $workspace
if [ -f $wxdir/srcroot_dir ]; then
else
fi
print -u2 "Workspace nametable changed: sccs_dirs out of date"
print -u2 "Updating $wxdir/sccs_dirs...this may take a few minutes.\n"
fi
cd $workspace
rm -f $wxtmp/checked_out
# Note if srcroot_dir = . this must be removed from the front of the
# filepaths.
tr \\040 \\012 | \
cd $origdir
}
# (perhaps by bringover?) and try to rename the active entry
# filepath.
notrenamed_list origdir=$(pwd)
cd $workspace
list_putback |\
while read fp; do
if [[ ! -f $fp ]]; then
# file not found, suspect rename.
# using renamed for error checking.
renamed=false
# search cached local nt to find old hash info
# find new filepath
[[ -z $newfp ]] && continue
echo "\nRenamed active file"\
renamed=true
break
fi
done
if ! $renamed; then
if [[ -z $notrenamed_list ]]; then
else
fi
fi
fi
done
if [[ -n $notrenamed_list ]]; then
cat <<-EOF
Warning, active file(s):
$(echo $notrenamed_list)
not found and cannot be renamed. Use "$ME ea" to edit the active list to
remove these entries if they do not exist in this workspace.
EOF
fi
cd $origdir
}
#
# Old style update the active file list (by appending all checked out files).
# This is what the original wx update did.
#
# Sort active if requested.
cd $wxdir
# sed has a hard tab, used to delete lines containing only whitespace
while read filepath ; do
done < tmp/files.new > active.new ||
fail "Error: cannot create $wxdir/active.new"
mv -f active active.old
mv -f active.new active
echo
echo "New active file list:"
echo
echo
echo "Diffs from previous active file list:"
echo
echo "End active diffs =========================="
# Do new file processing after active list is updated.
# Note, the parent nt read check below is hackish because we are
# assuming that lookup_parent needs to read the parent nt and if it
# can't then we want to just issue the warning.
if [[ -n $parent && ! -r $parent/Codemgr_wsdata/nametable ]]; then
echo "\nWarning: cannot read parent nametable, new file list"\
"not output." >&2
else
while read filepath; do
# lookup_parent populates local nt cache
if lookup_parent $filepath; then
else
fi
echo
echo "New new-file list:"
echo
echo
echo "Diffs from previous new-file list:"
echo
echo "End new diffs =========================="
fi
}
#
# Update various lists (active, renamed, new)
#
# default, update all lists
typeset update_active=true update_renamed=true update_new=true
while getopts :qrs i; do
case $i in
q) do_quick=true;;
r) update_active=false
update_new=false;;
"info.";;
esac
done
if $do_quick; then
# Do old school wx update (only for checked out files)
# This is faster but not as thorough.
return
fi
if [[ -z $parent ]]; then
"instead."
fi
if [[ ! -r $parent/Codemgr_wsdata/nametable ]]; then
fail "Error: cannot read $parent/Codemgr_wsdata/nametable"
fi
# create tmp/checked_out file which putback -n may not list.
# Do this before putback so it doesn't unnecessarily update the
# sccs dirs cache.
# Get output of putback -n to detect renames and active files.
if [ -f $wxdir/srcroot_dir ]; then
else
fi
cd $wxdir
if $update_renamed; then
if [[ -f renamed ]]; then
mv renamed renamed.old ||
fail "Error: cannot create $wxdir/renamed.old."
else
touch renamed.old ||
fail "Error: cannot create $wxdir/renamed.old."
fi
nawk ' /^rename from:/{orig_file=$3}
$1 == "to:" {print $2 " " orig_file}' \
tmp/putback.out |$ACTSORT > tmp/renamed ||\
done
echo "New renamed file list:"
echo
echo
echo "Diffs from previous renamed file list:"
echo
echo "End renamed diffs =========================="
fi
if $update_active; then
# Create active list from putback output.
nawk '/^(update|create): / {print $2};
/^The following files are currently checked out/ \
{p=1; continue};
/^"/ {continue};
NF == 0 {p=0; continue};
{if (p==1)
print $1}' tmp/putback.out |
sort -u > tmp/active_nawk_out ||
# list files in conflict also
sort -u > tmp/conflict_nawk_out ||
if [[ -s tmp/conflict_nawk_out && ! -r $wsdata/nametable ]]
then
fi
# clear the tmp active file
print -n > tmp/active.new || fail "Error: cannot create tmp/active.new."
# store current active list
# go through all the possible active files (keeping the existing
# ones as well). Note hard tab in sed arg.
# conflict files have a parent but the
# putback output only shows the parent's
# filename, need to find local name in
# case of rename
# continue if empty string
else
continue
fi
fi
>> tmp/active.new
done
rm -f tmp/active_nawk_out
mv -f active active.old
mv -f tmp/active.new active
echo
echo "New active file list:"
echo
echo
echo "Diffs from previous active file list:"
echo
echo "End active diffs =========================="
fi
# The new list is for caching names of new files to speed up commands
# that list the new files.
if $update_new; then
if [ -f new ]; then
elif [ ! -f new.old ]; then
fi
# Create new list from putback output.
echo
echo "New new-file list:"
echo
echo
echo "Diffs from previous new-file list:"
echo
echo "End new diffs =========================="
fi
}
# Must be called via wx_eval
echo "$filepath already checked out"
elif [ -f $file ]; then
echo $filepath
else
fi
else
echo "Warning. file $filepath not found."
fi
[[ $ACTSORT == sort ]] && do_active_sort=true
}
# Must be called via wx_eval
typeset -i force=0
# set positional args to contents of global $args
set -- $args
while getopts :f arg; do
f) force=1;;
"more info.";;
esac
done
msg="differs from parent file, will remain in active list."
echo "$filepath not checked out"
else
if [[ $backup_done -eq 0 ]]; then
yesno "Do you want to backup files first?"
fi
else
# only backup if necessary
print "Will backup wx and active files if necessary"
fi
backup_done=1;
# cd to the dir where the file is in case
# wx_backup took us somewhere else.
fi
echo $filepath
if wx_pnt_filepath $filepath; then
if cmp -s $file $parentfilepath; then
else
fi
fi
fi
else
fi
fi
fi
}
# Must be called via wx_eval
typeset arg
o) checkout=1;;
f) force=1;;
"more info.";;
esac
done
if [ ! -f $file ]; then
echo "Error! $filepath is not a file."
return 1
elif [ -f $workspace/deleted_files/$filepath ]; then
cat >&2 <<-EOF
Error: a deleted version of $filepath exists.
You must undelete the file and edit that version.
Run:
'cd $workspace'
'$ME mv deleted_files/$filepath $filepath'
'$ME edit $filepath'
EOF
return 1
cat >&2 <<-EOF
Error! $filepath exists in the parent workspace $parent.
Choose a different name.
EOF
return 1
elif [[ -n $parent && -f $parent/deleted_files/$filepath ]]; then
cat >&2 <<-EOF
Error! a deleted version of $filepath exists in the parent workspace
You must undelete the file and edit that version.
Run:
'cd $workspace'
'bringover deleted_files/$filepath'
'$ME mv deleted_files/$filepath $filepath'
'$ME edit $filepath'
EOF
return 1
"updated." >&2
else
# XXX it would be nice if keyword would work on new files
cat >&2 <<-EOF
Warning!!!
$filepath
is missing SCCS keywords. See
/net/wizard.eng/export/misc/general_docs/keyword_info.txt
for more info. Note, pay attention to the tabs.
EOF
echo "Aborting create $filepath"
return 1
fi
fi
fi
if ! wx_copyright; then
# Sound bell
cat >&2 <<-EOF
Warning!!!
$filepath
has copyright problems. See
/net/wizard.eng/export/misc/general_docs/golden_rules.txt
for more info.
EOF
echo "Aborting create $filepath"
return 1
fi
fi
fi
# Sound bell
cat >&2 <<-EOF
Warning!!!
$filepath
has CDDL block problems. See
http://www.opensolaris.org/os/community/onnv/devref_toc/devref_7/#7_2_3_nonformatting_considerations
for more info.
EOF
echo "Aborting create $filepath"
return 1
fi
fi
fi
if [[ ! -d SCCS ]]; then
fi
else
fi
fi
[[ $ACTSORT == sort ]] && do_active_sort=true
fi
}
# Must be called via wx_eval
# undoes a 'wx create'
typeset efp
typeset -i force=0
case $1 in
-f) force=1;;
esac
if [[ $backup_done -eq 0 ]]; then
yesno "Do you want to backup files first?"
fi
else
# only backup if necessary
print "Will backup wx and active files if necessary"
fi
backup_done=1;
cd $workspace/$dir
fi
if [[ ! -f $file ]]; then
echo "$filepath not found, skipping"
return 1
fi
if ! wx_pnt_filepath; then
# This is a new file so let's uncreate it.
answer='no'
cat <<-EOF
$filepath appears to be a new file.
Note, $command will remove its SCCS info from your
workspace and entry in the active list but will leave
the file in your workspace.
EOF
# yesno sets answer
else
# forced to yes
answer='yes'
fi
fi
# For later cleanup on exit
NEED_WS_CLEAN='y'
fi
fi
else
echo "skipping $filepath"
fi
else
echo "Not new, skipping $filepath"
fi # if ! wx_pnt_filepath
}
# Must be called via wx_eval
# resets a local file to the parent version
typeset efp
typeset -i force=0
case $1 in
-f) force=1;;
esac
if [[ $backup_done -eq 0 ]]; then
yesno "Do you want to backup files first?"
fi
else
# only backup if necessary
print "Will backup wx and active files if necessary"
fi
backup_done=1;
fi
if [[ ! -f $file ]]; then
print "$filepath not found, skipping"
return 1
fi
if wx_pnt_filepath; then
cat <<-EOF
Regarding: $filepath
$command will reset the file contents and sccs history to that of the parent:
$parentfilepath
and remove the entry from the active and renamed lists.
EOF
if [[ $filepath != $parentfile ]]; then
print "Note: local file will be reset to parent filepath."
fi
# yesno sets answer
else
# forced to yes
answer='yes'
fi
fi
if renamed; then
fi
fail "Error: cannot create $wxtmp/nametable.new ."
mv -f $wxtmp/nametable.new $wsdata/nametable || \
fail "Error: mv -f $wxtmp/nametable.new $wsdata/nametable failed."
# add to bringover list for more efficient bringover
else
fi
else
cat >&2 <<-EOF
Warning: skipping $filepath
as it appears to be new. Use 'uncreate' to remove this new file from the
workspace.
EOF
fi # if ! wx_pnt_filepath
}
# Detect the cyclic rename that causes Teamware problems.
# See 'man workspace' for more info
typeset new_filepath=$1 old_filepath=$2\
$old_filepath != $prev_new ]]; then
# Cyclic rename
return 0
fi
if [[ $new_filepath == $prev_old && $prev_new != $old_filepath ]]
then
# The new file was the old file of a previous rename
found_new=true
if $found_old; then
# Cyclic rename
return 0
fi
elif [[ $old_filepath == $prev_new &&
$new_filepath != $prev_old ]]; then
# The old filepath was the new filepath of a
# previous rename and this rename is not an undo
# (new filepath is diff from previous old
# filepath)
found_old=true
if $found_new; then
# Cyclic rename
return 0
fi
fi
# Not a cyclic rename
return 1
}
# Must be called via wx_eval
typeset efp
typeset -i force=0
case $1 in
-f) force=1;;
esac
if [[ $backup_done -eq 0 ]]; then
yesno "Do you want to backup files first?"
fi
else
# only backup if necessary
print "Will backup wx and active files if necessary"
fi
backup_done=1;
cd $workspace/$dir
fi
if [[ ! -f $file ]]; then
fi
# this is used a couple times so save escape_re value
if wx_pnt_filepath; then
# Not a new file (has a parent)
cat >&2 <<-EOF
Warning! $filepath
is in active list. You should run
"$ME reedit $filepath"
"$ME unedit $filepath"
which should remove it from the active list then run
"$ME $command $filepath".
Note, if you have made changes to this file that you want to keep, back
it up first.
$filepath not deleted.
EOF
return 1
fi
# See if this is already in the renamed list
if [[ -f $workspace/deleted_files/$filepath ]]; then
cat >&2 <<-EOF
Warning: $filepath
has already been deleted.
Check for deleted_files/$filepath
in $wxdir/renamed .
EOF
else
cat >&2 <<-EOF
Warning! the $ME renamed list appears to be corrupt.
EOF
"command again."
fi
fi
# we know filerm renames files under deleted_files/
print "$filepath deleted"
print
print "To recover $filepath do:"
print "'cd $workspace'"
else
print "There was an error while trying to delete $filepath"
fi
else
# This is a new file so let's remove it.
cat >&2 <<-EOF
Warning: $filepath
is in active list. You should run
"$ME uncreate $filepath"
which should remove it from the active list
then run "$ME $command $filepath".
$filepath not deleted.
EOF
return 1
fi
answer='no'
cat <<-EOF
Warning: $filepath
appears to be a new file.
Do you want to completely remove the file and SCCS info from
your workspace? (If you answer no, the file will just be
removed from the active list if it's in there. If you answer
yes, the file and associated SCCS history files will removed
from the active list and also removed entirely from the
workspace.)
EOF
# yesno sets answer
else
# forced to yes
answer='yes'
fi
echo "$filepath removed from workspace."
# For later cleanup, optional
NEED_WS_CLEAN='y'
fi
fi
fi
}
# create some local variables to avoid side effects
typeset efp old_filepath new_filepath
cd $workspace
old_filepath=$1
new_filepath=$2
then
return
fi
"while, please be patient."
# deal with directory to directory move
if [[ -d $new_filepath ]]; then
else
base=
fi
fail "sccsmv $old_filepath $new_filepath failed."
# remove previous renamed entry
# Old entries in workspace nametable so set this
# to clean up on exit
NEED_WS_CLEAN='y'
fi
# rename path of active entry
elif [[ -f $old_filepath && -d $new_filepath ]]; then
elif [[ -f $old_filepath && ! -f $new_filepath ]]; then
elif [[ ! -f $old_filepath ]]; then
fail "Error! $old_filepath not found."
elif [[ -f $new_filepath ]]; then
fail "Error! $new_filepath exists."
fi
}
# store literal filepath in local var. to avoid side effects
typeset efp old_filepath new_filepath
cd $workspace
old_filepath=$1
new_filepath=$2
if [[ ! -f $old_filepath ]]; then
fail "Error! $old_filepath does not exist."
elif [[ -f $new_filepath ]]; then
fail "Error! $new_filepath already exists."
else
if cyclic_rename $new_filepath $old_filepath; then
"for more info."
fi
if workspace filemv $old_filepath $new_filepath; then
if is_active $old_filepath; then
# In active list so update list with new
# file name
fi
fi
fi
else
fi
fi
}
# Note there are literal tabs in the []'s below so be careful when
# editing.
# file not in SCCS so return false (1)
if wx_pnt_filepath; then
else
# New file, no parent
egrep -v \
'^R [0-9]+(\.[0-9]+)+[ ].* (Codemgr|Fake)[ ]' |
fi
# an rmdel was done so return true
return 0
else
# no rmdel was done so return false
return 1
fi
}
# returns 0 (success) if an rmdel was done.
# Should be called via wx_eval().
if sccs_rmdel_done ; then
cat <<-EOF
Warning, it looks like 'sccs rmdel' was run on $filepath
This will cause a problem for Teamware. Please fix this.
Note, this can be fixed by doing '$ME reedit $filepath'
EOF
return 0
else
return 1
fi
}
typeset -i force=0
typeset arg comment_found=false
while getopts :f arg; do
f) force=1;;
"more info.";;
esac
done
# Check for keywords unless force is set or file is in
$wxdir/keywords.NOT 2>/dev/null &&
cat <<-EOF
The keywords check has detected a problem with $filepath
If this check should be skipped for this file, put the filepath in
${wxdir}/keywords.NOT.
See /net/wizard.eng/export/misc/general_docs/keyword_info.txt
for more info about keywords. Note, pay attention to the tabs.
EOF
return
fi
fi
# note hard tab in sed r.e.
comment_found=true
else
wx_show_comment >$wxtmp/comment && comment_found=true
fi
if $comment_found; then
echo $filepath
# file history so check in file
$file ||
else
# no file history so create file
$file ||
fi
else
print "\nError: no comments (NO_COMMENT) registered for $filepath"
else
fi
else
fi
fi
echo "$filepath already checked in"
fi
}
else
echo "$filepath not in SCCS"
fi
}
if [[ -w $file ]]; then
echo "$filepath (checked out)"
else
echo "$filepath (Warning, inconsistent state."
fi
elif [[ ! -f $file ]]; then
echo "$filepath (Warning, not found in $workspace)"
echo "$filepath (Warning, not in SCCS)"
else
echo "$filepath (checked in)"
fi
echo "Check-in comment:"
echo "Most recent delta: \c"
fi
echo "File name status:"
if renamed; then
# old is set by renamed
echo "Locally renamed, parent file = $parentfile"
elif lookup_parent $filepath; then
# parentfile is set by lookup_parent
echo "In parent ws, file renamed to: $parentfile"
else
echo "Same as parent."
fi
else
echo "New file (does not exist in parent ws)."
fi
echo
}
typeset _problem=0
*.adb) return;;
*.fdbg) return;;
*.in) return;;
esac
oldcopyright1='Copyright \(c\).* Sun Microsystems, Inc.'
# The backslash on the next line is just a hack so that
# 'wx copyright' on itself doesn't trigger a false positive.
oldcopyright2='Copyright\ .* by Sun Microsystems, Inc.'
reserved='All rights reserved.'
license='Use is subject to license terms.'
echo "old copyright with '(c)' in $filepath"
_problem=1
fi
_problem=1
fi
echo "Need two spaces between copyright and all rights "\
"reserved phrases in $filepath"
_problem=1
fi
echo "Only the current year should appear."
_problem=1
fi
_problem=1
fi
_problem=1
fi
return $_problem
}
# Get list of files with more that one delta when putback.
# set global multi_delta_list.
fi
}
typeset i newfiles only_multideltas=false
case $1 in
-m) only_multideltas=true;;
"info.";;
esac
echo "$wsdata/nametable not found, all files assumed new."
ok_to_proceed "Okay to continue with $command?"
fi
if $only_multideltas; then
# get_multi_deltas sets multi_delta_list
# set file_list for wx_eval wx_reedit_file below
fi
cd $workspace
for i in $file_list; do
if [[ ! -f $i ]]; then
fail "$i does not exist."
fi
if ! lookup_parent $i; then
if [[ -z $newfiles ]]; then
newfiles="$i"
else
fi
fi
done
if [[ -n $newfiles ]]; then
# If there are some new files, give user a warning
cat <<-EOF | ${PAGER:-more}
$ME thinks following files are new (not in parent workspace) and will
reset their file histories to version 1.1 (exit if this list isn't correct):
$(echo $newfiles)
EOF
ok_to_proceed "Okay to continue with $command?"
if ! $CHECKIN; then
cat <<-EOF
Hint, use '$ME redelget' to collapse/reset new file histories to version
1.1 since '$ME $command' will check out the file and '$ME delget' always
increments the file version doing the check in.
EOF
fi
fi
echo "WARNING: This workspace has the following children:"
echo
echo
echo "The reedit command will coalesce all children's deltas"
echo "into one, losing all delta comments in the process."
ok_to_proceed 'Are you sure you want to proceed?'
fi
echo
yesno "Do you want to backup files first?"
fi
echo "$command beginning..."
echo
echo
echo "$command complete"
echo
[[ $ACTSORT == sort ]] && do_active_sort=true
}
# Must be called via wx_eval
typeset comment_found=false
if [[ ! -f $file ]]; then
return
fi
echo $filepath
# Is there a parent file?
if wx_pnt_filepath; then
cp -p $parentsdot $wxtmp/s.$file ||
fail "Error: cannot cp $parentsdot $wxtmp/s.$file ."
# get the latest parent delta and comment and filter out
# certain fields removing trailing spaces
echo "Warning ${command}: skipping $filepath,"
echo "cannot get parent delta info"
echo
return 1
fi
# create a list of local deltas in the same format
# also removing trailing spaces
nawk '
/^D [0-9]+(\.[0-9]+)+ +[0-9][0-9]\/[0-9][0-9]/ {
if (delta != "") {
# print previous delta info
print delta comment;
}
delta=sprintf("%s %s %s %s ",$3, $4, $5, $8);
comment = "";
}
! /^D [0-9]+(\.[0-9]+)+ +[0-9][0-9]\/[0-9][0-9]/ {
# Add comment lines to comment variable
if (comment == "") {
if (NF > 0) {
comment = $0;
} else {
# empty lines require a space
# in comment.
comment = " ";
}
} else {
if (NF > 0) {
comment = comment " " $0;
} else {
comment = comment " ";
}
}
}
END {
if (delta != "") {
# print last delta info
print delta comment;
}
# If the latest parent delta doesn't appear in the local file
# then a bringover is required. Use fgrep because comment may
# have RE chars in it.
echo "\nWarning ${command}: skipping $filepath because:"
echo "parent's version of $filepath"
echo "is newer than child's -- bringover required."
echo
return 1
fi
else
fi
fi
# make copy of local file and copy parent's SCCS s. file over
# local.
else
fi
if $CHECKIN; then
fi
else
# reediting a new file.
# File needs to be checked out
fi
# clean up SCCS since we are going to create again.
fi
# clean up SCCS since we are going to create again.
wx_show_comment >$wxtmp/comment && comment_found=true
if $comment_found; then
echo $filepath
else
echo "\nError, no comments registered for $filepath"
else
fi
else
fi
fi
if $CHECKIN; then
# No need to check out file.
return
fi
else
fi
fi
}
#
# Warn if there are sccs delta issues
#
# must be run via wx_eval
typeset -i numdeltas
typeset newfile checkedout=false
if wx_pnt_filepath; then
# find number of deltas by subtracting the number in the parent
# from the local file (note the literal Control-A in the grep
# R.E.s below).
newfile=false
else
# checking a new file (note the literal Control-A in the grep
# R.E.)
newfile=true
fi
if [[ -z $numdeltas ]]; then
cat <<-EOF
Warning: the local file:
$filepath
does not appear to have a sccs delta history file or the sccs delta
history file is corrupt. If the local file is new try using:
"cd $dir"
"$ME create $file"
If the file is not new (exists in parent):
"cd $dir"
Save a copy of the local file
Remove the SCCS/[ps].$file history files
"bringover $filepath"
"$ME edit $file"
Then carefuly merge the saved copy of local file with the
file brought over from parent. Hint: twmerge is a good merge
tool.
EOF
return 1
fi
[[ -f SCCS/p.$file ]] && checkedout=true
# Note the use of hard tabs in the messages
case $numdeltas in
0) if $checkedout; then
# file is checked out so assume there
# will be 1 delta when checked in.
return 0
else
if [[ -n $parentfilepath ]]; then
if cmp -s $file $parentfilepath; then
cat <<-EOF
Warning: the local file:
$filepath
and the parent file:
$parentfilepath
content are identical. There are no new deltas in the local file.
If this file is no longer required in the active list use:
"cd $dir"
"$ME reset $file"
to remove file from the wx state files (active list, etc...)
EOF
else
cat <<-EOF
Warning: the local file:
$filepath
and the parent file:
$parentfilepath
have the same number of deltas but contents differ. A bringover may be
required before putback.
EOF
fi
else
cat <<-EOF
Warning: the local file:
$filepath
is new but doesn't appear to contain any deltas. The SCCS delta history file
may need to be recreated. If so:
"cd $dir"
"rm SCCS/s.$file"
"$ME create $file"
EOF
fi
return 1
fi ;;
1) if $checkedout; then
cat <<-EOF
Regarding $filepath
Warning! There may be more than 1 delta when you check this file in
(currently checked out). Run '$ME redelget' on this file to collapse
the deltas and check in with 1 delta unless putting back > 1 bug.
EOF
return 1
else
return 0
fi ;;
-*) # a negative number means the parent has more deltas
cat <<-EOF
Regarding $filepath
Warning! The parent file has more deltas than the local file.
You should bringover the local file to fix this.
EOF
;;
*) if $newfile && $checkedout; then
cat <<-EOF
Regarding $filepath
Warning! There may be more than 1 delta when you check this file in
(currently checked out). Run '$ME redelget' on this file to collapse
the deltas and check in with 1 delta unless putting back > 1 bug.
EOF
else
cat <<-EOF
Regarding $filepath
Warning! There is more than 1 delta. Run:
'cd $dir; $ME redelget $file'
to collapse the deltas on this file and check in with 1 delta unless
putting back > 1 bug.
EOF
fi
return 1;;
esac
}
*.[ch]) ;;
*) return;;
esac
(cd $workspace;
cstyle ${CSTYLE_FLAGS} $args $filepath >\
}
*.java) ;;
*) return;;
esac
(cd $workspace;
jstyle ${JSTYLE_FLAGS} $args $filepath >\
}
fi
fi
}
typeset backup_dir_file
# if backup_dir hasn't been set already...
# use the backup dir specifier in the wx/
if [[ ! ( -f $backup_dir_file && -r $backup_dir_file &&
-s $backup_dir_file ) ]]; then
fail "$backup_dir_file: missing, empty, or not readable"
fi
fi
fail "$backup_dir: missing, not a directory, or bad permissions"
fi
}
#
# disallows the existance of two incarnations of the same file (i.e.
# n.clear.tar and n.clear.tar.gz)
#
# It's up to the user to straighten things out if the above conditions are
# violated. The only time that is a problem is if they are trying to
# restore a version which violates the above rules.
#
# Takes one argument, the version number.
#
# Returns:
# (return code) 0 if exists and consistent,
# 1 if not found,
# 2 if inconsistent
# b_clear, b_sdot, b_pdot On success, the full path to the clear, sdot
# and pdot files comp, ext The compression program for and
# extension of said files
#
_version=$1
found=false
bad=false
#
# these arrays must be in sync with:
# 1. the immediately following _count variable
# 2. wx_find_last_backup's egrep expression
# 3. wx_backup's "$args" handling.
# 4. wx_find_compression_progs's programs
#
set -A _extns "" ".gz" ".bz2"
_count=3
idx=0
if $found; then
bad=true
else
found=true
fi
fi
echo "$backup_dir: $_clear exists; $_sdot does not"
bad=true
echo "$backup_dir: $_sdot exists; $_clear does not"
bad=true
echo "$backup_dir: $_pdot exists; $_sdot does not"
bad=true
fi
done
if [[ ! -f $_b_renamed && -f $_b_active ]]; then
# Can determine compression only
return 1
fi
if [[ -f $_b_renamed && -f $_b_active && -f $_b_new &&
-f $_b_local_nt ]]; then
found=true
else
bad=true
fi
$bad && return 2
$found || return 1
if [[ -f $backup_dir/$clear$ext && -f $backup_dir/$sdot$ext ]]; then
else
fi
# It's not an error if this doesn't exist.
if [[ -f $backup_dir/$pdot$ext ]]; then
else
fi
# It's not an error if this doesn't exist.
if [[ -f $backup_dir/$not ]]; then
else
fi
# It's not an error if this doesn't exist.
if [[ -f $_b_sort ]]; then
else
fi
return 0
}
#
# finds the number of the last backup.
#
# Returned in $result, which is -1 if no backups are found
#
#
# The list of extensions in the egrep expression must be in sync
# with wx_check_backup's arrays
#
result=`ls -1 $backup_dir | egrep \
'^[0-9][0-9]*\.((pdot|sdot|clear)\.tar($|\.gz$|\.bz2$)|active|renamed|new|local_nametable$)'| \
}
#
# wx_do_backup
# Returns 0 on successful backup, 1 if nothing to backup, 2 any other
# error.
#
_type=$1 # type of files (for user)
_out=$2 # file to write to
_evalarg=$4 # arg to wx_eval to get the correct file list
echo
echo
if [[ -z $backupfiles ]]; then
echo "Note, nothing to backup."
return 1
fi
( tar cvf - $backupfiles 2>$BACKUP_ERRORS || \
else
fi
return 0
}
_type=$1 # type of files (for user)
_in=$2 # file to read from
echo
echo
#
# if decompression fails, echo a bad value to make tar fail
#
else
fi
return 0
}
#
# do renames in a workspace from a backup set
#
typeset _in=$1 # file to read from
echo "$wsdata/nametable not found, not doing renames."
return 0
fi
echo
echo "Restoring renamed files from $_in"
echo
# Note this assumes we're staring in $workspace
# get current local file name
if [[ -z $current ]]; then
# nothing to rename
continue
fi
# rename not needed
continue
fi
if [[ ! -f $new ]]; then
fi
else
if [[ -f $current ]]; then
cat >&2 <<-EOF
Warning: $current
and $new
files both exist in current workspace with the
same hash. The restored renamed list should be recreated by running:
'$ME update -r'
Skipping rename of $current
to $new
EOF
fi
fi
done < $_in
return 0
}
typeset orig_file_list ws_file back_file
typeset newer=false
case $1 in
echo "Backup dir is $backup_dir"
echo "Backup dir is $backup_dir"
cd $origdir
return ;;
-t) newer=true
# backup if wx files are newer than last backup.
# Implies use of default compression and no
# interaction. Doing shift so case further down
# won't see -t.
shift;;
esac
# save state in case wx_backup called from another command.
# we always backup the active files.
if [[ ! -s $wxdir/renamed && -z $file_list ]]; then
echo "There isn't anything to backup."
return 0
fi
# must be in workspace to do backup
cd $workspace || fail "Error: cannot cd $workspace"
if $newer; then
# get latest wx state files and active files but skip
# get latest backup.
back_file=$(ls -1t $backup_dir/*|head -1)
$ws_file -nt $back_file ) ]]
then
: # continue with backup
else
print "Skipping backup, last backup newer than wx"\
"files."
cd $origdir
return 0
fi
fi
if [[ ! -w $backup_dir ]]; then
fail "$backup_dir: not writable"
fi
if wx_find_last_backup; then
else
version=0
fi
#
# This must be in sync with wx_check_backup's arrays
#
case $1 in
"-") shift;; # treat this as use default compression
"") ;; # treat this as use default compression
esac
if [[ -z "$1" ]]; then
#
# default to the compression of the previous backup
#
ext=
comp=
else
# A return of 1 is okay
if [ $? -gt 1 ]; then
"cannot determine previous "\
"compression."
if $newer; then
# Assume we want backup.
answer="yes"
else
"compression?"
fi
echo "No backup done."
cd $origdir
return
fi
ext=
comp=
fi
fi
fi
echo "${comp}: missing. defaulting to no compression"
ext=
comp=
fi
#
# If anything goes wrong, clean up after ourselves
#
trap "/usr/bin/rm -f $b_clear $b_sdot $b_pdot $b_active $b_renamed $b_new $b_local_nt $b_not_files $b_sort; exit 1" 0 1 2 3 15
fail_msg='failed. Cleaning up. '
#
# let the user know what's going on.
#
sdot_cmd='
_sdot="SCCS/s.$file";
_file="$dir/$_sdot";
if [[ -f $_sdot ]]; then
echo "$_file";
else
echo "$_file: not found" >&2;
fi
'
pdot_cmd='
_pdot="SCCS/p.$file";
_sdot="SCCS/s.$file";
_file="$dir/$_pdot";
if [[ -f $_pdot ]]; then
echo "$_file";
elif [[ ! -f $_sdot ]]; then
echo "$_file: not checked in" >&2;
elif [[ -w $file ]]; then
echo "$_file: not found but $file is writable!" >&2;
fi
'
# Do this first in case there are no active files
echo
echo "Saving renamed file list to $b_renamed"
echo
cp $wxdir/renamed $b_renamed || fail "$b_renamed: $fail_msg"
if [[ -f $wxdir/local_nametable ]]; then
echo
echo "Saving local_nametable to $b_local_nt"
echo
fi
if [[ -f $wxdir/sort_active ]]; then
print
print "Saving sort_active to $b_active"
print
fi
echo
echo "Saving .NOT files to $b_not_files"
echo
tar -cf $b_not_files wx/*.NOT || fail "$b_not_files: $fail_msg"
fi
# Are there any active files to backup?
if [[ -n $file_list ]]; then
echo
echo "Saving new list to $b_new"
echo
# It's not fatal if the backup error for pdot files is
# 'no files to backup'. This is because it's possible
# that the active files aren't checked out so there
# won't be any pdot files.
if [[ $? -gt 1 ]]; then
fi
fi
echo
echo "Saving active file list to $b_active"
echo
trap - 0 1 2 3 15
rm -f $BACKUP_ERRORS
# restore file_list state.
cd $origdir
return 0
}
typeset force=0
case $1 in
-f) force=1;;
esac
cat <<-EOF
Warning, the restore command will overwrite several files including the
active and renamed lists. This could be a problem if you have made
changes to your workspace and $ME related files following the last
backup. It may be a good idea to run:
$ME update
after the restore so that the active and renamed lists are updated with
the new changes in the workspace.
Also, restore may perform workspace renames in this workspace if it
finds that the existing file has a pathname that differs from that in
the backup being restored.
EOF
ok_to_proceed "Do you really want to do the restore?"
fi
if wx_find_last_backup; then
else
fail "$backup_dir: no backups found"
fi
fi
#
# wx_check_backup sets $comp, $b_clear, and $b_sdot when successful
#
if wx_check_backup $version; then
:
else
if [[ $? -eq 2 ]]; then
"inconsistent version"
else
fail "$backup_dir: Unable to find version $version"
fi
fi
fi
# must be in workspace to do restore
[[ -f $b_renamed ]] || fail "$b_renamed: missing"
[[ -r $b_renamed ]] || fail "$b_renamed: not readable"
if [[ -f $b_clear ]]; then
fi
if [[ -f $b_sdot ]]; then
fi
if [[ -f $b_pdot ]]; then
fi
if [[ -f $b_local_nt ]]; then
[[ -r $b_local_nt ]] || fail "$b_local_nt: not readable"
fi
if [[ -f $b_not_files ]]; then
[[ -r $b_not_files ]] || fail "$b_not_files: not readable"
fi
if [[ -f $b_sort ]]; then
fi
#
# If something goes wrong, we need to make sure they notice, so
# we make the message quite visible, and echo a BELL.
#
fail_msg='Extraction failed.
*DANGER* *DANGER* workspace could be corrupted *DANGER* *DANGER*'
if [[ -n $b_sort ]]; then
cp $b_sort $wxdir/sort_active || \
fi
# Need to move active files that are renamed in current ws back to
# their name in the active list to avoid two copies of the file
# occuring when the clear files are restored below.
if [[ -n $b_not_files ]]; then
fi
# It's not an error if there is no clear backup.
if [[ -f $b_clear ]]; then
fi
# It's not an error if there is no sdot backup.
if [[ -f $b_sdot ]]; then
fi
# It's not an error if there is no pdot backup.
if [[ -f $b_pdot ]]; then
fi
# Do some integrity checking
# If file is not writable then assume the
# file is checked out and a wx restore is done
# and the restored file was not checked out when
# it was backed up.
cat <<-EOF
Warning! $filepath is in inconsistent state.
$filepath is not writable and SCCS/p.$file exists.
Removing SCCS/p.$file
To edit the file run '$ME edit $filepath'
EOF
cat <<-EOF
Warning! $filepath is in inconsistent state.
$filepath is writable
but there is no SCCS/p.$file
EOF
yesno "Should this file be checked out?"
fi
fi
else
echo "Setting $filepath read only"
fi
fi
else
echo "\nWarning! Could not check sccs state of "\
fi
done
}
if wx_pnt_filepath; then
:
else
fi
if $show_comments && wx_show_comment > $wxdir/comment; then
else
fi
}
#
# Check on RTI status for bug ID's found in active list comments.
#
# gate contains the gate dir, not full path
if [[ -f $wxdir/rtichk.NOT ]]; then
print "\nSkipping RTI check:"
return
else
print "\nDoing RTI check:"
fi
while getopts :N opt; do
esac
done
# Is the parent a patch gate?
rtitype='Patch'
suffix='P'
gatetype='Patch'
fi
# Is the parent a test gate?
rtitype='RTI'
gatetype='RTI'
fi
# Use new RTI query tool if there's a gate and there is an
# executable webrticli.
# Note, webrticli needs a gate arg to correctly determine status.
if [[ -z $gate ]]; then
cat >&2 <<-EOF
Warning: cannot find a parent gate, skipping webrticli checking. Will
check RTI status using old style checking...
EOF
else
if [[ -z $webrticli ]]; then
# if webrticli isn't in the PATH, try default path
fi
if [[ -x $webrticli ]]; then
usewebrti='true'
else
cat >&2 <<-EOF
Warning: cannot find webrticli, skipping webrticli checking. Will check
RTI status using old style checking...
EOF
fi
fi
# Use wx_summary to output bug ID's in active list comments,
# redirecting warnings about non-bug ID's to file for later use.
((i = 0)) # init bugs array index
# skip this bug since it's accepted.
# Increment bugs[] index.
((i = i + 1))
continue
fi
if $usewebrti; then
# try new RTI query interface
$webrticli -g $gate RTIstatus $bug > $wxtmp/webrticli.out 2>&1
rc=$?
# paranoid: should only have 1 line
cat <<-EOF
Warning: for bug $bug the RTI status can not be determined using webrtcli.
Please contact the gatekeeper. The output of webrtcli is:
EOF
else
cat <<-EOF
Warning: for bug $bug the RTI $rti is a $rtitype type but the parent gate
$gate is a $gatetype gate. A $gatetype RTI must be submitted to putback
bug $bug to $gate.
EOF
# found accepted bug
bugs[i]='accept'
fi
fi
# skip old-style checking
((i = i + 1))
continue ;;
1) # Serious system related problem has occured
cat <<-EOF
Warning: for bug $bug the RTI status can not be determined using webrtcli.
Please contact the gatekeeper. The output of webrtcli is:
EOF
# skip old-style checking
((i = i + 1))
continue ;;
5) # Incorrect gate name specified.
# See if bug can be found at all.
$webrticli RTIstatus $bug > /dev/null 2>&1
if [[ $? -ne 3 ]]; then
# If the return is something
# other than the CR
# can't be found (3), issue
# a warning.
cat <<-EOF
Warning: for bug $bug webrticli was unable to map current parent gate $gate
to a RTI release. Please contact the gatekeeper. The output of webrtcli is:
EOF
# skip old-style checking
((i = i + 1))
continue
fi ;;
# Dealing with other error codes is
# tricky because the user may be using
# the old school rtitool and we don't
# want to needlessly warn.
esac
fi # end if $usewebrti
# If bug wasn't found above then fall back to old school rti lookup...
# XXX if it is determined at some point that everyone is
# using the new web RTI tool then the fallback code can
# be removed.
# Old style RTI lookup...
# See if there is an accepted rti (the filename indicates state)
# make sure the rti dir is mounted
cat <<-EOF
Warning: cannot check status of RTI's. Check with the gatekeepers to see why
$rtidir
is not accessible.
EOF
return 1
fi
rtifile="${rtidir}/${suffix}${bug}.accept"
# This bug was accepted since the
# rtifile exists
bugs[i]='accept'
((j = 0))
while (( j < ${#bugs[@]} )); do
# Let's see if any other bugs
# were accepted in the rti file
then
bugs[j]='accept'
fi
((j = j + 1))
done # while [[ j -lt ${#bugs[@]} ]]
# stop checking in rtidirs and go to next bug
break
fi # if [[ -f "$rtifile" ]]
done # rtidir in set of rtidirs
# Increment bugs[] index.
((i = i + 1))
done # for bug in ${bugs[@]}
cat <<-EOF
Warning: there doesn't seem to be an approved $rtitype RTI for the
following bug IDs listed in your active list comments (see '$ME bugs').
Make sure your $rtitype RTI is approved before putting back to an
official ON gate (hint, use either <http://webrti.sfbay> or 'rtitool'
depending on the project to submit an $rtitype RTI):
EOF
# set return code to indicate problem
fi
print $bug
fi
done
if [[ -s $wxtmp/bugwarnings ]]; then
cat <<-EOF
There are issues with the bug ID format in the
$wxdir/active file.
Please fix the following and run rtichk again:
EOF
fi
if [[ $i -eq 0 ]]; then
print "\nWarning: no bug ID's in active list."
fi
return $rc
}
#
# Do a Teamware putback of active and renamed files.
#
# Use pbargs array to store Teamware putback args.
# verbatim is for -v verbatim flag which doesn't get passed to
# putback.
typeset nolookup=false
if $FILES_PASSED; then
# use the user specified files
else
# use the pblist (active and renamed)
fi
case $i in
# Force the putback (no user interaction)
f) force=true;;
n) narg=true
pbargs[${#pbargs[@]}]="-$i" ;;
q) pbargs[${#pbargs[@]}]="-$i" ;;
p) pbargs[${#pbargs[@]}]="-$i"
pbargs[${#pbargs[@]}]="$OPTARG"
# setting parent for user prompt below
# -v doesn't get passed to putback.
"for more info.";;
esac
done
if ! $narg; then
# real putback
# get pb comments, will be used later.
if ! wx_summary -p $verbatim $nolookup >$wxtmp/pb_comments; then
# Fail if comments have problems.
"to bypass this check."
fi
if ! $force; then
# not force so give more warning.
( # using subshell to capture stdout to file.
cat <<-EOF
Remember to run '$ME pbchk' before doing a final putback (esp. if
doing a putback to an official ON gate). Make sure your workspace
parent ($parent) is correct.
It's a good idea to check your code diffs before putback ('$ME pdiffs').
Also, run '$ME $command -n' and check for conflicts before doing the
final putback.
EOF
cat <<-EOF
Don't forget the ARC ID info in your active list comments if there is an
ARC case associated with your putback.
EOF
fi
echo "\nThe putback comment will be:"
print "========== End of putback comments ======="
# Output warning if RTI isn't approved.
print "========== End of RTI check output ======="
cat <<-EOF
The following files will be used for putback:
$pbfiles
EOF
fi
fi
# Do the putback, passing in active list comments if required.
cd $workspace
if $narg; then
# Don't use putback comment if -n is given (trial putback)
else
# feed active list comments into real putback
fi
return
}
# List files that are checked out but not in active list.
# if $wxtmp/checked_out is 0 bytes then return
[[ -s $wxtmp/checked_out ]] || return
if $do_header; then
echo "\nWarning, the following active list files are"\
"checked out:"
do_header=false
fi
echo "$outfile"
done
do_header=true
if $do_header; then
cat <<-EOF
Warning, the following files are checked out but not in active list
(Run "$ME update -q" to add them to the active list):
EOF
do_header=false
fi
echo "$outfile"
done
}
#
# run Teamware resolve and do reedit only on merged files.
#
typeset merged_file
# clear the file_list, will be set below
# run Teamware resolve
# successfully merged.
# set file_list to files that were merged.
# set file_list for wx_eval later.
fi
done
if [[ -n $file_list ]]; then
ok_to_proceed "Re-edit merged files to collapse merge deltas?"
echo "Re-editing merged files"
echo
echo
echo "Re-edit complete"
echo
else
echo "No merged files to re-edit."
fi
}
#########################################################################
#
# Main
#
#
# Do some initial sanity checking and set up.
#
# Set the lang to standard English so wx doesn't get confused.
export LC_ALL=C
# Turn on debugging output early
typeset -ft $(typeset +f)
set -x
fi
export ME
# Want to use xpg4 versions of fgrep and grep
else
fi
unset CDPATH # if set "cd" will print the new directory on stdout
# which screws up wx_eval.
# output usage now to avoid unnecessary checking below.
fi
# output version now to avoid unnecessary checking below.
exit 0
fi
# Note, PUTBACK can be set to "cm_env -g -o putback" to use Casper Dik's
# turbo-dir.flp scripts to speed up thorough updates.
# ws was used.
# normalize the workspace name.
workspace=$(cd $CODEMGR_WS && workspace name)
# If the current dir is in a workspace check that it is the same
# as CODEMGR_WS.
cat <<-EOF
Warning, $ME will use $ME files in workspace $workspace (the current
directory is not in this workspace).
EOF
ok_to_proceed "Okay to proceed?"
fi
fi
else
# If current dir is in a workspace then use output of workspace
# name as current ws.
export CODEMGR_WS
fi
fi
"\"cd <workspace>\"."
wxdir=${WXDIR:-$workspace/wx}
else
fi
if [[ $parent == *:* ]]; then
parentnode=${parent%%:*}
if [[ $parentnode == $node ]]; then
else
fi
fi
# Store backup state
# store state if new files are deleted
NEED_WS_CLEAN='n'
# XXX doing this because keywords doesn't work on new files
# Note doing the echo so the tabs are apparent
# file that contains comments for use in create and checkin
# mode for updating comments in active list
comment_mode="replace"
# global for reedit command, don't checkin by default
CHECKIN=false
# Indicates that the parent nametable cache needs refreshing
need_pnt_refresh=true
# Indicate whether file args were specified
FILES_PASSED=false
# Used to store files that have more than one delta compared to parent
# Used to bringover any files just before exit of wx
# should codereviews include delta comments?
show_comments=true
# Determines if active list should be sorted by default
# If sort_active contains true then we sort the active list on updates.
else
fi
# These are set depending on what needs sorting
do_renamed_sort=false
do_active_sort=false
# Places to search for approved RTIs
# Places to search for approved Patch RTIs
#
# main section
#
# Get wx command
command=$1
shift
apply|eval) subcommand=$1; shift;;
echo "Note, nits is a subset of pbchk checks.";;
esac
orig_args="$@"
args=
typeset tmp_file_list tmp_args
#
# Some subcommands pass through all arguments.
#
esac
# Parse args
while [ $# -gt 0 ]; do
case $1 in
-c|-C)
# set global comment_file
comment_file=$2;
fi
"Run 'wx help' for info."
fi
"for comments."
# shift past the comment_file arg
shift
-z $WXDIFFCMD ]]; then
if [[ $2 != +([0-9]) ]]; then
# provide default context value for
# compat with old wx
else
# shift past context lines arg
shift
fi
else
fi;;
-D) : ;; # debug flag, already processed
# 2nd arg is a workspace
else
"Run 'wx help' for info."
fi
# shift past the parent ws arg
shift
else
# for other commands -p doesn't have a arg
fi;;
# 2nd arg is the version #
# shift past 2nd arg
shift
else
# for other commands -r doesn't have a arg
fi;;
else
silent=-s
fi;;
show_comments=false
else
fi ;;
file_list="$1"
else
file_list="$file_list $1"
fi;;
esac
shift
done
fi
exit
fi
echo "Workspace does not appear to be initialized for $ME."
echo "The initialization process will create a few files under"
echo "$wxdir but will not otherwise affect your workspace."
ok_to_proceed 'OK to proceed?'
# wx_init modifies file_list so save current value
# save off args and set to null to avoid side effects
args=
# restore original file list and cd to original dir in case there's
# a command to execute.
cd $dot
fi
if [[ ! -f $wxdir/local_nametable ]]; then
fi
# Doing this for backward compat since old wx doesn't have a renamed list
# if 'wx update' or 'wx update -r' is the command then skip
# renamed list creation since it will happen anyway.
cat <<-EOF
$ME needs to create a renamed file list. If you are sure that no files
were renamed or deleted in the current workspace then answer no to the
following question.
EOF
yesno "Okay to search for renamed files (can be slow)?"
then
wx_update -r
else
fi
fi
fi
# Doing this for backward compat since old wx doesn't have a new list
cat <<-EOF
$ME needs to create a new-file list (cache names of newly created
files). Please be patient.
EOF
# Avoid a putback -n which is slow, just use lookup_parent()
while read filepath; do
if ! lookup_parent $filepath; then
fi
done
echo "\nNew files:"
echo
fi
# If the backup dir was specified as a file arg...
fi
# unset file_list since this file arg has been processed here.
unset file_list
# Do this command before wx_active is run because the active list
# may be corrupt.
cd $wxdir
"them from the active list."
ok_to_proceed 'Do you REALLY want to do this?'
fi
# -v verbatim is not valid for these commands
fail "Invalid flag -v. Run 'wx help' for info."
fi
fi
fi
"remove them from the active list."
ok_to_proceed 'Do you REALLY want to do this?'
fi
fail "Error: cp $wsdata/nametable $wxtmp/nametable.orig failed."
fi
else
for basefile in $base_file_list; do
# normalize the filepaths
if [[ -d $basefile ]]; then
else
fi
if [[ ! -d $basedir ]]; then
fail "Error: $basefile isn't in current workspace: $workspace."
fi
else
fi
done
FILES_PASSED=true
fi
# skip nits/pbchk checks for files listed in $command.NOT
for _a_file in $file_list; do
then
"$_a_file (skipping)"
else
fi
done
fi
[[ -z $file_list ]] && exit 0
fi
# This is where the commands are executed.
cd $dot
renamed) list_renamed $args ;;
sccs get -s -p -k $filepath |
${WXDIFFCMD:-diff} $args - $filepath';;
tdiffs) ## As diffs but also shows new files.
## Read names of new files into space separated list.
while read new_file
do
new_files="${new_files}${new_file} "
else
new_files=""
fi
## all lines will appear to have been added.
wx_eval -r 'print -- "\n------- $filepath -------\n";
if [[ ${new_files} == *"${filepath} "* ]]; then
else
sccs get -s -p -k $filepath |
${WXDIFFCMD:-diff} $args - $filepath;
fi';;
## Parent Diffs - Compare with parent file. For
## 'tpdiffs' when the parent file does not exist the
## child file is assumed new and compared to
## added.
wx_eval '
print -- "\n------- $filepath -------\n";
if wx_pnt_filepath; then
echo "Index: $filepath";
${WXDIFFCMD:-diff} $args $parentfilepath
$workspace/$filepath;
$workspace/$filepath;
else
print "New file (does not exist in parent).";
fi';;
echo $filepath;
if wx_pnt_filepath; then
${EDITOR-vi} $args $parentfilepath;
else
echo "New file (does not exist in parent)";
fi';;
mv) wx_mv $file_list;;
putback|pb) wx_putback $args;;
bugs) wx_summary -ao $args;;
arcs) wx_summary -bo $args;;
pbcom) wx_summary -po $args;;
cstyle) echo "\nDoing cstyle check:"
export CSTYLE_INDEX=0;
wait;
;;
jstyle) echo "\nDoing jstyle check:"
export JSTYLE_INDEX=0;
wait;
;;
cd $workspace;
for filepath in $file_list ; do
then
echo "$filepath (skipping)"
else
fi
fi
done
hdrchk -a $args $hdrchk_files ;;
echo "\nDoing keywords check:";
cd $workspace;
for filepath in $file_list ; do
then
echo "$filepath (skipping)"
else
fi
done
keywords -p $args $keyword_files;;
echo "\nDoing CDDL block check:";
cd $workspace;
fi
#
# Split the file list into new files and existing files.
# New files must have a CDDL block whereas existing files don't
# necessarily have to have a block, but if they do it must be
# valid. Both sets of files are subject to cddlchk.NOT
# exception processing.
#
old=""
new=""
for filepath in $file_list; do
if wx_pnt_filepath $filepath; then
else
fi
done
;;
wx_eval '
then
echo $filepath;
fi';;
e) cd $wxdir; exec ${EDITOR-vi} $orig_args;;
ws) cd $wsdata; cat $orig_args;;
*) ring_bell;
echo "Command not found. Run 'wx help' for command list.";
exit 1;;
esac
done
# clean up the nametable
"take a while."
workspace updatenames >&2
fi
if [[ -n $bofilelist ]]; then
fi
# save sorting for last for some speed up.
if $do_renamed_sort; then
fi
if $do_active_sort; then
fi
fi