Author: paul
Date: 2006-04-26 04:43:58 +0200 (Wed, 26 Apr 2006)
New Revision: 1940
Log:
Originally, get-svn-revision displayed the local revision number.
This patch enables it to get remote (parent) repository revision, too.
By comparing local with remote revision number, we'll be able to determine
whether there are revisions to be pulled without actually pulling them.
(Kinda like bk changes -R.)
Modified:
trunk/tools/get-svn-revision
Modified: trunk/tools/get-svn-revision
===================================================================
--- trunk/tools/get-svn-revision 2006-04-26 02:15:23 UTC (rev 1939)
+++ trunk/tools/get-svn-revision 2006-04-26 02:43:58 UTC (rev 1940)
@@ -13,29 +13,79 @@
# Paul DuBois, paul@stripped
# 2005-11-17
-if [ -d .svn ]; then
- #echo "This is a Subversion repository."
- svn info | grep '^Revision' | sed -e 's/Revision: *//'
+# 2006-04-25
+# - Enable script to get remote (parent) repository revision, too
+# (use -R option). Default behavior is to get local revision, as
+# before (use no option or -L option).
+
+function get_local_revision {
+ if [ -d .svn ]; then
+ #echo "This is a Subversion repository."
+ svn info | grep '^Revision' | sed -e 's/Revision: *//'
+ else
+ #echo "This is a local SVK copy of a Subversion repository."
+ # The first 'Copied From:' line presumably is the parent in the
+ # SVK depot of this local copy.
+ DEPOT=`svk info \
+ | grep '^Copied From:' \
+ | head -n 1 \
+ | sed -e 's/^Copied From: *//' -e 's/,.*//'`
+ # Try info for parent if there is no "Copied From: in current directory
+ if [ "$DEPOT" = "" ]; then
+ DEPOT=`svk info .. \
+ | grep '^Copied From:' \
+ | head -n 1 \
+ | sed -e 's/^Copied From: *//' -e 's/,.*//'`
+ fi
+ # The info for the depot includes a 'Mirrored From:' line that
+ # indicates parent Subversion repository and the revision last
+ # mirrored.
+ # (If DEPOT is empty, then we are unable to tell the revision
+ # and there is no output.)
+ if [ "$DEPOT" != "" ]; then
+ svk info /$DEPOT | grep '^Mirrored From:' | sed -e 's/.*, Rev\. *//'
+ fi
+ fi
+}
+
+function get_remote_revision {
+ if [ -d .svn ]; then
+ #echo "This is a Subversion repository."
+ URL=`svn info | grep '^URL: ' | sed -e 's/^URL: *//'`
+ svn info $URL | grep '^Revision' | sed -e 's/Revision: *//'
+ else
+ #echo "This is a local SVK copy of a Subversion repository."
+ # The first 'Copied From:' line presumably is the parent in the
+ # SVK depot of this local copy.
+ DEPOT=`svk info \
+ | grep '^Copied From:' \
+ | head -n 1 \
+ | sed -e 's/^Copied From: *//' -e 's/,.*//'`
+ # Try info for parent if there is no "Copied From: in current directory
+ if [ "$DEPOT" = "" ]; then
+ DEPOT=`svk info .. \
+ | grep '^Copied From:' \
+ | head -n 1 \
+ | sed -e 's/^Copied From: *//' -e 's/,.*//'`
+ fi
+ # The info for the depot includes a 'Mirrored From:' line that
+ # indicates parent Subversion repository and the revision last
+ # mirrored.
+ # (If DEPOT is empty, then we are unable to tell the revision
+ # and there is no output.)
+ if [ "$DEPOT" != "" ]; then
+ URL=`svk info /$DEPOT | grep '^Mirrored From:' \
+ | sed -e 's/^Mirrored From: *//' \
+ | sed -e 's/,.*//'`
+ svn info $URL | grep '^Revision' | sed -e 's/Revision: *//'
+ fi
+ fi
+}
+
+if [ $# -eq 0 -o "$1" = "-L" ]; then
+ get_local_revision
+elif [ "$1" = "-R" ]; then
+ get_remote_revision
else
- #echo "This is a local SVK copy of a Subversion repository."
- # The first 'Copied From:' line presumably is the parent in the
- # SVK depot of this local copy.
- DEPOT=`svk info \
- | grep '^Copied From:' \
- | head -n 1 \
- | sed -e 's/^Copied From: *//' -e 's/,.*//'`
- # Try info for parent if there is no "Copied From: in current directory
- if [ "$DEPOT" = "" ]; then
- DEPOT=`svk info .. \
- | grep '^Copied From:' \
- | head -n 1 \
- | sed -e 's/^Copied From: *//' -e 's/,.*//'`
- fi
- # The info for the depot includes a 'Mirrored From:' line that
- # indicates the revision of the parent Subversion repository.
- # (If DEPOT is empty, then we are unable to tell the revision
- # and there is no output.)
- if [ "$DEPOT" != "" ]; then
- svk info /$DEPOT | grep '^Mirrored From:' | sed -e 's/.*, Rev. *//'
- fi
+ echo "Usage: $0 [-L|-R]" 1>&2
fi
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r1940 - trunk/tools | paul | 26 Apr |