#!/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 ..." which wget > /dev/null if [ -z $? ]; then wget -q -O $P4BIN ftp://ftp.perforce.com/perforce/r14.1/$MYPLAT/p4 wget -q -O $P4DBIN ftp://ftp.perforce.com/perforce/r14.1/$MYPLAT/p4d else curl -q -o $P4BIN ftp://ftp.perforce.com/perforce/r14.1/$MYPLAT/p4 curl -q -o $P4DBIN ftp://ftp.perforce.com/perforce/r14.1/$MYPLAT/p4d fi chmod a+x $P4BIN chmod a+x $P4DBIN echo "Done." fi export P4CONFIG=".myp4" 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 $P4BIN "$@" exit $? 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 P4IGNORE=.myp4ignore P4PORT=rsh:$P4DBIN -r $rootDir -Llog_file -i -vserver=3 FOOBAR cat > $baseDir/.myp4ignore <<FOOBAR .git .gitignore .myp4 .myp4d .myp4ignore FOOBAR cat > $baseDir/.gitignore <<FOOBAR .git .gitignore .myp4 .myp4d .myp4ignore FOOBAR cd $baseDir $P4BIN client -o | \ sed -e "s=//depot/... //$USER/...=//depot/master/... //$USER/...=" \ -e 's/noallwrite/allwrite/' \ -e 's/normdir/rmdir/' \ -e 's/submitunchanged/revertunchanged/' | \ $P4BIN client -i > /dev/null mkdir -p $rootDir/depot/master exit 0 fi curBranch=`$P4BIN client -o | \ egrep "//depot/[^/]+/... " | \ sed -e 's=^.*//depot/==' -e 's=/[.][.][.].*$=='` P4USER=$USER P4CLIENT=$USER case $1 in init) echo "Already within a Perforce storage structure: $rootDir" exit 1 ;; branches) cd $rootDir/depot for f in *; do if [ -d $f ]; then if [ "$f" == "$curBranch" ]; then echo "$f *" else echo $f fi fi done exit 0 ;; switch) toBranch="$2" if [ "$toBranch" == "" ]; then echo "Current branch $curBranch maps to //depot/$curBranch" exit 0 fi if [ ! -d $rootDir/depot/$2 ]; then echo "Branch $2 does not exist, yet" exit 1 fi if [ "$toBranch" == "$curBranch" ]; 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?" # One day add in (m) Move changes read -p '(s) Shelve changes for later (r) Revert changes (q) Quit? ' \ answer case $answer in s) newChange=`$P4BIN change -o | \ sed -e "s/<enter description here>/Shelf for $curBranch/" | \ $P4BIN change -i | sed -e 's/^Change //' -e 's/ .*//'` $P4BIN reconcile -c $newChange //$P4CLIENT/... $P4BIN shelve -c $newChange > /dev/null $P4BIN key "branchShelf-$curBranch" $newChange > /dev/null $P4BIN revert -w //depot/$curBranch/... > /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/$curBranch/... else echo "Aborting..." exit 1 fi ;; q) exit 0 ;; esac fi echo "Switch from $curBranch to $toBranch" $P4BIN client -o | \ sed -e "s=//depot/[^/]*/... //$USER/...=//depot/$toBranch/... //$USER/...=" | \ $P4BIN client -i > /dev/null $P4BIN sync -q //$P4CLIENT/... 2> /dev/null curShelf=`$P4BIN key "branchShelf-$toBranch"` 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 "branchShelf-$toBranch" > /dev/null fi exit 0 ;; branch) newBranch=$2 if [ "$newBranch" == "" ]; then echo "Current branch $curBranch maps to //depot/$curBranch" exit 0 fi if [ -d $rootDir/depot/$newBranch ]; then echo "Existing branch $newBranch maps to //depot/$newBranch" echo "Perhaps you meant to say: p4 switch $newBranch" 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?" # One day add in (m) Move changes read -p '(s) Shelve changes for later (r) Revert changes (q) Quit? ' \ answer case $answer in s) newChange=`$P4BIN change -o | \ sed -e "s/<enter description here>/Shelf for $curBranch/" | \ $P4BIN change -i | sed -e 's/^Change //' -e 's/ .*//'` $P4BIN reconcile -c $newChange //$P4CLIENT/... $P4BIN shelve -c $newChange > /dev/null $P4BIN key "branchShelf-$curBranch" $newChange > /dev/null $P4BIN revert -w //depot/$curBranch/... > /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/$curBranch/... else echo "Aborting..." exit 1 fi ;; q) exit 0 ;; esac fi emptyBranch=`$P4BIN -ztag files -m1 ... 2> /dev/null | egrep '^[.][.][.]' | wc -l` if [ $emptyBranch == 0 ]; then echo "No files to branch" else $P4BIN populate -d "Branching $curBranch to $newBranch" \ //depot/$curBranch/... //depot/$newBranch/... if [ $? != 0 ]; then echo "Failed to create branch $2 mapping to //depot/$newBranch" exit 1 fi fi mkdir -p $rootDir/depot/$newBranch echo "Switch from $curBranch to $newBranch" $P4BIN client -o | \ sed -e "s=//depot/[^/]*/... //$USER/...=//depot/$newBranch/... //$USER/...=" | \ $P4BIN client -i > /dev/null $P4BIN sync -q //$P4CLIENT/... 2> /dev/null exit 0 ;; *) $P4BIN $P4ENVARGS "$@" ;; 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 |