#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Check delta comments:
# - Have the correct form.
# - Have a synopsis matching that of the CR or ARC case.
# - Appear only once.
#
#
# Translate any acceptable case number format into "<ARC> <YEAR>/<NUM>"
# format.
#
'''Validate checkin comments against ON standards.
Comments must be a list of one-line comments, with no trailing
newline.
If check_db is True (the default), validate CR and ARC
synopses against the databases.
Error messages intended for the user are written to output,
which defaults to stderr
'''
errors = { 'bugnospc': [],
'mutant': [],
'dup': [],
'nomatch': [],
'nonexistent': [] }
bugs = {}
arcs = {}
ret = 0
# Our input must be newline-free, comments are line-wise.
# Ignore valid comments we can't check
continue
continue
if match:
continue
#
# Bugs missing a space after the ID are still bugs
# for the purposes of the duplicate ID and synopsis
# checks.
#
if match:
continue
# ARC case
if match:
continue
# Anything else is bogus
if not check_db:
continue
continue
#
# For each synopsis, compare the real synopsis with
# that in the comments, allowing for possible '(fix
# stuff)'-like trailing text
#
r'( \([^)]+\))?$', entered):
entered])
if check_db:
if not check_db:
continue
continue
#
# We first try a direct match between the actual case name
# and the entered comment. If that fails we remove a possible
# trailing (fix nit)-type comment, and re-try.
#
break
else:
# Try again with trailing (fix ...) removed.
entered])
if blanks:
ret = 1
if errors['dup']:
ret = 1
"comments:\n")
if errors['bugnospc']:
ret = 1
"the ID:\n")
if errors['mutant']:
ret = 1
if errors['nonexistent']:
ret = 1
"databases:\n")
if errors['nomatch']:
ret = 1
"the database entries:\n")
return ret