aboutsummaryrefslogtreecommitdiff
path: root/trunk/lib
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/lib')
-rw-r--r--trunk/lib/common.sh103
1 files changed, 101 insertions, 2 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh
index 9589568..5d125b7 100644
--- a/trunk/lib/common.sh
+++ b/trunk/lib/common.sh
@@ -664,10 +664,56 @@ function sync_repo {
function svn_add {
- if [ -e "$1" ] && [ -d "`dirname $1`/.svn" ] && ! svn_check $1; then
- su_svn add $1
+ local file="$1" folder folders dir_list cwd
+ local subfolder subfolders
+
+ if [ -e "$file" ] && ! svn_check $file; then
+
+ folder="`absolute_folder $file`"
+ cwd="`pwd`"
+
+ if [ -d "$folder/.svn" ]; then
+ cd $folder
+ su_svn add `basename $file`
+ else
+
+ # reverse folder order
+ dir_list="`echo $folder | tr '/' ' '`"
+ for i in $dir_list; do
+ folders="$i $folders"
+ done
+
+ cd $folder
+
+ for i in $folders; do
+ cd ..
+ if [ -d ".svn" ]; then
+ # add the parent folder
+ su_svn add --depth=empty $i
+
+ # add all subfolders
+ cd $i
+ subfolders="$(echo $folder | sed -e "s/^$(regexp_slash $(pwd))//")"
+ for subfolder in `echo $subfolders | tr '/' ' '`; do
+ if ! svn_check $subfolder; then
+ su_svn add --depth=empty $subfolder
+ cd $subfolder
+ fi
+ done
+
+ # add the file
+ cd $folder
+ su_svn add `basename $file`
+
+ break
+ fi
+ done
+
+ fi
fi
+ cd $cwd
+
}
function svn_del {
@@ -741,6 +787,43 @@ function svn_mkdir {
}
+function is_inside_svn_repo {
+
+ # check if a file is inside a svn repository
+ # usage: is_inside_svn_repo <file>
+
+ local file="$1" folder folders dir_list cwd
+
+ if [ -e "$file" ]; then
+ folder="`absolute_folder $file`"
+ fi
+
+ if [ -d "$folder/.svn" ]; then
+ return true
+ fi
+
+ # reverse folder order
+ dir_list="`echo $folder | tr '/' ' '`"
+ for i in $dir_list; do
+ folders="$i $folders"
+ done
+
+ cwd="`pwd`"
+ cd $folder
+
+ for i in $folders; do
+ cd ..
+ if [ -d ".svn" ]; then
+ cd $cwd
+ return true
+ fi
+ done
+
+ cd $cwd
+ return false
+
+}
+
function su_svn {
# execute svn using a different user
@@ -1532,6 +1615,22 @@ function file_extension {
}
+function absolute_folder {
+
+ # get the absolute folder from a file
+ # usage: absolute_folder <file>
+
+ local file="$1" cwd
+
+ if [ -e "$file" ]; then
+ cwd="`pwd`"
+ cd `dirname $file`
+ pwd
+ cd $cwd
+ fi
+
+}
+
function check_installed {
# checks if a package is installed