Browse Source

Implemented sde rename target

misl/sde-wrapper
Minto van der Sluis 17 years ago
parent
commit
30df04aa34
1 changed files with 71 additions and 1 deletions
  1. +71
    -1
      lib/sde-rename/target.in

+ 71
- 1
lib/sde-rename/target.in

@ -15,5 +15,75 @@
#Description: Renames an existing target identified by item to a new name.
#Alias: tgt
echo_abort 1 "Not yet implemented"
# Parse commandline arguments.
force=
sourcename=
destinationname=
quiet=
verbose=
while [ "$1" ] ; do
case "$1" in
-f|--force)
force=$1 ;;
-q|--quiet)
quiet=$1 ;;
-v|--verbose)
verbose=$1 ;;
-*)
echo_abort 1 "Option $1 not recognized" ;;
*)
# Only source and destination should be remain now.
case "$#" in
2)
sourcename=$1; shift
destinationname=$1 ;;
1|*)
echo_abort 1 "Exactly 2 arguments allowed not $#: $@" ;;
esac
break ;;
esac
shift
done
# Check for mutually exclusive options.
if [ -n "$verbose" -a -n "$quiet" ]; then
# No source config no action.
echo_abort 1 "Options '$verbose' and '$quiet' are mutually exclusive"
fi
# Determine locations where source and destination config info should go.
srclocation=$(sde_target_dir $sourcename)
dstlocation=$(sde_target_dir $destinationname)
# Check if the source target really exists.
if [ ! -d $srclocation ]; then
# No source config no action.
echo_abort 1 "Source target $sourcename does not exist"
fi
# Determine if the there already exists a target under the new name.
if [ -d $dstlocation -a -z "$force" ]; then
# Yes, the destination already exists and we are not
# allowed to overwrite it.
echo_abort 1 "Destination target $destinationname already exists"
fi
# If destinatin name already exists remove it.
if [ -d $dstlocation ]; then
# Given destination already exists. Remove it first.
# TODO: check if 'sde clean' works properly.
sde clean target $force $quiet $verbose $destinationname
fi
# if destination still exists it was/is under revision control and
# cannot be removed.
if [ -d $dstlocation ]; then
# Yes, the destination still exists.
echo_abort 1 "Destination target $destinationname already exists" \
"and can NOT be replaced, since it is under revision." \
"however it has been cleaned."
fi
# Now we can safely move the source target to the destination
echo_msg "Renaming target from $sourcename to $destinationname"
mv $srclocation $dstlocation

Loading…
Cancel
Save