From effad3771ed1c45241578a2b075e4cdd0887209a Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sat, 13 Apr 2013 08:50:04 -0400 Subject: [PATCH] renaming frenzy to make the revision control tools useful. sneakily renamed the library to version_control to avoid name completion annoyance. made more scripts rely on the version control library to avoid code duplication. cleanup is next. --- scripts/rev_control/checkin.sh | 39 +------- scripts/rev_control/getem.sh | 60 +----------- scripts/rev_control/rev_checkin.sh | 37 +++++++ .../{update_these.sh => rev_diff.sh} | 14 +-- ...{report_new_files.sh => rev_report_new.sh} | 8 +- scripts/rev_control/rev_update.sh | 35 +++++++ scripts/rev_control/svn_rm_dupes.sh | 76 --------------- .../{rev_control.sh => version_control.sh} | 97 +++++++++++++++++++ 8 files changed, 183 insertions(+), 183 deletions(-) create mode 100644 scripts/rev_control/rev_checkin.sh rename scripts/rev_control/{update_these.sh => rev_diff.sh} (57%) rename scripts/rev_control/{report_new_files.sh => rev_report_new.sh} (51%) create mode 100644 scripts/rev_control/rev_update.sh delete mode 100644 scripts/rev_control/svn_rm_dupes.sh rename scripts/rev_control/{rev_control.sh => version_control.sh} (53%) diff --git a/scripts/rev_control/checkin.sh b/scripts/rev_control/checkin.sh index 636eedab..c5008149 100644 --- a/scripts/rev_control/checkin.sh +++ b/scripts/rev_control/checkin.sh @@ -3,44 +3,7 @@ # checks in all the folders present in the REPOSITORY_LIST variable. source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" -source "$FEISTY_MEOW_SCRIPTS/rev_control/rev_control.sh" - -# selects the method for check-in based on where we are. -function do_checkin() -{ - local directory="$1"; shift - if [ -d "CVS" ]; then cvs ci . ; - elif [ -d ".svn" ]; then svn ci . ; - elif [ -d ".git" ]; then - # snag all new files. not to everyone's liking. - git add . - # tell git about all the files and get a check-in comment. - git commit . - # upload the files to the server so others can see them. - git push 2>&1 | grep -v "X11 forwarding request failed" - else - echo unknown repository for $directory... - fi -} - -# checks in all the folders in a specified list. -function checkin_list { - local list=$* - for i in $list; do - # turn repo list back into an array. - eval "repository_list=( ${REPOSITORY_LIST[*]} )" - for j in "${repository_list[@]}"; do - # add in the directory component. - j="$i/$j" - if [ ! -d "$j" ]; then continue; fi - - pushd $j &>/dev/null - echo "checking in '$j'..." - do_checkin $j - popd &>/dev/null - done - done -} +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" echo "Committing repositories at: $(date)" diff --git a/scripts/rev_control/getem.sh b/scripts/rev_control/getem.sh index f31a86ca..e8ff547f 100644 --- a/scripts/rev_control/getem.sh +++ b/scripts/rev_control/getem.sh @@ -3,7 +3,7 @@ # gets any updates for the repository folders present in the REPOSITORY_LIST variable. source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" -source "$FEISTY_MEOW_SCRIPTS/rev_control/rev_control.sh" +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" # trickery to ensure we can always update this file, even when the operating system has some # rude behavior with regard to file locking (ahem, windows...). @@ -26,64 +26,6 @@ if [ "$(\pwd)" != "$tmpdir" ]; then exec "$new_name" fi -# takes out the first few carriage returns that are in the input. -function squash_first_few_crs() -{ - i=0 - while read line; do - i=$((i+1)) - if [ $i -le 3 ]; then - echo -n "$line " - else - echo $line - fi - done - if [ $i -le 3 ]; then - # if we're still squashing eols, make sure we don't leave them hanging. - echo - fi -} - -# selects the checkout method based on where we are (the host the script runs on). -function do_update() -{ - directory="$1"; shift - - if [ -d "CVS" ]; then - cvs update . | squash_first_few_crs - elif [ -d ".svn" ]; then - svn update . | squash_first_few_crs - elif [ -d ".git" ]; then - git pull 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs - else - echo unknown repository for $directory... - fi -} - -# gets all the updates for a list of folders under revision control. -function checkout_list { - list=$* - for i in $list; do - # turn repo list back into an array. - eval "repository_list=( ${REPOSITORY_LIST[*]} )" - for j in "${repository_list[@]}"; do - # add in the directory for our purposes here. - j="$i/$j" - if [ ! -d $j ]; then - if [ ! -z "$SHELL_DEBUG" ]; then - echo "No directory called $j exists." - fi - continue - fi - - pushd $j &>/dev/null - echo -n "retrieving '$j'... " - do_update $j - popd &>/dev/null - done - done -} - ############## export TMPO_CHK=$TMP/zz_chk.log diff --git a/scripts/rev_control/rev_checkin.sh b/scripts/rev_control/rev_checkin.sh new file mode 100644 index 00000000..58782434 --- /dev/null +++ b/scripts/rev_control/rev_checkin.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# checks in the updated files in a set of folders checked out from subversion +# or git. this can take a directory as parameter, but will default to the +# current working directory. all the directories under the passed directory +# will be examined. + +dir="$1"; shift +if [ -z "$dir" ]; then + dir=. +fi + +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" + +pushd "$dir" &>/dev/null + +for i in * ; do + if [ -d "$i" ]; then + echo "[$i]" + do_checkin $i +# pushd $i &>/dev/null +# # only update if we see a repository living there. +# if [ -d ".svn" ]; then +# svn ci . +# elif [ -d ".git" ]; then +# git commit . +# git push +# elif [ -d "CVS" ]; then +# cvs diff . +# fi +# popd &>/dev/null + echo "=======" + fi +done + +popd &>/dev/null + + diff --git a/scripts/rev_control/update_these.sh b/scripts/rev_control/rev_diff.sh similarity index 57% rename from scripts/rev_control/update_these.sh rename to scripts/rev_control/rev_diff.sh index b0cc4b8a..596cc794 100644 --- a/scripts/rev_control/update_these.sh +++ b/scripts/rev_control/rev_diff.sh @@ -1,8 +1,8 @@ #!/bin/bash -# a simple script for updating a set of folders on a usb stick from subversion or git. -# currently -# just runs with no parameters and expects to get all archives from wherever the files originally -# came from. +# does differences on a set of folders checked out from subversion or git. +# this can take a directory as parameter, but will default to the current +# working directory. all the directories under the passed directory will +# be examined. dir="$1"; shift if [ -z "$dir" ]; then @@ -17,11 +17,11 @@ for i in * ; do pushd $i &>/dev/null # only update if we see a repository living there. if [ -d ".svn" ]; then - svn update . + svn diff . elif [ -d ".git" ]; then - git pull + git diff elif [ -d "CVS" ]; then - cvs update . + cvs diff . fi popd &>/dev/null echo "=======" diff --git a/scripts/rev_control/report_new_files.sh b/scripts/rev_control/rev_report_new.sh similarity index 51% rename from scripts/rev_control/report_new_files.sh rename to scripts/rev_control/rev_report_new.sh index ca65a563..cac32b6f 100644 --- a/scripts/rev_control/report_new_files.sh +++ b/scripts/rev_control/rev_report_new.sh @@ -1,8 +1,10 @@ #!/bin/bash -# a simple script for updating a set of folders on a usb stick from subversion or git. currently -# just runs with no parameters and expects to get all archives from wherever the files originally -# came from. +# this script reports files that are not checked in yet in a set of folders. +# it works with subversion only, since git handles new files well whereas +# subversion ignores them until you tell it about them. this script can take +# a directory as a parameter, but will default to the current directory. +# all the directories under the passed directory will be examined. dir="$1"; shift if [ -z "$dir" ]; then diff --git a/scripts/rev_control/rev_update.sh b/scripts/rev_control/rev_update.sh new file mode 100644 index 00000000..a6c658b3 --- /dev/null +++ b/scripts/rev_control/rev_update.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# a simple script for updating a set of folders from subversion or git. +# this can take a directory as parameter, but will default to the current +# working directory. all the directories under the passed directory will +# be examined. + +dir="$1"; shift +if [ -z "$dir" ]; then + dir=. +fi + +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" + +pushd "$dir" &>/dev/null + +for i in * ; do + if [ -d "$i" ]; then + echo "[$i]" + do_update "$i" +# pushd $i &>/dev/null +# # only update if we see a repository living there. +# if [ -d ".svn" ]; then +# svn update . +# elif [ -d ".git" ]; then +# git pull +# elif [ -d "CVS" ]; then +# cvs update . +# fi +# popd &>/dev/null + echo "=======" + fi +done + +popd &>/dev/null + diff --git a/scripts/rev_control/svn_rm_dupes.sh b/scripts/rev_control/svn_rm_dupes.sh deleted file mode 100644 index 70448dde..00000000 --- a/scripts/rev_control/svn_rm_dupes.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash - -# whacks the files in the current directory which are duplicates of the -# files in the directory passed as a parameter. -# if there is a second parameter, then it is used as the "current directory". - -exemplar_dir="$1"; shift -whack_dir="$1"; shift - -#hmmm: much code here is shared with whack_dupes. get into a library. - -# make sure they gave us a good directory to start with. -if [ -z "$exemplar_dir" ]; then - echo "whack_dupes" - echo "-----------" - echo "" - echo "This program needs at least one directory parameter. The files in the" - echo "current directory will be removed if a file in the specified directory" - echo "already exists. So... the current directory is the less important one" - echo "and is presumed to have duplicates AND the directory given as parameter" - echo "is considered important and has the best versions of the files." - echo "If there is an optional second parameter, then that is used as the" - echo "\"current\" directory where we start from; it will be the less important" - echo "directory and will have its entries cleaned if they're duplicates." - exit 42; -fi - -# check to make sure they gave us a good directory. -if [ ! -z "$whack_dir" -a ! -d "$whack_dir" ]; then - echo "the directory $whack_dir does not exist." - exit 3 -fi - -# test the tasty remote location with the better contents. -pushd "$exemplar_dir" &>/dev/null -if [ $? -ne 0 ]; then - # an error getting to this directory means its no good for us. - echo "the directory $exemplar_dir is inaccessible." - exit 2 -fi -the_good_place="$(pwd)" -popd &>/dev/null - -if [ ! -z "$whack_dir" ]; then - # use the directory as our "current" location. - pushd "$whack_dir" &>/dev/null -fi - -# now that we're in the directory to clean, make sure we're good there. -if [ ! -d ".svn" ]; then -# echo "Could not find a subversion directory; operation would be pointless." - exit 0 -fi - -current_dir="$(pwd)" - -#echo "currdir=$current_dir gooddir=$the_good_place" - -if [ "$current_dir" == "$the_good_place" ]; then - # this is not good; they're the same location. - echo "the request would whack all the files in the current directory; ignoring." - exit 4 -fi - -# do the real work now... -for i in *; do - if [ -f "$exemplar_dir/$i" ]; then - echo "whacking $i" - svn rm "$i" - fi -done - -if [ ! -z "$whack_dir" ]; then - popd &>/dev/null -fi - diff --git a/scripts/rev_control/rev_control.sh b/scripts/rev_control/version_control.sh similarity index 53% rename from scripts/rev_control/rev_control.sh rename to scripts/rev_control/version_control.sh index 291a1fcf..a4236302 100644 --- a/scripts/rev_control/rev_control.sh +++ b/scripts/rev_control/version_control.sh @@ -97,3 +97,100 @@ function compute_modifier() fi } +# selects the method for check-in based on where we are. +function do_checkin() +{ + local directory="$1"; shift + pushd "$directory" &>/dev/null + if [ -d "CVS" ]; then cvs ci . ; + elif [ -d ".svn" ]; then svn ci . ; + elif [ -d ".git" ]; then + # snag all new files. not to everyone's liking. + git add . + # tell git about all the files and get a check-in comment. + git commit . + # upload the files to the server so others can see them. + git push 2>&1 | grep -v "X11 forwarding request failed" + else + echo unknown repository for $directory... + fi + popd &>/dev/null +} + +# checks in all the folders in a specified list. +function checkin_list { + local list=$* + for i in $list; do + # turn repo list back into an array. + eval "repository_list=( ${REPOSITORY_LIST[*]} )" + for j in "${repository_list[@]}"; do + # add in the directory component. + j="$i/$j" + if [ ! -d "$j" ]; then continue; fi + +# pushd $j &>/dev/null + echo "checking in '$j'..." + do_checkin $j +# popd &>/dev/null + done + done +} + +# takes out the first few carriage returns that are in the input. +function squash_first_few_crs() +{ + i=0 + while read line; do + i=$((i+1)) + if [ $i -le 3 ]; then + echo -n "$line " + else + echo $line + fi + done + if [ $i -le 3 ]; then + # if we're still squashing eols, make sure we don't leave them hanging. + echo + fi +} + +# selects the checkout method based on where we are (the host the script runs on). +function do_update() +{ + directory="$1"; shift + + pushd "$directory" &>/dev/null + if [ -d "CVS" ]; then + cvs update . | squash_first_few_crs + elif [ -d ".svn" ]; then + svn update . | squash_first_few_crs + elif [ -d ".git" ]; then + git pull 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs + else + echo unknown repository for $directory... + fi + popd &>/dev/null +} + +# gets all the updates for a list of folders under revision control. +function checkout_list { + list=$* + for i in $list; do + # turn repo list back into an array. + eval "repository_list=( ${REPOSITORY_LIST[*]} )" + for j in "${repository_list[@]}"; do + # add in the directory for our purposes here. + j="$i/$j" + if [ ! -d $j ]; then + if [ ! -z "$SHELL_DEBUG" ]; then + echo "No directory called $j exists." + fi + continue + fi + + echo -n "retrieving '$j'... " + do_update $j + done + done +} + -- 2.34.1