diff --git a/config.lib b/config.lib index 80f0d9aabb..fda94e3fbf 100644 --- a/config.lib +++ b/config.lib @@ -1052,7 +1052,11 @@ check_params() { fi fi - if [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then + if [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then + log 1 "checking revision... git detection" + elif [ -f "$ROOT_DIR/.ottdrev-vc" ]; then + log 1 "checking revision... source release version" + elif [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then log 1 "checking revision... svn detection" elif [ -d "$ROOT_DIR/../.svn" ] && [ -n "`svn help 2>/dev/null`" ] && [ -n "`LC_ALL=C svn info $ROOT_DIR/.. | grep '^URL:.*tags$'`" ]; then # subversion changed its behaviour; now not all folders have a .svn folder, @@ -1060,12 +1064,8 @@ check_params() { # of the tags folder, the folder of the tag does not have a .svn folder # anymore and this fails to detect the subversion repository checkout. log 1 "checking revision... svn detection (tag)" - elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then - log 1 "checking revision... git detection" elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`HGPLAIN= hg help 2>/dev/null`" ]; then log 1 "checking revision... hg detection" - elif [ -f "$ROOT_DIR/.ottdrev-vc" ]; then - log 1 "checking revision... source release version" elif [ -f "$ROOT_DIR/.ottdrev" ]; then log 1 "checking revision... source tarball" else diff --git a/findversion.sh b/findversion.sh index d8acc5eb51..85c8d2f426 100755 --- a/findversion.sh +++ b/findversion.sh @@ -70,21 +70,7 @@ ROOT_DIR=`pwd` # Determine if we are using a modified version # Assume the dir is not modified MODIFIED="0" -if [ -d "$ROOT_DIR/.svn" ] || [ -d "$ROOT_DIR/../.svn" ]; then - # We are an svn checkout - if [ -n "`svnversion | grep 'M'`" ]; then - MODIFIED="2" - fi - # Find the revision like: rXXXXM-branch - BRANCH=`LC_ALL=C svn info | "$AWK" '/^URL:.*branches/ { split($2, a, "/"); for(i in a) if (a[i]=="branches") { print a[i+1]; break } }'` - TAG=`LC_ALL=C svn info | "$AWK" '/^URL:.*tags/ { split($2, a, "/"); for(i in a) if (a[i]=="tags") { print a[i+1]; break } }'` - REV_NR=`LC_ALL=C svn info | "$AWK" '/^Last Changed Rev:/ { print $4 }'` - if [ -n "$TAG" ]; then - REV=$TAG - else - REV="r$REV_NR" - fi -elif [ -d "$ROOT_DIR/.git" ]; then +if [ -d "$ROOT_DIR/.git" ]; then # We are a git checkout # Refresh the index to make sure file stat info is in sync, then look for modifications git update-index --refresh >/dev/null @@ -104,24 +90,6 @@ elif [ -d "$ROOT_DIR/.git" ]; then BRANCH="" REV="$TAG" fi -elif [ -d "$ROOT_DIR/.hg" ]; then - # We are a hg checkout - if [ -n "`HGPLAIN= hg status | grep -v '^?'`" ]; then - MODIFIED="2" - fi - HASH=`LC_ALL=C HGPLAIN= hg id -i | cut -c1-12` - REV="h`echo $HASH | cut -c1-8`" - BRANCH="`HGPLAIN= hg branch | sed 's@^default$@@'`" - TAG="`HGPLAIN= hg id -t | grep -v 'tip$'`" - if [ -n "$TAG" ]; then - BRANCH="" - REV="$TAG" - fi - REV_NR=`LC_ALL=C HGPLAIN= hg log -f -k "(svn r" -l 1 --template "{desc|firstline}\n" | grep "^(svn r[0-9]*)" | sed "s@.*(svn r\([0-9]*\)).*@\1@"` - if [ -z "$REV_NR" ]; then - # No rev? Maybe it is a custom hgsubversion clone - REV_NR=`LC_ALL=C HGPLAIN= hg parent --template="{svnrev}"` - fi elif [ -f "$ROOT_DIR/.ottdrev-vc" ]; then VERSION_DATA="`cat "$ROOT_DIR/.ottdrev-vc" | sed -n -e '1 p;'`" HASH_DATA="`cat "$ROOT_DIR/.ottdrev-vc" | sed -n -e '2 p;'`" @@ -146,6 +114,38 @@ elif [ -f "$ROOT_DIR/.ottdrev-vc" ]; then BRANCH="${BRANCH}H`echo "$CURRENT_HASH" | cut -c 1-8`" fi fi +elif [ -d "$ROOT_DIR/.svn" ] || [ -d "$ROOT_DIR/../.svn" ]; then + # We are an svn checkout + if [ -n "`svnversion | grep 'M'`" ]; then + MODIFIED="2" + fi + # Find the revision like: rXXXXM-branch + BRANCH=`LC_ALL=C svn info | "$AWK" '/^URL:.*branches/ { split($2, a, "/"); for(i in a) if (a[i]=="branches") { print a[i+1]; break } }'` + TAG=`LC_ALL=C svn info | "$AWK" '/^URL:.*tags/ { split($2, a, "/"); for(i in a) if (a[i]=="tags") { print a[i+1]; break } }'` + REV_NR=`LC_ALL=C svn info | "$AWK" '/^Last Changed Rev:/ { print $4 }'` + if [ -n "$TAG" ]; then + REV=$TAG + else + REV="r$REV_NR" + fi +elif [ -d "$ROOT_DIR/.hg" ]; then + # We are a hg checkout + if [ -n "`HGPLAIN= hg status | grep -v '^?'`" ]; then + MODIFIED="2" + fi + HASH=`LC_ALL=C HGPLAIN= hg id -i | cut -c1-12` + REV="h`echo $HASH | cut -c1-8`" + BRANCH="`HGPLAIN= hg branch | sed 's@^default$@@'`" + TAG="`HGPLAIN= hg id -t | grep -v 'tip$'`" + if [ -n "$TAG" ]; then + BRANCH="" + REV="$TAG" + fi + REV_NR=`LC_ALL=C HGPLAIN= hg log -f -k "(svn r" -l 1 --template "{desc|firstline}\n" | grep "^(svn r[0-9]*)" | sed "s@.*(svn r\([0-9]*\)).*@\1@"` + if [ -z "$REV_NR" ]; then + # No rev? Maybe it is a custom hgsubversion clone + REV_NR=`LC_ALL=C HGPLAIN= hg parent --template="{svnrev}"` + fi elif [ -f "$ROOT_DIR/.ottdrev" ]; then # We are an exported source bundle cat $ROOT_DIR/.ottdrev