make/scripts/webrev.ksh
author ohair
Tue, 01 Mar 2011 11:54:05 -0800
changeset 8442 0be681587b9c
child 15576 9bceeb53e794
permissions -rw-r--r--
7023111: Add webrev script to make/scripts Reviewed-by: darcy
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
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    22
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
    30
WEBREV_UPDATED=23.18-hg
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
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   149
	sed -e 's|[0-9]\{5,\}|<a href=\"'$BUGURL'&\">&</a>|g'
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 \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   233
#         '<a href="http://monaco.sfbay.sun.com/detail.jsp?cr=1234567">
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
   234
#          1234567</a> my bugid' > <file>.html
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1163
	  
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]];
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1421
                          if (rev > 0) 
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1439
	print " File list from hg foutgoing $PWS ..."
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1445
	print "\n No outgoing, perhaps you haven't commited."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1446
	print " File list from hg fstatus -mard ...\c"
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1449
        HG_LIST_FROM_COMMIT=0
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"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1462
    
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1469
    # But some of these could have been "moved" or renamed ones
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1477
    # is a move/rename
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1478
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1479
    $HGCMD -aC | $FILTER | while read LINE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1480
	ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1481
	while [ -z "$ldone" ]; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1482
	    ldone="1"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1483
	    set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1484
	    if [ $# -eq 2 -a "$1" == "A" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1485
		AFILE=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1486
		if read LINE2; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1487
		    set - $LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1488
		    if [ $# -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1489
			echo $TREE/$AFILE $TREE/$1 >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1490
		    elif [ $# -eq 2 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1491
			echo $TREE/$AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1492
			LINE=$LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1493
			ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1494
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1495
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1496
		    echo $TREE/$AFILE >>$FLIST
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
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1499
	done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1500
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1501
    $HGCMD -rn | $FILTER | while read RFILE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1502
	grep "$TREE/$RFILE" $FLIST >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1503
	if [ $? -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1504
	    echo $TREE/$RFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1505
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1506
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1507
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1508
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1509
function fstatus
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
    # forest extension is still being changed. For instance the output
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1513
    # of fstatus used to no prepend the tree path to filenames, but
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1514
    # this has changed recently. AWK code below does try to handle both
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1515
    # cases
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1516
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1517
    hg fstatus -mdn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1518
	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1519
	$1 != ""	{n=index($1,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1520
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1521
				{ printf("%s/%s\n",tree,$1)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1522
			 else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1523
				{ printf("%s\n",$1)}}' >> $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1524
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1525
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1526
    # 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
  1527
    # 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
  1528
    # old file. e.g.:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1529
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1530
    # $ hg fstatus -aC
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1531
    # [.]
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
    # [MyWS]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1534
    # A MyWS/subdir/File2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1535
    #  MyWS/ File2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1536
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1537
    # [MyWS2]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1538
    #
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
    hg fstatus -aC $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1541
	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1542
	/^A .*/		{n=index($2,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1543
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1544
				{ printf("A %s/%s\n",tree,$2)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1545
			 else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1546
				{ printf("A %s\n",$2)}; 
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1547
			 next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1548
	/^ /		{n=index($1,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1549
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1550
				{ printf("%s/%s\n",tree,$1)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1551
			 else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1552
				{ if (NF == 2)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1553
					printf("%s/%s\n",tree,$2)
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
					printf("%s\n",$1)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1556
				};
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1557
			 next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1558
	' | while read LINE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1559
	ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1560
	while [ -z "$ldone" ]; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1561
	    ldone="1"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1562
	    set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1563
	    if [ $# -eq 2 -a "$1" == "A" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1564
		AFILE=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1565
		if read LINE2; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1566
		    set - $LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1567
		    if [ $# -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1568
			echo $AFILE $1 >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1569
		    elif [ $# -eq 2 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1570
			echo $AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1571
			LINE=$LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1572
			ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1573
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1574
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1575
		    echo $AFILE >>$FLIST
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
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1578
	done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1579
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1580
    hg fstatus -rn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1581
	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1582
	$1 != ""	{n=index($1,tree);
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1583
			 if (n == 0)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1584
				{ printf("%s/%s\n",tree,$1)}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1585
			 else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1586
				{ printf("%s\n",$1)}}' | while read RFILE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1587
	grep "$RFILE" $FLIST >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1588
	if [ $? -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1589
	    echo $RFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1590
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1591
    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1592
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1593
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1594
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1595
# flist_from_mercurial $PWS
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
# Only local file based repositories are supported at present
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1598
# since even though we can determine the list from the parent finding
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1599
# the changes is harder.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1600
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1601
# 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
  1602
# 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
  1603
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1604
# 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
  1605
# If neither are set we don't know who to compare with.
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
function flist_from_mercurial 
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1608
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1609
#	if [ "${PWS##ssh://}" != "$PWS" -o \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1610
#	     "${PWS##http://}" != "$PWS" -o \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1611
#	     "${PWS##https://}" != "$PWS" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1612
#		print "Remote Mercurial repositories not currently supported."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1613
#		print "Set default and/or default-push to a local repository"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1614
#		exit
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1615
#	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1616
    if [[ -n $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1617
        HG_LIST_FROM_COMMIT=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1618
	flist_from_mercurial_forest
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1619
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1620
        STATUS_REV=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1621
        if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1622
            STATUS_REV="--rev $PARENT_REV"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1623
        elif [[ -n $OUTREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1624
            STATUS_REV="--rev $OUTREV"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1625
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1626
            # hg commit hasn't been run see what is lying around
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1627
            print "\n No outgoing, perhaps you haven't commited."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1628
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1629
	# First let's list all the modified or deleted files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1630
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1631
	hg status $STATUS_REV -mdn | $FILTER > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1632
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1633
	# Then all the added files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1634
	# But some of these could have been "moved" or renamed ones
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1635
	# so let's make sure we get the proper info
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1636
	# hg status -aC will produce something like:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1637
	#	A subdir/File3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1638
	#	A subdir/File4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1639
	#	  File4
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1640
	#	A subdir/File5
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1641
	# The first and last are simple addition while the middle one
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1642
	# is a move/rename
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1643
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1644
	hg status $STATUS_REV -aC | $FILTER >$FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1645
	while read LINE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1646
	    ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1647
	    while [ -z "$ldone" ]; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1648
		ldone="1"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1649
		set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1650
		if [ $# -eq 2 -a "$1" == "A" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1651
		    AFILE=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1652
		    if read LINE2; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1653
			set - $LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1654
			if [ $# -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1655
			    echo $AFILE $1 >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1656
			elif [ $# -eq 2 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1657
			    echo $AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1658
			    LINE=$LINE2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1659
			    ldone=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1660
			fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1661
		    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1662
			echo $AFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1663
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1664
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1665
	    done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1666
	done < $FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1667
	hg status $STATUS_REV -rn | $FILTER > $FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1668
	while read RFILE; do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1669
	    grep "$RFILE" $FLIST >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1670
	    if [ $? -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1671
		echo $RFILE >>$FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1672
	    fi
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
	rm -f $FLIST.temp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1675
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1676
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1677
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1678
function env_from_flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1679
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1680
	[[ -r $FLIST ]] || return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1681
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1682
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1683
	# Use "eval" to set env variables that are listed in the file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1684
	# list.  Then copy those into our local versions of those
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1685
	# variables if they have not been set already.
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
	eval `sed -e "s/#.*$//" $FLIST | grep = `
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
	[[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1690
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1691
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1692
	# Check to see if CODEMGR_PARENT is set in the flist file.
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
	[[ -z $codemgr_parent && -n $CODEMGR_PARENT ]] && \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1695
	    codemgr_parent=$CODEMGR_PARENT
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1696
}
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
# detect_scm
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
# We dynamically test the SCM type; this allows future extensions to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1702
# new SCM types
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
function detect_scm
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
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1707
	# If CODEMGR_WS is specified in the flist file, we assume teamware.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1708
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1709
	if [[ -r $FLIST ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1710
		egrep '^CODEMGR_WS=' $FLIST > /dev/null 2>&1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1711
		if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1712
			print "teamware"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1713
			return
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1714
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1715
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1716
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1717
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1718
	# The presence of $CODEMGR_WS and a Codemgr_wsdata directory
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1719
	# is our clue that this is a teamware workspace.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1720
	# Same if true if current directory has a Codemgr_wsdata sub-dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1721
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1722
	if [[ -z "$CODEMGR_WS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1723
	    CODEMGR_WS=`workspace name 2>/dev/null`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1724
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1725
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1726
	if [[ -n $CODEMGR_WS && -d "$CODEMGR_WS/Codemgr_wsdata" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1727
		print "teamware"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1728
	elif [[ -d $PWD/Codemgr_wsdata ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1729
		print "teamware"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1730
	elif hg root >/dev/null ; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1731
		print "mercurial"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1732
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1733
		print "unknown"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1734
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1735
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1736
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1737
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1738
# Extract the parent workspace from the Codemgr_wsdata/parent file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1739
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1740
function parent_from_teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1741
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1742
    if [[ -f "$1/Codemgr_wsdata/parent" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1743
	tail -1 "$1/Codemgr_wsdata/parent"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1744
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1745
}
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 look_for_prog
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
	typeset path
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1750
	typeset ppath
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1751
	typeset progname=$1
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
	DEVTOOLS=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1754
	OS=`uname`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1755
	if [[ "$OS" == "SunOS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1756
	    DEVTOOLS="/java/devtools/`uname -p`/bin"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1757
	elif [[ "$OS" == "Linux" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1758
	    DEVTOOLS="/java/devtools/linux/bin"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1759
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1760
	    
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1761
	ppath=$PATH
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1762
	ppath=$ppath:/usr/sfw/bin:/usr/bin:/usr/sbin
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1763
	ppath=$ppath:/opt/teamware/bin:/opt/onbld/bin
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1764
	ppath=$ppath:/opt/onbld/bin/`uname -p`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1765
	ppath=$ppath:/java/devtools/share/bin:$DEVTOOLS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1766
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1767
	PATH=$ppath prog=`whence $progname`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1768
	if [[ -n $prog ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1769
		print $prog
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1770
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1771
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1772
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1773
function build_old_new_teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1774
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1775
	# If the child's version doesn't exist then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1776
	# get a readonly copy.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1777
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1778
	if [[ ! -f $F && -f SCCS/s.$F ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1779
		$SCCS get -s $F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1780
	fi
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
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1783
	# Snag new version of file.
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
	rm -f $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1786
	cp $F $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1787
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
	# Get the parent's version of the file. First see whether the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1790
	# child's version is checked out and get the parent's version
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1791
	# with keywords expanded or unexpanded as appropriate.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1792
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1793
	if [ -f $PWS/$PDIR/SCCS/s.$PF -o \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1794
	    -f $PWS/$PDIR/SCCS/p.$PF ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1795
		rm -f $olddir/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1796
		if [ -f SCCS/p.$F ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1797
			$SCCS get -s -p -k $PWS/$PDIR/$PF \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1798
			    > $olddir/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1799
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1800
			$SCCS get -s -p    $PWS/$PDIR/$PF \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1801
			    > $olddir/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1802
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1803
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1804
		if [[ -f $PWS/$PDIR/$PF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1805
			# Parent is not a real workspace, but just a raw
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1806
			# directory tree - use the file that's there as
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1807
			# the old file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1808
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1809
			rm -f $olddir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1810
			cp $PWS/$PDIR/$PF $olddir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1811
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1812
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1813
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1814
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
# Find the parent for $1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1817
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1818
function find_outrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1819
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1820
    crev=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1821
    prev=`hg log -r $crev --template '{parents}\n'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1822
    if [[ -z "$prev" ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1823
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1824
	# No specific parent means previous changeset is parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1825
	prev=`expr $crev - 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1826
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1827
	# Format is either of the following two:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1828
	# 546:7df6fcf1183b
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1829
	# 548:16f1915bb5cd 547:ffaa4e775815
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1830
	prev=`echo $prev | sed -e 's/\([0-9]*\):.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1831
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1832
    print $prev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1833
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1834
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1835
function extract_ssh_infos
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1836
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1837
    CMD=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1838
    if expr "$CMD" : 'ssh://[^/]*@' >/dev/null; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1839
	ssh_user=`echo $CMD | sed -e 's/ssh:\/\/\(.*\)@.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1840
	ssh_host=`echo $CMD | sed -e 's/ssh:\/\/.*@\([^/]*\)\/.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1841
	ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/.*@[^/]*\/\(.*\)/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1842
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1843
	ssh_user=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1844
	ssh_host=`echo $CMD | sed -e 's/ssh:\/\/\([^/]*\)\/.*/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1845
	ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/[^/]*\/\(.*\)/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1846
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1847
    
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1848
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1849
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1850
function build_old_new_mercurial
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1851
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1852
	olddir=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1853
	newdir=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1854
	DIR=$3
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1855
	F=$4
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
	# new version of the file.
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
	rm -rf $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1860
	if [ -f $F ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1861
	    cp $F  $newdir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1862
	fi
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
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1865
	# Old version of the file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1866
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1867
	rm -rf $olddir/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1868
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1869
	if [ -n "$PWS" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1870
	    if expr "$PWS" : 'ssh://' >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1871
	    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1872
		extract_ssh_infos $PWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1873
		if [ -n "$ssh_user" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1874
		    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
  1875
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1876
		    parent="ssh $ssh_host hg -R $ssh_dir --cwd $ssh_dir"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1877
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1878
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1879
		parent="hg -R $PWS --cwd $PWS"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1880
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1881
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1882
	    parent=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1883
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1884
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1885
	if [ -z "$rename" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1886
	    if [ -n "$rflag" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1887
		parentrev=$PARENT_REV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1888
	    elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1889
                parentrev=$OUTREV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1890
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1891
                if [[ -n $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1892
                    parentrev=$HG_BRANCH
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1893
                else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1894
		    parentrev="tip"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1895
                fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1896
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1897
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1898
	    if [ -n "$parentrev" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1899
		if [ -z "$parent" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1900
		    hg cat --rev $parentrev --output $olddir/$DIR/$F $F 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1901
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1902
		    # when specifying a workspace we have to provide
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1903
		    # the full path
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1904
		    $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
  1905
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1906
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1907
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1908
	    # It's a rename (or a move), so let's make sure we move
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1909
	    # to the right directory first, then restore it once done
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1910
	    current_dir=`pwd`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1911
	    cd $CWS/$PDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1912
	    if [ -n "$rflag" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1913
		parentrev=$PARENT_REV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1914
	    elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1915
                parentrev=$OUTREV
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1916
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1917
	    if [ -z "$parentrev" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1918
		parentrev=`hg log -l1 $PF | $AWK -F: '/changeset/ {print $2}'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1919
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1920
	    if [ -n "$parentrev" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1921
		mkdir -p $olddir/$PDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1922
		if [ -z "$parent" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1923
		    hg cat --rev $parentrev --output $olddir/$PDIR/$PF $PF 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1924
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1925
		    $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
  1926
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1927
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1928
	    cd $current_dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1929
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1930
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1931
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1932
function build_old_new
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1933
{
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1934
	if [[ $SCM_MODE == "teamware" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1935
		build_old_new_teamware $@
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
	if [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1939
		build_old_new_mercurial $@
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1940
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1941
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1942
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1943
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
# Usage message.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1946
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1947
function usage
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
	print "Usage:\twebrev [common-options]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1950
	webrev [common-options] ( <file> | - )
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1951
	webrev [common-options] -w <wx file>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1952
	webrev [common-options] -l [arguments to 'putback']
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
Options:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1955
	-v: Print the version of this tool.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1956
        -b: Do not ignore changes in the amount of white space.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1957
        -c <CR#>: Include link to CR (aka bugid) in the main page.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1958
	-O: Print bugids/arc cases suitable for OpenJDK.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1959
	-i <filename>: Include <filename> in the index.html file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1960
	-o <outdir>: Output webrev to specified directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1961
	-p <compare-against>: Use specified parent wkspc or basis for comparison
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1962
	-w <wxfile>: Use specified wx active file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1963
        -u <username>: Use that username instead of 'guessing' one.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1964
	-m: Forces the use of Mercurial
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1965
	-t: Forces the use of Teamware
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1966
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1967
Mercurial only options:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1968
	-r rev: Compare against a specified revision
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1969
	-N: Skip 'hg outgoing', use only 'hg status'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1970
	-f: Use the forest extension
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1971
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1972
Environment:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1973
	WDIR: Control the output directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1974
	WEBREV_BUGURL: Control the URL prefix for bugids.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1975
	WEBREV_SACURL: Control the URL prefix for ARC cases.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1976
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1977
SCM Environment:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1978
	Teamware: CODEMGR_WS: Workspace location.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1979
	Teamware: CODEMGR_PARENT: Parent workspace location.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1980
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1981
"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1982
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1983
	exit 2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1984
}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1985
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1986
#
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
# Main program starts here
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
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1991
LANG="C"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1992
LC_ALL="C"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1993
export LANG LC_ALL
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1994
trap "rm -f /tmp/$$.* ; exit" 0 1 2 3 15
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1995
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1996
set +o noclobber
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
[[ -z $WDIFF ]] && WDIFF=`look_for_prog wdiff`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  1999
[[ -z $WX ]] && WX=`look_for_prog wx`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2000
[[ -z $CODEREVIEW ]] && CODEREVIEW=`look_for_prog codereview`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2001
[[ -z $PS2PDF ]] && PS2PDF=`look_for_prog ps2pdf`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2002
[[ -z $PERL ]] && PERL=`look_for_prog perl`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2003
[[ -z $SCCS ]] && SCCS=`look_for_prog sccs`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2004
[[ -z $AWK ]] && AWK=`look_for_prog nawk`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2005
[[ -z $AWK ]] && AWK=`look_for_prog gawk`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2006
[[ -z $AWK ]] && AWK=`look_for_prog awk`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2007
[[ -z $WSPACE ]] && WSPACE=`look_for_prog workspace`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2008
[[ -z $JAR ]] && JAR=`look_for_prog jar`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2009
[[ -z $ZIP ]] && ZIP=`look_for_prog zip`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2010
[[ -z $GETENT ]] && GETENT=`look_for_prog getent`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2011
[[ -z $WGET ]] && WGET=`look_for_prog wget`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2012
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2013
if uname | grep CYGWIN >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2014
then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2015
        ISWIN=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2016
        # Under windows mercurial outputs '\' instead of '/'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2017
        FILTER="tr '\\\\' '/'"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2018
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2019
        FILTER="cat"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2020
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2021
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2022
if [[ ! -x $PERL ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2023
	print -u2 "Error: No perl interpreter found.  Exiting."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2024
	exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2025
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2026
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2027
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2028
# 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
  2029
# 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
  2030
# determined that we actually need to try to invoke it.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2031
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2032
# [[ ! -x $CODEREVIEW ]] && print -u2 "WARNING: codereview(1) not found."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2033
# [[ ! -x $PS2PDF ]] && print -u2 "WARNING: ps2pdf(1) not found."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2034
# [[ ! -x $WDIFF ]] && print -u2 "WARNING: wdiff not found."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2035
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2036
# Declare global total counters.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2037
integer TOTL TINS TDEL TMOD TUNC
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
flist_mode=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2040
flist_file=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2041
bflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2042
iflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2043
oflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2044
pflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2045
uflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2046
lflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2047
wflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2048
Oflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2049
rflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2050
Nflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2051
forestflag=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2052
while getopts "c:i:o:p:r:u:lmtwONvfb" opt
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2053
do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2054
	case $opt in
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2055
        b)      bflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2056
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2057
	i)	iflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2058
		INCLUDE_FILE=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2059
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2060
	o)	oflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2061
		WDIR=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2062
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2063
	p)	pflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2064
		codemgr_parent=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2065
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2066
	u)      uflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2067
		username=$OPTARG;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2068
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2069
        c)      if [[ -z $CRID ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2070
                   CRID=$OPTARG
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2071
                else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2072
                   CRID="$CRID $OPTARG"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2073
                fi;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2074
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2075
	m)	SCM_MODE="mercurial";;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2076
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2077
	t)	SCM_MODE="teamware";;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2078
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2079
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2080
	# If -l has been specified, we need to abort further options
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2081
	# processing, because subsequent arguments are going to be
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2082
	# arguments to 'putback -n'.
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
	l)	lflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2085
		break;;
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
	w)	wflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2088
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2089
	O)	Oflag=1;;
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
	N)	Nflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2092
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2093
	f)	forestflag=1;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2094
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2095
	r)	rflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2096
		PARENT_REV=$OPTARG;;
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
	v)	print "$0 version: $WEBREV_UPDATED";;
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2101
	?)	usage;;
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2102
	esac
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2103
done
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
FLIST=/tmp/$$.flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2106
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2107
if [[ -n $wflag && -n $lflag ]]; then
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
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2110
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2111
if [[ -n $forestflag && -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2112
    print "The -r <rev> flag is incompatible with the use of forests"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2113
    exit 2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2114
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2115
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2116
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2117
# 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
  2118
# 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
  2119
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2120
if [[ -n $pflag && -d $codemgr_parent/raw_files/new ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2121
	parent_webrev="$codemgr_parent"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2122
	codemgr_parent="$codemgr_parent/raw_files/new"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2123
fi
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 [[ -z $wflag && -z $lflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2126
	shift $(($OPTIND - 1))
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 [[ $1 == "-" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2129
		cat > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2130
		flist_mode="stdin"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2131
		flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2132
		shift
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2133
	elif [[ -n $1 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2134
		if [[ ! -r $1 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2135
			print -u2 "$1: no such file or not readable"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2136
			usage
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2137
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2138
		cat $1 > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2139
		flist_mode="file"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2140
		flist_file=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2141
		flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2142
		shift
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2143
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2144
		flist_mode="auto"
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
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2147
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2148
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2149
# 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
  2150
# is in use.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2151
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2152
if [[ -z $SCM_MODE ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2153
    SCM_MODE=`detect_scm $FLIST`
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
if [[ $SCM_MODE == "unknown" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2156
	print -u2 "Unable to determine SCM type currently in use."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2157
	print -u2 "For teamware: webrev looks for \$CODEMGR_WS either in"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2158
	print -u2 "              the environment or in the file list."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2159
	print -u2 "For mercurial: webrev runs 'hg root'."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2160
	exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2161
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2162
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2163
print -u2 "   SCM detected: $SCM_MODE"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2164
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2165
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2166
if [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2167
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2168
    # determine Workspace and parent workspace paths
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2169
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2170
    CWS=`hg root | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2171
    if [[ -n $pflag && -z "$PWS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2172
	OUTPWS=$codemgr_parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2173
        # 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
  2174
        tmp=`hg path $OUTPWS 2>/dev/null | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2175
        if [[ -n $tmp ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2176
            OUTPWS="$tmp"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2177
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2178
        if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2179
	    if expr "$codemgr_parent" : 'ssh://.*' >/dev/null; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2180
	        PWS=$codemgr_parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2181
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2182
	        PWS=`hg -R "$codemgr_parent" root 2>/dev/null | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2183
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2184
        fi
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
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2187
    # OUTPWS is the parent repository to use when using 'hg outgoing'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2188
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2189
    if [[ -z $Nflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2190
        if [[ -n $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2191
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2192
            # for forest we have to rely on properly set default and
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2193
            # default-push because they can be different from the top one.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2194
            # unless of course it was explicitely speficied with -p
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2195
            if [[ -z $pflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2196
                OUTPWS=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2197
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2198
        else
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
            # Unfortunately mercurial is bugged and doesn't handle
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2201
            # aliases correctly in 'hg path default'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2202
            # So let's do it ourselves. Sigh...
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2203
            if [[ -z "$OUTPWS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2204
                OUTPWS=`grep default-push $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER`
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
            # Still empty, means no default-push
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2207
            if [[ -z "$OUTPWS" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2208
                OUTPWS=`grep 'default =' $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2209
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2210
            # 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
  2211
            tmp=`hg path $OUTPWS 2>/dev/null | $FILTER`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2212
            if [[ -n $tmp ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2213
                OUTPWS="$tmp"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2214
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2215
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2216
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2217
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2218
    # OUTPWS may contain username:password, let's make sure we remove the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2219
    # sensitive information before we print out anything in the HTML
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2220
    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2221
    OUTPWS2=$OUTPWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2222
    if [[ -n $OUTPWS ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2223
	if [[ `expr "$OUTPWS" : '.*://[^/]*@.*'` -gt 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2224
	    # Remove everything between '://' and '@'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2225
	    OUTPWS2=`echo $OUTPWS | sed -e 's/\(.*:\/\/\).*@\(.*\)/\1\2/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2226
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2227
    fi
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
    if [[ -z $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2230
        HG_BRANCH=`hg branch`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2231
        if [ "$HG_BRANCH" == "default" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2232
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2233
            # 'default' means no particular branch, so let's cancel that
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2234
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2235
            HG_BRANCH=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2236
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2237
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2238
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2239
    if [[ -z $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2240
        if [[ -z $Nflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2241
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2242
            # If no "-N", always do "hg outgoing" against parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2243
            # repository to determine list of outgoing revisions.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2244
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2245
            ALL_CREV=`hg outgoing -q --template '{rev}\n' $OUTPWS | sort -n`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2246
            if [[ -n $ALL_CREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2247
                FIRST_CREV=`echo "$ALL_CREV" | head -1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2248
                #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2249
                # If no "-r", choose revision to compare against by
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2250
                # finding the latest revision not in the outgoing list.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2251
                #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2252
                if [[ -z $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2253
                    OUTREV=`find_outrev "$FIRST_CREV"`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2254
                    if [[ -n $OUTREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2255
                        HG_LIST_FROM_COMMIT=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2256
                    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2257
                fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2258
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2259
        elif [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2260
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2261
            # If skipping "hg outgoing" but still comparing against a
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2262
            # specific revision (not the tip), set revision for comment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2263
            # accumulation.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2264
            #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2265
            FIRST_CREV=`hg log --rev $PARENT_REV --template '{rev}'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2266
            FIRST_CREV=`expr $FIRST_CREV + 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2267
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2268
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2269
    #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
  2270
    PREV=`hg parent | grep '^tag:.*tip$'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2271
    if [[ -z $PREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2272
        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
  2273
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2274
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2275
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2276
if [[ -n $lflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2277
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2278
	# 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
  2279
	# then generate the file list by extracting file names from a
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2280
	# putback -n.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2281
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2282
	shift $(($OPTIND - 1))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2283
	if [[ $SCM_MODE == "teamware" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2284
		flist_from_teamware "$*"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2285
	elif [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2286
		flist_from_mercurial
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2287
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2288
	flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2289
	shift $#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2290
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2291
elif [[ -n $wflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2292
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2293
	# 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
  2294
	# command format, i.e.  pathname lines alternating with SCCS comment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2295
	# lines with blank lines as separators.  Use the SCCS comments later
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2296
	# in building the index.html file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2297
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2298
	shift $(($OPTIND - 1))
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2299
	wxfile=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2300
	if [[ -z $wxfile && -n $CODEMGR_WS ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2301
		if [[ -r $CODEMGR_WS/wx/active ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2302
			wxfile=$CODEMGR_WS/wx/active
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2303
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2304
	fi
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
	[[ -z $wxfile ]] && print -u2 "wx file not specified, and could not " \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2307
	    "be auto-detected (check \$CODEMGR_WS)" && exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2308
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2309
	print -u2 " File list from: wx 'active' file '$wxfile' ... \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2310
	flist_from_wx $wxfile
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2311
	flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2312
	if [[ -n "$*" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2313
		shift
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2314
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2315
elif [[ $flist_mode == "stdin" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2316
	print -u2 " File list from: standard input"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2317
elif [[ $flist_mode == "file" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2318
	print -u2 " File list from: $flist_file"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2319
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2320
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2321
if [[ $# -gt 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2322
	print -u2 "WARNING: unused arguments: $*"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2323
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2324
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2325
if [[ $SCM_MODE == "teamware" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2326
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2327
	# Parent (internally $codemgr_parent) and workspace ($codemgr_ws) can
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2328
	# be set in a number of ways, in decreasing precedence:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2329
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2330
	#      1) on the command line (only for the parent)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2331
	#      2) in the user environment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2332
	#      3) in the flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2333
	#      4) automatically based on the workspace (only for the parent)
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2336
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2337
	# Here is case (2): the user environment
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2338
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2339
	[[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2340
	[[ -z $codemgr_ws && -n $WSPACE ]] && codemgr_ws=`$WSPACE name`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2341
	    
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2342
	if [[ -n $codemgr_ws && ! -d $codemgr_ws ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2343
		print -u2 "$codemgr_ws: no such workspace"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2344
		exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2345
	fi
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_parent && -n $CODEMGR_PARENT ]] && \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2348
	    codemgr_parent=$CODEMGR_PARENT
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2349
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2350
	if [[ -n $codemgr_parent && ! -d $codemgr_parent ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2351
		print -u2 "$codemgr_parent: no such directory"
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
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2356
	# 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
  2357
	# list, then see if we can get it by probing for wx.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2358
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2359
	if [[ -z $flist_done && $flist_mode == "auto" && -n $codemgr_ws ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2360
		if [[ ! -x $WX ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2361
			print -u2 "WARNING: wx not found!"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2362
		fi
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
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2365
		# 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
  2366
		# but only if a wx active file exists-- otherwise wx will
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2367
		# hang asking us to initialize our wx information.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2368
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2369
		if [[ -x $WX && -f $codemgr_ws/wx/active ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2370
			print -u2 " File list from: 'wx list -w' ... \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2371
			$WX list -w > $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2372
			$WX comments > /tmp/$$.wx_comments
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2373
			wxfile=/tmp/$$.wx_comments
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2374
			print -u2 "done"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2375
			flist_done=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2376
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2377
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2378
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2379
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2380
	# 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
  2381
	# from the command line), eval it to extract environment variables from
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2382
	# it: This is step (3).
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2383
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2384
	env_from_flist
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2385
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
	# 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
  2388
	# it from teamware.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2389
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2390
	if [[ -z $flist_done ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2391
		flist_from_teamware
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
	fi
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
	if [[ -z $codemgr_ws && -d $PWD/Codemgr_wsdata ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2396
	    codemgr_ws=$PWD
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2397
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2398
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2399
	# Observe true directory name of CODEMGR_WS, as used later in
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2400
	# webrev title.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2401
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2402
	if [[ -n $codemgr_ws ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2403
	    codemgr_ws=$(cd $codemgr_ws;print $PWD)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2404
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2405
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2406
	if [[ -n $codemgr_parent ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2407
	    codemgr_parent=$(cd $codemgr_parent;print $PWD)
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2408
	fi
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
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2411
	# (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
  2412
	# from workspace.
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
	[[ -z $codemgr_parent && -n $WSPACE ]] && codemgr_parent=`$WSPACE parent`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2415
	[[ -z $codemgr_parent ]] && codemgr_parent=`parent_from_teamware $codemgr_ws`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2416
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2417
	if [[ ! -d $codemgr_parent ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2418
	    print -u2 "$CODEMGR_PARENT: no such parent workspace"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2419
	    exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2420
	fi
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
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2423
	# Reset CODEMGR_WS to make sure teamware commands are happy.
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
	CODEMGR_WS=$codemgr_ws
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2426
	CWS=$codemgr_ws
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2427
	PWS=$codemgr_parent
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2428
elif [[ $SCM_MODE == "mercurial" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2429
    if [[ -z $flist_done ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2430
	flist_from_mercurial $PWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2431
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2432
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2433
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2434
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2435
# 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
  2436
# webrev-info file in the workspace directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2437
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2438
if [[ -z $iflag && -r "$CWS/webrev-info" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2439
	iflag=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2440
	INCLUDE_FILE="$CWS/webrev-info"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2441
fi
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 [[ -n $iflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2444
	if [[ ! -r $INCLUDE_FILE ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2445
		print -u2 "include file '$INCLUDE_FILE' does not exist or is" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2446
		    "not readable."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2447
		exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2448
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2449
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2450
		# $INCLUDE_FILE may be a relative path, and the script alters
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2451
		# PWD, so we just stash a copy in /tmp.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2452
		#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2453
		cp $INCLUDE_FILE /tmp/$$.include
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2454
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2455
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2456
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
# Output directory.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2459
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2460
if [[ -z $WDIR ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2461
    WDIR=$CWS/webrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2462
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2463
    # If the output directory doesn't end with '/webrev' or '/webrev/'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2464
    # then add '/webrev'. This is for backward compatibility
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2465
    if ! expr $WDIR : '.*/webrev/\?$' >/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2466
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2467
	WDIR=$WDIR/webrev
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2468
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2469
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2470
# WDIR=${WDIR:-$CWS/webrev}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2471
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2472
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2473
# Name of the webrev, derived from the workspace name; in the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2474
# future this could potentially be an option.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2475
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2476
# Let's keep what's after the last '/'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2477
WNAME=${CWS##*/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2478
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
# If WDIR doesn't start with '/' or 'x:' prepend the current dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2481
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2482
if [ ${WDIR%%/*} ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2483
    if [[ -n $ISWIN ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2484
        if [ ${WDIR%%[A-Za-z]:*} ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2485
	    WDIR=$PWD/$WDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2486
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2487
    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2488
	WDIR=$PWD/$WDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2489
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2490
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2491
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2492
if [[ ! -d $WDIR ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2493
	mkdir -p $WDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2494
	[[ $? != 0 ]] && exit 1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2495
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2496
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2497
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2498
# Summarize what we're going to do.
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
print "      Workspace: $CWS"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2501
if [[ -n $parent_webrev ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2502
    print "Compare against: webrev at $parent_webrev"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2503
elif [[ -n $OUTPWS2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2504
    print "Compare against: $OUTPWS2"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2505
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2506
if [[ -n $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2507
    print "         Branch: $HG_BRANCH"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2508
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2509
if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2510
        print "Compare against version: $PARENT_REV"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2511
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2512
[[ -n $INCLUDE_FILE ]] && print "      Including: $INCLUDE_FILE"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2513
print "      Output to: $WDIR"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2514
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2515
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2516
# Save the file list in the webrev dir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2517
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2518
[[ ! $FLIST -ef $WDIR/file.list ]] && cp $FLIST $WDIR/file.list
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2519
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2520
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2521
#    Bug IDs will be replaced by a URL.  Order of precedence
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2522
#    is: default location, $WEBREV_BUGURL, the -O flag.
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
BUGURL='http://monaco.sfbay.sun.com/detail.jsp?cr='
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2525
[[ -n $WEBREV_BUGURL ]] && BUGURL="$WEBREV_BUGURL"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2526
[[ -n "$Oflag" ]] && \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2527
    BUGURL='http://bugs.sun.com/bugdatabase/view_bug.do?bug_id='
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
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2530
#    Likewise, ARC cases will be replaced by a URL.  Order of precedence
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2531
#    is: default, $WEBREV_SACURL, the -O flag.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2532
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2533
#    Note that -O also triggers different substitution behavior for
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2534
#    SACURL.  See sac2url().
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2535
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2536
SACURL='http://sac.eng.sun.com'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2537
[[ -n $WEBREV_SACURL ]] && SACURL="$WEBREV_SACURL"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2538
[[ -n $Oflag ]] && \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2539
    SACURL='http://www.opensolaris.org/os/community/arc/caselog'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2540
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2541
rm -f $WDIR/$WNAME.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2542
rm -f $WDIR/$WNAME.ps
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2543
rm -f $WDIR/$WNAME.pdf
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2544
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2545
touch $WDIR/$WNAME.patch
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
print "   Output Files:"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2548
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
# Clean up the file list: Remove comments, blank lines and env variables.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2551
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2552
sed -e "s/#.*$//" -e "/=/d" -e "/^[   ]*$/d" $FLIST > /tmp/$$.flist.clean
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2553
FLIST=/tmp/$$.flist.clean
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
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2556
# Clean up residual raw files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2557
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2558
if [ -d $WDIR/raw_files ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2559
    rm -rf $WDIR/raw_files 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2560
fi
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
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2563
# Should we ignore changes in white spaces when generating diffs?
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
if [[ -n $bflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2566
    DIFFOPTS="-t"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2567
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2568
    DIFFOPTS="-bt"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2569
fi
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
# First pass through the files: generate the per-file webrev HTML-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
while read LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2574
do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2575
	set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2576
	P=$1
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
        if [[ $1 == "Revision:" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2579
            OUTREV=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2580
            continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2581
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2582
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2583
	# 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
  2584
	# file that has been modified or created in the child.  A file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2585
	# that is renamed in the child workspace has two names on the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2586
	# line: new name followed by the old name.
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
	oldname=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2589
	oldpath=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2590
	rename=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2591
	if [[ $# -eq 2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2592
		PP=$2			# old filename
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2593
		oldname=" (was $PP)"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2594
		oldpath="$PP"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2595
		rename=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2596
        	PDIR=${PP%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2597
        	if [[ $PDIR == $PP ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2598
			PDIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2599
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2600
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2601
		PF=${PP##*/}
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
	        DIR=${P%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2604
	        if [[ $DIR == $P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2605
			DIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2606
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2607
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2608
		F=${P##*/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2609
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2610
	        DIR=${P%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2611
	        if [[ "$DIR" == "$P" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2612
			DIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2613
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2614
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2615
		F=${P##*/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2616
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2617
		PP=$P
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2618
		PDIR=$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2619
		PF=$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2620
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2621
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2622
        # Make the webrev directory if necessary as it may have been
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2623
        # removed because it was empty
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2624
        if [ ! -d $CWS/$DIR ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2625
	    mkdir -p $CWS/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2626
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2627
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2628
	COMM=`getcomments html $P $PP`
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
	print "\t$P$oldname\n\t\t\c"
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
	# Make the webrev mirror directory if necessary
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2633
	mkdir -p $WDIR/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2634
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2635
	# cd to the directory so the names are short
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2636
	cd $CWS/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2637
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2638
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2639
	# If we're in OpenSolaris mode, we enforce a minor policy:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2640
	# help to make sure the reviewer doesn't accidentally publish
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2641
	# source which is in usr/closed/*
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
	if [[ -n $Oflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2644
		pclosed=${P##usr/closed/}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2645
		if [[ $pclosed != $P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2646
			print "*** Omitting closed source for OpenSolaris" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2647
			    "mode review"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2648
			continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2649
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2650
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2651
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
	# We stash old and new files into parallel directories in /tmp
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2654
	# and do our diffs there.  This makes it possible to generate
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2655
	# clean looking diffs which don't have absolute paths present.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2656
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2657
	olddir=$WDIR/raw_files/old
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2658
	newdir=$WDIR/raw_files/new
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2659
	mkdir -p $olddir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2660
	mkdir -p $newdir
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2661
	mkdir -p $olddir/$PDIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2662
	mkdir -p $newdir/$DIR
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2663
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2664
	build_old_new $olddir $newdir $DIR $F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2665
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2666
	if [[ ! -f $F && ! -f $olddir/$DIR/$F ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2667
		print "*** Error: file not in parent or child"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2668
		continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2669
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2670
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2671
	cd $WDIR/raw_files
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2672
	ofile=old/$PDIR/$PF
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2673
	nfile=new/$DIR/$F
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2674
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2675
	mv_but_nodiff=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2676
	cmp $ofile $nfile > /dev/null 2>&1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2677
	if [[ $? == 0 && $rename == 1 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2678
		mv_but_nodiff=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2679
	fi
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
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2682
        # Cleaning up
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2683
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2684
        rm -f $WDIR/$DIR/$F.cdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2685
        rm -f $WDIR/$DIR/$F.udiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2686
        rm -f $WDIR/$DIR/$F.wdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2687
        rm -f $WDIR/$DIR/$F.sdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2688
        rm -f $WDIR/$DIR/$F-.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2689
        rm -f $WDIR/$DIR/$F.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2690
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2691
	its_a_jar=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2692
	if expr $F : '.*\.jar' >/dev/null; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2693
	    its_a_jar=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2694
	    # It's a JAR file, let's do it differntly
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2695
	    if [[ -z $JAR ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2696
		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
  2697
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2698
		if [ -f $ofile ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2699
		    $JAR -tvf $ofile >"$ofile".lst
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2700
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2701
		if [ -f $nfile ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2702
		    $JAR -tvf $nfile >"$nfile".lst
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2703
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2704
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2705
		if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2706
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2707
		    ${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
  2708
		    diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2709
			> $WDIR/$DIR/$F.cdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2710
		    print " cdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2711
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2712
		    ${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
  2713
		    diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2714
			> $WDIR/$DIR/$F.udiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2715
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2716
		    print " udiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2717
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2718
		    if [[ -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2719
			$WDIFF -c "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2720
			    -t "$WNAME Wdiff $DIR/$F" $ofile.lst $nfile.lst > \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2721
			    $WDIR/$DIR/$F.wdiff.html 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2722
			if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2723
			    print " wdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2724
			else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2725
			    print " wdiffs[fail]\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2726
			fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2727
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2728
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2729
		    sdiff_to_html $ofile $nfile $F $DIR "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2730
			> $WDIR/$DIR/$F.sdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2731
		    print " sdiffs\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
		    print " frames\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2734
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2735
		    rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2736
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2737
		    difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2738
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2739
		elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2740
		# renamed file: may also have differences
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2741
		    difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2742
		elif [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2743
		# new file: count added lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2744
		    difflines /dev/null $nfile.lst > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2745
		elif [[ -f $ofile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2746
		# old file: count deleted lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2747
		    difflines $ofile.lst /dev/null > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2748
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2749
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2750
	else
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
	    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2753
	    # 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
  2754
	    # appropriate diffs.  This is complicated by a couple of factors:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2755
	    #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2756
	    #	- renames must be handled specially: we emit a 'remove'
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2757
	    #	  diff and an 'add' diff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2758
	    #	- new files and deleted files must be handled specially
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2759
	    #	- Solaris patch(1m) can't cope with file creation
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2760
	    #	  (and hence renames) as of this writing.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2761
	    #   - To make matters worse, gnu patch doesn't interpret the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2762
	    #	  output of Solaris diff properly when it comes to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2763
	    #	  adds and deletes.  We need to do some "cleansing"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2764
	    #     transformations:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2765
	    # 	    [to add a file] @@ -1,0 +X,Y @@  -->  @@ -0,0 +X,Y @@
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2766
	    #	    [to del a file] @@ -X,Y +1,0 @@  -->  @@ -X,Y +0,0 @@
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
	    cleanse_rmfile="sed 's/^\(@@ [0-9+,-]*\) [0-9+,-]* @@$/\1 +0,0 @@/'"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2769
	    cleanse_newfile="sed 's/^@@ [0-9+,-]* \([0-9+,-]* @@\)$/@@ -0,0 \1/'"
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
	    rm -f $WDIR/$DIR/$F.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2772
	    if [[ -z $rename ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2773
		if [ ! -f $ofile ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2774
		    diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2775
			> $WDIR/$DIR/$F.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2776
		elif [ ! -f $nfile ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2777
		    diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2778
			> $WDIR/$DIR/$F.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2779
		else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2780
		    diff -u $ofile $nfile > $WDIR/$DIR/$F.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2781
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2782
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2783
		diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2784
		    > $WDIR/$DIR/$F.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2785
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2786
		diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2787
		    >> $WDIR/$DIR/$F.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2788
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2789
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2790
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2791
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2792
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2793
	# Tack the patch we just made onto the accumulated patch for the
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2794
	# whole wad.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2795
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2796
	    cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2797
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2798
	    print " patch\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2799
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2800
	    if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2801
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2802
		${CDIFFCMD:-diff -bt -C 5} $ofile $nfile > $WDIR/$DIR/$F.cdiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2803
		diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2804
		    > $WDIR/$DIR/$F.cdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2805
		print " cdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2806
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2807
		${UDIFFCMD:-diff -bt -U 5} $ofile $nfile > $WDIR/$DIR/$F.udiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2808
		diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2809
		    > $WDIR/$DIR/$F.udiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2810
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2811
		print " udiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2812
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2813
		if [[ -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2814
		    $WDIFF -c "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2815
			-t "$WNAME Wdiff $DIR/$F" $ofile $nfile > \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2816
			$WDIR/$DIR/$F.wdiff.html 2>/dev/null
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2817
		    if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2818
			print " wdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2819
		    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2820
			print " wdiffs[fail]\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2821
		    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2822
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2823
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2824
		sdiff_to_html $ofile $nfile $F $DIR "$COMM" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2825
		    > $WDIR/$DIR/$F.sdiff.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2826
		print " sdiffs\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2827
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2828
		print " frames\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2829
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2830
		rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2831
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2832
		difflines $ofile $nfile > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2833
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2834
	    elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2835
		# renamed file: may also have differences
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2836
		difflines $ofile $nfile > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2837
	    elif [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2838
		# new file: count added lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2839
		difflines /dev/null $nfile > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2840
	    elif [[ -f $ofile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2841
		# old file: count deleted lines
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2842
		difflines $ofile /dev/null > $WDIR/$DIR/$F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2843
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2844
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2845
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2846
	# Now we generate the postscript for this file.  We generate diffs
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2847
	# 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
  2848
	# tree-killing to print out the contents of deleted files).
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
	if [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2851
		ocr=$ofile
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2852
		[[ ! -f $ofile ]] && ocr=/dev/null
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
		if [[ -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2855
			textcomm=`getcomments text $P $PP`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2856
			if [[ -x $CODEREVIEW ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2857
				$CODEREVIEW -y "$textcomm" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2858
				    -e $ocr $nfile \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2859
				    > /tmp/$$.psfile 2>/dev/null &&
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2860
				    cat /tmp/$$.psfile >> $WDIR/$WNAME.ps
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2861
				if [[ $? -eq 0 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2862
					print " ps\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2863
				else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2864
					print " ps[fail]\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2865
				fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2866
			fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2867
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2868
	fi
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 $ofile && -z $mv_but_nodiff ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2871
	    if [[ -n $its_a_jar ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2872
		source_to_html Old $P < $ofile.lst > $WDIR/$DIR/$F-.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2873
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2874
		source_to_html Old $P < $ofile > $WDIR/$DIR/$F-.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2875
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2876
		print " old\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2877
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2878
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2879
	if [[ -f $nfile ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2880
	    if [[ -n $its_a_jar ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2881
		source_to_html New $P < $nfile.lst > $WDIR/$DIR/$F.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2882
	    else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2883
		source_to_html New $P < $nfile > $WDIR/$DIR/$F.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2884
	    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2885
		print " new\c"
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
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2888
	print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2889
done < $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2890
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2891
frame_nav_js > $WDIR/ancnav.js
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2892
frame_navigation > $WDIR/ancnav.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2893
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2894
if [[ -f $WDIR/$WNAME.ps && -x $CODEREVIEW && -x $PS2PDF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2895
	print " Generating PDF: \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2896
	fix_postscript $WDIR/$WNAME.ps | $PS2PDF - > $WDIR/$WNAME.pdf
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2897
	print "Done."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2898
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2899
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2900
# Now build the index.html file that contains
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2901
# links to the source files and their diffs.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2902
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2903
cd $CWS
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2904
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2905
# Save total changed lines for Code Inspection.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2906
print "$TOTL" > $WDIR/TotalChangedLines
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 "     index.html: \c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2909
INDEXFILE=$WDIR/index.html
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2910
exec 3<&1			# duplicate stdout to FD3.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2911
exec 1<&-			# Close stdout.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2912
exec > $INDEXFILE		# Open stdout to index file.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2913
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2914
print "$HTML<head>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2915
print "<meta name=\"scm\" content=\"$SCM_MODE\" />"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2916
print "$STDHEAD"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2917
print "<title>$WNAME</title>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2918
print "</head>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2919
print "<body id=\"SUNWwebrev\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2920
print "<div class=\"summary\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2921
print "<h2>Code Review for $WNAME</h2>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2922
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2923
print "<table>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2924
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2925
if [[ -z $uflag ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2926
then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2927
    if [[ $SCM_MODE == "mercurial" ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2928
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2929
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2930
        # Let's try to extract the user name from the .hgrc file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2931
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2932
	username=`grep '^username' $HOME/.hgrc | sed 's/^username[ ]*=[ ]*\(.*\)/\1/'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2933
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2934
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2935
    if [[ -z $username ]]
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2936
    then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2937
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2938
        # Figure out the username and gcos name.  To maintain compatibility
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2939
        # with passwd(4), we must support '&' substitutions.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2940
        #
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2941
	username=`id | cut -d '(' -f 2 | cut -d ')' -f 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2942
	if [[ -x $GETENT ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2943
	    realname=`$GETENT passwd $username | cut -d':' -f 5 | cut -d ',' -f 1`
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
	userupper=`print "$username" | sed 's/\<./\u&/g'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2946
	realname=`print $realname | sed s/\&/$userupper/`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2947
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2948
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2949
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2950
date="on `date`"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2951
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2952
if [[ -n "$username" && -n "$realname" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2953
	print "<tr><th>Prepared by:</th>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2954
	print "<td>$realname ($username) $date</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2955
elif [[ -n "$username" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2956
	print "<tr><th>Prepared by:</th><td>$username $date</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2957
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2958
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2959
print "<tr><th>Workspace:</th><td>$CWS</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2960
if [[ -n $parent_webrev ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2961
        print "<tr><th>Compare against:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2962
	print "webrev at $parent_webrev"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2963
else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2964
    if [[ -n $OUTPWS2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2965
        print "<tr><th>Compare against:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2966
	print "$OUTPWS2"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2967
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2968
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2969
print "</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2970
if [[ -n $rflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2971
    print "<tr><th>Compare against version:</th><td>$PARENT_REV</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2972
elif [[ -n $OUTREV ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2973
    if [[ -z $forestflag ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2974
        print "<tr><th>Compare against version:</th><td>$OUTREV</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2975
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2976
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2977
if [[ -n $HG_BRANCH ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2978
    print "<tr><th>Branch:</th><td>$HG_BRANCH</td></tr>"
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
print "<tr><th>Summary of changes:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2982
printCI $TOTL $TINS $TDEL $TMOD $TUNC
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2983
print "</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2984
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2985
if [[ -f $WDIR/$WNAME.patch ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2986
	print "<tr><th>Patch of changes:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2987
	print "<a href=\"$WNAME.patch\">$WNAME.patch</a></td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2988
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2989
if [[ -f $WDIR/$WNAME.pdf ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2990
	print "<tr><th>Printable review:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2991
	print "<a href=\"$WNAME.pdf\">$WNAME.pdf</a></td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2992
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2993
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2994
if [[ -n "$iflag" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2995
	print "<tr><th>Author comments:</th><td><div>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2996
	cat /tmp/$$.include
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2997
	print "</div></td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2998
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  2999
# Add links to referenced CRs, if any
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3000
# external URL has a <title> like:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3001
# <title>Bug ID: 6641309 Wrong Cookie separator used in HttpURLConnection</title>
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3002
# while internal URL has <title> like:
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3003
# <title>6641309: Wrong Cookie separator used in HttpURLConnection</title>
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
if [[ -n $CRID ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3006
    for id in $CRID
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3007
    do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3008
        print "<tr><th>Bug id:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3009
        url="${BUGURL}${id}"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3010
        if [[ -n $WGET ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3011
            msg=`$WGET -q $url -O - | grep '<title>' | sed 's/<title>\(.*\)<\/title>/\1/' | sed 's/Bug ID://'`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3012
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3013
        if [[ -n $msg ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3014
            print "<a href=\"$url\">$msg</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3015
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3016
            print $id | bug2url
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3017
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3018
        
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3019
        print "</td></tr>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3020
    done
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
print "<tr><th>Legend:</th><td>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3023
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
  3024
print "</table>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3025
print "</div>"
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
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3028
# Second pass through the files: generate the rest of the index file
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3029
#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3030
while read LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3031
do
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3032
	set - $LINE
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3033
        if [[ $1 == "Revision:" ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3034
            FIRST_CREV=`expr $3 + 1`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3035
            continue
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3036
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3037
	P=$1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3038
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3039
	if [[ $# == 2 ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3040
		PP=$2
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3041
		oldname=" <i>(was $PP)</i>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3042
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3043
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3044
		PP=$P
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3045
		oldname=""
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3046
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3047
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3048
	DIR=${P%/*}
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3049
	if [[ $DIR == $P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3050
		DIR="."   # File at root of workspace
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3051
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3052
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3053
	# Avoid processing the same file twice.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3054
	# It's possible for renamed files to
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3055
	# appear twice in the file list
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3056
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3057
	F=$WDIR/$P
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3058
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3059
	print "<p><code>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3060
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3061
	# If there's a diffs file, make diffs links
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3062
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3063
        NODIFFS=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3064
	if [[ -f $F.cdiff.html ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3065
		print "<a href=\"$P.cdiff.html\">Cdiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3066
		print "<a href=\"$P.udiff.html\">Udiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3067
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3068
		if [[ -f $F.wdiff.html && -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3069
			print "<a href=\"$P.wdiff.html\">Wdiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3070
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3071
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3072
		print "<a href=\"$P.sdiff.html\">Sdiffs</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3073
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3074
		print "<a href=\"$P.frames.html\">Frames</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3075
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3076
                NODIFFS=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3077
		print " ------ ------ ------"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3078
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3079
		if [[ -x $WDIFF ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3080
			print " ------"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3081
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3082
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3083
		print " ------"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3084
	fi
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
	# If there's an old file, make the link
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3087
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3088
        NOOLD=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3089
	if [[ -f $F-.html ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3090
		print "<a href=\"$P-.html\">Old</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3091
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3092
                NOOLD=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3093
		print " ---"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3094
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3095
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3096
	# If there's an new file, make the link
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
        NONEW=
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3099
	if [[ -f $F.html ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3100
		print "<a href=\"$P.html\">New</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3101
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3102
                NONEW=1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3103
		print " ---"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3104
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3105
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3106
	if [[ -f $F.patch ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3107
		print "<a href=\"$P.patch\">Patch</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3108
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3109
		print " -----"
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
	if [[ -f $WDIR/raw_files/new/$P ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3113
		print "<a href=\"raw_files/new/$P\">Raw</a>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3114
	else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3115
		print " ---"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3116
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3117
        print "</code>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3118
        if [[ -n $NODIFFS && -z $oldname ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3119
            if [[ -n $NOOLD ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3120
                print "<font color=green><b>$P</b></font>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3121
            elif [[ -n $NONEW ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3122
                print "<font color=red><b>$P</b></font>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3123
            fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3124
        else
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3125
	    print "<b>$P</b> $oldname"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3126
        fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3127
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3128
	#
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3129
	# Check for usr/closed
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
	if [ ! -z "$Oflag" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3132
		if [[ $P == usr/closed/* ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3133
			print "&nbsp;&nbsp;<i>Closed source: omitted from" \
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3134
			    "this review</i>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3135
		fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3136
	fi
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
	print "</p><blockquote>\c"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3139
	# Insert delta comments if any
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3140
	comments=`getcomments html $P $PP`
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3141
	if [ -n "$comments" ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3142
	    print "<pre>$comments</pre>"
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
	# Add additional comments comment
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
	print "<!-- Add comments to explain changes in $P here -->"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3148
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3149
	# Add count of changes.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3150
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3151
	if [[ -f $F.count ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3152
	    cat $F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3153
	    rm $F.count
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3154
	fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3155
        print "</blockquote>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3156
done < $FLIST
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3157
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3158
print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3159
print
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3160
print "<hr />"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3161
print "<p style=\"font-size: small\">"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3162
print "This code review page was prepared using <b>$0</b>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3163
print "(vers $WEBREV_UPDATED)."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3164
print "</body>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3165
print "</html>"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3166
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3167
if [[ -n $ZIP ]]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3168
    # Let's generate a zip file for convenience
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3169
    cd $WDIR/..
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3170
    if [ -f webrev.zip ]; then
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3171
	rm webrev.zip
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3172
    fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3173
    $ZIP -r webrev webrev >/dev/null 2>&1
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3174
fi
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3175
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3176
exec 1<&-			# Close FD 1.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3177
exec 1<&3			# dup FD 3 to restore stdout.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3178
exec 3<&-			# close FD 3.
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3179
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3180
print "Done."
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3181
print "Output to: $WDIR"
0be681587b9c 7023111: Add webrev script to make/scripts
ohair
parents:
diff changeset
  3182