Review Board

beta

Add configuration variables to the top of post-review for site-wide defaults

Updated 9 months, 1 week ago

Marc Hedlund Reviewers
reviewboard
None Review Board SVN
This adds a set of configuration variables to the top of post-review, one for each of the command-line switches where it would make sense, so that sites can easily set site-wide defaults.  

I also made the command-line option definitions more consistent, and added '-n' as a short flag for the '--output-diff' option (since '-n' usually means "tell me what you're going to do without actually doing it," which seems appropriate here and is how I use that option).

Finally, I updated the usage string.
I've done basic sanity-checking on each of the configuration variables.

Diff revision 1 (Latest)

  1. /trunk/reviewboard/contrib/tools/post-review: 21 changes [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ]
/trunk/reviewboard/contrib/tools/post-review
Revision 1255 New Change
12
import urllib2
12
import urllib2
13
from optparse import OptionParser
13
from optparse import OptionParser
14
from tempfile import mkstemp
14
from tempfile import mkstemp
15
from urlparse import urljoin
15
from urlparse import urljoin
16
16
17
###
18
# Default configuration -- user-settable variables follow.
19
###
20
21
# The following settings aren't ever needed, but if your Review
22
# Board crew has specific preferences and doesn't want to express
23
# them with command line switches, set them here and you're done.
24
# In particular, setting the REVIEWBOARD_URL variable will allow
25
# you to make it easy for people to submit reviews regardless of
26
# their SCM setup.
27
28
# Reviewboard URL.  This is a required setting, but you can set it
29
# one of several ways.  You can set it via your SCM system (for
30
# instance, using Subversion properties, such as:
31
#   svn setprop reviewboard:url=http://reviewboard.example.com
32
# ), or you can set it from the command line, or you can set it
33
# below. While the SCM property method is better, since it allows
34
# you to support multiple Review Board servers based on your
35
# current source tree, setting it here is easier and will let you
36
# get started quickly.
37
REVIEWBOARD_URL = None
38
39
# Default submission arguments.  These are all optional; run this
40
# script with --help for descriptions of each argument.
41
TARGET_GROUPS   = None
42
TARGET_PEOPLE   = None
43
SUBMIT_AS       = None
44
PUBLISH         = False
45
OPEN_BROWSER    = False
46
47
# Debugging.  For development...
48
DEBUG           = False
49
50
###
51
# End user-settable variables.
52
###
53
17
VERSION = "0.6"
54
VERSION = "0.6"
18
55
19
# Who stole the cookies from the cookie jar?
56
# Who stole the cookies from the cookie jar?
20
# Was it you?
57
# Was it you?
21
# >:(
58
# >:(
1012
1049
1013
    return review_url
1050
    return review_url
1014
1051
1015
1052
1016
def parse_options(tool, repository_info, args):
1053
def parse_options(tool, repository_info, args):
1017
    parser = OptionParser(usage="%prog [-p] [-o] changenum",
1054
    parser = OptionParser(usage="%prog [-pond] [-r review_id] [changenum]",
1018
                          version="%prog " + VERSION)
1055
                          version="%prog " + VERSION)
1019
1056
1020
    parser.add_option("-p", "--publish",
1057
    parser.add_option("-p", "--publish",
1021
                      action="store_true", dest="publish", default=False,
1058
                      dest="publish", action="store_true", default=PUBLISH,
1022
                      help="publish the review request immediately after " +
1059
                      help="publish the review request immediately after " +
1023
                           "submitting")
1060
                           "submitting")
1061
    parser.add_option("-r", "--review-request-id",
1062
                      dest="rid", metavar="ID", default=None,
1063
                      help="existing review request ID to update")
1024
    parser.add_option("-o", "--open",
1064
    parser.add_option("-o", "--open",
1025
                      action="store_true", dest="open_browser", default=False,
1065
                      dest="open_browser", action="store_true",
1066
                      default=OPEN_BROWSER,
1026
                      help="open a web browser to the review request page")
1067
                      help="open a web browser to the review request page")
1027
    parser.add_option("--output-diff",
1068
    parser.add_option("-n", "--output-diff",
1028
                      action="store_true", dest="output_diff_only",
1069
                      dest="output_diff_only", action="store_true",
1029
                      default=False,
1070
                      default=False,
1030
                      help="outputs a diff to the console and exits. " +
1071
                      help="outputs a diff to the console and exits. " +
1031
                           "Does not post")
1072
                           "Does not post")
1032
    parser.add_option("--server", dest="server",
1073
    parser.add_option("--server",
1074
                      dest="server", default=REVIEWBOARD_URL,
1033
                      metavar="SERVER",
1075
                      metavar="SERVER",
1034
                      help="specify a different Review Board server " +
1076
                      help="specify a different Review Board server " +
1035
                           "to use")
1077
                           "to use")
1036
    parser.add_option("--diff-only", dest="diff_only",
1078
    parser.add_option("--diff-only",
1037
                      action="store_true", default=False,
1079
                      dest="diff_only", action="store_true", default=False,
1038
                      help="uploads a new diff, but does not update " +
1080
                      help="uploads a new diff, but does not update " +
1039
                           "info from changelist")
1081
                           "info from changelist")
1040
    parser.add_option("--target-groups", dest="target_groups",
1082
    parser.add_option("--target-groups",
1041
                      default=None,
1083
                      dest="target_groups", default=TARGET_GROUPS,
1042
                      help="names of the groups who will perform " +
1084
                      help="names of the groups who will perform " +
1043
                           "the review")
1085
                           "the review")
1044
    parser.add_option("--target-people", dest="target_people",
1086
    parser.add_option("--target-people",
1045
                      default=None,
1087
                      dest="target_people", default=TARGET_PEOPLE,
1046
                      help="names of the people who will perform " +
1088
                      help="names of the people who will perform " +
1047
                           "the review")
1089
                           "the review")
1048
    parser.add_option("--summary", dest="summary",
1090
    parser.add_option("--summary",
1049
                      default=None,
1091
                      dest="summary", default=None,
1050
                      help="summary of the review ")
1092
                      help="summary of the review ")
1051
    parser.add_option("--description", dest="description",
1093
    parser.add_option("--description",
1052
                      default=None,
1094
                      dest="description", default=None,
1053
                      help="description of the review ")
1095
                      help="description of the review ")
1054
    parser.add_option("--revision-range", dest="revision_range",
1096
    parser.add_option("--revision-range",
1055
                      default=None,
1097
                      dest="revision_range", default=None,
1056
                      help="generate the diff for review based on given " +
1098
                      help="generate the diff for review based on given " +
1057
                           "revision range")
1099
                           "revision range")
1058
    parser.add_option("-r", "--review-request-id", dest="rid", metavar="ID",
1100
    parser.add_option("--submit-as",
1059
                      default=None,
1101
                      dest="submit_as", default=SUBMIT_AS, metavar="USERNAME",
1060
                      help="existing review request ID to update")
1061
    parser.add_option("--submit-as", dest="submit_as", metavar="USERNAME",
1062
                      default=None,
1063
                      help="user name to be recorded as the author of the "
1102
                      help="user name to be recorded as the author of the "
1064
                           "review request, instead of the logged in user")
1103
                           "review request, instead of the logged in user")
1065
1104
1066
    if repository_info:
1105
    if repository_info:
1067
        if repository_info.supports_changesets:
1106
        if repository_info.supports_changesets:
1068
            parser.add_option("--change-only", dest="change_only",
1107
            parser.add_option("--change-only",
1069
                              action="store_true", default=False,
1108
                              dest="change_only", action="store_true",
1109
                              default=False,
1070
                              help="updates info from changelist, but does " +
1110
                              help="updates info from changelist, but does " +
1071
                                   "not upload a new diff")
1111
                                   "not upload a new diff")
1072
1112
1073
        tool.add_options(parser)
1113
        tool.add_options(parser)
1074
1114
1075
1115
1076
    parser.add_option("-d", "--debug", action="store_true",
1116
    parser.add_option("-d", "--debug",
1077
                      dest="debug", default=False, help="display debug output")
1117
                      action="store_true", dest="debug", default=DEBUG,
1118
                      help="display debug output")
1078
1119
1079
    (globals()["options"], args) = parser.parse_args(args)
1120
    (globals()["options"], args) = parser.parse_args(args)
1080
1121
1081
    return args
1122
    return args
1082
1123
  1. /trunk/reviewboard/contrib/tools/post-review: 21 changes [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ]