#!/bin/bash set -u Version=1.0.4 function bail () { echo -e "\nError: ${1:-Unknown Error}\n"; exit ${2:-1}; } declare Owner=perforce_software declare Product=Unset declare Branch=Unset declare OutFile=/tmp/tmp.output.mdcu.$$.$RANDOM declare ChangeFile=/tmp/tmp.change.mdcu.$$.$RANDOM declare Changelist= [[ $PWD != "/pub/"* ]] && bail "This script assumes a workspace root starting with '/pub'." Product=${PWD#/pub/} Product=${Product%%/*} Cmd="p4 -s opened /pub/$Product/..." echo -e "Checking for any opened files:\n\t$Cmd" $Cmd < /dev/null > $OutFile 2>&1 egrep "error: .* - file\(s\) not opened on this client." $OutFile > /dev/null if [[ $? -ne 0 ]]; then cat $OutFile bail "Files are checked out. Run only when no files are checked out. Aborting." fi echo Verified: No files checked out. if [[ $PWD == *"/dev"* ]]; then Branch=dev elif [[ $PWD == *"/ntx64"* ]]; then Branch=ntx64 else bail "Could not determine branch from current dir [$PWD]. Aborting." fi BranchSpec=$Owner-$Product-$Branch Cmd="p4 -s merge -n -b $BranchSpec" echo -e "Doing Merge Down Preview with:\n\t$Cmd" $Cmd < /dev/null > $OutFile 2>&1 grep 'error: All revision(s) already integrated.' $OutFile > /dev/null if [[ $? -ne 0 ]]; then cat $OutFile bail "Merge work required. Aborting." fi echo -e "\nVerified: No merge down required. Proceeding with Copy Up." # Do some quick inline Perl to generate a changelist, but ignore the # jobs picked up by JobView. p4 change -o | perl -e "while(<>){ last if /^Jobs:/; s/<enter description here>/Copy Up using 'p4 copy -r -b $BranchSpec'./g; print; }" > $ChangeFile p4 change -i < $ChangeFile > $OutFile 2>&1 egrep 'Change \d+ created.' $OutFile if [[ $? -ne 0 ]]; then cat $OutFile bail "Failed to create pending changelist. Aborting." fi # Parse the generated changelist number from the output file. Changelist=$(cat $OutFile) Changelist=${Changelist#Change } Changelist=${Changelist%% *} Changelist=$(echo $Changelist) Cmd="p4 -ztag -F %change% interchanges -r -b $BranchSpec" $Cmd < /dev/null > $OutFile 2>&1 cat $OutFile echo -e "\n============\nDescribing changes to help build a good Promotion changelist description.D" while read c; do Cmd="p4 describe -s $c" $Cmd done < $OutFile Cmd="p4 -s copy -c $Changelist -r -b $BranchSpec" echo -e "Doing Copy Up with:\n\t$Cmd" $Cmd < /dev/null > $OutFile 2>&1 cat $OutFile /bin/rm -f $OutFile $ChangeFile
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 25932 | C. Thomas Tyler |
Adjusted mdcu.sh script because 'Files not checked out' and 'All revisions already integrated' messages were changed from 'error:' to 'warning:' along the way (which is more appropriate). Also made mdcu.sh shellcheck compliant (v0.6.0). |
||
#5 | 21523 | C. Thomas Tyler | Minor tweak to make it easier to submit. | ||
#4 | 21031 | C. Thomas Tyler | Removed silly dependency on workspace root starting with /pub. | ||
#3 | 20576 | C. Thomas Tyler | Removed noise; accounted for new process based on jobs. | ||
#2 | 20520 | C. Thomas Tyler | Enhanced mdcu.sh script. | ||
#1 | 16681 | C. Thomas Tyler |
Added basic Merge Down/Copy Up script for working on the SDP. |