make/scripts/webrev.ksh
author mduigou
Fri, 13 Sep 2013 12:06:53 -0700
changeset 19754 76f369edc1ca
parent 16821 a7d69ce6432c
child 20274 b76b26641346
permissions -rw-r--r--
8024201: Update bugdatabase url Reviewed-by: wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     1
#!/bin/ksh -p
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     2
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     3
# CDDL HEADER START
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     4
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     8
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    11
# See the License for the specific language governing permissions
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    12
# and limitations under the License.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    13
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    19
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    20
# CDDL HEADER END
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    21
#
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
    22
# Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    23
# Use is subject to license terms.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    24
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    25
# This script takes a file list and a workspace and builds a set of html files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    26
# suitable for doing a code review of source changes via a web page.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    27
# Documentation is available via 'webrev -h'.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    28
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    29
19754
76f369edc1ca 8024201: Update bugdatabase url
mduigou
parents: 16821
diff changeset
    30
WEBREV_UPDATED=24.1-hg+openjdk.java.net
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    31
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    32
HTML='<?xml version="1.0"?>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    33
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    34
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    35
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    36
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    37
FRAMEHTML='<?xml version="1.0"?>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    38
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    39
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    40
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    41
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    42
STDHEAD='<meta http-equiv="cache-control" content="no-cache" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    43
<meta http-equiv="Pragma" content="no-cache" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    44
<meta http-equiv="Expires" content="-1" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    45
<!--
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    46
   Note to customizers: the body of the webrev is IDed as SUNWwebrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    47
   to allow easy overriding by users of webrev via the userContent.css
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    48
   mechanism available in some browsers.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    49
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    50
   For example, to have all "removed" information be red instead of
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    51
   brown, set a rule in your userContent.css file like:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    52
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    53
       body#SUNWwebrev span.removed { color: red ! important; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    54
-->
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    55
<style type="text/css" media="screen">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    56
body {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    57
    background-color: #eeeeee;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    58
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    59
hr {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    60
    border: none 0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    61
    border-top: 1px solid #aaa;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    62
    height: 1px;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    63
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    64
div.summary {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    65
    font-size: .8em;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    66
    border-bottom: 1px solid #aaa;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    67
    padding-left: 1em;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    68
    padding-right: 1em;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    69
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    70
div.summary h2 {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    71
    margin-bottom: 0.3em;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    72
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    73
div.summary table th {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    74
    text-align: right;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    75
    vertical-align: top;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    76
    white-space: nowrap;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    77
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    78
span.lineschanged {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    79
    font-size: 0.7em;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    80
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    81
span.oldmarker {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    82
    color: red;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    83
    font-size: large;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    84
    font-weight: bold;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    85
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    86
span.newmarker {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    87
    color: green;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    88
    font-size: large;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    89
    font-weight: bold;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    90
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    91
span.removed {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    92
    color: brown;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    93
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    94
span.changed {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    95
    color: blue;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    96
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    97
span.new {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    98
    color: blue;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    99
    font-weight: bold;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   100
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   101
a.print { font-size: x-small; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   102
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   103
</style>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   104
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   105
<style type="text/css" media="print">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   106
pre { font-size: 0.8em; font-family: courier, monospace; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   107
span.removed { color: #444; font-style: italic }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   108
span.changed { font-weight: bold; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   109
span.new { font-weight: bold; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   110
span.newmarker { font-size: 1.2em; font-weight: bold; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   111
span.oldmarker { font-size: 1.2em; font-weight: bold; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   112
a.print {display: none}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   113
hr { border: none 0; border-top: 1px solid #aaa; height: 1px; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   114
</style>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   115
'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   116
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   117
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   118
# UDiffs need a slightly different CSS rule for 'new' items (we don't
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   119
# want them to be bolded as we do in cdiffs or sdiffs).
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   120
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   121
UDIFFCSS='
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   122
<style type="text/css" media="screen">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   123
span.new {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   124
    color: blue;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   125
    font-weight: normal;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   126
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   127
</style>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   128
'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   129
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   130
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   131
# input_cmd | html_quote | output_cmd
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   132
# or
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   133
# html_quote filename | output_cmd
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   134
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   135
# Make a piece of source code safe for display in an HTML <pre> block.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   136
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   137
html_quote()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   138
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   139
	sed -e "s/&/\&amp;/g" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" "$@" | expand
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   140
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   141
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   142
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   143
# input_cmd | bug2url | output_cmd
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   144
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   145
# Scan for bugids and insert <a> links to the relevent bug database.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   146
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   147
bug2url()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   148
{
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
   149
	sed -e 's|[0-9]\{5,\}|<a href=\"'$BUGURL$IDPREFIX'&\">&</a>|g'
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   150
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   151
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   152
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   153
# input_cmd | sac2url | output_cmd
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   154
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   155
# Scan for ARC cases and insert <a> links to the relevent SAC database.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   156
# This is slightly complicated because inside the SWAN, SAC cases are
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   157
# grouped by ARC: PSARC/2006/123.  But on OpenSolaris.org, they are
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   158
# referenced as 2006/123 (without labelling the ARC).
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   159
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   160
sac2url()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   161
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   162
	if [[ -z $Oflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   163
	    sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'\1/\2/\3\">\1 \2/\3</a>|g'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   164
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   165
	    sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'/\2/\3\">\1 \2/\3</a>|g'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   166
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   167
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   168
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   169
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   170
# strip_unchanged <infile> | output_cmd
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   171
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   172
# Removes chunks of sdiff documents that have not changed. This makes it
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   173
# easier for a code reviewer to find the bits that have changed.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   174
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   175
# Deleted lines of text are replaced by a horizontal rule. Some
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   176
# identical lines are retained before and after the changed lines to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   177
# provide some context.  The number of these lines is controlled by the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   178
# variable C in the $AWK script below.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   179
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   180
# The script detects changed lines as any line that has a "<span class="
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   181
# string embedded (unchanged lines have no particular class and are not
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   182
# part of a <span>).  Blank lines (without a sequence number) are also
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   183
# detected since they flag lines that have been inserted or deleted.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   184
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   185
strip_unchanged()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   186
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   187
	$AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   188
	BEGIN	{ C = c = 20 }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   189
	NF == 0 || /span class=/ {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   190
		if (c > C) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   191
			c -= C
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   192
			inx = 0
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   193
			if (c > C) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   194
				print "\n</pre><hr></hr><pre>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   195
				inx = c % C
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   196
				c = C
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   197
			}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   198
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   199
			for (i = 0; i < c; i++)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   200
				print ln[(inx + i) % C]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   201
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   202
		c = 0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   203
		print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   204
		next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   205
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   206
	{	if (c >= C) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   207
			ln[c % C] = $0
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   208
			c++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   209
			next;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   210
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   211
		c++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   212
		print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   213
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   214
	END	{ if (c > (C * 2)) print "\n</pre><hr></hr>" }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   215
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   216
	' $1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   217
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   218
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   219
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   220
# sdiff_to_html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   221
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   222
# This function takes two files as arguments, obtains their diff, and
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   223
# processes the diff output to present the files as an HTML document with
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   224
# the files displayed side-by-side, differences shown in color.  It also
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   225
# takes a delta comment, rendered as an HTML snippet, as the third
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   226
# argument.  The function takes two files as arguments, then the name of
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   227
# file, the path, and the comment.  The HTML will be delivered on stdout,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   228
# e.g.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   229
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   230
#   $ sdiff_to_html old/usr/src/tools/scripts/webrev.sh \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   231
#         new/usr/src/tools/scripts/webrev.sh \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   232
#         webrev.sh usr/src/tools/scripts \
19754
76f369edc1ca 8024201: Update bugdatabase url
mduigou
parents: 16821
diff changeset
   233
#         '<a href="https://bugs.openjdk.java.net/browse/JDK-1234567">
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
   234
#          JDK-1234567</a> my bugid' > <file>.html
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   235
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   236
# framed_sdiff() is then called which creates $2.frames.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   237
# in the webrev tree.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   238
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   239
# FYI: This function is rather unusual in its use of awk.  The initial
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   240
# diff run produces conventional diff output showing changed lines mixed
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   241
# with editing codes.  The changed lines are ignored - we're interested in
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   242
# the editing codes, e.g.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   243
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   244
#      8c8
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   245
#      57a61
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   246
#      63c66,76
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   247
#      68,93d80
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   248
#      106d90
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   249
#      108,110d91
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   250
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   251
#  These editing codes are parsed by the awk script and used to generate
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   252
#  another awk script that generates HTML, e.g the above lines would turn
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   253
#  into something like this:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   254
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   255
#      BEGIN { printf "<pre>\n" }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   256
#      function sp(n) {for (i=0;i<n;i++)printf "\n"}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   257
#      function wl(n) {printf "<font color=%s>%4d %s </font>\n", n, NR, $0}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   258
#      NR==8           {wl("#7A7ADD");next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   259
#      NR==54          {wl("#7A7ADD");sp(3);next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   260
#      NR==56          {wl("#7A7ADD");next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   261
#      NR==57          {wl("black");printf "\n"; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   262
#        :               :
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   263
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   264
#  This script is then run on the original source file to generate the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   265
#  HTML that corresponds to the source file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   266
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   267
#  The two HTML files are then combined into a single piece of HTML that
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   268
#  uses an HTML table construct to present the files side by side.  You'll
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   269
#  notice that the changes are color-coded:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   270
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   271
#   black     - unchanged lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   272
#   blue      - changed lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   273
#   bold blue - new lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   274
#   brown     - deleted lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   275
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   276
#  Blank lines are inserted in each file to keep unchanged lines in sync
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   277
#  (side-by-side).  This format is familiar to users of sdiff(1) or
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   278
#  Teamware's filemerge tool.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   279
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   280
sdiff_to_html()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   281
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   282
	diff -b $1 $2 > /tmp/$$.diffs
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   283
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   284
	TNAME=$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   285
	TPATH=$4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   286
	COMMENT=$5
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   287
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   288
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   289
	#  Now we have the diffs, generate the HTML for the old file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   290
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   291
	$AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   292
	BEGIN	{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   293
		printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   294
		printf "function removed() "
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   295
		printf "{printf \"<span class=\\\"removed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   296
		printf "function changed() "
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   297
		printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   298
		printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   299
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   300
	/^</	{next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   301
	/^>/	{next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   302
	/^---/	{next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   303
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   304
	{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   305
	split($1, a, /[cad]/) ;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   306
	if (index($1, "a")) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   307
		if (a[1] == 0) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   308
			n = split(a[2], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   309
			if (n == 1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   310
				printf "BEGIN\t\t{sp(1)}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   311
			else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   312
				printf "BEGIN\t\t{sp(%d)}\n",\
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   313
				(r[2] - r[1]) + 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   314
			next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   315
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   316
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   317
		printf "NR==%s\t\t{", a[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   318
		n = split(a[2], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   319
		s = r[1];
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   320
		if (n == 1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   321
			printf "bl();printf \"\\n\"; next}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   322
		else {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   323
			n = r[2] - r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   324
			printf "bl();sp(%d);next}\n",\
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   325
			(r[2] - r[1]) + 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   326
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   327
		next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   328
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   329
	if (index($1, "d")) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   330
		n = split(a[1], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   331
		n1 = r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   332
		n2 = r[2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   333
		if (n == 1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   334
			printf "NR==%s\t\t{removed(); next}\n" , n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   335
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   336
			printf "NR==%s,NR==%s\t{removed(); next}\n" , n1, n2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   337
		next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   338
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   339
	if (index($1, "c")) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   340
		n = split(a[1], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   341
		n1 = r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   342
		n2 = r[2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   343
		final = n2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   344
		d1 = 0
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   345
		if (n == 1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   346
			printf "NR==%s\t\t{changed();" , n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   347
		else {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   348
			d1 = n2 - n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   349
			printf "NR==%s,NR==%s\t{changed();" , n1, n2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   350
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   351
		m = split(a[2], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   352
		n1 = r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   353
		n2 = r[2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   354
		if (m > 1) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   355
			d2  = n2 - n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   356
			if (d2 > d1) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   357
				if (n > 1) printf "if (NR==%d)", final
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   358
				printf "sp(%d);", d2 - d1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   359
			}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   360
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   361
		printf "next}\n" ;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   362
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   363
		next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   364
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   365
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   366
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   367
	END	{ printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   368
	' /tmp/$$.diffs > /tmp/$$.file1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   369
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   370
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   371
	#  Now generate the HTML for the new file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   372
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   373
	$AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   374
	BEGIN	{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   375
		printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   376
		printf "function new() "
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   377
		printf "{printf \"<span class=\\\"new\\\">%%4d %%s</span>\\n\", NR, $0}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   378
		printf "function changed() "
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   379
		printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   380
		printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   381
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   382
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   383
	/^</	{next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   384
	/^>/	{next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   385
	/^---/	{next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   386
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   387
	{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   388
	split($1, a, /[cad]/) ;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   389
	if (index($1, "d")) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   390
		if (a[2] == 0) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   391
			n = split(a[1], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   392
			if (n == 1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   393
				printf "BEGIN\t\t{sp(1)}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   394
			else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   395
				printf "BEGIN\t\t{sp(%d)}\n",\
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   396
				(r[2] - r[1]) + 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   397
			next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   398
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   399
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   400
		printf "NR==%s\t\t{", a[2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   401
		n = split(a[1], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   402
		s = r[1];
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   403
		if (n == 1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   404
			printf "bl();printf \"\\n\"; next}\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   405
		else {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   406
			n = r[2] - r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   407
			printf "bl();sp(%d);next}\n",\
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   408
			(r[2] - r[1]) + 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   409
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   410
		next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   411
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   412
	if (index($1, "a")) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   413
		n = split(a[2], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   414
		n1 = r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   415
		n2 = r[2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   416
		if (n == 1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   417
			printf "NR==%s\t\t{new() ; next}\n" , n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   418
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   419
			printf "NR==%s,NR==%s\t{new() ; next}\n" , n1, n2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   420
		next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   421
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   422
	if (index($1, "c")) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   423
		n = split(a[2], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   424
		n1 = r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   425
		n2 = r[2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   426
		final = n2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   427
		d2 = 0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   428
		if (n == 1) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   429
			final = n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   430
			printf "NR==%s\t\t{changed();" , n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   431
		} else {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   432
			d2 = n2 - n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   433
			printf "NR==%s,NR==%s\t{changed();" , n1, n2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   434
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   435
		m = split(a[1], r, /,/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   436
		n1 = r[1]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   437
		n2 = r[2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   438
		if (m > 1) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   439
			d1  = n2 - n1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   440
			if (d1 > d2) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   441
				if (n > 1) printf "if (NR==%d)", final
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   442
				printf "sp(%d);", d1 - d2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   443
			}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   444
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   445
		printf "next}\n" ;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   446
		next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   447
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   448
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   449
	END	{ printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   450
	' /tmp/$$.diffs > /tmp/$$.file2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   451
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   452
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   453
	# Post-process the HTML files by running them back through $AWK
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   454
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   455
	html_quote < $1 | $AWK -f /tmp/$$.file1 > /tmp/$$.file1.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   456
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   457
	html_quote < $2 | $AWK -f /tmp/$$.file2 > /tmp/$$.file2.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   458
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   459
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   460
	# Now combine into a valid HTML file and side-by-side into a table
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   461
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   462
	print "$HTML<head>$STDHEAD"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   463
	print "<title>$WNAME Sdiff $TPATH </title>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   464
	print "</head><body id=\"SUNWwebrev\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   465
	print "<h2>$TPATH/$TNAME</h2>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   466
        print "<a class=\"print\" href=\"javascript:print()\">Print this page</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   467
	print "<pre>$COMMENT</pre>\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   468
	print "<table><tr valign=\"top\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   469
	print "<td><pre>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   470
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   471
	strip_unchanged /tmp/$$.file1.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   472
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   473
	print "</pre></td><td><pre>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   474
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   475
	strip_unchanged /tmp/$$.file2.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   476
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   477
	print "</pre></td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   478
	print "</tr></table>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   479
	print "</body></html>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   480
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   481
	framed_sdiff $TNAME $TPATH /tmp/$$.file1.html /tmp/$$.file2.html \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   482
	    "$COMMENT"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   483
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   484
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   485
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   486
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   487
# framed_sdiff <filename> <filepath> <lhsfile> <rhsfile> <comment>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   488
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   489
# Expects lefthand and righthand side html files created by sdiff_to_html.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   490
# We use insert_anchors() to augment those with HTML navigation anchors,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   491
# and then emit the main frame.  Content is placed into:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   492
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   493
#    $WDIR/DIR/$TNAME.lhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   494
#    $WDIR/DIR/$TNAME.rhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   495
#    $WDIR/DIR/$TNAME.frames.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   496
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   497
# NOTE: We rely on standard usage of $WDIR and $DIR.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   498
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   499
function framed_sdiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   500
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   501
	typeset TNAME=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   502
	typeset TPATH=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   503
	typeset lhsfile=$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   504
	typeset rhsfile=$4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   505
	typeset comments=$5
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   506
	typeset RTOP
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   507
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   508
	# Enable html files to access WDIR via a relative path.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   509
	RTOP=$(relative_dir $TPATH $WDIR)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   510
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   511
	# Make the rhs/lhs files and output the frameset file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   512
	print "$HTML<head>$STDHEAD" > $WDIR/$DIR/$TNAME.lhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   513
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   514
	cat >> $WDIR/$DIR/$TNAME.lhs.html <<-EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   515
	    <script type="text/javascript" src="$RTOP/ancnav.js"></script>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   516
	    </head>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   517
	    <body id="SUNWwebrev" onkeypress="keypress(event);">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   518
	    <a name="0"></a>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   519
	    <pre>$comments</pre><hr></hr>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   520
	EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   521
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   522
	cp $WDIR/$DIR/$TNAME.lhs.html $WDIR/$DIR/$TNAME.rhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   523
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   524
	insert_anchors $lhsfile >> $WDIR/$DIR/$TNAME.lhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   525
	insert_anchors $rhsfile >> $WDIR/$DIR/$TNAME.rhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   526
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   527
	close='</body></html>'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   528
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   529
	print $close >> $WDIR/$DIR/$TNAME.lhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   530
	print $close >> $WDIR/$DIR/$TNAME.rhs.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   531
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   532
	print "$FRAMEHTML<head>$STDHEAD" > $WDIR/$DIR/$TNAME.frames.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   533
	print "<title>$WNAME Framed-Sdiff " \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   534
	    "$TPATH/$TNAME</title> </head>" >> $WDIR/$DIR/$TNAME.frames.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   535
	cat >> $WDIR/$DIR/$TNAME.frames.html <<-EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   536
	  <frameset rows="*,60">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   537
	    <frameset cols="50%,50%">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   538
	      <frame src="$TNAME.lhs.html" scrolling="auto" name="lhs" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   539
	      <frame src="$TNAME.rhs.html" scrolling="auto" name="rhs" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   540
	    </frameset>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   541
	  <frame src="$RTOP/ancnav.html" scrolling="no" marginwidth="0"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   542
	   marginheight="0" name="nav" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   543
	  <noframes>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   544
            <body id="SUNWwebrev">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   545
	      Alas 'frames' webrev requires that your browser supports frames
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   546
	      and has the feature enabled.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   547
            </body>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   548
	  </noframes>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   549
	  </frameset>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   550
	</html>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   551
	EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   552
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   553
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   554
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   555
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   556
# fix_postscript
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   557
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   558
# Merge codereview output files to a single conforming postscript file, by:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   559
# 	- removing all extraneous headers/trailers
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   560
#	- making the page numbers right
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   561
#	- removing pages devoid of contents which confuse some
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   562
#	  postscript readers.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   563
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   564
# From Casper.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   565
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   566
function fix_postscript
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   567
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   568
	infile=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   569
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   570
	cat > /tmp/$$.crmerge.pl << \EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   571
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   572
	print scalar(<>);		# %!PS-Adobe---
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   573
	print "%%Orientation: Landscape\n";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   574
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   575
	$pno = 0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   576
	$doprint = 1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   577
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   578
	$page = "";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   579
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   580
	while (<>) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   581
		next if (/^%%Pages:\s*\d+/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   582
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   583
		if (/^%%Page:/) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   584
			if ($pno == 0 || $page =~ /\)S/) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   585
				# Header or single page containing text
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   586
				print "%%Page: ? $pno\n" if ($pno > 0);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   587
				print $page;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   588
				$pno++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   589
			} else {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   590
				# Empty page, skip it.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   591
			}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   592
			$page = "";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   593
			$doprint = 1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   594
			next;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   595
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   596
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   597
		# Skip from %%Trailer of one document to Endprolog
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   598
		# %%Page of the next
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   599
		$doprint = 0 if (/^%%Trailer/);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   600
		$page .= $_ if ($doprint);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   601
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   602
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   603
	if ($page =~ /\)S/) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   604
		print "%%Page: ? $pno\n";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   605
		print $page;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   606
	} else {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   607
		$pno--;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   608
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   609
	print "%%Trailer\n%%Pages: $pno\n";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   610
EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   611
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   612
	$PERL /tmp/$$.crmerge.pl < $infile
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   613
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   614
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   615
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   616
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   617
# input_cmd | insert_anchors | output_cmd
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   618
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   619
# Flag blocks of difference with sequentially numbered invisible
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   620
# anchors.  These are used to drive the frames version of the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   621
# sdiffs output.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   622
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   623
# NOTE: Anchor zero flags the top of the file irrespective of changes,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   624
# an additional anchor is also appended to flag the bottom.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   625
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   626
# The script detects changed lines as any line that has a "<span
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   627
# class=" string embedded (unchanged lines have no class set and are
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   628
# not part of a <span>.  Blank lines (without a sequence number)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   629
# are also detected since they flag lines that have been inserted or
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   630
# deleted.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   631
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   632
function insert_anchors
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   633
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   634
	$AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   635
	function ia() {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   636
		# This should be able to be a singleton <a /> but that
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   637
		# seems to trigger a bug in firefox a:hover rule processing
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   638
		printf "<a name=\"%d\" id=\"anc%d\"></a>", anc, anc++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   639
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   640
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   641
	BEGIN {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   642
		anc=1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   643
		inblock=1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   644
		printf "<pre>\n";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   645
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   646
	NF == 0 || /^<span class=/ {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   647
		if (inblock == 0) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   648
			ia();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   649
			inblock=1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   650
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   651
		print;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   652
		next;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   653
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   654
	{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   655
		inblock=0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   656
		print;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   657
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   658
	END {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   659
		ia();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   660
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   661
		printf "<b style=\"font-size: large; color: red\">";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   662
		printf "--- EOF ---</b>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   663
        	for(i=0;i<8;i++) printf "\n\n\n\n\n\n\n\n\n\n";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   664
		printf "</pre>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   665
		printf "<form name=\"eof\">";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   666
		printf "<input name=\"value\" value=\"%d\" type=\"hidden\" />",
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   667
		    anc - 1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   668
		printf "</form>";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   669
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   670
	' $1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   671
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   672
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   673
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   674
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   675
# relative_dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   676
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   677
# Print a relative return path from $1 to $2.  For example if
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   678
# $1=/tmp/myreview/raw_files/usr/src/tools/scripts and $2=/tmp/myreview,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   679
# this function would print "../../../../".
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   680
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   681
# In the event that $1 is not in $2 a warning is printed to stderr,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   682
# and $2 is returned-- the result of this is that the resulting webrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   683
# is not relocatable.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   684
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   685
function relative_dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   686
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   687
    d1=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   688
    d2=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   689
    if [[ "$d1" == "." ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   690
	print "."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   691
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   692
	typeset cur="${d1##$d2?(/)}"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   693
	typeset ret=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   694
	if [[ $d2 == $cur ]]; then   # Should never happen.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   695
		# Should never happen.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   696
		print -u2 "\nWARNING: relative_dir: \"$1\" not relative "
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   697
		print -u2 "to \"$2\".  Check input paths.  Framed webrev "
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   698
		print -u2 "will not be relocatable!"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   699
		print $2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   700
		return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   701
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   702
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   703
	while [[ -n ${cur} ]];
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   704
	do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   705
		cur=${cur%%*(/)*([!/])}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   706
		if [[ -z $ret ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   707
			ret=".."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   708
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   709
			ret="../$ret"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   710
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   711
	done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   712
	print $ret
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   713
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   714
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   715
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   716
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   717
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   718
# frame_nav_js
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   719
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   720
# Emit javascript for frame navigation
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   721
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   722
function frame_nav_js
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   723
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   724
cat << \EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   725
var myInt;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   726
var scrolling=0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   727
var sfactor = 3;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   728
var scount=10;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   729
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   730
function scrollByPix() {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   731
	if (scount<=0) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   732
		sfactor*=1.2;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   733
		scount=10;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   734
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   735
	parent.lhs.scrollBy(0,sfactor);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   736
	parent.rhs.scrollBy(0,sfactor);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   737
	scount--;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   738
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   739
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   740
function scrollToAnc(num) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   741
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   742
	// Update the value of the anchor in the form which we use as
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   743
	// storage for this value.  setAncValue() will take care of
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   744
	// correcting for overflow and underflow of the value and return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   745
	// us the new value.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   746
	num = setAncValue(num);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   747
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   748
	// Set location and scroll back a little to expose previous
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   749
	// lines.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   750
	//
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   751
	// Note that this could be improved: it is possible although
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   752
	// complex to compute the x and y position of an anchor, and to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   753
	// scroll to that location directly.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   754
	//
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   755
	parent.lhs.location.replace(parent.lhs.location.pathname + "#" + num);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   756
	parent.rhs.location.replace(parent.rhs.location.pathname + "#" + num);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   757
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   758
	parent.lhs.scrollBy(0,-30);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   759
	parent.rhs.scrollBy(0,-30);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   760
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   761
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   762
function getAncValue()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   763
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   764
	return (parseInt(parent.nav.document.diff.real.value));
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   765
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   766
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   767
function setAncValue(val)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   768
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   769
	if (val <= 0) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   770
		val = 0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   771
		parent.nav.document.diff.real.value = val;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   772
		parent.nav.document.diff.display.value = "BOF";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   773
		return (val);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   774
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   775
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   776
	//
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   777
	// The way we compute the max anchor value is to stash it
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   778
	// inline in the left and right hand side pages-- it's the same
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   779
	// on each side, so we pluck from the left.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   780
	//
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   781
	maxval = parent.lhs.document.eof.value.value;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   782
	if (val < maxval) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   783
		parent.nav.document.diff.real.value = val;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   784
		parent.nav.document.diff.display.value = val.toString();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   785
		return (val);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   786
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   787
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   788
	// this must be: val >= maxval
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   789
	val = maxval;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   790
	parent.nav.document.diff.real.value = val;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   791
	parent.nav.document.diff.display.value = "EOF";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   792
	return (val);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   793
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   794
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   795
function stopScroll() {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   796
	if (scrolling==1) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   797
		clearInterval(myInt);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   798
		scrolling=0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   799
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   800
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   801
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   802
function startScroll() {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   803
	stopScroll();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   804
	scrolling=1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   805
	myInt=setInterval("scrollByPix()",10);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   806
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   807
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   808
function handlePress(b) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   809
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   810
	switch (b) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   811
	    case 1 :
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   812
		scrollToAnc(-1);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   813
		break;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   814
	    case 2 :
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   815
		scrollToAnc(getAncValue() - 1);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   816
		break;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   817
	    case 3 :
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   818
		sfactor=-3;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   819
		startScroll();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   820
		break;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   821
	    case 4 :
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   822
		sfactor=3;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   823
		startScroll();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   824
		break;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   825
	    case 5 :
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   826
		scrollToAnc(getAncValue() + 1);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   827
		break;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   828
	    case 6 :
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   829
		scrollToAnc(999999);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   830
		break;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   831
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   832
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   833
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   834
function handleRelease(b) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   835
	stopScroll();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   836
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   837
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   838
function keypress(ev) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   839
	var keynum;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   840
	var keychar;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   841
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   842
	if (window.event) { // IE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   843
		keynum = ev.keyCode;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   844
	} else if (ev.which) { // non-IE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   845
		keynum = ev.which;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   846
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   847
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   848
	keychar = String.fromCharCode(keynum);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   849
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   850
	if (keychar == "k") {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   851
		handlePress(2);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   852
		return (0);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   853
	} else if (keychar == "j" || keychar == " ") {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   854
		handlePress(5);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   855
		return (0);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   856
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   857
	return (1);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   858
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   859
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   860
function ValidateDiffNum(){
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   861
	val = parent.nav.document.diff.display.value;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   862
	if (val == "EOF") {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   863
		scrollToAnc(999999);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   864
		return;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   865
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   866
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   867
	if (val == "BOF") {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   868
		scrollToAnc(0);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   869
		return;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   870
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   871
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   872
        i=parseInt(val);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   873
        if (isNaN(i)) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   874
                parent.nav.document.diff.display.value = getAncValue();
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   875
        } else {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   876
                scrollToAnc(i);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   877
        }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   878
        return false;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   879
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   880
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   881
EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   882
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   883
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   884
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   885
# frame_navigation
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   886
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   887
# Output anchor navigation file for framed sdiffs.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   888
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   889
function frame_navigation
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   890
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   891
	print "$HTML<head>$STDHEAD"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   892
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   893
	cat << \EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   894
<title>Anchor Navigation</title>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   895
<meta http-equiv="Content-Script-Type" content="text/javascript" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   896
<meta http-equiv="Content-Type" content="text/html" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   897
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   898
<style type="text/css">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   899
    div.button td { padding-left: 5px; padding-right: 5px;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   900
		    background-color: #eee; text-align: center;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   901
		    border: 1px #444 outset; cursor: pointer; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   902
    div.button a { font-weight: bold; color: black }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   903
    div.button td:hover { background: #ffcc99; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   904
</style>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   905
EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   906
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   907
	print "<script type=\"text/javascript\" src=\"ancnav.js\"></script>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   908
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   909
	cat << \EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   910
</head>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   911
<body id="SUNWwebrev" bgcolor="#eeeeee" onload="document.diff.real.focus();"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   912
	onkeypress="keypress(event);">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   913
    <noscript lang="javascript">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   914
      <center>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   915
	<p><big>Framed Navigation controls require Javascript</big><br />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   916
	Either this browser is incompatable or javascript is not enabled</p>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   917
      </center>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   918
    </noscript>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   919
    <table width="100%" border="0" align="center">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   920
	<tr>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   921
          <td valign="middle" width="25%">Diff navigation:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   922
          Use 'j' and 'k' for next and previous diffs; or use buttons
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   923
          at right</td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   924
	  <td align="center" valign="top" width="50%">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   925
	    <div class="button">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   926
	      <table border="0" align="center">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   927
                  <tr>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   928
		    <td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   929
		      <a onMouseDown="handlePress(1);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   930
			 onMouseUp="handleRelease(1);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   931
			 onMouseOut="handleRelease(1);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   932
			 onClick="return false;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   933
			 title="Go to Beginning Of file">BOF</a></td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   934
		    <td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   935
		      <a onMouseDown="handlePress(3);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   936
			 onMouseUp="handleRelease(3);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   937
			 onMouseOut="handleRelease(3);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   938
			 title="Scroll Up: Press and Hold to accelerate"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   939
			 onClick="return false;">Scroll Up</a></td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   940
		    <td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   941
		      <a onMouseDown="handlePress(2);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   942
			 onMouseUp="handleRelease(2);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   943
			 onMouseOut="handleRelease(2);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   944
			 title="Go to previous Diff"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   945
			 onClick="return false;">Prev Diff</a>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   946
		    </td></tr>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   947
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   948
		  <tr>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   949
		    <td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   950
		      <a onMouseDown="handlePress(6);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   951
			 onMouseUp="handleRelease(6);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   952
			 onMouseOut="handleRelease(6);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   953
			 onClick="return false;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   954
			 title="Go to End Of File">EOF</a></td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   955
		    <td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   956
		      <a onMouseDown="handlePress(4);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   957
			 onMouseUp="handleRelease(4);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   958
			 onMouseOut="handleRelease(4);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   959
			 title="Scroll Down: Press and Hold to accelerate"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   960
			 onClick="return false;">Scroll Down</a></td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   961
		    <td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   962
		      <a onMouseDown="handlePress(5);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   963
			 onMouseUp="handleRelease(5);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   964
			 onMouseOut="handleRelease(5);return true;"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   965
			 title="Go to next Diff"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   966
			 onClick="return false;">Next Diff</a></td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   967
		  </tr>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   968
              </table>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   969
	    </div>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   970
	  </td>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   971
	  <th valign="middle" width="25%">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   972
	    <form action="" name="diff" onsubmit="return ValidateDiffNum();">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   973
		<input name="display" value="BOF" size="8" type="text" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   974
		<input name="real" value="0" size="8" type="hidden" />
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   975
	    </form>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   976
	  </th>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   977
	</tr>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   978
    </table>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   979
  </body>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   980
</html>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   981
EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   982
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   983
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   984
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   985
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   986
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   987
# diff_to_html <filename> <filepath> { U | C } <comment>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   988
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   989
# Processes the output of diff to produce an HTML file representing either
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   990
# context or unified diffs.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   991
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   992
diff_to_html()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   993
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   994
	TNAME=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   995
	TPATH=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   996
	DIFFTYPE=$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   997
	COMMENT=$4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   998
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   999
	print "$HTML<head>$STDHEAD"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1000
	print "<title>$WNAME ${DIFFTYPE}diff $TPATH</title>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1001
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1002
	if [[ $DIFFTYPE == "U" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1003
		print "$UDIFFCSS"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1004
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1005
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1006
	cat <<-EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1007
	</head>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1008
	<body id="SUNWwebrev">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1009
	<h2>$TPATH</h2>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1010
        <a class="print" href="javascript:print()">Print this page</a>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1011
	<pre>$COMMENT</pre>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1012
        <pre>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1013
EOF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1014
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1015
	html_quote | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1016
	/^--- new/	{ next }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1017
	/^\+\+\+ new/	{ next }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1018
	/^--- old/	{ next }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1019
	/^\*\*\* old/	{ next }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1020
	/^\*\*\*\*/	{ next }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1021
	/^-------/	{ printf "<center><h1>%s</h1></center>\n", $0; next }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1022
	/^\@\@.*\@\@$/	{ printf "</pre><hr /><pre>\n";
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1023
			  printf "<span class=\"newmarker\">%s</span>\n", $0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1024
			  next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1025
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1026
	/^\*\*\*/	{ printf "<hr /><span class=\"oldmarker\">%s</span>\n", $0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1027
			  next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1028
	/^---/		{ printf "<span class=\"newmarker\">%s</span>\n", $0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1029
			  next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1030
	/^\+/		{printf "<span class=\"new\">%s</span>\n", $0; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1031
	/^!/		{printf "<span class=\"changed\">%s</span>\n", $0; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1032
	/^-/		{printf "<span class=\"removed\">%s</span>\n", $0; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1033
			{printf "%s\n", $0; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1034
	'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1035
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1036
	print "</pre></body></html>\n"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1037
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1038
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1039
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1040
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1041
# source_to_html { new | old } <filename>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1042
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1043
# Process a plain vanilla source file to transform it into an HTML file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1044
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1045
source_to_html()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1046
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1047
	WHICH=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1048
	TNAME=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1049
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1050
	print "$HTML<head>$STDHEAD"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1051
	print "<title>$WHICH $TNAME</title>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1052
	print "<body id=\"SUNWwebrev\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1053
	print "<pre>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1054
	html_quote | $AWK '{line += 1 ; printf "%4d %s\n", line, $0 }'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1055
	print "</pre></body></html>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1056
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1057
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1058
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1059
# teamwarecomments {text|html} parent-file child-file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1060
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1061
# Find the first delta in the child that's not in the parent.  Get the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1062
# newest delta from the parent, get all deltas from the child starting
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1063
# with that delta, and then get all info starting with the second oldest
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1064
# delta in that list (the first delta unique to the child).
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1065
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1066
# This code adapted from Bill Shannon's "spc" script
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1067
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1068
comments_from_teamware()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1069
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1070
	fmt=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1071
	pfile=$PWS/$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1072
	cfile=$CWS/$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1073
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1074
	psid=$($SCCS prs -d:I: $pfile 2>/dev/null)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1075
	if [[ -z "$psid" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1076
	    psid=1.1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1077
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1078
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1079
	set -A sids $($SCCS prs -l -r$psid -d:I: $cfile 2>/dev/null)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1080
	N=${#sids[@]}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1081
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1082
	nawkprg='
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1083
		/^COMMENTS:/	{p=1; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1084
		/^D [0-9]+\.[0-9]+/ {printf "--- %s ---\n", $2; p=0; }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1085
		NF == 0u	{ next }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1086
		{if (p==0) next; print $0 }'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1087
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1088
	if [[ $N -ge 2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1089
		sid1=${sids[$((N-2))]}	# Gets 2nd to last sid
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1090
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1091
		if [[ $fmt == "text" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1092
			$SCCS prs -l -r$sid1 $cfile  2>/dev/null | \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1093
			    $AWK "$nawkprg"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1094
			return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1095
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1096
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1097
		$SCCS prs -l -r$sid1 $cfile  2>/dev/null | \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1098
		    html_quote | bug2url | sac2url | $AWK "$nawkprg"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1099
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1100
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1101
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1102
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1103
# wxcomments {text|html} filepath
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1104
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1105
# Given the pathname of a file, find its location in a "wx" active file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1106
# list and print the following sccs comment.  Output is either text or
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1107
# HTML; if the latter, embedded bugids (sequence of 5 or more digits) are
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1108
# turned into URLs.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1109
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1110
comments_from_wx()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1111
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1112
	typeset fmt=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1113
	typeset p=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1114
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1115
	comm=`$AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1116
	$1 == "'$p'" {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1117
		do getline ; while (NF > 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1118
		getline
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1119
		while (NF > 0) { print ; getline }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1120
		exit
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1121
	}' < $wxfile`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1122
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1123
	if [[ $fmt == "text" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1124
		print "$comm"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1125
		return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1126
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1127
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1128
	print "$comm" | html_quote | bug2url | sac2url
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1129
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1130
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1131
comments_from_mercurial()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1132
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1133
	fmt=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1134
	pfile=$PWS/$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1135
	cfile=$CWS/$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1136
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1137
        logdir=`dirname $cfile`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1138
        logf=`basename $cfile`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1139
        if [ -d $logdir ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1140
            ( cd $logdir;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1141
	        active=`hg status $logf 2>/dev/null`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1142
                # If the output from 'hg status' is not empty, it means the file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1143
                # hasn't been committed, so don't fetch comments.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1144
	        if [[ -z $active ]] ; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1145
                    if [[ -n $ALL_CREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1146
                        rev_opt=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1147
                        for rev in $ALL_CREV; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1148
                            rev_opt="$rev_opt --rev $rev"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1149
                        done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1150
                        comm=`hg log $rev_opt --follow --template 'rev {rev} : {desc}\n' $logf`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1151
                    elif [[ -n $FIRST_CREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1152
		        comm=`hg log --rev $FIRST_CREV:tip --follow --template 'rev {rev} : {desc}\n' $logf`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1153
                    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1154
		        comm=`hg log -l1 --follow --template 'rev {rev} : {desc}\n' $logf`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1155
                    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1156
	        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1157
	            comm=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1158
	        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1159
	        if [[ $fmt == "text" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1160
	            print "$comm"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1161
	            return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1162
	        fi
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  1163
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1164
	        print "$comm" | html_quote | bug2url | sac2url
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1165
                )
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1166
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1167
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1168
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1169
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1170
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1171
# getcomments {text|html} filepath parentpath
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1172
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1173
# Fetch the comments depending on what SCM mode we're in.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1174
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1175
getcomments()
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1176
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1177
	typeset fmt=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1178
	typeset p=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1179
	typeset pp=$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1180
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1181
	if [[ -n $wxfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1182
		comments_from_wx $fmt $p
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1183
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1184
		if [[ $SCM_MODE == "teamware" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1185
			comments_from_teamware $fmt $pp $p
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1186
		elif [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1187
			comments_from_mercurial $fmt $pp $p
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1188
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1189
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1190
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1191
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1192
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1193
# printCI <total-changed> <inserted> <deleted> <modified> <unchanged>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1194
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1195
# Print out Code Inspection figures similar to sccs-prt(1) format.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1196
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1197
function printCI
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1198
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1199
	integer tot=$1 ins=$2 del=$3 mod=$4 unc=$5
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1200
	typeset str
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1201
	if (( tot == 1 )); then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1202
		str="line"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1203
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1204
		str="lines"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1205
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1206
	printf '%d %s changed: %d ins; %d del; %d mod; %d unchg' \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1207
	    $tot $str $ins $del $mod $unc
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1208
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1209
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1210
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1211
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1212
# difflines <oldfile> <newfile>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1213
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1214
# Calculate and emit number of added, removed, modified and unchanged lines,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1215
# and total lines changed, the sum of added + removed + modified.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1216
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1217
function difflines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1218
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1219
	integer tot mod del ins unc err
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1220
	typeset filename
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1221
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1222
	eval $( diff -e $1 $2 | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1223
	# Change range of lines: N,Nc
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1224
	/^[0-9]*,[0-9]*c$/ {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1225
		n=split(substr($1,1,length($1)-1), counts, ",");
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1226
		if (n != 2) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1227
		    error=2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1228
		    exit;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1229
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1230
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1231
		# 3,5c means lines 3 , 4 and 5 are changed, a total of 3 lines.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1232
		# following would be 5 - 3 = 2! Hence +1 for correction.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1233
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1234
		r=(counts[2]-counts[1])+1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1235
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1236
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1237
		# Now count replacement lines: each represents a change instead
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1238
		# of a delete, so increment c and decrement r.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1239
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1240
		while (getline != /^\.$/) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1241
			c++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1242
			r--;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1243
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1244
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1245
		# If there were more replacement lines than original lines,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1246
		# then r will be negative; in this case there are no deletions,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1247
		# but there are r changes that should be counted as adds, and
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1248
		# since r is negative, subtract it from a and add it to c.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1249
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1250
		if (r < 0) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1251
			a-=r;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1252
			c+=r;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1253
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1254
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1255
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1256
		# If there were more original lines than replacement lines, then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1257
		# r will be positive; in this case, increment d by that much.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1258
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1259
		if (r > 0) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1260
			d+=r;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1261
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1262
		next;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1263
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1264
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1265
	# Change lines: Nc
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1266
	/^[0-9].*c$/ {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1267
		# The first line is a replacement; any more are additions.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1268
		if (getline != /^\.$/) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1269
			c++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1270
			while (getline != /^\.$/) a++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1271
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1272
		next;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1273
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1274
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1275
	# Add lines: both Na and N,Na
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1276
	/^[0-9].*a$/ {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1277
		while (getline != /^\.$/) a++;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1278
		next;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1279
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1280
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1281
	# Delete range of lines: N,Nd
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1282
	/^[0-9]*,[0-9]*d$/ {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1283
		n=split(substr($1,1,length($1)-1), counts, ",");
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1284
		if (n != 2) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1285
			error=2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1286
			exit;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1287
		}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1288
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1289
		# 3,5d means lines 3 , 4 and 5 are deleted, a total of 3 lines.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1290
		# following would be 5 - 3 = 2! Hence +1 for correction.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1291
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1292
		r=(counts[2]-counts[1])+1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1293
		d+=r;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1294
		next;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1295
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1296
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1297
	# Delete line: Nd.   For example 10d says line 10 is deleted.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1298
	/^[0-9]*d$/ {d++; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1299
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1300
	# Should not get here!
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1301
	{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1302
		error=1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1303
		exit;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1304
	}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1305
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1306
	# Finish off - print results
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1307
	END {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1308
		printf("tot=%d;mod=%d;del=%d;ins=%d;err=%d\n",
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1309
		    (c+d+a), c, d, a, error);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1310
	}' )
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1311
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1312
	# End of $AWK, Check to see if any trouble occurred.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1313
	if (( $? > 0 || err > 0 )); then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1314
		print "Unexpected Error occurred reading" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1315
		    "\`diff -e $1 $2\`: \$?=$?, err=" $err
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1316
		return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1317
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1318
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1319
	# Accumulate totals
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1320
	(( TOTL += tot ))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1321
	(( TMOD += mod ))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1322
	(( TDEL += del ))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1323
	(( TINS += ins ))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1324
	# Calculate unchanged lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1325
	unc=`wc -l < $1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1326
	if (( unc > 0 )); then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1327
		(( unc -= del + mod ))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1328
		(( TUNC += unc ))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1329
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1330
	# print summary
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1331
	print "<span class=\"lineschanged\">\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1332
	printCI $tot $ins $del $mod $unc
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1333
	print "</span>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1334
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1335
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1336
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1337
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1338
# flist_from_wx
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1339
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1340
# Sets up webrev to source its information from a wx-formatted file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1341
# Sets the global 'wxfile' variable.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1342
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1343
function flist_from_wx
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1344
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1345
	typeset argfile=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1346
	if [[ -n ${argfile%%/*} ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1347
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1348
		# If the wx file pathname is relative then make it absolute
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1349
		# because the webrev does a "cd" later on.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1350
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1351
		wxfile=$PWD/$argfile
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1352
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1353
		wxfile=$argfile
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1354
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1355
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1356
	$AWK '{ c = 1; print;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1357
	  while (getline) {
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1358
		if (NF == 0) { c = -c; continue }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1359
		if (c > 0) print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1360
	  }
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1361
	}' $wxfile > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1362
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1363
	print " Done."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1364
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1365
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1366
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1367
# flist_from_teamware [ <args-to-putback-n> ]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1368
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1369
# Generate the file list by extracting file names from a putback -n.  Some
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1370
# names may come from the "update/create" messages and others from the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1371
# "currently checked out" warning.  Renames are detected here too.  Extract
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1372
# values for CODEMGR_WS and CODEMGR_PARENT from the output of the putback
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1373
# -n as well, but remove them if they are already defined.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1374
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1375
function flist_from_teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1376
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1377
	if [[ -n $codemgr_parent ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1378
		if [[ ! -d $codemgr_parent/Codemgr_wsdata ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1379
			print -u2 "parent $codemgr_parent doesn't look like a" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1380
			    "valid teamware workspace"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1381
			exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1382
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1383
		parent_args="-p $codemgr_parent"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1384
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1385
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1386
	print " File list from: 'putback -n $parent_args $*' ... \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1387
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1388
	putback -n $parent_args $* 2>&1 |
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1389
	    $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1390
		/^update:|^create:/	{print $2}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1391
		/^Parent workspace:/	{printf("CODEMGR_PARENT=%s\n",$3)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1392
		/^Child workspace:/	{printf("CODEMGR_WS=%s\n",$3)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1393
		/^The following files are currently checked out/ {p = 1; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1394
		NF == 0			{p=0 ; next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1395
		/^rename/		{old=$3}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1396
		$1 == "to:"		{print $2, old}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1397
		/^"/			{next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1398
		p == 1			{print $1}' |
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1399
	    sort -r -k 1,1 -u | sort > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1400
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1401
	print " Done."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1402
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1403
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1404
function outgoing_from_mercurial_forest
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1405
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1406
    hg foutgoing --template 'rev: {rev}\n' $OUTPWS | $FILTER | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1407
        BEGIN           {ntree=0}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1408
        /^comparing/    {next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1409
        /^no changes/   {next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1410
        /^searching/    {next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1411
	/^\[.*\]$/	{tree=substr($1,2,length($1)-2);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1412
                         trees[ntree++] = tree;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1413
                         revs[tree]=-1;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1414
                         next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1415
        /^rev:/   {rev=$2+0;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1416
                   if (revs[tree] == -1 || rev < revs[tree])
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1417
                        { revs[tree] = rev; };
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1418
                  next;}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1419
        END       {for (tree in trees)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1420
                        { rev=revs[trees[tree]];
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  1421
                          if (rev > 0)
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1422
                                {printf("%s %d\n",trees[tree],rev-1)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1423
                        }}' | while read LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1424
    do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1425
        set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1426
        TREE=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1427
        REV=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1428
        A=`hg -R $CWS/$TREE log --rev $REV --template '{node}'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1429
        FSTAT_OPT="--rev $A"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1430
        print "Revision: $A $REV" >> $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1431
        treestatus $TREE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1432
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1433
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1434
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1435
function flist_from_mercurial_forest
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1436
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1437
    rm -f $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1438
    if [ -z "$Nflag" ]; then
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1439
        print " File list from hg foutgoing $PWS ..."
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1440
        outgoing_from_mercurial_forest
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1441
        HG_LIST_FROM_COMMIT=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1442
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1443
    if [ ! -f $FLIST ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1444
        # hg commit hasn't been run see what is lying around
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1445
        print "\n No outgoing, perhaps you haven't commited."
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1446
        print " File list from hg fstatus -mard ...\c"
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1447
        FSTAT_OPT=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1448
        fstatus
16821
a7d69ce6432c 8011347: JKD-8009824 has broken webrev with some ksh versions
jgish
parents: 16654
diff changeset
  1449
        HG_LIST_FROM_COMMIT=
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1450
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1451
    print " Done."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1452
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1453
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1454
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1455
# Used when dealing with the result of 'hg foutgoing'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1456
# When now go down the tree and generate the change list
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1457
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1458
function treestatus
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1459
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1460
    TREE=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1461
    HGCMD="hg -R $CWS/$TREE status $FSTAT_OPT"
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  1462
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1463
    $HGCMD -mdn 2>/dev/null | $FILTER | while read F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1464
    do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1465
        echo $TREE/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1466
    done >> $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1467
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1468
    # Then all the added files
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1469
    # But some of these could have been "moved" or renamed ones or copied ones
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1470
    # so let's make sure we get the proper info
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1471
    # hg status -aC will produce something like:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1472
    #	A subdir/File3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1473
    #	A subdir/File4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1474
    #	  File4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1475
    #	A subdir/File5
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1476
    # The first and last are simple addition while the middle one
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1477
    # is a move/rename or a copy.  We can't distinguish from a rename vs a copy
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1478
    # without also getting the status of removed files.  The middle case above
19754
76f369edc1ca 8024201: Update bugdatabase url
mduigou
parents: 16821
diff changeset
  1479
    # is a rename if File4 is also shown a being removed.  If File4 is not a
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1480
    # removed file, then the middle case is a copy from File4 to subdir/File4
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1481
    # FIXME - we're not distinguishing copy from rename
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1482
    $HGCMD -aC | $FILTER | while read LINE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1483
	ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1484
	while [ -z "$ldone" ]; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1485
	    ldone="1"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1486
	    set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1487
	    if [ $# -eq 2 -a "$1" == "A" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1488
		AFILE=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1489
		if read LINE2; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1490
		    set - $LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1491
		    if [ $# -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1492
			echo $TREE/$AFILE $TREE/$1 >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1493
		    elif [ $# -eq 2 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1494
			echo $TREE/$AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1495
			LINE=$LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1496
			ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1497
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1498
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1499
		    echo $TREE/$AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1500
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1501
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1502
	done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1503
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1504
    $HGCMD -rn | $FILTER | while read RFILE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1505
	grep "$TREE/$RFILE" $FLIST >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1506
	if [ $? -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1507
	    echo $TREE/$RFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1508
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1509
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1510
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1511
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1512
function fstatus
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1513
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1514
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1515
    # forest extension is still being changed. For instance the output
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1516
    # of fstatus used to no prepend the tree path to filenames, but
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1517
    # this has changed recently. AWK code below does try to handle both
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1518
    # cases
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1519
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1520
    hg fstatus -mdn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1521
	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1522
	$1 != ""	{n=index($1,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1523
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1524
				{ printf("%s/%s\n",tree,$1)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1525
			 else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1526
				{ printf("%s\n",$1)}}' >> $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1527
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1528
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1529
    # There is a bug in the output of fstatus -aC on recent versions: it
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1530
    # inserts a space between the name of the tree and the filename of the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1531
    # old file. e.g.:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1532
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1533
    # $ hg fstatus -aC
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1534
    # [.]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1535
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1536
    # [MyWS]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1537
    # A MyWS/subdir/File2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1538
    #  MyWS/ File2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1539
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1540
    # [MyWS2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1541
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1542
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1543
    hg fstatus -aC $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1544
	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1545
	/^A .*/		{n=index($2,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1546
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1547
				{ printf("A %s/%s\n",tree,$2)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1548
			 else
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  1549
				{ printf("A %s\n",$2)};
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1550
			 next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1551
	/^ /		{n=index($1,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1552
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1553
				{ printf("%s/%s\n",tree,$1)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1554
			 else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1555
				{ if (NF == 2)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1556
					printf("%s/%s\n",tree,$2)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1557
				  else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1558
					printf("%s\n",$1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1559
				};
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1560
			 next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1561
	' | while read LINE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1562
	ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1563
	while [ -z "$ldone" ]; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1564
	    ldone="1"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1565
	    set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1566
	    if [ $# -eq 2 -a "$1" == "A" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1567
		AFILE=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1568
		if read LINE2; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1569
		    set - $LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1570
		    if [ $# -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1571
			echo $AFILE $1 >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1572
		    elif [ $# -eq 2 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1573
			echo $AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1574
			LINE=$LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1575
			ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1576
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1577
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1578
		    echo $AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1579
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1580
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1581
	done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1582
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1583
    hg fstatus -rn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1584
	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1585
	$1 != ""	{n=index($1,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1586
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1587
				{ printf("%s/%s\n",tree,$1)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1588
			 else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1589
				{ printf("%s\n",$1)}}' | while read RFILE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1590
	grep "$RFILE" $FLIST >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1591
	if [ $? -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1592
	    echo $RFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1593
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1594
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1595
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1596
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1597
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1598
# flist_from_mercurial $PWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1599
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1600
# Only local file based repositories are supported at present
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1601
# since even though we can determine the list from the parent finding
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1602
# the changes is harder.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1603
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1604
# We first look for any outgoing files, this is for when the user has
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1605
# run hg commit.  If we don't find any then we look with hg status.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1606
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1607
# We need at least one of default-push or default paths set in .hg/hgrc
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1608
# If neither are set we don't know who to compare with.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1609
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  1610
function flist_from_mercurial
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1611
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1612
#	if [ "${PWS##ssh://}" != "$PWS" -o \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1613
#	     "${PWS##http://}" != "$PWS" -o \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1614
#	     "${PWS##https://}" != "$PWS" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1615
#		print "Remote Mercurial repositories not currently supported."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1616
#		print "Set default and/or default-push to a local repository"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1617
#		exit
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1618
#	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1619
    if [[ -n $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1620
        HG_LIST_FROM_COMMIT=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1621
	flist_from_mercurial_forest
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1622
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1623
        STATUS_REV=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1624
        if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1625
            STATUS_REV="--rev $PARENT_REV"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1626
        elif [[ -n $OUTREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1627
            STATUS_REV="--rev $OUTREV"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1628
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1629
            # hg commit hasn't been run see what is lying around
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1630
            print "\n No outgoing, perhaps you haven't commited."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1631
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1632
	# First let's list all the modified or deleted files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1633
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1634
	hg status $STATUS_REV -mdn | $FILTER > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1635
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1636
	# Then all the added files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1637
	# But some of these could have been "moved" or renamed ones
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1638
	# so let's make sure we get the proper info
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1639
	# hg status -aC will produce something like:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1640
	#	A subdir/File3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1641
	#	A subdir/File4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1642
	#	  File4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1643
	#	A subdir/File5
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1644
        # The first and last are simple addition while the middle one
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1645
        # is a move/rename or a copy.  We can't distinguish from a rename vs a copy
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1646
        # without also getting the status of removed files.  The middle case above
19754
76f369edc1ca 8024201: Update bugdatabase url
mduigou
parents: 16821
diff changeset
  1647
        # is a rename if File4 is also shown a being removed.  If File4 is not a
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1648
        # removed file, then the middle case is a copy from File4 to subdir/File4
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1649
        # FIXME - we're not distinguishing copy from rename
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1650
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1651
	hg status $STATUS_REV -aC | $FILTER >$FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1652
	while read LINE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1653
	    ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1654
	    while [ -z "$ldone" ]; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1655
		ldone="1"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1656
		set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1657
		if [ $# -eq 2 -a "$1" == "A" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1658
		    AFILE=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1659
		    if read LINE2; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1660
			set - $LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1661
			if [ $# -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1662
			    echo $AFILE $1 >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1663
			elif [ $# -eq 2 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1664
			    echo $AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1665
			    LINE=$LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1666
			    ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1667
			fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1668
		    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1669
			echo $AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1670
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1671
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1672
	    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1673
	done < $FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1674
	hg status $STATUS_REV -rn | $FILTER > $FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1675
	while read RFILE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1676
	    grep "$RFILE" $FLIST >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1677
	    if [ $? -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1678
		echo $RFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1679
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1680
	done < $FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1681
	rm -f $FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1682
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1683
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1684
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1685
function env_from_flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1686
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1687
	[[ -r $FLIST ]] || return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1688
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1689
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1690
	# Use "eval" to set env variables that are listed in the file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1691
	# list.  Then copy those into our local versions of those
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1692
	# variables if they have not been set already.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1693
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1694
	eval `sed -e "s/#.*$//" $FLIST | grep = `
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1695
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1696
	[[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1697
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1698
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1699
	# Check to see if CODEMGR_PARENT is set in the flist file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1700
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1701
	[[ -z $codemgr_parent && -n $CODEMGR_PARENT ]] && \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1702
	    codemgr_parent=$CODEMGR_PARENT
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1703
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1704
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1705
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1706
# detect_scm
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1707
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1708
# We dynamically test the SCM type; this allows future extensions to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1709
# new SCM types
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1710
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1711
function detect_scm
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1712
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1713
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1714
	# If CODEMGR_WS is specified in the flist file, we assume teamware.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1715
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1716
	if [[ -r $FLIST ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1717
		egrep '^CODEMGR_WS=' $FLIST > /dev/null 2>&1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1718
		if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1719
			print "teamware"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1720
			return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1721
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1722
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1723
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1724
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1725
	# The presence of $CODEMGR_WS and a Codemgr_wsdata directory
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1726
	# is our clue that this is a teamware workspace.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1727
	# Same if true if current directory has a Codemgr_wsdata sub-dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1728
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1729
	if [[ -z "$CODEMGR_WS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1730
	    CODEMGR_WS=`workspace name 2>/dev/null`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1731
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1732
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1733
	if [[ -n $CODEMGR_WS && -d "$CODEMGR_WS/Codemgr_wsdata" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1734
		print "teamware"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1735
	elif [[ -d $PWD/Codemgr_wsdata ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1736
		print "teamware"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1737
	elif hg root >/dev/null ; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1738
		print "mercurial"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1739
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1740
		print "unknown"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1741
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1742
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1743
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1744
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1745
# Extract the parent workspace from the Codemgr_wsdata/parent file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1746
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1747
function parent_from_teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1748
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1749
    if [[ -f "$1/Codemgr_wsdata/parent" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1750
	tail -1 "$1/Codemgr_wsdata/parent"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1751
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1752
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1753
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1754
function look_for_prog
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1755
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1756
	typeset path
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1757
	typeset ppath
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1758
	typeset progname=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1759
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1760
	DEVTOOLS=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1761
	OS=`uname`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1762
	if [[ "$OS" == "SunOS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1763
	    DEVTOOLS="/java/devtools/`uname -p`/bin"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1764
	elif [[ "$OS" == "Linux" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1765
	    DEVTOOLS="/java/devtools/linux/bin"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1766
	fi
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  1767
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1768
	ppath=$PATH
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1769
	ppath=$ppath:/usr/sfw/bin:/usr/bin:/usr/sbin
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1770
	ppath=$ppath:/opt/teamware/bin:/opt/onbld/bin
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1771
	ppath=$ppath:/opt/onbld/bin/`uname -p`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1772
	ppath=$ppath:/java/devtools/share/bin:$DEVTOOLS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1773
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1774
	PATH=$ppath prog=`whence $progname`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1775
	if [[ -n $prog ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1776
		print $prog
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1777
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1778
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1779
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1780
function build_old_new_teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1781
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1782
	# If the child's version doesn't exist then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1783
	# get a readonly copy.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1784
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1785
	if [[ ! -f $F && -f SCCS/s.$F ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1786
		$SCCS get -s $F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1787
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1788
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1789
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1790
	# Snag new version of file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1791
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1792
	rm -f $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1793
	cp $F $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1794
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1795
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1796
	# Get the parent's version of the file. First see whether the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1797
	# child's version is checked out and get the parent's version
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1798
	# with keywords expanded or unexpanded as appropriate.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1799
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1800
	if [ -f $PWS/$PDIR/SCCS/s.$PF -o \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1801
	    -f $PWS/$PDIR/SCCS/p.$PF ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1802
		rm -f $olddir/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1803
		if [ -f SCCS/p.$F ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1804
			$SCCS get -s -p -k $PWS/$PDIR/$PF \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1805
			    > $olddir/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1806
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1807
			$SCCS get -s -p    $PWS/$PDIR/$PF \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1808
			    > $olddir/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1809
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1810
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1811
		if [[ -f $PWS/$PDIR/$PF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1812
			# Parent is not a real workspace, but just a raw
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1813
			# directory tree - use the file that's there as
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1814
			# the old file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1815
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1816
			rm -f $olddir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1817
			cp $PWS/$PDIR/$PF $olddir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1818
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1819
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1820
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1821
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1822
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1823
# Find the parent for $1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1824
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1825
function find_outrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1826
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1827
    crev=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1828
    prev=`hg log -r $crev --template '{parents}\n'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1829
    if [[ -z "$prev" ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1830
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1831
	# No specific parent means previous changeset is parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1832
	prev=`expr $crev - 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1833
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1834
	# Format is either of the following two:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1835
	# 546:7df6fcf1183b
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1836
	# 548:16f1915bb5cd 547:ffaa4e775815
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1837
	prev=`echo $prev | sed -e 's/\([0-9]*\):.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1838
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1839
    print $prev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1840
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1841
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1842
function extract_ssh_infos
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1843
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1844
    CMD=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1845
    if expr "$CMD" : 'ssh://[^/]*@' >/dev/null; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1846
	ssh_user=`echo $CMD | sed -e 's/ssh:\/\/\(.*\)@.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1847
	ssh_host=`echo $CMD | sed -e 's/ssh:\/\/.*@\([^/]*\)\/.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1848
	ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/.*@[^/]*\/\(.*\)/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1849
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1850
	ssh_user=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1851
	ssh_host=`echo $CMD | sed -e 's/ssh:\/\/\([^/]*\)\/.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1852
	ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/[^/]*\/\(.*\)/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1853
    fi
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  1854
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1855
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1856
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1857
function build_old_new_mercurial
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1858
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1859
	olddir=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1860
	newdir=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1861
	DIR=$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1862
	F=$4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1863
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1864
	# new version of the file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1865
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1866
	rm -rf $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1867
	if [ -f $F ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1868
	    cp $F  $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1869
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1870
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1871
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1872
	# Old version of the file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1873
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1874
	rm -rf $olddir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1875
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1876
	if [ -n "$PWS" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1877
	    if expr "$PWS" : 'ssh://' >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1878
	    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1879
		extract_ssh_infos $PWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1880
		if [ -n "$ssh_user" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1881
		    parent="ssh -l $ssh_user $ssh_host hg -R $ssh_dir --cwd $ssh_dir"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1882
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1883
		    parent="ssh $ssh_host hg -R $ssh_dir --cwd $ssh_dir"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1884
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1885
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1886
		parent="hg -R $PWS --cwd $PWS"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1887
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1888
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1889
	    parent=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1890
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1891
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1892
	if [ -z "$rename" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1893
	    if [ -n "$rflag" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1894
		parentrev=$PARENT_REV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1895
	    elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1896
                parentrev=$OUTREV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1897
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1898
                if [[ -n $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1899
                    parentrev=$HG_BRANCH
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1900
                else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1901
		    parentrev="tip"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1902
                fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1903
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1904
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1905
	    if [ -n "$parentrev" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1906
		if [ -z "$parent" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1907
		    hg cat --rev $parentrev --output $olddir/$DIR/$F $F 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1908
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1909
		    # when specifying a workspace we have to provide
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1910
		    # the full path
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1911
		    $parent cat --rev $parentrev --output $olddir/$DIR/$F $DIR/$F 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1912
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1913
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1914
	else
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  1915
	    # It's a rename (or a move), or a copy, so let's make sure we move
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1916
	    # to the right directory first, then restore it once done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1917
	    current_dir=`pwd`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1918
	    cd $CWS/$PDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1919
	    if [ -n "$rflag" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1920
		parentrev=$PARENT_REV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1921
	    elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1922
                parentrev=$OUTREV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1923
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1924
	    if [ -z "$parentrev" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1925
		parentrev=`hg log -l1 $PF | $AWK -F: '/changeset/ {print $2}'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1926
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1927
	    if [ -n "$parentrev" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1928
		mkdir -p $olddir/$PDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1929
		if [ -z "$parent" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1930
		    hg cat --rev $parentrev --output $olddir/$PDIR/$PF $PF 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1931
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1932
		    $parent cat --rev $parentrev --output $olddir/$PDIR/$PF $PDIR/$PF 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1933
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1934
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1935
	    cd $current_dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1936
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1937
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1938
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1939
function build_old_new
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1940
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1941
	if [[ $SCM_MODE == "teamware" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1942
		build_old_new_teamware $@
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1943
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1944
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1945
	if [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1946
		build_old_new_mercurial $@
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1947
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1948
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1949
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1950
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1951
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1952
# Usage message.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1953
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1954
function usage
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1955
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1956
	print "Usage:\twebrev [common-options]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1957
	webrev [common-options] ( <file> | - )
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1958
	webrev [common-options] -w <wx file>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1959
	webrev [common-options] -l [arguments to 'putback']
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1960
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1961
Options:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1962
	-v: Print the version of this tool.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1963
        -b: Do not ignore changes in the amount of white space.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1964
        -c <CR#>: Include link to CR (aka bugid) in the main page.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1965
	-O: Print bugids/arc cases suitable for OpenJDK.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1966
	-i <filename>: Include <filename> in the index.html file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1967
	-o <outdir>: Output webrev to specified directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1968
	-p <compare-against>: Use specified parent wkspc or basis for comparison
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1969
	-w <wxfile>: Use specified wx active file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1970
        -u <username>: Use that username instead of 'guessing' one.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1971
	-m: Forces the use of Mercurial
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1972
	-t: Forces the use of Teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1973
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1974
Mercurial only options:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1975
	-r rev: Compare against a specified revision
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1976
	-N: Skip 'hg outgoing', use only 'hg status'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1977
	-f: Use the forest extension
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1978
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1979
Environment:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1980
	WDIR: Control the output directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1981
	WEBREV_BUGURL: Control the URL prefix for bugids.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1982
	WEBREV_SACURL: Control the URL prefix for ARC cases.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1983
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1984
SCM Environment:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1985
	Teamware: CODEMGR_WS: Workspace location.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1986
	Teamware: CODEMGR_PARENT: Parent workspace location.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1987
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1988
"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1989
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1990
	exit 2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1991
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1992
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1993
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1994
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1995
# Main program starts here
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1996
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1997
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1998
LANG="C"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1999
LC_ALL="C"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2000
export LANG LC_ALL
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2001
trap "rm -f /tmp/$$.* ; exit" 0 1 2 3 15
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2002
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2003
set +o noclobber
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2004
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2005
[[ -z $WDIFF ]] && WDIFF=`look_for_prog wdiff`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2006
[[ -z $WX ]] && WX=`look_for_prog wx`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2007
[[ -z $CODEREVIEW ]] && CODEREVIEW=`look_for_prog codereview`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2008
[[ -z $PS2PDF ]] && PS2PDF=`look_for_prog ps2pdf`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2009
[[ -z $PERL ]] && PERL=`look_for_prog perl`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2010
[[ -z $SCCS ]] && SCCS=`look_for_prog sccs`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2011
[[ -z $AWK ]] && AWK=`look_for_prog nawk`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2012
[[ -z $AWK ]] && AWK=`look_for_prog gawk`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2013
[[ -z $AWK ]] && AWK=`look_for_prog awk`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2014
[[ -z $WSPACE ]] && WSPACE=`look_for_prog workspace`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2015
[[ -z $JAR ]] && JAR=`look_for_prog jar`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2016
[[ -z $ZIP ]] && ZIP=`look_for_prog zip`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2017
[[ -z $GETENT ]] && GETENT=`look_for_prog getent`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2018
[[ -z $WGET ]] && WGET=`look_for_prog wget`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2019
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2020
if uname | grep CYGWIN >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2021
then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2022
        ISWIN=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2023
        # Under windows mercurial outputs '\' instead of '/'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2024
        FILTER="tr '\\\\' '/'"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2025
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2026
        FILTER="cat"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2027
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2028
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2029
if [[ ! -x $PERL ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2030
	print -u2 "Error: No perl interpreter found.  Exiting."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2031
	exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2032
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2033
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2034
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2035
# These aren't fatal, but we want to note them to the user.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2036
# We don't warn on the absence of 'wx' until later when we've
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2037
# determined that we actually need to try to invoke it.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2038
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2039
# [[ ! -x $CODEREVIEW ]] && print -u2 "WARNING: codereview(1) not found."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2040
# [[ ! -x $PS2PDF ]] && print -u2 "WARNING: ps2pdf(1) not found."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2041
# [[ ! -x $WDIFF ]] && print -u2 "WARNING: wdiff not found."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2042
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2043
# Declare global total counters.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2044
integer TOTL TINS TDEL TMOD TUNC
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2045
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2046
flist_mode=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2047
flist_file=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2048
bflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2049
iflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2050
oflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2051
pflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2052
uflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2053
lflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2054
wflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2055
Oflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2056
rflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2057
Nflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2058
forestflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2059
while getopts "c:i:o:p:r:u:lmtwONvfb" opt
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2060
do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2061
	case $opt in
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2062
        b)      bflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2063
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2064
	i)	iflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2065
		INCLUDE_FILE=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2066
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2067
	o)	oflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2068
		WDIR=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2069
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2070
	p)	pflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2071
		codemgr_parent=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2072
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2073
	u)      uflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2074
		username=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2075
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2076
        c)      if [[ -z $CRID ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2077
                   CRID=$OPTARG
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2078
                else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2079
                   CRID="$CRID $OPTARG"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2080
                fi;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2081
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2082
	m)	SCM_MODE="mercurial";;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2083
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2084
	t)	SCM_MODE="teamware";;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2085
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2086
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2087
	# If -l has been specified, we need to abort further options
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2088
	# processing, because subsequent arguments are going to be
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2089
	# arguments to 'putback -n'.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2090
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2091
	l)	lflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2092
		break;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2093
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2094
	w)	wflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2095
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2096
	O)	Oflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2097
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2098
	N)	Nflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2099
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2100
	f)	forestflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2101
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2102
	r)	rflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2103
		PARENT_REV=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2104
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2105
	v)	print "$0 version: $WEBREV_UPDATED";;
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2106
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2107
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2108
	?)	usage;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2109
	esac
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2110
done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2111
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2112
FLIST=/tmp/$$.flist
16821
a7d69ce6432c 8011347: JKD-8009824 has broken webrev with some ksh versions
jgish
parents: 16654
diff changeset
  2113
HG_LIST_FROM_COMMIT=
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2114
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2115
if [[ -n $wflag && -n $lflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2116
	usage
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2117
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2118
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2119
if [[ -n $forestflag && -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2120
    print "The -r <rev> flag is incompatible with the use of forests"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2121
    exit 2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2122
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2123
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2124
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2125
# If this manually set as the parent, and it appears to be an earlier webrev,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2126
# then note that fact and set the parent to the raw_files/new subdirectory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2127
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2128
if [[ -n $pflag && -d $codemgr_parent/raw_files/new ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2129
	parent_webrev="$codemgr_parent"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2130
	codemgr_parent="$codemgr_parent/raw_files/new"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2131
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2132
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2133
if [[ -z $wflag && -z $lflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2134
	shift $(($OPTIND - 1))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2135
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2136
	if [[ $1 == "-" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2137
		cat > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2138
		flist_mode="stdin"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2139
		flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2140
		shift
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2141
	elif [[ -n $1 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2142
		if [[ ! -r $1 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2143
			print -u2 "$1: no such file or not readable"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2144
			usage
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2145
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2146
		cat $1 > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2147
		flist_mode="file"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2148
		flist_file=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2149
		flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2150
		shift
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2151
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2152
		flist_mode="auto"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2153
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2154
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2155
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2156
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2157
# Before we go on to further consider -l and -w, work out which SCM we think
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2158
# is in use.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2159
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2160
if [[ -z $SCM_MODE ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2161
    SCM_MODE=`detect_scm $FLIST`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2162
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2163
if [[ $SCM_MODE == "unknown" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2164
	print -u2 "Unable to determine SCM type currently in use."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2165
	print -u2 "For teamware: webrev looks for \$CODEMGR_WS either in"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2166
	print -u2 "              the environment or in the file list."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2167
	print -u2 "For mercurial: webrev runs 'hg root'."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2168
	exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2169
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2170
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2171
print -u2 "   SCM detected: $SCM_MODE"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2172
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2173
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2174
if [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2175
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2176
    # determine Workspace and parent workspace paths
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2177
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2178
    CWS=`hg root | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2179
    if [[ -n $pflag && -z "$PWS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2180
	OUTPWS=$codemgr_parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2181
        # Let's try to expand it if it's an alias defined in [paths]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2182
        tmp=`hg path $OUTPWS 2>/dev/null | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2183
        if [[ -n $tmp ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2184
            OUTPWS="$tmp"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2185
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2186
        if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2187
	    if expr "$codemgr_parent" : 'ssh://.*' >/dev/null; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2188
	        PWS=$codemgr_parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2189
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2190
	        PWS=`hg -R "$codemgr_parent" root 2>/dev/null | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2191
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2192
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2193
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2194
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2195
    # OUTPWS is the parent repository to use when using 'hg outgoing'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2196
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2197
    if [[ -z $Nflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2198
        if [[ -n $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2199
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2200
            # for forest we have to rely on properly set default and
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2201
            # default-push because they can be different from the top one.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2202
            # unless of course it was explicitely speficied with -p
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2203
            if [[ -z $pflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2204
                OUTPWS=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2205
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2206
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2207
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2208
            # Unfortunately mercurial is bugged and doesn't handle
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2209
            # aliases correctly in 'hg path default'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2210
            # So let's do it ourselves. Sigh...
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2211
            if [[ -z "$OUTPWS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2212
                OUTPWS=`grep default-push $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2213
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2214
            # Still empty, means no default-push
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2215
            if [[ -z "$OUTPWS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2216
                OUTPWS=`grep 'default =' $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2217
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2218
            # Let's try to expand it if it's an alias defined in [paths]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2219
            tmp=`hg path $OUTPWS 2>/dev/null | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2220
            if [[ -n $tmp ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2221
                OUTPWS="$tmp"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2222
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2223
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2224
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2225
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2226
    # OUTPWS may contain username:password, let's make sure we remove the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2227
    # sensitive information before we print out anything in the HTML
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2228
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2229
    OUTPWS2=$OUTPWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2230
    if [[ -n $OUTPWS ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2231
	if [[ `expr "$OUTPWS" : '.*://[^/]*@.*'` -gt 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2232
	    # Remove everything between '://' and '@'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2233
	    OUTPWS2=`echo $OUTPWS | sed -e 's/\(.*:\/\/\).*@\(.*\)/\1\2/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2234
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2235
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2236
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2237
    if [[ -z $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2238
        HG_BRANCH=`hg branch`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2239
        if [ "$HG_BRANCH" == "default" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2240
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2241
            # 'default' means no particular branch, so let's cancel that
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2242
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2243
            HG_BRANCH=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2244
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2245
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2246
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2247
    if [[ -z $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2248
        if [[ -z $Nflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2249
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2250
            # If no "-N", always do "hg outgoing" against parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2251
            # repository to determine list of outgoing revisions.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2252
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2253
            ALL_CREV=`hg outgoing -q --template '{rev}\n' $OUTPWS | sort -n`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2254
            if [[ -n $ALL_CREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2255
                FIRST_CREV=`echo "$ALL_CREV" | head -1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2256
                #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2257
                # If no "-r", choose revision to compare against by
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2258
                # finding the latest revision not in the outgoing list.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2259
                #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2260
                if [[ -z $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2261
                    OUTREV=`find_outrev "$FIRST_CREV"`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2262
                    if [[ -n $OUTREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2263
                        HG_LIST_FROM_COMMIT=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2264
                    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2265
                fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2266
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2267
        elif [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2268
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2269
            # If skipping "hg outgoing" but still comparing against a
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2270
            # specific revision (not the tip), set revision for comment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2271
            # accumulation.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2272
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2273
            FIRST_CREV=`hg log --rev $PARENT_REV --template '{rev}'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2274
            FIRST_CREV=`expr $FIRST_CREV + 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2275
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2276
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2277
    #Let's check if a merge is needed, if so, issue a warning
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2278
    PREV=`hg parent | grep '^tag:.*tip$'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2279
    if [[ -z $PREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2280
        print "WARNING: parent rev is not tip. Maybe an update or merge is needed"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2281
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2282
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2283
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2284
if [[ -n $lflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2285
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2286
	# If the -l flag is given instead of the name of a file list,
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2287
	# then generate the file list by extracting file names from a
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2288
	# putback -n.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2289
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2290
	shift $(($OPTIND - 1))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2291
	if [[ $SCM_MODE == "teamware" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2292
		flist_from_teamware "$*"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2293
	elif [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2294
		flist_from_mercurial
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2295
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2296
	flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2297
	shift $#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2298
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2299
elif [[ -n $wflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2300
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2301
	# If the -w is given then assume the file list is in Bonwick's "wx"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2302
	# command format, i.e.  pathname lines alternating with SCCS comment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2303
	# lines with blank lines as separators.  Use the SCCS comments later
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2304
	# in building the index.html file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2305
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2306
	shift $(($OPTIND - 1))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2307
	wxfile=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2308
	if [[ -z $wxfile && -n $CODEMGR_WS ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2309
		if [[ -r $CODEMGR_WS/wx/active ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2310
			wxfile=$CODEMGR_WS/wx/active
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2311
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2312
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2313
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2314
	[[ -z $wxfile ]] && print -u2 "wx file not specified, and could not " \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2315
	    "be auto-detected (check \$CODEMGR_WS)" && exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2316
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2317
	print -u2 " File list from: wx 'active' file '$wxfile' ... \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2318
	flist_from_wx $wxfile
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2319
	flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2320
	if [[ -n "$*" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2321
		shift
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2322
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2323
elif [[ $flist_mode == "stdin" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2324
	print -u2 " File list from: standard input"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2325
elif [[ $flist_mode == "file" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2326
	print -u2 " File list from: $flist_file"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2327
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2328
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2329
if [[ $# -gt 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2330
	print -u2 "WARNING: unused arguments: $*"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2331
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2332
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2333
if [[ $SCM_MODE == "teamware" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2334
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2335
	# Parent (internally $codemgr_parent) and workspace ($codemgr_ws) can
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2336
	# be set in a number of ways, in decreasing precedence:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2337
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2338
	#      1) on the command line (only for the parent)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2339
	#      2) in the user environment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2340
	#      3) in the flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2341
	#      4) automatically based on the workspace (only for the parent)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2342
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2343
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2344
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2345
	# Here is case (2): the user environment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2346
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2347
	[[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2348
	[[ -z $codemgr_ws && -n $WSPACE ]] && codemgr_ws=`$WSPACE name`
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2349
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2350
	if [[ -n $codemgr_ws && ! -d $codemgr_ws ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2351
		print -u2 "$codemgr_ws: no such workspace"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2352
		exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2353
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2354
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2355
	[[ -z $codemgr_parent && -n $CODEMGR_PARENT ]] && \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2356
	    codemgr_parent=$CODEMGR_PARENT
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2357
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2358
	if [[ -n $codemgr_parent && ! -d $codemgr_parent ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2359
		print -u2 "$codemgr_parent: no such directory"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2360
		exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2361
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2362
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2363
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2364
	# If we're in auto-detect mode and we haven't already gotten the file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2365
	# list, then see if we can get it by probing for wx.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2366
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2367
	if [[ -z $flist_done && $flist_mode == "auto" && -n $codemgr_ws ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2368
		if [[ ! -x $WX ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2369
			print -u2 "WARNING: wx not found!"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2370
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2371
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2372
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2373
		# We need to use wx list -w so that we get renamed files, etc.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2374
		# but only if a wx active file exists-- otherwise wx will
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2375
		# hang asking us to initialize our wx information.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2376
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2377
		if [[ -x $WX && -f $codemgr_ws/wx/active ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2378
			print -u2 " File list from: 'wx list -w' ... \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2379
			$WX list -w > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2380
			$WX comments > /tmp/$$.wx_comments
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2381
			wxfile=/tmp/$$.wx_comments
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2382
			print -u2 "done"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2383
			flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2384
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2385
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2386
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2387
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2388
	# If by hook or by crook we've gotten a file list by now (perhaps
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2389
	# from the command line), eval it to extract environment variables from
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2390
	# it: This is step (3).
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2391
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2392
	env_from_flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2393
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2394
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2395
	# Continuing step (3): If we still have no file list, we'll try to get
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2396
	# it from teamware.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2397
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2398
	if [[ -z $flist_done ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2399
		flist_from_teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2400
		env_from_flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2401
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2402
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2403
	if [[ -z $codemgr_ws && -d $PWD/Codemgr_wsdata ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2404
	    codemgr_ws=$PWD
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2405
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2406
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2407
	# Observe true directory name of CODEMGR_WS, as used later in
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2408
	# webrev title.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2409
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2410
	if [[ -n $codemgr_ws ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2411
	    codemgr_ws=$(cd $codemgr_ws;print $PWD)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2412
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2413
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2414
	if [[ -n $codemgr_parent ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2415
	    codemgr_parent=$(cd $codemgr_parent;print $PWD)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2416
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2417
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2418
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2419
	# (4) If we still don't have a value for codemgr_parent, get it
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2420
	# from workspace.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2421
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2422
	[[ -z $codemgr_parent && -n $WSPACE ]] && codemgr_parent=`$WSPACE parent`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2423
	[[ -z $codemgr_parent ]] && codemgr_parent=`parent_from_teamware $codemgr_ws`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2424
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2425
	if [[ ! -d $codemgr_parent ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2426
	    print -u2 "$CODEMGR_PARENT: no such parent workspace"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2427
	    exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2428
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2429
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2430
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2431
	# Reset CODEMGR_WS to make sure teamware commands are happy.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2432
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2433
	CODEMGR_WS=$codemgr_ws
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2434
	CWS=$codemgr_ws
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2435
	PWS=$codemgr_parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2436
elif [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2437
    if [[ -z $flist_done ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2438
	flist_from_mercurial $PWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2439
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2440
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2441
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2442
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2443
# If the user didn't specify a -i option, check to see if there is a
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2444
# webrev-info file in the workspace directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2445
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2446
if [[ -z $iflag && -r "$CWS/webrev-info" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2447
	iflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2448
	INCLUDE_FILE="$CWS/webrev-info"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2449
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2450
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2451
if [[ -n $iflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2452
	if [[ ! -r $INCLUDE_FILE ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2453
		print -u2 "include file '$INCLUDE_FILE' does not exist or is" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2454
		    "not readable."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2455
		exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2456
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2457
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2458
		# $INCLUDE_FILE may be a relative path, and the script alters
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2459
		# PWD, so we just stash a copy in /tmp.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2460
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2461
		cp $INCLUDE_FILE /tmp/$$.include
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2462
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2463
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2464
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2465
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2466
# Output directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2467
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2468
if [[ -z $WDIR ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2469
    WDIR=$CWS/webrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2470
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2471
    # If the output directory doesn't end with '/webrev' or '/webrev/'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2472
    # then add '/webrev'. This is for backward compatibility
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2473
    if ! expr $WDIR : '.*/webrev/\?$' >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2474
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2475
	WDIR=$WDIR/webrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2476
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2477
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2478
# WDIR=${WDIR:-$CWS/webrev}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2479
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2480
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2481
# Name of the webrev, derived from the workspace name; in the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2482
# future this could potentially be an option.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2483
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2484
# Let's keep what's after the last '/'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2485
WNAME=${CWS##*/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2486
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2487
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2488
# If WDIR doesn't start with '/' or 'x:' prepend the current dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2489
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2490
if [ ${WDIR%%/*} ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2491
    if [[ -n $ISWIN ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2492
        if [ ${WDIR%%[A-Za-z]:*} ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2493
	    WDIR=$PWD/$WDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2494
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2495
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2496
	WDIR=$PWD/$WDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2497
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2498
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2499
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2500
if [[ ! -d $WDIR ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2501
	mkdir -p $WDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2502
	[[ $? != 0 ]] && exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2503
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2504
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2505
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2506
# Summarize what we're going to do.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2507
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2508
print "      Workspace: $CWS"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2509
if [[ -n $parent_webrev ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2510
    print "Compare against: webrev at $parent_webrev"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2511
elif [[ -n $OUTPWS2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2512
    print "Compare against: $OUTPWS2"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2513
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2514
if [[ -n $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2515
    print "         Branch: $HG_BRANCH"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2516
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2517
if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2518
        print "Compare against version: $PARENT_REV"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2519
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2520
[[ -n $INCLUDE_FILE ]] && print "      Including: $INCLUDE_FILE"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2521
print "      Output to: $WDIR"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2522
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2523
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2524
# Save the file list in the webrev dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2525
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2526
[[ ! $FLIST -ef $WDIR/file.list ]] && cp $FLIST $WDIR/file.list
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2527
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2528
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2529
#    Bug IDs will be replaced by a URL.  Order of precedence
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2530
#    is: default location, $WEBREV_BUGURL, the -O flag.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2531
#
19754
76f369edc1ca 8024201: Update bugdatabase url
mduigou
parents: 16821
diff changeset
  2532
BUGURL='https://bugs.openjdk.java.net/browse/'
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2533
[[ -n $WEBREV_BUGURL ]] && BUGURL="$WEBREV_BUGURL"
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2534
if [[ -n "$Oflag" ]]; then
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2535
    CRID=`echo $CRID | sed -e 's/JDK-//'`
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2536
    BUGURL='http://bugs.sun.com/bugdatabase/view_bug.do?bug_id='
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2537
    IDPREFIX=''
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2538
else
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2539
    IDPREFIX='JDK-'
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2540
fi
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2541
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2542
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2543
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2544
#    Likewise, ARC cases will be replaced by a URL.  Order of precedence
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2545
#    is: default, $WEBREV_SACURL, the -O flag.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2546
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2547
#    Note that -O also triggers different substitution behavior for
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2548
#    SACURL.  See sac2url().
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2549
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2550
SACURL='http://sac.eng.sun.com'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2551
[[ -n $WEBREV_SACURL ]] && SACURL="$WEBREV_SACURL"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2552
[[ -n $Oflag ]] && \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2553
    SACURL='http://www.opensolaris.org/os/community/arc/caselog'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2554
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2555
rm -f $WDIR/$WNAME.patch
16821
a7d69ce6432c 8011347: JKD-8009824 has broken webrev with some ksh versions
jgish
parents: 16654
diff changeset
  2556
rm -f $WDIR/$WNAME.changeset
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2557
rm -f $WDIR/$WNAME.ps
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2558
rm -f $WDIR/$WNAME.pdf
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2559
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2560
touch $WDIR/$WNAME.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2561
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2562
print "   Output Files:"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2563
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2564
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2565
# Clean up the file list: Remove comments, blank lines and env variables.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2566
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2567
sed -e "s/#.*$//" -e "/=/d" -e "/^[   ]*$/d" $FLIST > /tmp/$$.flist.clean
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2568
FLIST=/tmp/$$.flist.clean
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2569
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2570
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2571
# Clean up residual raw files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2572
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2573
if [ -d $WDIR/raw_files ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2574
    rm -rf $WDIR/raw_files 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2575
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2576
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2577
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2578
# Should we ignore changes in white spaces when generating diffs?
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2579
#
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2580
if [[ -n $bflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2581
    DIFFOPTS="-t"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2582
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2583
    DIFFOPTS="-bt"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2584
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2585
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2586
# First pass through the files: generate the per-file webrev HTML-files.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2587
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2588
while read LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2589
do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2590
	set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2591
	P=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2592
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2593
        if [[ $1 == "Revision:" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2594
            OUTREV=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2595
            continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2596
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2597
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2598
	# Normally, each line in the file list is just a pathname of a
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2599
	# file that has been modified or created in the child.  A file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2600
	# that is renamed in the child workspace has two names on the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2601
	# line: new name followed by the old name.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2602
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2603
	oldname=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2604
	oldpath=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2605
	rename=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2606
	if [[ $# -eq 2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2607
		PP=$2			# old filename
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2608
		oldname=" (was $PP)"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2609
		oldpath="$PP"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2610
		rename=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2611
        	PDIR=${PP%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2612
        	if [[ $PDIR == $PP ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2613
			PDIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2614
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2615
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2616
		PF=${PP##*/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2617
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2618
	        DIR=${P%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2619
	        if [[ $DIR == $P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2620
			DIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2621
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2622
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2623
		F=${P##*/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2624
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2625
	        DIR=${P%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2626
	        if [[ "$DIR" == "$P" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2627
			DIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2628
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2629
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2630
		F=${P##*/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2631
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2632
		PP=$P
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2633
		PDIR=$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2634
		PF=$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2635
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2636
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2637
        # Make the webrev directory if necessary as it may have been
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2638
        # removed because it was empty
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2639
        if [ ! -d $CWS/$DIR ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2640
	    mkdir -p $CWS/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2641
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2642
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2643
	COMM=`getcomments html $P $PP`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2644
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2645
	print "\t$P$oldname\n\t\t\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2646
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2647
	# Make the webrev mirror directory if necessary
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2648
	mkdir -p $WDIR/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2649
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2650
	# cd to the directory so the names are short
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2651
	cd $CWS/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2652
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2653
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2654
	# If we're in OpenSolaris mode, we enforce a minor policy:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2655
	# help to make sure the reviewer doesn't accidentally publish
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2656
	# source which is in usr/closed/*
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2657
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2658
	if [[ -n $Oflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2659
		pclosed=${P##usr/closed/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2660
		if [[ $pclosed != $P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2661
			print "*** Omitting closed source for OpenSolaris" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2662
			    "mode review"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2663
			continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2664
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2665
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2666
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2667
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2668
	# We stash old and new files into parallel directories in /tmp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2669
	# and do our diffs there.  This makes it possible to generate
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2670
	# clean looking diffs which don't have absolute paths present.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2671
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2672
	olddir=$WDIR/raw_files/old
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2673
	newdir=$WDIR/raw_files/new
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2674
	mkdir -p $olddir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2675
	mkdir -p $newdir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2676
	mkdir -p $olddir/$PDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2677
	mkdir -p $newdir/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2678
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2679
	build_old_new $olddir $newdir $DIR $F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2680
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2681
	if [[ ! -f $F && ! -f $olddir/$DIR/$F ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2682
		print "*** Error: file not in parent or child"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2683
		continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2684
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2685
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2686
	cd $WDIR/raw_files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2687
	ofile=old/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2688
	nfile=new/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2689
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2690
	mv_but_nodiff=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2691
	cmp $ofile $nfile > /dev/null 2>&1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2692
	if [[ $? == 0 && $rename == 1 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2693
		mv_but_nodiff=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2694
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2695
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2696
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2697
        # Cleaning up
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2698
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2699
        rm -f $WDIR/$DIR/$F.cdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2700
        rm -f $WDIR/$DIR/$F.udiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2701
        rm -f $WDIR/$DIR/$F.wdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2702
        rm -f $WDIR/$DIR/$F.sdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2703
        rm -f $WDIR/$DIR/$F-.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2704
        rm -f $WDIR/$DIR/$F.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2705
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2706
	its_a_jar=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2707
	if expr $F : '.*\.jar' >/dev/null; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2708
	    its_a_jar=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2709
	    # It's a JAR file, let's do it differntly
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2710
	    if [[ -z $JAR ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2711
		print "No access to jar, so can't produce diffs for jar files"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2712
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2713
		if [ -f $ofile ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2714
		    $JAR -tvf $ofile >"$ofile".lst
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2715
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2716
		if [ -f $nfile ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2717
		    $JAR -tvf $nfile >"$nfile".lst
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2718
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2719
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2720
		if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2721
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2722
		    ${CDIFFCMD:-diff -bt -C 5} $ofile.lst $nfile.lst > $WDIR/$DIR/$F.cdiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2723
		    diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2724
			> $WDIR/$DIR/$F.cdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2725
		    print " cdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2726
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2727
		    ${UDIFFCMD:-diff -bt -U 5} $ofile.lst $nfile.lst > $WDIR/$DIR/$F.udiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2728
		    diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2729
			> $WDIR/$DIR/$F.udiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2730
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2731
		    print " udiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2732
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2733
		    if [[ -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2734
			$WDIFF -c "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2735
			    -t "$WNAME Wdiff $DIR/$F" $ofile.lst $nfile.lst > \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2736
			    $WDIR/$DIR/$F.wdiff.html 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2737
			if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2738
			    print " wdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2739
			else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2740
			    print " wdiffs[fail]\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2741
			fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2742
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2743
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2744
		    sdiff_to_html $ofile $nfile $F $DIR "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2745
			> $WDIR/$DIR/$F.sdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2746
		    print " sdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2747
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2748
		    print " frames\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2749
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2750
		    rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2751
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2752
		    difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2753
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2754
		elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2755
		# renamed file: may also have differences
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2756
		    difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2757
		elif [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2758
		# new file: count added lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2759
		    difflines /dev/null $nfile.lst > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2760
		elif [[ -f $ofile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2761
		# old file: count deleted lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2762
		    difflines $ofile.lst /dev/null > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2763
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2764
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2765
	else
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  2766
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2767
	    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2768
	    # If we have old and new versions of the file then run the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2769
	    # appropriate diffs.  This is complicated by a couple of factors:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2770
	    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2771
	    #	- renames must be handled specially: we emit a 'remove'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2772
	    #	  diff and an 'add' diff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2773
	    #	- new files and deleted files must be handled specially
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2774
	    #	- Solaris patch(1m) can't cope with file creation
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2775
	    #	  (and hence renames) as of this writing.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2776
	    #   - To make matters worse, gnu patch doesn't interpret the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2777
	    #	  output of Solaris diff properly when it comes to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2778
	    #	  adds and deletes.  We need to do some "cleansing"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2779
	    #     transformations:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2780
	    # 	    [to add a file] @@ -1,0 +X,Y @@  -->  @@ -0,0 +X,Y @@
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2781
	    #	    [to del a file] @@ -X,Y +1,0 @@  -->  @@ -X,Y +0,0 @@
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2782
	    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2783
	    cleanse_rmfile="sed 's/^\(@@ [0-9+,-]*\) [0-9+,-]* @@$/\1 +0,0 @@/'"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2784
	    cleanse_newfile="sed 's/^@@ [0-9+,-]* \([0-9+,-]* @@\)$/@@ -0,0 \1/'"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2785
16821
a7d69ce6432c 8011347: JKD-8009824 has broken webrev with some ksh versions
jgish
parents: 16654
diff changeset
  2786
            if [[ ! "$HG_LIST_FROM_COMMIT" -eq 1 || ! $flist_mode == "auto" ]];
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2787
            then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2788
              # Only need to generate a patch file here if there are no commits in outgoing
16821
a7d69ce6432c 8011347: JKD-8009824 has broken webrev with some ksh versions
jgish
parents: 16654
diff changeset
  2789
              # or if we've specified a file list
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2790
              rm -f $WDIR/$DIR/$F.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2791
              if [[ -z $rename ]]; then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2792
                  if [ ! -f $ofile ]; then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2793
                      diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2794
                          > $WDIR/$DIR/$F.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2795
                  elif [ ! -f $nfile ]; then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2796
                      diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2797
                          > $WDIR/$DIR/$F.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2798
                  else
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2799
                      diff -u $ofile $nfile > $WDIR/$DIR/$F.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2800
                  fi
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2801
              else
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2802
                  diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2803
                      > $WDIR/$DIR/$F.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2804
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2805
                  diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2806
                      >> $WDIR/$DIR/$F.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2807
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2808
              fi
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2809
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2810
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2811
            #
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2812
            # Tack the patch we just made onto the accumulated patch for the
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2813
            # whole wad.
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2814
            #
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2815
              cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2816
            fi
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2817
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2818
            print " patch\c"
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2819
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2820
	    if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2821
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2822
		${CDIFFCMD:-diff -bt -C 5} $ofile $nfile > $WDIR/$DIR/$F.cdiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2823
		diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2824
		    > $WDIR/$DIR/$F.cdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2825
		print " cdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2826
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2827
		${UDIFFCMD:-diff -bt -U 5} $ofile $nfile > $WDIR/$DIR/$F.udiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2828
		diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2829
		    > $WDIR/$DIR/$F.udiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2830
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2831
		print " udiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2832
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2833
		if [[ -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2834
		    $WDIFF -c "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2835
			-t "$WNAME Wdiff $DIR/$F" $ofile $nfile > \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2836
			$WDIR/$DIR/$F.wdiff.html 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2837
		    if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2838
			print " wdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2839
		    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2840
			print " wdiffs[fail]\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2841
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2842
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2843
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2844
		sdiff_to_html $ofile $nfile $F $DIR "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2845
		    > $WDIR/$DIR/$F.sdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2846
		print " sdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2847
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2848
		print " frames\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2849
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2850
		rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2851
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2852
		difflines $ofile $nfile > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2853
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2854
	    elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2855
		# renamed file: may also have differences
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2856
		difflines $ofile $nfile > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2857
	    elif [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2858
		# new file: count added lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2859
		difflines /dev/null $nfile > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2860
	    elif [[ -f $ofile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2861
		# old file: count deleted lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2862
		difflines $ofile /dev/null > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2863
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2864
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2865
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2866
	# Now we generate the postscript for this file.  We generate diffs
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2867
	# only in the event that there is delta, or the file is new (it seems
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2868
	# tree-killing to print out the contents of deleted files).
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2869
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2870
	if [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2871
		ocr=$ofile
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2872
		[[ ! -f $ofile ]] && ocr=/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2873
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2874
		if [[ -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2875
			textcomm=`getcomments text $P $PP`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2876
			if [[ -x $CODEREVIEW ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2877
				$CODEREVIEW -y "$textcomm" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2878
				    -e $ocr $nfile \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2879
				    > /tmp/$$.psfile 2>/dev/null &&
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2880
				    cat /tmp/$$.psfile >> $WDIR/$WNAME.ps
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2881
				if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2882
					print " ps\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2883
				else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2884
					print " ps[fail]\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2885
				fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2886
			fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2887
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2888
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2889
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2890
	if [[ -f $ofile && -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2891
	    if [[ -n $its_a_jar ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2892
		source_to_html Old $P < $ofile.lst > $WDIR/$DIR/$F-.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2893
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2894
		source_to_html Old $P < $ofile > $WDIR/$DIR/$F-.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2895
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2896
		print " old\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2897
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2898
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2899
	if [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2900
	    if [[ -n $its_a_jar ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2901
		source_to_html New $P < $nfile.lst > $WDIR/$DIR/$F.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2902
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2903
		source_to_html New $P < $nfile > $WDIR/$DIR/$F.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2904
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2905
		print " new\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2906
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2907
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2908
	print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2909
done < $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2910
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2911
# Create the new style mercurial patch here using hg export -r [all-revs] -g -o $CHANGESETPATH
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2912
if [[ $SCM_MODE == "mercurial" ]]; then
16821
a7d69ce6432c 8011347: JKD-8009824 has broken webrev with some ksh versions
jgish
parents: 16654
diff changeset
  2913
  if [[ "$HG_LIST_FROM_COMMIT" -eq 1 && $flist_mode == "auto" ]]; then
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2914
    EXPORTCHANGESET="$WNAME.changeset"
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2915
    CHANGESETPATH=${WDIR}/${EXPORTCHANGESET}
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2916
    rm -f $CHANGESETPATH
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2917
    touch $CHANGESETPATH
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2918
    if [[ -n $ALL_CREV ]]; then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2919
      rev_opt=
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2920
      for rev in $ALL_CREV; do
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2921
        rev_opt="$rev_opt --rev $rev"
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2922
      done
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2923
    elif [[ -n $FIRST_CREV ]]; then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2924
      rev_opt="--rev $FIRST_CREV"
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2925
    fi
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2926
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2927
    if [[ -n $rev_opt ]]; then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2928
      (cd $CWS;hg export -g $rev_opt -o $CHANGESETPATH)
16821
a7d69ce6432c 8011347: JKD-8009824 has broken webrev with some ksh versions
jgish
parents: 16654
diff changeset
  2929
      echo "Created changeset: $CHANGESETPATH" 1>&2
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2930
      # Use it in place of the jdk.patch created above
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2931
      rm -f $WDIR/$WNAME.patch
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2932
    fi
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2933
  set +x
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2934
  fi
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2935
fi
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  2936
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2937
frame_nav_js > $WDIR/ancnav.js
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2938
frame_navigation > $WDIR/ancnav.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2939
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2940
if [[ -f $WDIR/$WNAME.ps && -x $CODEREVIEW && -x $PS2PDF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2941
	print " Generating PDF: \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2942
	fix_postscript $WDIR/$WNAME.ps | $PS2PDF - > $WDIR/$WNAME.pdf
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2943
	print "Done."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2944
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2945
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2946
# Now build the index.html file that contains
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2947
# links to the source files and their diffs.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2948
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2949
cd $CWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2950
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2951
# Save total changed lines for Code Inspection.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2952
print "$TOTL" > $WDIR/TotalChangedLines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2953
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2954
print "     index.html: \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2955
INDEXFILE=$WDIR/index.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2956
exec 3<&1			# duplicate stdout to FD3.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2957
exec 1<&-			# Close stdout.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2958
exec > $INDEXFILE		# Open stdout to index file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2959
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2960
print "$HTML<head>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2961
print "<meta name=\"scm\" content=\"$SCM_MODE\" />"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2962
print "$STDHEAD"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2963
print "<title>$WNAME</title>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2964
print "</head>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2965
print "<body id=\"SUNWwebrev\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2966
print "<div class=\"summary\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2967
print "<h2>Code Review for $WNAME</h2>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2968
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2969
print "<table>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2970
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2971
if [[ -z $uflag ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2972
then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2973
    if [[ $SCM_MODE == "mercurial" ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2974
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2975
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2976
        # Let's try to extract the user name from the .hgrc file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2977
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2978
	username=`grep '^username' $HOME/.hgrc | sed 's/^username[ ]*=[ ]*\(.*\)/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2979
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2980
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2981
    if [[ -z $username ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2982
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2983
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2984
        # Figure out the username and gcos name.  To maintain compatibility
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2985
        # with passwd(4), we must support '&' substitutions.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2986
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2987
	username=`id | cut -d '(' -f 2 | cut -d ')' -f 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2988
	if [[ -x $GETENT ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2989
	    realname=`$GETENT passwd $username | cut -d':' -f 5 | cut -d ',' -f 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2990
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2991
	userupper=`print "$username" | sed 's/\<./\u&/g'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2992
	realname=`print $realname | sed s/\&/$userupper/`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2993
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2994
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2995
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2996
date="on `date`"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2997
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2998
if [[ -n "$username" && -n "$realname" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2999
	print "<tr><th>Prepared by:</th>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3000
	print "<td>$realname ($username) $date</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3001
elif [[ -n "$username" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3002
	print "<tr><th>Prepared by:</th><td>$username $date</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3003
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3004
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3005
print "<tr><th>Workspace:</th><td>$CWS</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3006
if [[ -n $parent_webrev ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3007
        print "<tr><th>Compare against:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3008
	print "webrev at $parent_webrev"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3009
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3010
    if [[ -n $OUTPWS2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3011
        print "<tr><th>Compare against:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3012
	print "$OUTPWS2"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3013
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3014
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3015
print "</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3016
if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3017
    print "<tr><th>Compare against version:</th><td>$PARENT_REV</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3018
elif [[ -n $OUTREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3019
    if [[ -z $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3020
        print "<tr><th>Compare against version:</th><td>$OUTREV</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3021
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3022
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3023
if [[ -n $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3024
    print "<tr><th>Branch:</th><td>$HG_BRANCH</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3025
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3026
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3027
print "<tr><th>Summary of changes:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3028
printCI $TOTL $TINS $TDEL $TMOD $TUNC
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3029
print "</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3030
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3031
if [[ -f $WDIR/$WNAME.patch ]]; then
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  3032
  print "<tr><th>Patch of changes:</th><td>"
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  3033
  print "<a href=\"$WNAME.patch\">$WNAME.patch</a></td></tr>"
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  3034
elif [[ -f $CHANGESETPATH ]]; then
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  3035
  print "<tr><th>Changeset:</th><td>"
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  3036
  print "<a href=\"$EXPORTCHANGESET\">$EXPORTCHANGESET</a></td></tr>"
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3037
fi
16654
09c4f110096c 8009824: webrev.ksh generated jdk.patch files do not handle renames, copies, and shouldn't be applied
jgish
parents: 15901
diff changeset
  3038
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3039
if [[ -f $WDIR/$WNAME.pdf ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3040
	print "<tr><th>Printable review:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3041
	print "<a href=\"$WNAME.pdf\">$WNAME.pdf</a></td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3042
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3043
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3044
if [[ -n "$iflag" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3045
	print "<tr><th>Author comments:</th><td><div>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3046
	cat /tmp/$$.include
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3047
	print "</div></td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3048
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3049
# Add links to referenced CRs, if any
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3050
# external URL has a <title> like:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3051
# <title>Bug ID: 6641309 Wrong Cookie separator used in HttpURLConnection</title>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3052
# while internal URL has <title> like:
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3053
# <title>[#JDK-6641309] Wrong Cookie separator used in HttpURLConnection</title>
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3054
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3055
if [[ -n $CRID ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3056
    for id in $CRID
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3057
    do
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3058
        if [[ -z "$Oflag" ]]; then
19754
76f369edc1ca 8024201: Update bugdatabase url
mduigou
parents: 16821
diff changeset
  3059
            #add "JDK-" to raw bug id for openjdk.java.net links.
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3060
            id=`echo ${id} | sed 's/^\([0-9]\{5,\}\)$/JDK-\1/'`
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3061
        fi
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3062
        print "<tr><th>Bug id:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3063
        url="${BUGURL}${id}"
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3064
        if [[ -n "$Oflag" ]]; then
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3065
            cleanup='s/Bug ID: \([0-9]\{5,\}\) \(.*\)/JDK-\1 : \2/'
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3066
        else
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3067
            cleanup='s|\[#\(JDK-[0-9]\{5,\}\)\] \(.*\)|\1 : \2|'
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3068
        fi
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3069
        if [[ -n $WGET ]]; then
15901
3b8ad6fd84b5 8008629: webrev.ksh needs to quote bug title it gets back from scraping bugs.sun.com
mduigou
parents: 15576
diff changeset
  3070
            msg=`$WGET --timeout=10 --tries=1 -q $url -O - | grep '<title>' | sed 's/<title>\(.*\)<\/title>/\1/' | sed "$cleanup" | html_quote`
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3071
        fi
15576
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3072
        if [[ -z $msg ]]; then
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3073
            msg="${id}"
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3074
        fi
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3075
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3076
        print "<a href=\"$url\">$msg</a>"
9bceeb53e794 8004726: Link bug ids to jbs rather than monaco.
mduigou
parents: 8442
diff changeset
  3077
8442
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3078
        print "</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3079
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3080
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3081
print "<tr><th>Legend:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3082
print "<b>Modified file</b><br><font color=red><b>Deleted file</b></font><br><font color=green><b>New file</b></font></td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3083
print "</table>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3084
print "</div>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3085
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3086
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3087
# Second pass through the files: generate the rest of the index file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3088
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3089
while read LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3090
do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3091
	set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3092
        if [[ $1 == "Revision:" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3093
            FIRST_CREV=`expr $3 + 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3094
            continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3095
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3096
	P=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3097
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3098
	if [[ $# == 2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3099
		PP=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3100
		oldname=" <i>(was $PP)</i>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3101
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3102
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3103
		PP=$P
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3104
		oldname=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3105
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3106
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3107
	DIR=${P%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3108
	if [[ $DIR == $P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3109
		DIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3110
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3111
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3112
	# Avoid processing the same file twice.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3113
	# It's possible for renamed files to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3114
	# appear twice in the file list
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3115
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3116
	F=$WDIR/$P
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3117
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3118
	print "<p><code>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3119
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3120
	# If there's a diffs file, make diffs links
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3121
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3122
        NODIFFS=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3123
	if [[ -f $F.cdiff.html ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3124
		print "<a href=\"$P.cdiff.html\">Cdiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3125
		print "<a href=\"$P.udiff.html\">Udiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3126
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3127
		if [[ -f $F.wdiff.html && -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3128
			print "<a href=\"$P.wdiff.html\">Wdiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3129
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3130
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3131
		print "<a href=\"$P.sdiff.html\">Sdiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3132
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3133
		print "<a href=\"$P.frames.html\">Frames</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3134
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3135
                NODIFFS=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3136
		print " ------ ------ ------"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3137
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3138
		if [[ -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3139
			print " ------"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3140
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3141
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3142
		print " ------"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3143
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3144
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3145
	# If there's an old file, make the link
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3146
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3147
        NOOLD=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3148
	if [[ -f $F-.html ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3149
		print "<a href=\"$P-.html\">Old</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3150
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3151
                NOOLD=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3152
		print " ---"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3153
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3154
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3155
	# If there's an new file, make the link
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3156
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3157
        NONEW=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3158
	if [[ -f $F.html ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3159
		print "<a href=\"$P.html\">New</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3160
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3161
                NONEW=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3162
		print " ---"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3163
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3164
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3165
	if [[ -f $F.patch ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3166
		print "<a href=\"$P.patch\">Patch</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3167
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3168
		print " -----"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3169
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3170
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3171
	if [[ -f $WDIR/raw_files/new/$P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3172
		print "<a href=\"raw_files/new/$P\">Raw</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3173
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3174
		print " ---"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3175
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3176
        print "</code>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3177
        if [[ -n $NODIFFS && -z $oldname ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3178
            if [[ -n $NOOLD ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3179
                print "<font color=green><b>$P</b></font>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3180
            elif [[ -n $NONEW ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3181
                print "<font color=red><b>$P</b></font>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3182
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3183
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3184
	    print "<b>$P</b> $oldname"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3185
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3186
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3187
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3188
	# Check for usr/closed
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3189
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3190
	if [ ! -z "$Oflag" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3191
		if [[ $P == usr/closed/* ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3192
			print "&nbsp;&nbsp;<i>Closed source: omitted from" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3193
			    "this review</i>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3194
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3195
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3196
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3197
	print "</p><blockquote>\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3198
	# Insert delta comments if any
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3199
	comments=`getcomments html $P $PP`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3200
	if [ -n "$comments" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3201
	    print "<pre>$comments</pre>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3202
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3203
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3204
	# Add additional comments comment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3205
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3206
	print "<!-- Add comments to explain changes in $P here -->"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3207
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3208
	# Add count of changes.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3209
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3210
	if [[ -f $F.count ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3211
	    cat $F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3212
	    rm $F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3213
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3214
        print "</blockquote>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3215
done < $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3216
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3217
print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3218
print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3219
print "<hr />"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3220
print "<p style=\"font-size: small\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3221
print "This code review page was prepared using <b>$0</b>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3222
print "(vers $WEBREV_UPDATED)."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3223
print "</body>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3224
print "</html>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3225
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3226
if [[ -n $ZIP ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3227
    # Let's generate a zip file for convenience
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3228
    cd $WDIR/..
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3229
    if [ -f webrev.zip ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3230
	rm webrev.zip
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3231
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3232
    $ZIP -r webrev webrev >/dev/null 2>&1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3233
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3234
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3235
exec 1<&-			# Close FD 1.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3236
exec 1<&3			# dup FD 3 to restore stdout.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3237
exec 3<&-			# close FD 3.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3238
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3239
print "Done."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3240
print "Output to: $WDIR"