-
Notifications
You must be signed in to change notification settings - Fork 58
/
installpreferences.py
297 lines (286 loc) · 18.4 KB
/
installpreferences.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# -*- mode: python; encoding: utf-8 -*-
#
# Copyright 2012 Jens Lindström, Opera Software ASA
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
PREFERENCES = [ { "item": 'email.newReview.displayReviewers',
"type": 'boolean',
"default_integer": 1,
"description": 'Include a list of all assigned reviewers in the email sent when a new review is submitted.' },
{ "item": 'email.newReview.displayWatchers',
"type": 'boolean',
"default_integer": 1,
"description": 'Include a list of all additional watchers in the email sent when a new review is submitted.' },
{ "item": 'email.newReview.diff.contextLines',
"type": 'integer',
"default_integer": 3,
"description": 'Number of context lines added to diffs in the email sent when a new review is submitted.' },
{ "item": 'email.newReview.displayCommits',
"type": 'boolean',
"default_integer": 1,
"description": 'Include a list of all commits to be reviewed in the email sent when a new review is submitted.' },
{ "item": 'email.newReview.displayDiffs',
"type": 'boolean',
"default_integer": 1,
"description": 'Include diffs of each commit to be reviewed in the email sent when a new review is submitted.' },
{ "item": 'email.newReview.diff.maxLines',
"type": 'integer',
"default_integer": 250,
"description": 'Maximum number of lines of diffs to include in the email sent when a new review is submitted. If exceeded, no diffs are included at all.' },
{ "item": 'email.lineLength',
"type": 'integer',
"default_integer": 80,
"description": 'Maximum line length in emails sent. Plain text will be reflowed to adhere to this. Diffs and other non-prose items are never reflowed.' },
{ "item": 'commit.diff.contextLines',
"type": 'integer',
"default_integer": 5,
"description": "Default number of context lines added to diffs when displaying commits. Can be overridden by 'context' URI parameter." },
{ "item": 'commit.diff.rulerColumn',
"type": 'integer',
"default_integer": 0,
"description": "The column at which a ruler is shown. Can be set to 0 to disable the ruler." },
{ "item": 'email.comment.contextLines',
"type": 'integer',
"default_integer": 0,
"description": 'Default number of context lines added to code excerpts when displaying comment threads in emails.' },
{ "item": 'email.updatedReview.displayCommits',
"type": 'boolean',
"default_integer": 1,
"description": 'Include a list of all new commits to be reviewed in the email sent when a review is updated.' },
{ "item": 'email.updatedReview.diff.contextLines',
"type": 'integer',
"default_integer": 3,
"description": 'Number of context lines added to diffs in the email sent when a review is updated.' },
{ "item": 'email.updatedReview.diff.maxLines',
"type": 'integer',
"default_integer": 250,
"description": 'Maximum number of lines of diffs to include in the email sent when a review is updated. If exceeded, no diffs are included at all.' },
{ "item": 'email.updatedReview.commentThreading',
"type": 'boolean',
"default_integer": 0,
"description": 'Send emails containing comments so that comment threads form email threads. This will increase the number of emails sent from Critic to the user.' },
{ "item": 'review.createViaPush',
"type": 'boolean',
"default_integer": 0,
"description": 'If enabled, reviews can be requested by pushing a new branch whose name starts with "r/" to the repository.' },
{ "item": 'ui.keyboardShortcuts',
"type": 'boolean',
"default_integer": 1,
"description": 'Enabled keyboard shortcuts on those pages that define any.' },
{ "item": 'commit.expandAllFiles',
"type": 'boolean',
"default_integer": 0,
"description": "On the 'showcommit' page, expand the diffs in all files on page load." },
{ "item": 'review.pingAnyReview',
"type": 'boolean',
"default_integer": 0,
"description": 'Show the "Ping Review" button on the front-page of every review, instead of only those you own.' },
{ "item": 'review.dropAnyReview',
"type": 'boolean',
"default_integer": 0,
"description": 'Show the "Drop Review" button on the front-page of every review, instead of only those you own.' },
{ "item": 'defaultPage',
"type": 'string',
"default_string": 'home',
"description": 'The default page displayed when accessing the system.' },
{ "item": 'email.updatedReview.relevantChangesOnly',
"type": 'boolean',
"default_integer": 0,
"description": 'Only generate emails about reviewed files and written comments that are relevant.' },
{ "item": 'email.activated',
"type": 'boolean',
"default_integer": 1,
"description": 'Must be enabled before the system sends any emails to the user.' },
{ "item": 'style.defaultFont',
"type": 'string',
"default_string": 'font-size: 10pt; font-family: sans-serif',
"description": 'Font setting applied to the BODY element on every page.' },
{ "item": 'style.sourceFont',
"type": 'string',
"default_string": 'font-size: 10pt; font-family: monospace',
"description": 'Font setting applied to source code text in diff display.' },
{ "item": 'style.tutorialFont',
"type": 'string',
"default_string": 'font-size: 11pt; font-family: serif',
"description": 'Font setting applied to tutorial text.' },
{ "item": 'ui.resolveIssueWarning',
"type": 'boolean',
"default_integer": 1,
"description": 'Show a warning when resolving an issue raised by another user.' },
{ "item": 'defaultRepository',
"type": 'string',
"default_string": '',
"description": 'Name of default repository. In situations where the repository is not implied, this is the one that is used, or preferred.' },
{ "item": 'review.updateCheckInterval',
"type": 'integer',
"default_integer": 300,
"description": 'Check for updates of reviews every N seconds while displaying review front pages. If zero, the check is disabled.' },
{ "item": 'email.urlType',
"type": 'string',
"default_string": 'main',
"description": 'Type of URLs used in emails.' },
{ "item": 'review.applyUpstreamFilters',
"type": 'boolean',
"default_integer": 1,
"description": 'If enabled, filters from upstream repositories are applied when creating review via push.' },
{ "item": 'commit.diff.collapseSimpleHunks',
"type": 'boolean',
"default_integer": 0,
"description": 'When a hunk in a diff contains only deleted or only inserted lines, collapse the "other" side, so that the hunk is displayed as a single wide column. NOT FULLY FUNCTIONAL!' },
{ "item": 'ui.title.showReview',
"type": 'string',
"default_string": '%(id)s (%(progress)s) - %(summary)s - Opera Critic',
"description": 'Python format string for title of review front-page documents.' },
{ "item": 'comment.diff.contextLines',
"type": 'integer',
"default_integer": 3,
"description": "Default number of context lines added to diffs when displaying comment chains. Can be overridden by 'context' URI parameter." },
{ "item": 'email.newReview.displayStats',
"type": 'boolean',
"default_integer": 0,
"description": 'Include --stat output for commits added to the review.' },
{ "item": 'email.updatedReview.displayStats',
"type": 'boolean',
"default_integer": 0,
"description": 'Include --stat output for commits added to the review.' },
{ "item": 'email.newReview.stats.maxLines',
"type": 'integer',
"default_integer": 250,
"description": 'Maximum number of lines of commit stats to include in the email sent when a review is submitted. If exceeded, no stats are included at all.' },
{ "item": 'email.updatedReview.stats.maxLines',
"type": 'integer',
"default_integer": 250,
"description": 'Maximum number of lines of commit stats to include in the email sent when a review is updated. If exceeded, no stats are included at all.' },
{ "item": 'commit.expandFilesLimit',
"type": 'integer',
"default_integer": 0,
"description": "If 'commit.expandAllFiles' is enabled, and this limit is non-zero, all files are initially collapsed if the diff contains changes in more files than this limit." },
{ "item": 'email.updatedReview.quotedComments',
"type": 'string',
"default_string": 'all',
"description": 'Selection of comments in a comment thread that are quoted when new replies are submitted.' },
{ "item": 'commit.diff.visualTabs',
"type": 'boolean',
"default_integer": 0,
"description": "Replace tab characters with U+2192 (RIGHTWARDS ARROW) styled to the correct width (taking the file's Emacs mode-line into account.)" },
{ "item": 'email.subjectLine.newReview',
"type": 'string',
"default_string": 'New Review: %(summary)s',
"description": 'Python format string for subject line of email sent for newly created reviews.' },
{ "item": 'email.subjectLine.newishReview',
"type": 'string',
"default_string": 'New(ish) Review: %(summary)s',
"description": 'Python format string for subject line of email sent for new(ish) reviews.' },
{ "item": 'email.subjectLine.updatedReview.commitsPushed',
"type": 'string',
"default_string": 'Updated Review: %(summary)s',
"description": 'Python format string for subject line of email sent when someone pushes additional commits to a review.' },
{ "item": 'email.subjectLine.updatedReview.assignmentsChanged',
"type": 'string',
"default_string": 'Updated Review: %(summary)s',
"description": 'Python format string for subject line of email sent when someone changes review assignments.' },
{ "item": 'email.subjectLine.updatedReview.parentFiltersApplied',
"type": 'string',
"default_string": 'Updated Review: %(summary)s',
"description": 'Python format string for subject line of email sent when someone applies parent repository filters to a review.' },
{ "item": 'email.subjectLine.pingedReview',
"type": 'string',
"default_string": 'Pinged Review: %(summary)s',
"description": 'Python format string for subject line of email sent when someone pings a review.' },
{ "item": 'commit.diff.compactMode',
"type": 'boolean',
"default_integer": 1,
"description": 'Generate more compact HTML for diffs, and generate some HTML on-demand client-side. Faster download and initial rendering, and slower interaction.' },
{ "item": 'debug.extensions.customProcessCommits',
"type": 'boolean',
"default_integer": 0,
"description": 'Enable button for performing installed ProcessCommits hooks on arbitrary sets of commits for testing.' },
{ "item": 'email.subjectLine.updatedReview.submittedChanges',
"type": 'string',
"default_string": 'Updated Review: %(summary)s',
"description": 'Python format string for subject line of email sent when someone submits changes to a review.' },
{ "item": 'email.subjectLine.updatedReview.reviewRebased',
"type": 'string',
"default_string": 'Updated Review: %(summary)s',
"description": 'Python format string for subject line of email sent when someone rebases a review branch.' },
{ "item": 'debug.enabled',
"type": 'boolean',
"default_integer": 0,
"description": 'Enable debugging preferences.' },
{ "item": 'debug.profiling.submitChanges',
"type": 'boolean',
"default_integer": 0,
"description": 'Enable profiling of /submitchanges.' },
{ "item": 'dashboard.defaultGroups',
"type": 'string',
"default_string": 'owned,draft,active,watched',
"description": 'Review groups to show on the dashboard by default. Available groups are owned, draft, active, watched, open and closed.' },
{ "item": 'email.subjectLine.extensionOutput',
"type": 'string',
"default_string": 'Extension Output: %(summary)s',
"description": "Python format string for subject line of email sent when an extension's ProcessChanges hook produces output (or fails.)" },
{ "item": 'debug.profiling.pageGeneration',
"type": 'boolean',
"default_integer": 0,
"description": 'Enable profiling of generation of various pages. Results are emitted as a comment at the end of the HTML.' },
{ "item": 'email.ignoreOwnChanges',
"type": 'boolean',
"default_integer": 0,
"description": "Don't send emails about own changes (reviewing, commits added to reviews and rebased reviews.)" },
{ "item": 'commit.diff.highlightIllegalWhitespace',
"type": 'boolean',
"default_integer": 1,
"description": 'Use an angry red color scheme for illegal whitespace (trailing whitespace or tabs in files with "intent-tabs-mode: nil".)' },
{ "item": 'ui.convertIssueToNote',
"type": 'boolean',
"default_integer": 0,
"description": 'Enable "Convert To Note" operation for issues. This operation is considered an inferior alternative to resolving an issue; use of it is not recommended.' },
{ "item": 'debug.profiling.abortChanges',
"type": 'boolean',
"default_integer": 0,
"description": 'Enable profiling of /abortchanges.' },
{ "item": 'ui.asynchronousReviewMarking',
"type": 'boolean',
"default_integer": 0,
"description": 'Mark changes as reviewed (or not reviewed) using an asynchronous XMLHttpRequest.' },
{ "item": 'debug.profiling.databaseQueries',
"type": 'boolean',
"default_integer": 0,
"description": 'Enable profiling of database queries.' },
{ "item": 'review.useMustRevalidate',
"type": 'boolean',
"default_integer": 1,
"description": 'Deliver review front-pages with "Cache-Control: must-revalidate" to prevent history navigation to stale versions.' } ]
def installPreferences(db, quiet):
cursor = db.cursor()
for preference in PREFERENCES:
item = preference["item"]
type = preference["type"]
default_integer = preference.get("default_integer")
default_string = preference.get("default_string")
description = preference["description"]
cursor.execute("SELECT 1 FROM preferences WHERE item=%s", (item,))
if cursor.fetchone():
if not quiet: print "Updating: %s" % item
cursor.execute("UPDATE preferences SET type=%s, default_integer=%s, default_string=%s, description=%s WHERE item=%s", (type, default_integer, default_string, description, item))
else:
if not quiet: print "Adding: %s" % item
cursor.execute("INSERT INTO preferences (item, type, default_integer, default_string, description) VALUES (%s, %s, %s, %s, %s)", (item, type, default_integer, default_string, description))
if __name__ == "__main__":
import sys
import os.path
sys.path.insert(0, os.path.dirname(os.path.dirname(sys.argv[0])))
import dbaccess
db = dbaccess.connect()
installPreferences(db, "--quiet" in sys.argv or "-q" in sys.argv)
db.commit()