-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathuploadopts2wiki.py
103 lines (75 loc) · 2.96 KB
/
uploadopts2wiki.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
#!/usr/bin/env python
import os
import sys
from optparse import HelpFormatter
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, ROOT)
import upload
class GCWikiHelpFormatter (HelpFormatter):
"""Format help with wiki markup for Google Code."""
def __init__(self,
indent_increment=2,
max_help_position=24,
width=None,
short_first=1):
HelpFormatter.__init__(
self, indent_increment, max_help_position, width, short_first)
self._dl_open = False
def indent(self):
self._pending = 'INDENT'
HelpFormatter.indent(self)
def dedent(self):
self._pending = 'DEDENT'
HelpFormatter.dedent(self)
def format_usage(self, usage):
return "*Usage summary:* `%s`\n" % usage
def format_heading(self, heading):
if self._dl_open:
pre = '\n</dl>\n'
else:
pre = ''
markup = '='*(self.current_indent+2)
self._dl_open = True
return "%s%s %s %s\n<dl>\n" % (pre, markup, heading, markup)
def format_option(self, option):
result = []
opts = self.option_strings[option]
result.append('<dt>`%s`</dt>\n' % opts)
if option.help:
help_text = '<dd>%s</dd>\n' % self.expand_default(option)
result.append(help_text)
return ''.join(result)
def main():
upload.parser.formatter = GCWikiHelpFormatter()
print HEADER
print upload.parser.format_option_help()
print '</dl>' # TODO: Formatter should do this
print FOOTER
print
HEADER = """#summary upload.py usage and options.
<wiki:comment>
THIS PAGE IS AUTOGENERATED. DO NOT EDIT.
To update this page run tools/uploadopts2wiki.py
</wiki:comment>
= upload.py Usage =
[http://codereview.appspot.com/static/upload.py upload.py] is a tool
for uploading diffs from a version control system to the codereview app.
*Usage summary:*
{{{upload.py [options] [-- diff_options]}}}
Diff options are passed to the diff command of the underlying system.
*Supported version control systems:*
* Git
* Mercurial
* Subversion
* Perforce
It is important for Git/Mercurial users to specify a tree/node/branch to diff
against by using the '--rev' option.
"""
FOOTER = """\
==== Running upload.py from perforce GUIs ====
You can right click on a perforce changelist and create a new Rietveld code review by adding a custom tool with the following settings:
Application: python Arguments: /PATH/TO/upload.py -s MY_SERVER --p4_changelist %p --p4_port $p --p4_user $u --p4_client $c Start In: empty. Check "Add to applicable context menus", "Run tool in terminal window" (or system equivalent), and "Ignore P4CONFIG files".
Replace /PATH/TO/ with the location of upload.py, and MY_SERVER with the rietveld code review server. See screenshot [http://alexmccarthy.net/Rietveld%20-%20P4V%20Custom%20Tool%20Settings.png here].
"""
if __name__ == '__main__':
main()