OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 # Copyright 2013 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are |
| 5 # met: |
| 6 # |
| 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following |
| 11 # disclaimer in the documentation and/or other materials provided |
| 12 # with the distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived |
| 15 # from this software without specific prior written permission. |
| 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
| 29 |
| 30 ########## Global variable definitions |
| 31 |
| 32 VERSION="src/version.cc" |
| 33 MAJOR="MAJOR_VERSION" |
| 34 MINOR="MINOR_VERSION" |
| 35 BUILD="BUILD_NUMBER" |
| 36 PATCH="PATCH_LEVEL" |
| 37 |
| 38 V8="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 39 |
| 40 ########## Function definitions |
| 41 |
| 42 cd $V8 |
| 43 |
| 44 usage() { |
| 45 cat << EOF |
| 46 usage: $0 OPTIONS |
| 47 |
| 48 Fetches V8 revision information from a git-svn checkout. |
| 49 |
| 50 OPTIONS: |
| 51 -h Show this message. |
| 52 -i Print revision info for all branches matching the V8 version. |
| 53 -v Print the V8 version tag for a trunk SVN revision. |
| 54 -m Print all patches that were merged to the specified V8 branch. |
| 55 -p Print all patches merged to a specific V8 point-release. |
| 56 EOF |
| 57 } |
| 58 |
| 59 tags() { |
| 60 git for-each-ref --format="%(objectname) %(refname:short)" refs/remotes/svn |
| 61 } |
| 62 |
| 63 tag_revision() { |
| 64 cut -d" " -f1 |
| 65 } |
| 66 |
| 67 tag_log() { |
| 68 git log --format="%h %ci %ce %s" -1 $1 |
| 69 } |
| 70 |
| 71 v8_hash() { |
| 72 tags | grep "svn/tags/$1$" | tag_revision |
| 73 } |
| 74 |
| 75 point_merges() { |
| 76 echo $1 | grep -o "r[0-9]\+" |
| 77 } |
| 78 |
| 79 hash_to_svn() { |
| 80 git svn log -1 --oneline $1 | cut -d" " -f1 |
| 81 } |
| 82 |
| 83 tag_version() { |
| 84 tags | grep svn/tags/$1 | while read tag; do |
| 85 id=$(echo $tag | grep -o "[^/]*$") |
| 86 rev=$(echo $tag | tag_revision) |
| 87 svn=$(hash_to_svn $rev) |
| 88 echo $rev $svn $id |
| 89 done |
| 90 } |
| 91 |
| 92 svn_rev() { |
| 93 git svn find-rev $2 svn/$1 |
| 94 } |
| 95 |
| 96 v8_rev() { |
| 97 cd $(git rev-parse --show-toplevel) |
| 98 rev=$(git show $1:$VERSION \ |
| 99 | grep "#define" \ |
| 100 | grep "$MAJOR\|$MINOR\|$BUILD\|$PATCH" \ |
| 101 | grep -o "[0-9]\+$" \ |
| 102 | tr "\\n" ".") |
| 103 echo ${rev%?} |
| 104 } |
| 105 |
| 106 merges_to_branch() { |
| 107 git cherry -v svn/trunk svn/$1 | while read merge; do |
| 108 h=$(echo $merge | cut -d" " -f2) |
| 109 svn=$(svn_rev $1 $h) |
| 110 merges=$(echo $merge | grep -o "r[0-9]\+") |
| 111 echo branches/$1 r$svn $merges |
| 112 done |
| 113 } |
| 114 |
| 115 ########## Option parsing |
| 116 |
| 117 while getopts ":hi:v:m:p:" OPTION ; do |
| 118 case $OPTION in |
| 119 h) usage |
| 120 exit 0 |
| 121 ;; |
| 122 i) tag_version $OPTARG |
| 123 ;; |
| 124 v) v8_rev $(svn_rev trunk r$OPTARG) |
| 125 ;; |
| 126 m) merges_to_branch $OPTARG |
| 127 ;; |
| 128 p) point_merges "$(tag_log $(v8_hash $OPTARG)^1)" |
| 129 ;; |
| 130 ?) echo "Illegal option: -$OPTARG" |
| 131 usage |
| 132 exit 1 |
| 133 ;; |
| 134 esac |
| 135 done |
OLD | NEW |