##// END OF EJS Templates
Generate docs for help topics
Matt Mackall -
r3797:54fd4d3b default
parent child Browse files
Show More
@@ -1,92 +1,104 b''
1 import sys, textwrap
1 import 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 from mercurial.commands import table, globalopts
4 from mercurial.commands import table, globalopts
5 from mercurial.i18n import gettext as _
5 from mercurial.i18n import gettext as _
6 from mercurial.help import helptable
6
7
7 def get_desc(docstr):
8 def get_desc(docstr):
8 if not docstr:
9 if not docstr:
9 return "", ""
10 return "", ""
10 # sanitize
11 # sanitize
11 docstr = docstr.strip("\n")
12 docstr = docstr.strip("\n")
12 docstr = docstr.rstrip()
13 docstr = docstr.rstrip()
13 shortdesc = docstr.splitlines()[0].strip()
14 shortdesc = docstr.splitlines()[0].strip()
14
15
15 i = docstr.find("\n")
16 i = docstr.find("\n")
16 if i != -1:
17 if i != -1:
17 desc = docstr[i+2:]
18 desc = docstr[i+2:]
18 else:
19 else:
19 desc = " %s" % shortdesc
20 desc = " %s" % shortdesc
20 return (shortdesc, desc)
21 return (shortdesc, desc)
21
22
22 def get_opts(opts):
23 def get_opts(opts):
23 for shortopt, longopt, default, desc in opts:
24 for shortopt, longopt, default, desc in opts:
24 allopts = []
25 allopts = []
25 if shortopt:
26 if shortopt:
26 allopts.append("-%s" % shortopt)
27 allopts.append("-%s" % shortopt)
27 if longopt:
28 if longopt:
28 allopts.append("--%s" % longopt)
29 allopts.append("--%s" % longopt)
29 desc += default and _(" (default: %s)") % default or ""
30 desc += default and _(" (default: %s)") % default or ""
30 yield(", ".join(allopts), desc)
31 yield(", ".join(allopts), desc)
31
32
32 def get_cmd(cmd):
33 def get_cmd(cmd):
33 d = {}
34 d = {}
34 attr = table[cmd]
35 attr = table[cmd]
35 cmds = cmd.lstrip("^").split("|")
36 cmds = cmd.lstrip("^").split("|")
36
37
37 d['synopsis'] = attr[2]
38 d['synopsis'] = attr[2]
38 d['cmd'] = cmds[0]
39 d['cmd'] = cmds[0]
39 d['aliases'] = cmd.split("|")[1:]
40 d['aliases'] = cmd.split("|")[1:]
40 d['desc'] = get_desc(attr[0].__doc__)
41 d['desc'] = get_desc(attr[0].__doc__)
41 d['opts'] = list(get_opts(attr[1]))
42 d['opts'] = list(get_opts(attr[1]))
42 return d
43 return d
43
44
44
45
45 def show_doc(ui):
46 def show_doc(ui):
46 def bold(s, text=""):
47 def bold(s, text=""):
47 ui.write("%s\n%s\n%s\n" % (s, "="*len(s), text))
48 ui.write("%s\n%s\n%s\n" % (s, "="*len(s), text))
48 def underlined(s, text=""):
49 def underlined(s, text=""):
49 ui.write("%s\n%s\n%s\n" % (s, "-"*len(s), text))
50 ui.write("%s\n%s\n%s\n" % (s, "-"*len(s), text))
50
51
51 # print options
52 # print options
52 underlined(_("OPTIONS"))
53 underlined(_("OPTIONS"))
53 for optstr, desc in get_opts(globalopts):
54 for optstr, desc in get_opts(globalopts):
54 ui.write("%s::\n %s\n\n" % (optstr, desc))
55 ui.write("%s::\n %s\n\n" % (optstr, desc))
55
56
56 # print cmds
57 # print cmds
57 underlined(_("COMMANDS"))
58 underlined(_("COMMANDS"))
58 h = {}
59 h = {}
59 for c, attr in table.items():
60 for c, attr in table.items():
60 f = c.split("|")[0]
61 f = c.split("|")[0]
61 f = f.lstrip("^")
62 f = f.lstrip("^")
62 h[f] = c
63 h[f] = c
63 cmds = h.keys()
64 cmds = h.keys()
64 cmds.sort()
65 cmds.sort()
65
66
66 for f in cmds:
67 for f in cmds:
67 if f.startswith("debug"): continue
68 if f.startswith("debug"): continue
68 d = get_cmd(h[f])
69 d = get_cmd(h[f])
69 # synopsis
70 # synopsis
70 ui.write("%s::\n" % d['synopsis'].replace("hg ","", 1))
71 ui.write("%s::\n" % d['synopsis'].replace("hg ","", 1))
71 # description
72 # description
72 ui.write("%s\n\n" % d['desc'][1])
73 ui.write("%s\n\n" % d['desc'][1])
73 # options
74 # options
74 opt_output = list(d['opts'])
75 opt_output = list(d['opts'])
75 if opt_output:
76 if opt_output:
76 opts_len = max([len(line[0]) for line in opt_output])
77 opts_len = max([len(line[0]) for line in opt_output])
77 ui.write(_(" options:\n"))
78 ui.write(_(" options:\n"))
78 for optstr, desc in opt_output:
79 for optstr, desc in opt_output:
79 if desc:
80 if desc:
80 s = "%-*s %s" % (opts_len, optstr, desc)
81 s = "%-*s %s" % (opts_len, optstr, desc)
81 else:
82 else:
82 s = optstr
83 s = optstr
83 s = textwrap.fill(s, initial_indent=4 * " ",
84 s = textwrap.fill(s, initial_indent=4 * " ",
84 subsequent_indent=(6 + opts_len) * " ")
85 subsequent_indent=(6 + opts_len) * " ")
85 ui.write("%s\n" % s)
86 ui.write("%s\n" % s)
86 ui.write("\n")
87 ui.write("\n")
87 # aliases
88 # aliases
88 if d['aliases']:
89 if d['aliases']:
89 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases']))
90 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases']))
90
91
92 # print topics
93 for t in helptable:
94 l = t.split("|")
95 section = l[-1]
96 underlined(_(section).upper())
97 doc = helptable[t]
98 if callable(doc):
99 doc = doc()
100 ui.write(_(doc))
101 ui.write("\n")
102
91 if __name__ == "__main__":
103 if __name__ == "__main__":
92 show_doc(sys.stdout)
104 show_doc(sys.stdout)
@@ -1,275 +1,239 b''
1 HG(1)
1 HG(1)
2 =====
2 =====
3 Matt Mackall <mpm@selenic.com>
3 Matt Mackall <mpm@selenic.com>
4
4
5 NAME
5 NAME
6 ----
6 ----
7 hg - Mercurial source code management system
7 hg - Mercurial source code management system
8
8
9 SYNOPSIS
9 SYNOPSIS
10 --------
10 --------
11 'hg' [global option]... <command> [command/global option]... [argument]...
11 'hg' [global option]... <command> [command/global option]... [argument]...
12
12
13 DESCRIPTION
13 DESCRIPTION
14 -----------
14 -----------
15 The hg(1) command provides a command line interface to the Mercurial system.
15 The hg(1) command provides a command line interface to the Mercurial system.
16
16
17 COMMAND ELEMENTS
17 COMMAND ELEMENTS
18 ----------------
18 ----------------
19
19
20 files ...::
20 files ...::
21 indicates one or more filename or relative path filenames; see
21 indicates one or more filename or relative path filenames; see
22 "FILE NAME PATTERNS" for information on pattern matching
22 "FILE NAME PATTERNS" for information on pattern matching
23
23
24 path::
24 path::
25 indicates a path on the local machine
25 indicates a path on the local machine
26
26
27 revision::
27 revision::
28 indicates a changeset which can be specified as a changeset revision
28 indicates a changeset which can be specified as a changeset revision
29 number, a tag, or a unique substring of the changeset hash value
29 number, a tag, or a unique substring of the changeset hash value
30
30
31 repository path::
31 repository path::
32 either the pathname of a local repository or the URI of a remote
32 either the pathname of a local repository or the URI of a remote
33 repository. There are two available URI protocols, http:// which is
33 repository. There are two available URI protocols, http:// which is
34 fast and the static-http:// protocol which is much slower but does not
34 fast and the static-http:// protocol which is much slower but does not
35 require a special server on the web host.
35 require a special server on the web host.
36
36
37
37
38 include::hg.1.gendoc.txt[]
38 include::hg.1.gendoc.txt[]
39
39
40 FILE NAME PATTERNS
40 FILE NAME PATTERNS
41 ------------------
41 ------------------
42
42
43 Mercurial accepts several notations for identifying one or more
43 Mercurial accepts several notations for identifying one or more
44 files at a time.
44 files at a time.
45
45
46 By default, Mercurial treats filenames as shell-style extended
46 By default, Mercurial treats filenames as shell-style extended
47 glob patterns.
47 glob patterns.
48
48
49 Alternate pattern notations must be specified explicitly.
49 Alternate pattern notations must be specified explicitly.
50
50
51 To use a plain path name without any pattern matching, start a
51 To use a plain path name without any pattern matching, start a
52 name with "path:". These path names must match completely, from
52 name with "path:". These path names must match completely, from
53 the root of the current repository.
53 the root of the current repository.
54
54
55 To use an extended glob, start a name with "glob:". Globs are
55 To use an extended glob, start a name with "glob:". Globs are
56 rooted at the current directory; a glob such as "*.c" will match
56 rooted at the current directory; a glob such as "*.c" will match
57 files ending in ".c" in the current directory only.
57 files ending in ".c" in the current directory only.
58
58
59 The supported glob syntax extensions are "**" to match any string
59 The supported glob syntax extensions are "**" to match any string
60 across path separators, and "{a,b}" to mean "a or b".
60 across path separators, and "{a,b}" to mean "a or b".
61
61
62 To use a Perl/Python regular expression, start a name with "re:".
62 To use a Perl/Python regular expression, start a name with "re:".
63 Regexp pattern matching is anchored at the root of the repository.
63 Regexp pattern matching is anchored at the root of the repository.
64
64
65 Plain examples:
65 Plain examples:
66
66
67 path:foo/bar a name bar in a directory named foo in the root of
67 path:foo/bar a name bar in a directory named foo in the root of
68 the repository
68 the repository
69 path:path:name a file or directory named "path:name"
69 path:path:name a file or directory named "path:name"
70
70
71 Glob examples:
71 Glob examples:
72
72
73 glob:*.c any name ending in ".c" in the current directory
73 glob:*.c any name ending in ".c" in the current directory
74 *.c any name ending in ".c" in the current directory
74 *.c any name ending in ".c" in the current directory
75 **.c any name ending in ".c" in the current directory, or
75 **.c any name ending in ".c" in the current directory, or
76 any subdirectory
76 any subdirectory
77 foo/*.c any name ending in ".c" in the directory foo
77 foo/*.c any name ending in ".c" in the directory foo
78 foo/**.c any name ending in ".c" in the directory foo, or any
78 foo/**.c any name ending in ".c" in the directory foo, or any
79 subdirectory
79 subdirectory
80
80
81 Regexp examples:
81 Regexp examples:
82
82
83 re:.*\.c$ any name ending in ".c", anywhere in the repository
83 re:.*\.c$ any name ending in ".c", anywhere in the repository
84
84
85
85
86 SPECIFYING SINGLE REVISIONS
86 SPECIFYING SINGLE REVISIONS
87 ---------------------------
87 ---------------------------
88
88
89 Mercurial accepts several notations for identifying individual
89 Mercurial accepts several notations for identifying individual
90 revisions.
90 revisions.
91
91
92 A plain integer is treated as a revision number. Negative
92 A plain integer is treated as a revision number. Negative
93 integers are treated as offsets from the tip, with -1 denoting the
93 integers are treated as offsets from the tip, with -1 denoting the
94 tip.
94 tip.
95
95
96 A 40-digit hexadecimal string is treated as a unique revision
96 A 40-digit hexadecimal string is treated as a unique revision
97 identifier.
97 identifier.
98
98
99 A hexadecimal string less than 40 characters long is treated as a
99 A hexadecimal string less than 40 characters long is treated as a
100 unique revision identifier, and referred to as a short-form
100 unique revision identifier, and referred to as a short-form
101 identifier. A short-form identifier is only valid if it is the
101 identifier. A short-form identifier is only valid if it is the
102 prefix of one full-length identifier.
102 prefix of one full-length identifier.
103
103
104 Any other string is treated as a tag name, which is a symbolic
104 Any other string is treated as a tag name, which is a symbolic
105 name associated with a revision identifier. Tag names may not
105 name associated with a revision identifier. Tag names may not
106 contain the ":" character.
106 contain the ":" character.
107
107
108 The reserved name "tip" is a special tag that always identifies
108 The reserved name "tip" is a special tag that always identifies
109 the most recent revision.
109 the most recent revision.
110
110
111 SPECIFYING MULTIPLE REVISIONS
111 SPECIFYING MULTIPLE REVISIONS
112 -----------------------------
112 -----------------------------
113
113
114 When Mercurial accepts more than one revision, they may be
114 When Mercurial accepts more than one revision, they may be
115 specified individually, or provided as a continuous range,
115 specified individually, or provided as a continuous range,
116 separated by the ":" character.
116 separated by the ":" character.
117
117
118 The syntax of range notation is [BEGIN]:[END], where BEGIN and END
118 The syntax of range notation is [BEGIN]:[END], where BEGIN and END
119 are revision identifiers. Both BEGIN and END are optional. If
119 are revision identifiers. Both BEGIN and END are optional. If
120 BEGIN is not specified, it defaults to revision number 0. If END
120 BEGIN is not specified, it defaults to revision number 0. If END
121 is not specified, it defaults to the tip. The range ":" thus
121 is not specified, it defaults to the tip. The range ":" thus
122 means "all revisions".
122 means "all revisions".
123
123
124 If BEGIN is greater than END, revisions are treated in reverse
124 If BEGIN is greater than END, revisions are treated in reverse
125 order.
125 order.
126
126
127 A range acts as a closed interval. This means that a range of 3:5
127 A range acts as a closed interval. This means that a range of 3:5
128 gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2.
128 gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2.
129
129
130 DATE FORMATS
131 ------------
132
133 Some commands (backout, commit, tag) allow the user to specify a date.
134 Possible formats for dates are:
135
136 YYYY-mm-dd \HH:MM[:SS] [(+|-)NNNN]::
137 This is a subset of ISO 8601, allowing just the recommended notations
138 for date and time. The last part represents the timezone; if omitted,
139 local time is assumed. Examples:
140
141 "2005-08-22 03:27 -0700"
142
143 "2006-04-19 21:39:51"
144
145 aaa bbb dd HH:MM:SS YYYY [(+|-)NNNN]::
146 This is the date format used by the C library. Here, aaa stands for
147 abbreviated weekday name and bbb for abbreviated month name. The last
148 part represents the timezone; if omitted, local time is assumed.
149 Examples:
150
151 "Mon Aug 22 03:27:00 2005 -0700"
152
153 "Wed Apr 19 21:39:51 2006"
154
155 unixtime offset::
156 This is the internal representation format for dates. unixtime is
157 the number of seconds since the epoch (1970-01-01 00:00 UTC). offset
158 is the offset of the local timezone, in seconds west of UTC (negative
159 if the timezone is east of UTC).
160 Examples:
161
162 "1124706420 25200" (2005-08-22 03:27:00 -0700)
163
164 "1145475591 -7200" (2006-04-19 21:39:51 +0200)
165
166 ENVIRONMENT VARIABLES
130 ENVIRONMENT VARIABLES
167 ---------------------
131 ---------------------
168
132
169 HGEDITOR::
133 HGEDITOR::
170 This is the name of the editor to use when committing. Defaults to the
134 This is the name of the editor to use when committing. Defaults to the
171 value of EDITOR.
135 value of EDITOR.
172
136
173 (deprecated, use .hgrc)
137 (deprecated, use .hgrc)
174
138
175 HGENCODING::
139 HGENCODING::
176 This overrides the default locale setting detected by Mercurial.
140 This overrides the default locale setting detected by Mercurial.
177 This setting is used to convert data including usernames,
141 This setting is used to convert data including usernames,
178 changeset descriptions, tag names, and branches. This setting can
142 changeset descriptions, tag names, and branches. This setting can
179 be overridden with the --encoding command-line option.
143 be overridden with the --encoding command-line option.
180
144
181 HGENCODINGMODE::
145 HGENCODINGMODE::
182 This sets Mercurial's behavior for handling unknown characters
146 This sets Mercurial's behavior for handling unknown characters
183 while transcoding user inputs. The default is "strict", which
147 while transcoding user inputs. The default is "strict", which
184 causes Mercurial to abort if it can't translate a character. Other
148 causes Mercurial to abort if it can't translate a character. Other
185 settings include "replace", which replaces unknown characters, and
149 settings include "replace", which replaces unknown characters, and
186 "ignore", which drops them. This setting can be overridden with
150 "ignore", which drops them. This setting can be overridden with
187 the --encodingmode command-line option.
151 the --encodingmode command-line option.
188
152
189 HGMERGE::
153 HGMERGE::
190 An executable to use for resolving merge conflicts. The program
154 An executable to use for resolving merge conflicts. The program
191 will be executed with three arguments: local file, remote file,
155 will be executed with three arguments: local file, remote file,
192 ancestor file.
156 ancestor file.
193
157
194 The default program is "hgmerge", which is a shell script provided
158 The default program is "hgmerge", which is a shell script provided
195 by Mercurial with some sensible defaults.
159 by Mercurial with some sensible defaults.
196
160
197 (deprecated, use .hgrc)
161 (deprecated, use .hgrc)
198
162
199 HGRCPATH::
163 HGRCPATH::
200 A list of files or directories to search for hgrc files. Item
164 A list of files or directories to search for hgrc files. Item
201 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
165 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
202 platform default search path is used. If empty, only .hg/hgrc of
166 platform default search path is used. If empty, only .hg/hgrc of
203 current repository is read.
167 current repository is read.
204
168
205 For each element in path, if a directory, all entries in directory
169 For each element in path, if a directory, all entries in directory
206 ending with ".rc" are added to path. Else, element itself is
170 ending with ".rc" are added to path. Else, element itself is
207 added to path.
171 added to path.
208
172
209 HGUSER::
173 HGUSER::
210 This is the string used for the author of a commit.
174 This is the string used for the author of a commit.
211
175
212 (deprecated, use .hgrc)
176 (deprecated, use .hgrc)
213
177
214 EMAIL::
178 EMAIL::
215 If HGUSER is not set, this will be used as the author for a commit.
179 If HGUSER is not set, this will be used as the author for a commit.
216
180
217 LOGNAME::
181 LOGNAME::
218 If neither HGUSER nor EMAIL is set, LOGNAME will be used (with
182 If neither HGUSER nor EMAIL is set, LOGNAME will be used (with
219 '@hostname' appended) as the author value for a commit.
183 '@hostname' appended) as the author value for a commit.
220
184
221 EDITOR::
185 EDITOR::
222 This is the name of the editor used in the hgmerge script. It will be
186 This is the name of the editor used in the hgmerge script. It will be
223 used for commit messages if HGEDITOR isn't set. Defaults to 'vi'.
187 used for commit messages if HGEDITOR isn't set. Defaults to 'vi'.
224
188
225 PYTHONPATH::
189 PYTHONPATH::
226 This is used by Python to find imported modules and may need to be set
190 This is used by Python to find imported modules and may need to be set
227 appropriately if Mercurial is not installed system-wide.
191 appropriately if Mercurial is not installed system-wide.
228
192
229 FILES
193 FILES
230 -----
194 -----
231 .hgignore::
195 .hgignore::
232 This file contains regular expressions (one per line) that describe file
196 This file contains regular expressions (one per line) that describe file
233 names that should be ignored by hg. For details, see hgignore(5).
197 names that should be ignored by hg. For details, see hgignore(5).
234
198
235 .hgtags::
199 .hgtags::
236 This file contains changeset hash values and text tag names (one of each
200 This file contains changeset hash values and text tag names (one of each
237 separated by spaces) that correspond to tagged versions of the repository
201 separated by spaces) that correspond to tagged versions of the repository
238 contents.
202 contents.
239
203
240 /etc/mercurial/hgrc, $HOME/.hgrc, .hg/hgrc::
204 /etc/mercurial/hgrc, $HOME/.hgrc, .hg/hgrc::
241 This file contains defaults and configuration. Values in .hg/hgrc
205 This file contains defaults and configuration. Values in .hg/hgrc
242 override those in $HOME/.hgrc, and these override settings made in the
206 override those in $HOME/.hgrc, and these override settings made in the
243 global /etc/mercurial/hgrc configuration. See hgrc(5) for details of
207 global /etc/mercurial/hgrc configuration. See hgrc(5) for details of
244 the contents and format of these files.
208 the contents and format of these files.
245
209
246 Some commands (e.g. revert) produce backup files ending in .orig, if
210 Some commands (e.g. revert) produce backup files ending in .orig, if
247 the .orig file already exists and is not tracked by Mercurial, it
211 the .orig file already exists and is not tracked by Mercurial, it
248 will be overwritten.
212 will be overwritten.
249
213
250 BUGS
214 BUGS
251 ----
215 ----
252 Probably lots, please post them to the mailing list (See Resources below)
216 Probably lots, please post them to the mailing list (See Resources below)
253 when you find them.
217 when you find them.
254
218
255 SEE ALSO
219 SEE ALSO
256 --------
220 --------
257 hgignore(5), hgrc(5)
221 hgignore(5), hgrc(5)
258
222
259 AUTHOR
223 AUTHOR
260 ------
224 ------
261 Written by Matt Mackall <mpm@selenic.com>
225 Written by Matt Mackall <mpm@selenic.com>
262
226
263 RESOURCES
227 RESOURCES
264 ---------
228 ---------
265 http://selenic.com/mercurial[Main Web Site]
229 http://selenic.com/mercurial[Main Web Site]
266
230
267 http://selenic.com/hg[Source code repository]
231 http://selenic.com/hg[Source code repository]
268
232
269 http://selenic.com/mailman/listinfo/mercurial[Mailing list]
233 http://selenic.com/mailman/listinfo/mercurial[Mailing list]
270
234
271 COPYING
235 COPYING
272 -------
236 -------
273 Copyright \(C) 2005, 2006 Matt Mackall.
237 Copyright \(C) 2005, 2006 Matt Mackall.
274 Free use of this software is granted under the terms of the GNU General
238 Free use of this software is granted under the terms of the GNU General
275 Public License (GPL).
239 Public License (GPL).
General Comments 0
You need to be logged in to leave comments. Login now