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
32DEPS_STRING='"v8_revision":'
33INFO=tools/v8-info.sh
34
35V8="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
36
37########## Function definitions
38
39usage() {
40cat << EOF
41usage: $0 OPTIONS
42
43Run in chromium/src to get information about V8 rolls.
44
45OPTIONS:
46  -h    Show this message.
47  -n    Number of rolls to print information about.
48  -s    Chromium git hash to start printing V8 information about.
49EOF
50}
51
52v8_line() {
53  git show $1:DEPS | grep -n $DEPS_STRING | cut -d":" -f1
54}
55
56v8_info() {
57  git blame -L$(v8_line $1),+1 $1 DEPS | grep $DEPS_STRING
58}
59
60v8_svn() {
61  sed -e 's/^.*"\([0-9]\+\)",$/\1/'
62}
63
64v8_roll() {
65  cut -d" " -f1
66}
67
68find_rev() {
69  git svn find-rev $1
70}
71
72msg() {
73  msg=$(git log --format="%h %ci %ce" -1 $1)
74  h=$(echo $msg | cut -d" " -f1)
75  d=$(echo $msg | cut -d" " -f2)
76  t=$(echo $msg | cut -d" " -f3)
77  a=$(echo $msg | cut -d" " -f5)
78  a1=$(echo $a | cut -d"@" -f1)
79  a2=$(echo $a | cut -d"@" -f2)
80  echo $h $d $t $a1@$a2
81}
82
83v8_revision() {
84  cd $V8
85  $INFO -v $1
86}
87
88rolls() {
89  roll=$2
90  for i in $(seq 1 $1); do
91    info=$(v8_info $roll)
92    roll=$(echo $info | v8_roll $roll)
93    trunk=$(echo $info | v8_svn $roll)
94    echo "$(v8_revision $trunk) $trunk $(find_rev $roll) $(msg $roll)"
95    roll=$roll^1
96  done
97}
98
99########## Option parsing
100
101REVISIONS=1
102START=HEAD
103
104while getopts ":hn:s:" OPTION ; do
105  case $OPTION in
106    h)  usage
107        exit 0
108        ;;
109    n) REVISIONS=$OPTARG
110        ;;
111    s) START=$OPTARG
112        ;;
113    ?)  echo "Illegal option: -$OPTARG"
114        usage
115        exit 1
116        ;;
117  esac
118done
119
120rolls $REVISIONS $START
121