equal
deleted
inserted
replaced
1 import os, sys |
1 import os, sys, textwrap |
2 # import from the live mercurial repo |
2 # import from the live mercurial repo |
3 sys.path.insert(0, "..") |
3 sys.path.insert(0, "..") |
4 # fall back to pure modules if required C extensions are not available |
4 # fall back to pure modules if required C extensions are not available |
5 sys.path.append(os.path.join('..', 'mercurial', 'pure')) |
5 sys.path.append(os.path.join('..', 'mercurial', 'pure')) |
6 from mercurial import demandimport; demandimport.enable() |
6 from mercurial import demandimport; demandimport.enable() |
19 |
19 |
20 i = docstr.find("\n") |
20 i = docstr.find("\n") |
21 if i != -1: |
21 if i != -1: |
22 desc = docstr[i + 2:] |
22 desc = docstr[i + 2:] |
23 else: |
23 else: |
24 desc = " %s" % shortdesc |
24 desc = shortdesc |
|
25 |
|
26 desc = textwrap.dedent(desc) |
|
27 |
25 return (shortdesc, desc) |
28 return (shortdesc, desc) |
26 |
29 |
27 def get_opts(opts): |
30 def get_opts(opts): |
28 for opt in opts: |
31 for opt in opts: |
29 if len(opt) == 5: |
32 if len(opt) == 5: |
67 |
70 |
68 def show_doc(ui): |
71 def show_doc(ui): |
69 # print options |
72 # print options |
70 section(ui, _("Options")) |
73 section(ui, _("Options")) |
71 for optstr, desc in get_opts(globalopts): |
74 for optstr, desc in get_opts(globalopts): |
72 ui.write("%s\n %s\n\n" % (optstr, desc)) |
75 ui.write("%s\n%s\n\n" % (optstr, desc)) |
73 |
76 |
74 # print cmds |
77 # print cmds |
75 section(ui, _("Commands")) |
78 section(ui, _("Commands")) |
76 commandprinter(ui, table) |
79 commandprinter(ui, table) |
77 |
80 |
100 continue |
103 continue |
101 d = get_cmd(h[f], cmdtable) |
104 d = get_cmd(h[f], cmdtable) |
102 subsection(ui, d['cmd']) |
105 subsection(ui, d['cmd']) |
103 # synopsis |
106 # synopsis |
104 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1)) |
107 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1)) |
|
108 ui.write("\n") |
105 # description |
109 # description |
106 ui.write("%s\n\n" % d['desc'][1]) |
110 ui.write("%s\n\n" % d['desc'][1]) |
107 # options |
111 # options |
108 opt_output = list(d['opts']) |
112 opt_output = list(d['opts']) |
109 if opt_output: |
113 if opt_output: |
110 opts_len = max([len(line[0]) for line in opt_output]) |
114 opts_len = max([len(line[0]) for line in opt_output]) |
111 ui.write(_(" options:\n\n")) |
115 ui.write(_("options:\n\n")) |
112 for optstr, desc in opt_output: |
116 for optstr, desc in opt_output: |
113 if desc: |
117 if desc: |
114 s = "%-*s %s" % (opts_len, optstr, desc) |
118 s = "%-*s %s" % (opts_len, optstr, desc) |
115 else: |
119 else: |
116 s = optstr |
120 s = optstr |
117 ui.write(" %s\n" % s) |
121 ui.write("%s\n" % s) |
118 ui.write("\n") |
122 ui.write("\n") |
119 # aliases |
123 # aliases |
120 if d['aliases']: |
124 if d['aliases']: |
121 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases'])) |
125 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases'])) |
122 |
126 |