[PATCH]: New script for contrib
Paolo Bonzini
bonzini@gnu.org
Tue Nov 1 22:21:00 GMT 2005
Daniel Berlin wrote:
> This is a slight modification of the find-start-rev script that richard
> guenther sent me and i resent to gcc@.
>
> I'm sure somebody who actually does shell programming "for real" can
> make this better
>
>
>
> ------------------------------------------------------------------------
>
> 2005-10-31 Daniel Berlin <dberlin@dberlin.org>
> Richard Guenther <rguenther@suse.de>
>
> * svn-find-start-rev: New file.
> Index: svn-find-start-rev
> ===================================================================
> --- svn-find-start-rev (revision 0)
> +++ svn-find-start-rev (revision 0)
> @@ -0,0 +1,37 @@
> +# Find the version in which a repository path came into existence
> +
> +usage () {
> +cat <<EOF
> + Usage:
> + svn-find-start-rev <url> <directory or file path in repository>
> +
> + Example:
> + svn-find-start-rev svn://gcc.gnu.org/svn/gcc branches/gcc-3_4-branch
> +EOF
> +exit 1
> +}
> +
> +test $# -lt 2 && usage
> +
> +rev=`svn info $1/trunk | grep '^Revision:' | sed -e 's/Revision: //'`
> +echo trunk is at rev $rev
> +width=$[$rev / 2]
> +rev=$[$rev - $width]
> +echo "Starting with $rev, $width"
> +while true; do
> + width=$[$width / 2]
> + echo svn info $1/$2@$rev
> + svn info $1/$2@$rev 2>&1 | grep "Not a valid URL"
> + if ! test $? == 0; then
> + echo - exists.
> + rev=$[$rev - $width]
> + else
> + rev=$[$rev + $width]
> + fi
> + if test $width == 0; then
> + break;
> + fi
> +done
> +startrev=$[$rev + 1]
> +echo "$2 started at $rev"
> +
For the record, the two non portable constructs I see are
- you should use `expr ... ` instead of $[...]
- you should not use ! test $? == 0
in this case, $? is not necessary at all
if svn info $1/$2@$rev 2>&! | grep 'Not a valid URL'; then
# grep succeeded
rev=`expr $rev + $width`
else
# grep failed
echo - exists.
rev=`expr $rev - $width`
fi
Paolo
More information about the Gcc-patches
mailing list