#!/bin/sh # # RM_EMPTY_BRANCH.sh # # When cleartool uncheckout, rmbranch or rmver are performed # remove the parent branch if the parent branch has no # checkouts, sub-branches or labeled versions associated # with it IFF (IF AND ONLY IF) the uncheckout file is # the 0th element or removing the branch causes the parent # branch to also be "empty". # # NOTE: Also submitted as ftp.atria.com/contrib/T0031 # # Author: Charles W. Clarke III (ABS) # email: charles@abs-consulting.com # URL: http://www.abs-consulting.com # Date: Sep. 17, 1996 ############################################################ # History: 09/17/96 : Created for A Better Solution, Inc. ############################################################ if [ $CLEARCASE_OP_KIND = "uncheckout" ] then case $CLEARCASE_ID_STR in */0) : ;; *) exit 0 ;; esac fi BRANCH_DIR="`dirname $CLEARCASE_XPN`" if [ `ls $BRANCH_DIR | wc -w` -ne 2 ] then ######################################################## # There are either checked-out versions of the file or # # other branches created off of this branch or labeled # # versions. # ######################################################## exit 0 else ##################### # Remove the branch # ##################### case $BRANCH_DIR in */main) ######################################## # Don't attempt to delete /main branch # ######################################## exit 0 ;; *) ################################## # Delete the empty parent branch # ################################## cleartool rmbranch -force \ -c "Automatic removal of empty branch via trigger..." \ $BRANCH_DIR exit 0 ;; esac fi