#!/bin/bash MYP4BIN=$HOME/bin MYPLAT="bin.darwin90x86_64" P4BIN=$MYP4BIN/p4.bin P4DBIN=$MYP4BIN/p4d.bin if [ ! -f $P4BIN ]; then echo "Downloading required Perforce binaries for $MYPLAT ..." wget -q -O $P4BIN ftp://ftp.perforce.com/perforce/r14.1/$MYPLAT/p4 chmod a+x $P4BIN wget -q -O $P4DBIN ftp://ftp.perforce.com/perforce/r14.1/$MYPLAT/p4d chmod a+x $P4DBIN echo "Done." fi P4CONFIG=".myp4" P4USER="$USER" P4CLIENT="$USER" rootDir=`$P4BIN -ztag set | egrep '^P4CONFIG=.myp4' | sed -e 's/^P4CONFIG=.myp4..config..//' -e "s/')//" -e 's/myp4$/myp4d/'` if [ "$rootDir" == 'noconfig' ]; then if [ "$1" != 'init' ]; then echo "Not within a Perforce storage system, perhaps you meant to run init" exit 1 fi echo 'Initializing...' baseDir="$PWD" if [ "$2" != '' ]; then baseDir="$PWD/$2" fi rootDir="$baseDir/.myp4d" if [ -d $rootDir ]; then echo "Perforce storage already maps to $rootDir" exit 1 fi mkdir -p $rootDir cat > $baseDir/.myp4 <<FOOBAR P4USER=$USER P4CLIENT=$USER FOOBAR cat > $baseDir/.myp4ignore <<FOOBAR .git .gitignore .myp4 .myp4d .myp4ignore FOOBAR cat > $baseDir/.gitignore <<FOOBAR .git .gitignore .myp4 .myp4d .myp4ignore FOOBAR export P4ROOT=$rootDir export P4PORT="rsh:$P4DBIN -Llog_file -i -vserver=3" cd $baseDir $P4BIN client -o | \ sed -e "s=//depot/... //$USER/...=//depot/1/... //$USER/...=" \ -e 's/noallwrite/allwrite/' \ -e 's/normdir/rmdir/' \ -e 's/submitunchanged/revertunchanged/' | \ $P4BIN client -i > /dev/null $P4BIN key -i "branchId" > /dev/null $P4BIN key "branchId-1" master > /dev/null $P4BIN key "branch-master" 1 > /dev/null exit 0 fi export P4ROOT=$rootDir export P4IGNORE=.myp4ignore export P4PORT="rsh:$P4DBIN -Llog_file -i -vserver=3" case $1 in init) echo "Already within a Perforce storage structure: $rootDir" exit 1 ;; branches) $P4BIN keys -e 'branchId-*' | sed -e 's/branchId-[0-9]* = //' exit 0 ;; switch) curBranchId=`$P4BIN client -o | \ egrep "//depot/[0-9]+/... " | \ sed -e 's=^.*//depot/==' -e 's=/[.][.][.].*$=='` curBranch=`$P4BIN key "branchId-$curBranchId"` if [ "$2" == "" ]; then echo "Current branch $curBranch maps to //depot/$curBranchId" exit 0 fi branchId=`$P4BIN key "branch-$2"` if [ "$branchId" == '0' ]; then echo "Branch $2 does not exist, yet" exit 1 fi if [ "$branchId" == "$curBranchId" ]; then echo "Already there, wasn't that fast?" exit 0 fi work=`$P4BIN -ztag opened //$P4CLIENT/... 2> /dev/null | wc -l` if [ $work -eq 0 ]; then work=`$P4BIN -ztag status //$P4CLIENT/... 2> /dev/null | wc -l` fi if [ $work -gt 0 ]; then echo "There are pending changes, how do you want to proceed?" read -p '(s) Shelve changes for later (r) Revert changes (m) Move changes (q) Quit? ' \ answer case $answer in s) newChange=`$P4BIN change -o | \ sed -e "s/<enter description here>/$curBranch shelf/" | \ $P4BIN change -i | sed -e 's/^Change //' -e 's/ .*//'` $P4BIN reconcile -c $newChange //$P4CLIENT/... $P4BIN shelve -c $newChange > /dev/null $P4BIN key "branchIdShelf-$curBranchId" $newChange > /dev/null $P4BIN revert -w //depot/$curBranchId/... > /dev/null ;; r) read -p 'New files will be deleted, edits discarded, etc. Are you sure? ' \ answer if [ "$answer" == "y" ]; then $P4BIN reconcile //$P4CLIENT/... > /dev/null 2> /dev/null $P4BIN revert -w //depot/$curBranchId/... else echo "Aborting..." exit 1 fi ;; m) echo MOVE exit 1 # TBD ;; q) exit 0 ;; esac fi echo "Switch from $curBranch to $2" $P4BIN client -o | \ sed -e "s=//depot/[0-9][0-9]*/... //$USER/...=//depot/$branchId/... //$USER/...=" | \ $P4BIN client -i > /dev/null $P4BIN sync -q //$P4CLIENT/... 2> /dev/null curShelf=`$P4BIN key "branchIdShelf-$branchId"` if [ $curShelf != 0 ]; then echo "Unshelving $curShelf" $P4BIN unshelve -s $curShelf $P4BIN shelve -d -c $curShelf > /dev/null $P4BIN change -d $curShelf > /dev/null $P4BIN key -d "branchIdShelf-$branchId" > /dev/null fi exit 0 ;; branch) curBranchId=`$P4BIN client -o | \ egrep "//depot/[0-9]+/... " | \ sed -e 's=^.*//depot/==' -e 's=/[.][.][.].*$=='` curBranch=`$P4BIN key "branchId-$curBranchId"` if [ "$2" == "" ]; then echo "Current branch $curBranch maps to //depot/$curBranchId" exit 0 fi branchId=`$P4BIN key "branch-$2"` if [ "$branchId" != '0' ]; then echo "Existing branch $2 maps to //depot/$branchId" echo "Perhaps you meant to say: p4 switch $2" exit 1 fi work=`$P4BIN -ztag opened //$P4CLIENT/... 2> /dev/null | wc -l` if [ $work -eq 0 ]; then work=`$P4BIN -ztag status //$P4CLIENT/... 2> /dev/null | wc -l` fi if [ $work -gt 0 ]; then echo "There are pending changes, how do you want to proceed?" read -p '(s) Shelve changes for later (r) Revert changes (m) Move changes (q) Quit? ' \ answer case $answer in s) newChange=`$P4BIN change -o | \ sed -e "s/<enter description here>/$curBranch shelf/" | \ $P4BIN change -i | sed -e 's/^Change //' -e 's/ .*//'` $P4BIN reconcile -c $newChange //$P4CLIENT/... $P4BIN shelve -c $newChange > /dev/null $P4BIN key "branchIdShelf-$curBranchId" $newChange > /dev/null $P4BIN revert -w //depot/$curBranchId/... > /dev/null ;; r) read -p 'New files will be deleted, edits discarded, etc. Are you sure? ' \ answer if [ "$answer" == "y" ]; then $P4BIN reconcile //$P4CLIENT/... > /dev/null 2> /dev/null $P4BIN revert -w //depot/$curBranchId/... else echo "Aborting..." exit 1 fi ;; m) echo MOVE ;; q) exit 0 ;; esac fi emptyBranch=`$P4BIN -ztag files -m1 ... 2> /dev/null | egrep '^[.][.][.]' | wc -l` branchId=`$P4BIN key -i "branchId"` if [ $emptyBranch == 0 ]; then echo "No files to branch" else $P4BIN populate -d "Branching $curBranch ($curBranchId) to $2 ($branchId)" \ //depot/$curBranchId/... //depot/$branchId/... if [ $? != 0 ]; then echo "Failed to create branch $2 mapping to //depot/$branchId" exit 1 fi fi echo "Switch from $curBranch to $2" $P4BIN key "branch-$2" "$branchId" > /dev/null $P4BIN key "branchId-$branchId" "$2" > /dev/null $P4BIN client -o | \ sed -e "s=//depot/[0-9][0-9]*/... //$USER/...=//depot/$branchId/... //$USER/...=" | \ $P4BIN client -i > /dev/null $P4BIN sync -q //$P4CLIENT/... 2> /dev/null exit 0 ;; *) $P4BIN $P4TAGGED "$@" ;; esac
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#29 | 10704 | Alan H Teague | Updating to 14.2 p4/p4d binaries | ||
#28 | 9724 | Alan H Teague | Clean up help | ||
#27 | 9700 | Alan H Teague | Adding in p4 check command | ||
#26 | 9175 | Alan H Teague | Revise new version check to work on systems without curl | ||
#25 | 9136 | Alan H Teague | fix incorrect test and try to guess platform | ||
#24 | 9029 | Alan H Teague | update the rev counter | ||
#23 | 9028 | Alan H Teague |
Remove 'p4 branch' 'p4 branches' 'p4 branchspec' 'p4 branchspecs' Add 'p4 switch -a' to list all branches Add 'p4 switch -b NEWBRANCH' to create new branch Update help accordingly |
||
#22 | 9027 | Alan H Teague | use client -s -t to switch client view | ||
#21 | 9022 | Alan H Teague | use modtime and -m for checkpoint | ||
#20 | 8982 | Alan H Teague | Suggest a merge branchspec for complex branches | ||
#19 | 8974 | Alan H Teague |
Exclude vi .swp files Switch from back-tick to $() syntax for subcommands |
||
#18 | 8921 | Alan H Teague |
Allow for spaces in directory names Update help for current set of commands Prevent creating of branches which contain spaces |
||
#17 | 8920 | Alan H Teague | Add in 'p4 server {port}' to launch network server | ||
#16 | 8918 | Alan H Teague | Add 'p4 checkpoint' command to reconcile/submit | ||
#15 | 8891 | Alan H Teague | don't check for new versions often | ||
#14 | 8878 | Alan H Teague | Fix inserted issues, correct test | ||
#13 | 8877 | Alan H Teague | Missing fi fi fi | ||
#12 | 8876 | Alan H Teague | set version | ||
#11 | 8875 | Alan H Teague | Add rcs'ism | ||
#10 | 8874 | Alan H Teague | Fix reconcile bug - aka losing files | ||
#9 | 8861 | Alan H Teague |
Cleanup return codes Normalize test of strings exist/not exist |
||
#8 | 8860 | Alan H Teague |
Modify myp4 to use existing P4CONFIG and P4IGNORE values. This change also simplifies the root construction code a bit. #review @alan_h_teague Will make some immediate changes... ;-) |
||
#7 | 8806 | Alan H Teague |
Revert back to using branch instead of newbranch Add in conversion from 'p4 branchspec(s)' to 'p4 branch(es)' Add in hints to above Append to 'p4 help' Check for complex views in mergefrom command |
||
#6 | 8802 | Alan H Teague | Update to add mergedown | ||
#5 | 8799 | Alan H Teague |
Create client template per branch instead of using filesystem structure Enable user specific shelving and non-user specific use of branches |
||
#4 | 8791 | Alan H Teague |
Change from depot to branch for base depot for branches Enable use of user-defined branches based off clients named USER-BRANCH |
||
#3 | 8778 | Alan H Teague | Make it work with both basic p4 and wrapped p4 | ||
#2 | 8776 | Alan H Teague | Remove indirection of branch names | ||
#1 | 8774 | Alan H Teague | Initial import of the myp4 project |