##// END OF EJS Templates
help: distinguish sections when multiple match (issue4802)
timeless@mozdev.org -
r26113:9b70eda7 default
parent child Browse files
Show More
@@ -1,751 +1,763 b''
1 # minirst.py - minimal reStructuredText parser
1 # minirst.py - minimal reStructuredText parser
2 #
2 #
3 # Copyright 2009, 2010 Matt Mackall <mpm@selenic.com> and others
3 # Copyright 2009, 2010 Matt Mackall <mpm@selenic.com> and others
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 """simplified reStructuredText parser.
8 """simplified reStructuredText parser.
9
9
10 This parser knows just enough about reStructuredText to parse the
10 This parser knows just enough about reStructuredText to parse the
11 Mercurial docstrings.
11 Mercurial docstrings.
12
12
13 It cheats in a major way: nested blocks are not really nested. They
13 It cheats in a major way: nested blocks are not really nested. They
14 are just indented blocks that look like they are nested. This relies
14 are just indented blocks that look like they are nested. This relies
15 on the user to keep the right indentation for the blocks.
15 on the user to keep the right indentation for the blocks.
16
16
17 Remember to update http://mercurial.selenic.com/wiki/HelpStyleGuide
17 Remember to update http://mercurial.selenic.com/wiki/HelpStyleGuide
18 when adding support for new constructs.
18 when adding support for new constructs.
19 """
19 """
20
20
21 from __future__ import absolute_import
21 from __future__ import absolute_import
22
22
23 import cgi
23 import cgi
24 import re
24 import re
25
25
26 from .i18n import _
26 from .i18n import _
27 from . import (
27 from . import (
28 encoding,
28 encoding,
29 util,
29 util,
30 )
30 )
31
31
32 def section(s):
32 def section(s):
33 return "%s\n%s\n\n" % (s, "\"" * encoding.colwidth(s))
33 return "%s\n%s\n\n" % (s, "\"" * encoding.colwidth(s))
34
34
35 def subsection(s):
35 def subsection(s):
36 return "%s\n%s\n\n" % (s, '=' * encoding.colwidth(s))
36 return "%s\n%s\n\n" % (s, '=' * encoding.colwidth(s))
37
37
38 def subsubsection(s):
38 def subsubsection(s):
39 return "%s\n%s\n\n" % (s, "-" * encoding.colwidth(s))
39 return "%s\n%s\n\n" % (s, "-" * encoding.colwidth(s))
40
40
41 def subsubsubsection(s):
41 def subsubsubsection(s):
42 return "%s\n%s\n\n" % (s, "." * encoding.colwidth(s))
42 return "%s\n%s\n\n" % (s, "." * encoding.colwidth(s))
43
43
44 def replace(text, substs):
44 def replace(text, substs):
45 '''
45 '''
46 Apply a list of (find, replace) pairs to a text.
46 Apply a list of (find, replace) pairs to a text.
47
47
48 >>> replace("foo bar", [('f', 'F'), ('b', 'B')])
48 >>> replace("foo bar", [('f', 'F'), ('b', 'B')])
49 'Foo Bar'
49 'Foo Bar'
50 >>> encoding.encoding = 'latin1'
50 >>> encoding.encoding = 'latin1'
51 >>> replace('\\x81\\\\', [('\\\\', '/')])
51 >>> replace('\\x81\\\\', [('\\\\', '/')])
52 '\\x81/'
52 '\\x81/'
53 >>> encoding.encoding = 'shiftjis'
53 >>> encoding.encoding = 'shiftjis'
54 >>> replace('\\x81\\\\', [('\\\\', '/')])
54 >>> replace('\\x81\\\\', [('\\\\', '/')])
55 '\\x81\\\\'
55 '\\x81\\\\'
56 '''
56 '''
57
57
58 # some character encodings (cp932 for Japanese, at least) use
58 # some character encodings (cp932 for Japanese, at least) use
59 # ASCII characters other than control/alphabet/digit as a part of
59 # ASCII characters other than control/alphabet/digit as a part of
60 # multi-bytes characters, so direct replacing with such characters
60 # multi-bytes characters, so direct replacing with such characters
61 # on strings in local encoding causes invalid byte sequences.
61 # on strings in local encoding causes invalid byte sequences.
62 utext = text.decode(encoding.encoding)
62 utext = text.decode(encoding.encoding)
63 for f, t in substs:
63 for f, t in substs:
64 utext = utext.replace(f.decode("ascii"), t.decode("ascii"))
64 utext = utext.replace(f.decode("ascii"), t.decode("ascii"))
65 return utext.encode(encoding.encoding)
65 return utext.encode(encoding.encoding)
66
66
67 _blockre = re.compile(r"\n(?:\s*\n)+")
67 _blockre = re.compile(r"\n(?:\s*\n)+")
68
68
69 def findblocks(text):
69 def findblocks(text):
70 """Find continuous blocks of lines in text.
70 """Find continuous blocks of lines in text.
71
71
72 Returns a list of dictionaries representing the blocks. Each block
72 Returns a list of dictionaries representing the blocks. Each block
73 has an 'indent' field and a 'lines' field.
73 has an 'indent' field and a 'lines' field.
74 """
74 """
75 blocks = []
75 blocks = []
76 for b in _blockre.split(text.lstrip('\n').rstrip()):
76 for b in _blockre.split(text.lstrip('\n').rstrip()):
77 lines = b.splitlines()
77 lines = b.splitlines()
78 if lines:
78 if lines:
79 indent = min((len(l) - len(l.lstrip())) for l in lines)
79 indent = min((len(l) - len(l.lstrip())) for l in lines)
80 lines = [l[indent:] for l in lines]
80 lines = [l[indent:] for l in lines]
81 blocks.append({'indent': indent, 'lines': lines})
81 blocks.append({'indent': indent, 'lines': lines})
82 return blocks
82 return blocks
83
83
84 def findliteralblocks(blocks):
84 def findliteralblocks(blocks):
85 """Finds literal blocks and adds a 'type' field to the blocks.
85 """Finds literal blocks and adds a 'type' field to the blocks.
86
86
87 Literal blocks are given the type 'literal', all other blocks are
87 Literal blocks are given the type 'literal', all other blocks are
88 given type the 'paragraph'.
88 given type the 'paragraph'.
89 """
89 """
90 i = 0
90 i = 0
91 while i < len(blocks):
91 while i < len(blocks):
92 # Searching for a block that looks like this:
92 # Searching for a block that looks like this:
93 #
93 #
94 # +------------------------------+
94 # +------------------------------+
95 # | paragraph |
95 # | paragraph |
96 # | (ends with "::") |
96 # | (ends with "::") |
97 # +------------------------------+
97 # +------------------------------+
98 # +---------------------------+
98 # +---------------------------+
99 # | indented literal block |
99 # | indented literal block |
100 # +---------------------------+
100 # +---------------------------+
101 blocks[i]['type'] = 'paragraph'
101 blocks[i]['type'] = 'paragraph'
102 if blocks[i]['lines'][-1].endswith('::') and i + 1 < len(blocks):
102 if blocks[i]['lines'][-1].endswith('::') and i + 1 < len(blocks):
103 indent = blocks[i]['indent']
103 indent = blocks[i]['indent']
104 adjustment = blocks[i + 1]['indent'] - indent
104 adjustment = blocks[i + 1]['indent'] - indent
105
105
106 if blocks[i]['lines'] == ['::']:
106 if blocks[i]['lines'] == ['::']:
107 # Expanded form: remove block
107 # Expanded form: remove block
108 del blocks[i]
108 del blocks[i]
109 i -= 1
109 i -= 1
110 elif blocks[i]['lines'][-1].endswith(' ::'):
110 elif blocks[i]['lines'][-1].endswith(' ::'):
111 # Partially minimized form: remove space and both
111 # Partially minimized form: remove space and both
112 # colons.
112 # colons.
113 blocks[i]['lines'][-1] = blocks[i]['lines'][-1][:-3]
113 blocks[i]['lines'][-1] = blocks[i]['lines'][-1][:-3]
114 elif len(blocks[i]['lines']) == 1 and \
114 elif len(blocks[i]['lines']) == 1 and \
115 blocks[i]['lines'][0].lstrip(' ').startswith('.. ') and \
115 blocks[i]['lines'][0].lstrip(' ').startswith('.. ') and \
116 blocks[i]['lines'][0].find(' ', 3) == -1:
116 blocks[i]['lines'][0].find(' ', 3) == -1:
117 # directive on its own line, not a literal block
117 # directive on its own line, not a literal block
118 i += 1
118 i += 1
119 continue
119 continue
120 else:
120 else:
121 # Fully minimized form: remove just one colon.
121 # Fully minimized form: remove just one colon.
122 blocks[i]['lines'][-1] = blocks[i]['lines'][-1][:-1]
122 blocks[i]['lines'][-1] = blocks[i]['lines'][-1][:-1]
123
123
124 # List items are formatted with a hanging indent. We must
124 # List items are formatted with a hanging indent. We must
125 # correct for this here while we still have the original
125 # correct for this here while we still have the original
126 # information on the indentation of the subsequent literal
126 # information on the indentation of the subsequent literal
127 # blocks available.
127 # blocks available.
128 m = _bulletre.match(blocks[i]['lines'][0])
128 m = _bulletre.match(blocks[i]['lines'][0])
129 if m:
129 if m:
130 indent += m.end()
130 indent += m.end()
131 adjustment -= m.end()
131 adjustment -= m.end()
132
132
133 # Mark the following indented blocks.
133 # Mark the following indented blocks.
134 while i + 1 < len(blocks) and blocks[i + 1]['indent'] > indent:
134 while i + 1 < len(blocks) and blocks[i + 1]['indent'] > indent:
135 blocks[i + 1]['type'] = 'literal'
135 blocks[i + 1]['type'] = 'literal'
136 blocks[i + 1]['indent'] -= adjustment
136 blocks[i + 1]['indent'] -= adjustment
137 i += 1
137 i += 1
138 i += 1
138 i += 1
139 return blocks
139 return blocks
140
140
141 _bulletre = re.compile(r'(-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ')
141 _bulletre = re.compile(r'(-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ')
142 _optionre = re.compile(r'^(-([a-zA-Z0-9]), )?(--[a-z0-9-]+)'
142 _optionre = re.compile(r'^(-([a-zA-Z0-9]), )?(--[a-z0-9-]+)'
143 r'((.*) +)(.*)$')
143 r'((.*) +)(.*)$')
144 _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)')
144 _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)')
145 _definitionre = re.compile(r'[^ ]')
145 _definitionre = re.compile(r'[^ ]')
146 _tablere = re.compile(r'(=+\s+)*=+')
146 _tablere = re.compile(r'(=+\s+)*=+')
147
147
148 def splitparagraphs(blocks):
148 def splitparagraphs(blocks):
149 """Split paragraphs into lists."""
149 """Split paragraphs into lists."""
150 # Tuples with (list type, item regexp, single line items?). Order
150 # Tuples with (list type, item regexp, single line items?). Order
151 # matters: definition lists has the least specific regexp and must
151 # matters: definition lists has the least specific regexp and must
152 # come last.
152 # come last.
153 listtypes = [('bullet', _bulletre, True),
153 listtypes = [('bullet', _bulletre, True),
154 ('option', _optionre, True),
154 ('option', _optionre, True),
155 ('field', _fieldre, True),
155 ('field', _fieldre, True),
156 ('definition', _definitionre, False)]
156 ('definition', _definitionre, False)]
157
157
158 def match(lines, i, itemre, singleline):
158 def match(lines, i, itemre, singleline):
159 """Does itemre match an item at line i?
159 """Does itemre match an item at line i?
160
160
161 A list item can be followed by an indented line or another list
161 A list item can be followed by an indented line or another list
162 item (but only if singleline is True).
162 item (but only if singleline is True).
163 """
163 """
164 line1 = lines[i]
164 line1 = lines[i]
165 line2 = i + 1 < len(lines) and lines[i + 1] or ''
165 line2 = i + 1 < len(lines) and lines[i + 1] or ''
166 if not itemre.match(line1):
166 if not itemre.match(line1):
167 return False
167 return False
168 if singleline:
168 if singleline:
169 return line2 == '' or line2[0] == ' ' or itemre.match(line2)
169 return line2 == '' or line2[0] == ' ' or itemre.match(line2)
170 else:
170 else:
171 return line2.startswith(' ')
171 return line2.startswith(' ')
172
172
173 i = 0
173 i = 0
174 while i < len(blocks):
174 while i < len(blocks):
175 if blocks[i]['type'] == 'paragraph':
175 if blocks[i]['type'] == 'paragraph':
176 lines = blocks[i]['lines']
176 lines = blocks[i]['lines']
177 for type, itemre, singleline in listtypes:
177 for type, itemre, singleline in listtypes:
178 if match(lines, 0, itemre, singleline):
178 if match(lines, 0, itemre, singleline):
179 items = []
179 items = []
180 for j, line in enumerate(lines):
180 for j, line in enumerate(lines):
181 if match(lines, j, itemre, singleline):
181 if match(lines, j, itemre, singleline):
182 items.append({'type': type, 'lines': [],
182 items.append({'type': type, 'lines': [],
183 'indent': blocks[i]['indent']})
183 'indent': blocks[i]['indent']})
184 items[-1]['lines'].append(line)
184 items[-1]['lines'].append(line)
185 blocks[i:i + 1] = items
185 blocks[i:i + 1] = items
186 break
186 break
187 i += 1
187 i += 1
188 return blocks
188 return blocks
189
189
190 _fieldwidth = 14
190 _fieldwidth = 14
191
191
192 def updatefieldlists(blocks):
192 def updatefieldlists(blocks):
193 """Find key for field lists."""
193 """Find key for field lists."""
194 i = 0
194 i = 0
195 while i < len(blocks):
195 while i < len(blocks):
196 if blocks[i]['type'] != 'field':
196 if blocks[i]['type'] != 'field':
197 i += 1
197 i += 1
198 continue
198 continue
199
199
200 j = i
200 j = i
201 while j < len(blocks) and blocks[j]['type'] == 'field':
201 while j < len(blocks) and blocks[j]['type'] == 'field':
202 m = _fieldre.match(blocks[j]['lines'][0])
202 m = _fieldre.match(blocks[j]['lines'][0])
203 key, rest = m.groups()
203 key, rest = m.groups()
204 blocks[j]['lines'][0] = rest
204 blocks[j]['lines'][0] = rest
205 blocks[j]['key'] = key
205 blocks[j]['key'] = key
206 j += 1
206 j += 1
207
207
208 i = j + 1
208 i = j + 1
209
209
210 return blocks
210 return blocks
211
211
212 def updateoptionlists(blocks):
212 def updateoptionlists(blocks):
213 i = 0
213 i = 0
214 while i < len(blocks):
214 while i < len(blocks):
215 if blocks[i]['type'] != 'option':
215 if blocks[i]['type'] != 'option':
216 i += 1
216 i += 1
217 continue
217 continue
218
218
219 optstrwidth = 0
219 optstrwidth = 0
220 j = i
220 j = i
221 while j < len(blocks) and blocks[j]['type'] == 'option':
221 while j < len(blocks) and blocks[j]['type'] == 'option':
222 m = _optionre.match(blocks[j]['lines'][0])
222 m = _optionre.match(blocks[j]['lines'][0])
223
223
224 shortoption = m.group(2)
224 shortoption = m.group(2)
225 group3 = m.group(3)
225 group3 = m.group(3)
226 longoption = group3[2:].strip()
226 longoption = group3[2:].strip()
227 desc = m.group(6).strip()
227 desc = m.group(6).strip()
228 longoptionarg = m.group(5).strip()
228 longoptionarg = m.group(5).strip()
229 blocks[j]['lines'][0] = desc
229 blocks[j]['lines'][0] = desc
230
230
231 noshortop = ''
231 noshortop = ''
232 if not shortoption:
232 if not shortoption:
233 noshortop = ' '
233 noshortop = ' '
234
234
235 opt = "%s%s" % (shortoption and "-%s " % shortoption or '',
235 opt = "%s%s" % (shortoption and "-%s " % shortoption or '',
236 ("%s--%s %s") % (noshortop, longoption,
236 ("%s--%s %s") % (noshortop, longoption,
237 longoptionarg))
237 longoptionarg))
238 opt = opt.rstrip()
238 opt = opt.rstrip()
239 blocks[j]['optstr'] = opt
239 blocks[j]['optstr'] = opt
240 optstrwidth = max(optstrwidth, encoding.colwidth(opt))
240 optstrwidth = max(optstrwidth, encoding.colwidth(opt))
241 j += 1
241 j += 1
242
242
243 for block in blocks[i:j]:
243 for block in blocks[i:j]:
244 block['optstrwidth'] = optstrwidth
244 block['optstrwidth'] = optstrwidth
245 i = j + 1
245 i = j + 1
246 return blocks
246 return blocks
247
247
248 def prunecontainers(blocks, keep):
248 def prunecontainers(blocks, keep):
249 """Prune unwanted containers.
249 """Prune unwanted containers.
250
250
251 The blocks must have a 'type' field, i.e., they should have been
251 The blocks must have a 'type' field, i.e., they should have been
252 run through findliteralblocks first.
252 run through findliteralblocks first.
253 """
253 """
254 pruned = []
254 pruned = []
255 i = 0
255 i = 0
256 while i + 1 < len(blocks):
256 while i + 1 < len(blocks):
257 # Searching for a block that looks like this:
257 # Searching for a block that looks like this:
258 #
258 #
259 # +-------+---------------------------+
259 # +-------+---------------------------+
260 # | ".. container ::" type |
260 # | ".. container ::" type |
261 # +---+ |
261 # +---+ |
262 # | blocks |
262 # | blocks |
263 # +-------------------------------+
263 # +-------------------------------+
264 if (blocks[i]['type'] == 'paragraph' and
264 if (blocks[i]['type'] == 'paragraph' and
265 blocks[i]['lines'][0].startswith('.. container::')):
265 blocks[i]['lines'][0].startswith('.. container::')):
266 indent = blocks[i]['indent']
266 indent = blocks[i]['indent']
267 adjustment = blocks[i + 1]['indent'] - indent
267 adjustment = blocks[i + 1]['indent'] - indent
268 containertype = blocks[i]['lines'][0][15:]
268 containertype = blocks[i]['lines'][0][15:]
269 prune = True
269 prune = True
270 for c in keep:
270 for c in keep:
271 if c in containertype.split('.'):
271 if c in containertype.split('.'):
272 prune = False
272 prune = False
273 if prune:
273 if prune:
274 pruned.append(containertype)
274 pruned.append(containertype)
275
275
276 # Always delete "..container:: type" block
276 # Always delete "..container:: type" block
277 del blocks[i]
277 del blocks[i]
278 j = i
278 j = i
279 i -= 1
279 i -= 1
280 while j < len(blocks) and blocks[j]['indent'] > indent:
280 while j < len(blocks) and blocks[j]['indent'] > indent:
281 if prune:
281 if prune:
282 del blocks[j]
282 del blocks[j]
283 else:
283 else:
284 blocks[j]['indent'] -= adjustment
284 blocks[j]['indent'] -= adjustment
285 j += 1
285 j += 1
286 i += 1
286 i += 1
287 return blocks, pruned
287 return blocks, pruned
288
288
289 _sectionre = re.compile(r"""^([-=`:.'"~^_*+#])\1+$""")
289 _sectionre = re.compile(r"""^([-=`:.'"~^_*+#])\1+$""")
290
290
291 def findtables(blocks):
291 def findtables(blocks):
292 '''Find simple tables
292 '''Find simple tables
293
293
294 Only simple one-line table elements are supported
294 Only simple one-line table elements are supported
295 '''
295 '''
296
296
297 for block in blocks:
297 for block in blocks:
298 # Searching for a block that looks like this:
298 # Searching for a block that looks like this:
299 #
299 #
300 # === ==== ===
300 # === ==== ===
301 # A B C
301 # A B C
302 # === ==== === <- optional
302 # === ==== === <- optional
303 # 1 2 3
303 # 1 2 3
304 # x y z
304 # x y z
305 # === ==== ===
305 # === ==== ===
306 if (block['type'] == 'paragraph' and
306 if (block['type'] == 'paragraph' and
307 len(block['lines']) > 2 and
307 len(block['lines']) > 2 and
308 _tablere.match(block['lines'][0]) and
308 _tablere.match(block['lines'][0]) and
309 block['lines'][0] == block['lines'][-1]):
309 block['lines'][0] == block['lines'][-1]):
310 block['type'] = 'table'
310 block['type'] = 'table'
311 block['header'] = False
311 block['header'] = False
312 div = block['lines'][0]
312 div = block['lines'][0]
313
313
314 # column markers are ASCII so we can calculate column
314 # column markers are ASCII so we can calculate column
315 # position in bytes
315 # position in bytes
316 columns = [x for x in xrange(len(div))
316 columns = [x for x in xrange(len(div))
317 if div[x] == '=' and (x == 0 or div[x - 1] == ' ')]
317 if div[x] == '=' and (x == 0 or div[x - 1] == ' ')]
318 rows = []
318 rows = []
319 for l in block['lines'][1:-1]:
319 for l in block['lines'][1:-1]:
320 if l == div:
320 if l == div:
321 block['header'] = True
321 block['header'] = True
322 continue
322 continue
323 row = []
323 row = []
324 # we measure columns not in bytes or characters but in
324 # we measure columns not in bytes or characters but in
325 # colwidth which makes things tricky
325 # colwidth which makes things tricky
326 pos = columns[0] # leading whitespace is bytes
326 pos = columns[0] # leading whitespace is bytes
327 for n, start in enumerate(columns):
327 for n, start in enumerate(columns):
328 if n + 1 < len(columns):
328 if n + 1 < len(columns):
329 width = columns[n + 1] - start
329 width = columns[n + 1] - start
330 v = encoding.getcols(l, pos, width) # gather columns
330 v = encoding.getcols(l, pos, width) # gather columns
331 pos += len(v) # calculate byte position of end
331 pos += len(v) # calculate byte position of end
332 row.append(v.strip())
332 row.append(v.strip())
333 else:
333 else:
334 row.append(l[pos:].strip())
334 row.append(l[pos:].strip())
335 rows.append(row)
335 rows.append(row)
336
336
337 block['table'] = rows
337 block['table'] = rows
338
338
339 return blocks
339 return blocks
340
340
341 def findsections(blocks):
341 def findsections(blocks):
342 """Finds sections.
342 """Finds sections.
343
343
344 The blocks must have a 'type' field, i.e., they should have been
344 The blocks must have a 'type' field, i.e., they should have been
345 run through findliteralblocks first.
345 run through findliteralblocks first.
346 """
346 """
347 for block in blocks:
347 for block in blocks:
348 # Searching for a block that looks like this:
348 # Searching for a block that looks like this:
349 #
349 #
350 # +------------------------------+
350 # +------------------------------+
351 # | Section title |
351 # | Section title |
352 # | ------------- |
352 # | ------------- |
353 # +------------------------------+
353 # +------------------------------+
354 if (block['type'] == 'paragraph' and
354 if (block['type'] == 'paragraph' and
355 len(block['lines']) == 2 and
355 len(block['lines']) == 2 and
356 encoding.colwidth(block['lines'][0]) == len(block['lines'][1]) and
356 encoding.colwidth(block['lines'][0]) == len(block['lines'][1]) and
357 _sectionre.match(block['lines'][1])):
357 _sectionre.match(block['lines'][1])):
358 block['underline'] = block['lines'][1][0]
358 block['underline'] = block['lines'][1][0]
359 block['type'] = 'section'
359 block['type'] = 'section'
360 del block['lines'][1]
360 del block['lines'][1]
361 return blocks
361 return blocks
362
362
363 def inlineliterals(blocks):
363 def inlineliterals(blocks):
364 substs = [('``', '"')]
364 substs = [('``', '"')]
365 for b in blocks:
365 for b in blocks:
366 if b['type'] in ('paragraph', 'section'):
366 if b['type'] in ('paragraph', 'section'):
367 b['lines'] = [replace(l, substs) for l in b['lines']]
367 b['lines'] = [replace(l, substs) for l in b['lines']]
368 return blocks
368 return blocks
369
369
370 def hgrole(blocks):
370 def hgrole(blocks):
371 substs = [(':hg:`', '"hg '), ('`', '"')]
371 substs = [(':hg:`', '"hg '), ('`', '"')]
372 for b in blocks:
372 for b in blocks:
373 if b['type'] in ('paragraph', 'section'):
373 if b['type'] in ('paragraph', 'section'):
374 # Turn :hg:`command` into "hg command". This also works
374 # Turn :hg:`command` into "hg command". This also works
375 # when there is a line break in the command and relies on
375 # when there is a line break in the command and relies on
376 # the fact that we have no stray back-quotes in the input
376 # the fact that we have no stray back-quotes in the input
377 # (run the blocks through inlineliterals first).
377 # (run the blocks through inlineliterals first).
378 b['lines'] = [replace(l, substs) for l in b['lines']]
378 b['lines'] = [replace(l, substs) for l in b['lines']]
379 return blocks
379 return blocks
380
380
381 def addmargins(blocks):
381 def addmargins(blocks):
382 """Adds empty blocks for vertical spacing.
382 """Adds empty blocks for vertical spacing.
383
383
384 This groups bullets, options, and definitions together with no vertical
384 This groups bullets, options, and definitions together with no vertical
385 space between them, and adds an empty block between all other blocks.
385 space between them, and adds an empty block between all other blocks.
386 """
386 """
387 i = 1
387 i = 1
388 while i < len(blocks):
388 while i < len(blocks):
389 if (blocks[i]['type'] == blocks[i - 1]['type'] and
389 if (blocks[i]['type'] == blocks[i - 1]['type'] and
390 blocks[i]['type'] in ('bullet', 'option', 'field')):
390 blocks[i]['type'] in ('bullet', 'option', 'field')):
391 i += 1
391 i += 1
392 elif not blocks[i - 1]['lines']:
392 elif not blocks[i - 1]['lines']:
393 # no lines in previous block, do not separate
393 # no lines in previous block, do not separate
394 i += 1
394 i += 1
395 else:
395 else:
396 blocks.insert(i, {'lines': [''], 'indent': 0, 'type': 'margin'})
396 blocks.insert(i, {'lines': [''], 'indent': 0, 'type': 'margin'})
397 i += 2
397 i += 2
398 return blocks
398 return blocks
399
399
400 def prunecomments(blocks):
400 def prunecomments(blocks):
401 """Remove comments."""
401 """Remove comments."""
402 i = 0
402 i = 0
403 while i < len(blocks):
403 while i < len(blocks):
404 b = blocks[i]
404 b = blocks[i]
405 if b['type'] == 'paragraph' and (b['lines'][0].startswith('.. ') or
405 if b['type'] == 'paragraph' and (b['lines'][0].startswith('.. ') or
406 b['lines'] == ['..']):
406 b['lines'] == ['..']):
407 del blocks[i]
407 del blocks[i]
408 if i < len(blocks) and blocks[i]['type'] == 'margin':
408 if i < len(blocks) and blocks[i]['type'] == 'margin':
409 del blocks[i]
409 del blocks[i]
410 else:
410 else:
411 i += 1
411 i += 1
412 return blocks
412 return blocks
413
413
414 _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|"
414 _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|"
415 r"error|hint|important|note|tip|warning)::",
415 r"error|hint|important|note|tip|warning)::",
416 flags=re.IGNORECASE)
416 flags=re.IGNORECASE)
417
417
418 def findadmonitions(blocks):
418 def findadmonitions(blocks):
419 """
419 """
420 Makes the type of the block an admonition block if
420 Makes the type of the block an admonition block if
421 the first line is an admonition directive
421 the first line is an admonition directive
422 """
422 """
423 i = 0
423 i = 0
424 while i < len(blocks):
424 while i < len(blocks):
425 m = _admonitionre.match(blocks[i]['lines'][0])
425 m = _admonitionre.match(blocks[i]['lines'][0])
426 if m:
426 if m:
427 blocks[i]['type'] = 'admonition'
427 blocks[i]['type'] = 'admonition'
428 admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower()
428 admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower()
429
429
430 firstline = blocks[i]['lines'][0][m.end() + 1:]
430 firstline = blocks[i]['lines'][0][m.end() + 1:]
431 if firstline:
431 if firstline:
432 blocks[i]['lines'].insert(1, ' ' + firstline)
432 blocks[i]['lines'].insert(1, ' ' + firstline)
433
433
434 blocks[i]['admonitiontitle'] = admonitiontitle
434 blocks[i]['admonitiontitle'] = admonitiontitle
435 del blocks[i]['lines'][0]
435 del blocks[i]['lines'][0]
436 i = i + 1
436 i = i + 1
437 return blocks
437 return blocks
438
438
439 _admonitiontitles = {'attention': _('Attention:'),
439 _admonitiontitles = {'attention': _('Attention:'),
440 'caution': _('Caution:'),
440 'caution': _('Caution:'),
441 'danger': _('!Danger!') ,
441 'danger': _('!Danger!') ,
442 'error': _('Error:'),
442 'error': _('Error:'),
443 'hint': _('Hint:'),
443 'hint': _('Hint:'),
444 'important': _('Important:'),
444 'important': _('Important:'),
445 'note': _('Note:'),
445 'note': _('Note:'),
446 'tip': _('Tip:'),
446 'tip': _('Tip:'),
447 'warning': _('Warning!')}
447 'warning': _('Warning!')}
448
448
449 def formatoption(block, width):
449 def formatoption(block, width):
450 desc = ' '.join(map(str.strip, block['lines']))
450 desc = ' '.join(map(str.strip, block['lines']))
451 colwidth = encoding.colwidth(block['optstr'])
451 colwidth = encoding.colwidth(block['optstr'])
452 usablewidth = width - 1
452 usablewidth = width - 1
453 hanging = block['optstrwidth']
453 hanging = block['optstrwidth']
454 initindent = '%s%s ' % (block['optstr'], ' ' * ((hanging - colwidth)))
454 initindent = '%s%s ' % (block['optstr'], ' ' * ((hanging - colwidth)))
455 hangindent = ' ' * (encoding.colwidth(initindent) + 1)
455 hangindent = ' ' * (encoding.colwidth(initindent) + 1)
456 return ' %s\n' % (util.wrap(desc, usablewidth,
456 return ' %s\n' % (util.wrap(desc, usablewidth,
457 initindent=initindent,
457 initindent=initindent,
458 hangindent=hangindent))
458 hangindent=hangindent))
459
459
460 def formatblock(block, width):
460 def formatblock(block, width):
461 """Format a block according to width."""
461 """Format a block according to width."""
462 if width <= 0:
462 if width <= 0:
463 width = 78
463 width = 78
464 indent = ' ' * block['indent']
464 indent = ' ' * block['indent']
465 if block['type'] == 'admonition':
465 if block['type'] == 'admonition':
466 admonition = _admonitiontitles[block['admonitiontitle']]
466 admonition = _admonitiontitles[block['admonitiontitle']]
467 if not block['lines']:
467 if not block['lines']:
468 return indent + admonition + '\n'
468 return indent + admonition + '\n'
469 hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip())
469 hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip())
470
470
471 defindent = indent + hang * ' '
471 defindent = indent + hang * ' '
472 text = ' '.join(map(str.strip, block['lines']))
472 text = ' '.join(map(str.strip, block['lines']))
473 return '%s\n%s\n' % (indent + admonition,
473 return '%s\n%s\n' % (indent + admonition,
474 util.wrap(text, width=width,
474 util.wrap(text, width=width,
475 initindent=defindent,
475 initindent=defindent,
476 hangindent=defindent))
476 hangindent=defindent))
477 if block['type'] == 'margin':
477 if block['type'] == 'margin':
478 return '\n'
478 return '\n'
479 if block['type'] == 'literal':
479 if block['type'] == 'literal':
480 indent += ' '
480 indent += ' '
481 return indent + ('\n' + indent).join(block['lines']) + '\n'
481 return indent + ('\n' + indent).join(block['lines']) + '\n'
482 if block['type'] == 'section':
482 if block['type'] == 'section':
483 underline = encoding.colwidth(block['lines'][0]) * block['underline']
483 underline = encoding.colwidth(block['lines'][0]) * block['underline']
484 return "%s%s\n%s%s\n" % (indent, block['lines'][0],indent, underline)
484 return "%s%s\n%s%s\n" % (indent, block['lines'][0],indent, underline)
485 if block['type'] == 'table':
485 if block['type'] == 'table':
486 table = block['table']
486 table = block['table']
487 # compute column widths
487 # compute column widths
488 widths = [max([encoding.colwidth(e) for e in c]) for c in zip(*table)]
488 widths = [max([encoding.colwidth(e) for e in c]) for c in zip(*table)]
489 text = ''
489 text = ''
490 span = sum(widths) + len(widths) - 1
490 span = sum(widths) + len(widths) - 1
491 indent = ' ' * block['indent']
491 indent = ' ' * block['indent']
492 hang = ' ' * (len(indent) + span - widths[-1])
492 hang = ' ' * (len(indent) + span - widths[-1])
493
493
494 for row in table:
494 for row in table:
495 l = []
495 l = []
496 for w, v in zip(widths, row):
496 for w, v in zip(widths, row):
497 pad = ' ' * (w - encoding.colwidth(v))
497 pad = ' ' * (w - encoding.colwidth(v))
498 l.append(v + pad)
498 l.append(v + pad)
499 l = ' '.join(l)
499 l = ' '.join(l)
500 l = util.wrap(l, width=width, initindent=indent, hangindent=hang)
500 l = util.wrap(l, width=width, initindent=indent, hangindent=hang)
501 if not text and block['header']:
501 if not text and block['header']:
502 text = l + '\n' + indent + '-' * (min(width, span)) + '\n'
502 text = l + '\n' + indent + '-' * (min(width, span)) + '\n'
503 else:
503 else:
504 text += l + "\n"
504 text += l + "\n"
505 return text
505 return text
506 if block['type'] == 'definition':
506 if block['type'] == 'definition':
507 term = indent + block['lines'][0]
507 term = indent + block['lines'][0]
508 hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip())
508 hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip())
509 defindent = indent + hang * ' '
509 defindent = indent + hang * ' '
510 text = ' '.join(map(str.strip, block['lines'][1:]))
510 text = ' '.join(map(str.strip, block['lines'][1:]))
511 return '%s\n%s\n' % (term, util.wrap(text, width=width,
511 return '%s\n%s\n' % (term, util.wrap(text, width=width,
512 initindent=defindent,
512 initindent=defindent,
513 hangindent=defindent))
513 hangindent=defindent))
514 subindent = indent
514 subindent = indent
515 if block['type'] == 'bullet':
515 if block['type'] == 'bullet':
516 if block['lines'][0].startswith('| '):
516 if block['lines'][0].startswith('| '):
517 # Remove bullet for line blocks and add no extra
517 # Remove bullet for line blocks and add no extra
518 # indention.
518 # indention.
519 block['lines'][0] = block['lines'][0][2:]
519 block['lines'][0] = block['lines'][0][2:]
520 else:
520 else:
521 m = _bulletre.match(block['lines'][0])
521 m = _bulletre.match(block['lines'][0])
522 subindent = indent + m.end() * ' '
522 subindent = indent + m.end() * ' '
523 elif block['type'] == 'field':
523 elif block['type'] == 'field':
524 key = block['key']
524 key = block['key']
525 subindent = indent + _fieldwidth * ' '
525 subindent = indent + _fieldwidth * ' '
526 if len(key) + 2 > _fieldwidth:
526 if len(key) + 2 > _fieldwidth:
527 # key too large, use full line width
527 # key too large, use full line width
528 key = key.ljust(width)
528 key = key.ljust(width)
529 else:
529 else:
530 # key fits within field width
530 # key fits within field width
531 key = key.ljust(_fieldwidth)
531 key = key.ljust(_fieldwidth)
532 block['lines'][0] = key + block['lines'][0]
532 block['lines'][0] = key + block['lines'][0]
533 elif block['type'] == 'option':
533 elif block['type'] == 'option':
534 return formatoption(block, width)
534 return formatoption(block, width)
535
535
536 text = ' '.join(map(str.strip, block['lines']))
536 text = ' '.join(map(str.strip, block['lines']))
537 return util.wrap(text, width=width,
537 return util.wrap(text, width=width,
538 initindent=indent,
538 initindent=indent,
539 hangindent=subindent) + '\n'
539 hangindent=subindent) + '\n'
540
540
541 def formathtml(blocks):
541 def formathtml(blocks):
542 """Format RST blocks as HTML"""
542 """Format RST blocks as HTML"""
543
543
544 out = []
544 out = []
545 headernest = ''
545 headernest = ''
546 listnest = []
546 listnest = []
547
547
548 def escape(s):
548 def escape(s):
549 return cgi.escape(s, True)
549 return cgi.escape(s, True)
550
550
551 def openlist(start, level):
551 def openlist(start, level):
552 if not listnest or listnest[-1][0] != start:
552 if not listnest or listnest[-1][0] != start:
553 listnest.append((start, level))
553 listnest.append((start, level))
554 out.append('<%s>\n' % start)
554 out.append('<%s>\n' % start)
555
555
556 blocks = [b for b in blocks if b['type'] != 'margin']
556 blocks = [b for b in blocks if b['type'] != 'margin']
557
557
558 for pos, b in enumerate(blocks):
558 for pos, b in enumerate(blocks):
559 btype = b['type']
559 btype = b['type']
560 level = b['indent']
560 level = b['indent']
561 lines = b['lines']
561 lines = b['lines']
562
562
563 if btype == 'admonition':
563 if btype == 'admonition':
564 admonition = escape(_admonitiontitles[b['admonitiontitle']])
564 admonition = escape(_admonitiontitles[b['admonitiontitle']])
565 text = escape(' '.join(map(str.strip, lines)))
565 text = escape(' '.join(map(str.strip, lines)))
566 out.append('<p>\n<b>%s</b> %s\n</p>\n' % (admonition, text))
566 out.append('<p>\n<b>%s</b> %s\n</p>\n' % (admonition, text))
567 elif btype == 'paragraph':
567 elif btype == 'paragraph':
568 out.append('<p>\n%s\n</p>\n' % escape('\n'.join(lines)))
568 out.append('<p>\n%s\n</p>\n' % escape('\n'.join(lines)))
569 elif btype == 'margin':
569 elif btype == 'margin':
570 pass
570 pass
571 elif btype == 'literal':
571 elif btype == 'literal':
572 out.append('<pre>\n%s\n</pre>\n' % escape('\n'.join(lines)))
572 out.append('<pre>\n%s\n</pre>\n' % escape('\n'.join(lines)))
573 elif btype == 'section':
573 elif btype == 'section':
574 i = b['underline']
574 i = b['underline']
575 if i not in headernest:
575 if i not in headernest:
576 headernest += i
576 headernest += i
577 level = headernest.index(i) + 1
577 level = headernest.index(i) + 1
578 out.append('<h%d>%s</h%d>\n' % (level, escape(lines[0]), level))
578 out.append('<h%d>%s</h%d>\n' % (level, escape(lines[0]), level))
579 elif btype == 'table':
579 elif btype == 'table':
580 table = b['table']
580 table = b['table']
581 out.append('<table>\n')
581 out.append('<table>\n')
582 for row in table:
582 for row in table:
583 out.append('<tr>')
583 out.append('<tr>')
584 for v in row:
584 for v in row:
585 out.append('<td>')
585 out.append('<td>')
586 out.append(escape(v))
586 out.append(escape(v))
587 out.append('</td>')
587 out.append('</td>')
588 out.append('\n')
588 out.append('\n')
589 out.pop()
589 out.pop()
590 out.append('</tr>\n')
590 out.append('</tr>\n')
591 out.append('</table>\n')
591 out.append('</table>\n')
592 elif btype == 'definition':
592 elif btype == 'definition':
593 openlist('dl', level)
593 openlist('dl', level)
594 term = escape(lines[0])
594 term = escape(lines[0])
595 text = escape(' '.join(map(str.strip, lines[1:])))
595 text = escape(' '.join(map(str.strip, lines[1:])))
596 out.append(' <dt>%s\n <dd>%s\n' % (term, text))
596 out.append(' <dt>%s\n <dd>%s\n' % (term, text))
597 elif btype == 'bullet':
597 elif btype == 'bullet':
598 bullet, head = lines[0].split(' ', 1)
598 bullet, head = lines[0].split(' ', 1)
599 if bullet == '-':
599 if bullet == '-':
600 openlist('ul', level)
600 openlist('ul', level)
601 else:
601 else:
602 openlist('ol', level)
602 openlist('ol', level)
603 out.append(' <li> %s\n' % escape(' '.join([head] + lines[1:])))
603 out.append(' <li> %s\n' % escape(' '.join([head] + lines[1:])))
604 elif btype == 'field':
604 elif btype == 'field':
605 openlist('dl', level)
605 openlist('dl', level)
606 key = escape(b['key'])
606 key = escape(b['key'])
607 text = escape(' '.join(map(str.strip, lines)))
607 text = escape(' '.join(map(str.strip, lines)))
608 out.append(' <dt>%s\n <dd>%s\n' % (key, text))
608 out.append(' <dt>%s\n <dd>%s\n' % (key, text))
609 elif btype == 'option':
609 elif btype == 'option':
610 openlist('dl', level)
610 openlist('dl', level)
611 opt = escape(b['optstr'])
611 opt = escape(b['optstr'])
612 desc = escape(' '.join(map(str.strip, lines)))
612 desc = escape(' '.join(map(str.strip, lines)))
613 out.append(' <dt>%s\n <dd>%s\n' % (opt, desc))
613 out.append(' <dt>%s\n <dd>%s\n' % (opt, desc))
614
614
615 # close lists if indent level of next block is lower
615 # close lists if indent level of next block is lower
616 if listnest:
616 if listnest:
617 start, level = listnest[-1]
617 start, level = listnest[-1]
618 if pos == len(blocks) - 1:
618 if pos == len(blocks) - 1:
619 out.append('</%s>\n' % start)
619 out.append('</%s>\n' % start)
620 listnest.pop()
620 listnest.pop()
621 else:
621 else:
622 nb = blocks[pos + 1]
622 nb = blocks[pos + 1]
623 ni = nb['indent']
623 ni = nb['indent']
624 if (ni < level or
624 if (ni < level or
625 (ni == level and
625 (ni == level and
626 nb['type'] not in 'definition bullet field option')):
626 nb['type'] not in 'definition bullet field option')):
627 out.append('</%s>\n' % start)
627 out.append('</%s>\n' % start)
628 listnest.pop()
628 listnest.pop()
629
629
630 return ''.join(out)
630 return ''.join(out)
631
631
632 def parse(text, indent=0, keep=None):
632 def parse(text, indent=0, keep=None):
633 """Parse text into a list of blocks"""
633 """Parse text into a list of blocks"""
634 pruned = []
634 pruned = []
635 blocks = findblocks(text)
635 blocks = findblocks(text)
636 for b in blocks:
636 for b in blocks:
637 b['indent'] += indent
637 b['indent'] += indent
638 blocks = findliteralblocks(blocks)
638 blocks = findliteralblocks(blocks)
639 blocks = findtables(blocks)
639 blocks = findtables(blocks)
640 blocks, pruned = prunecontainers(blocks, keep or [])
640 blocks, pruned = prunecontainers(blocks, keep or [])
641 blocks = findsections(blocks)
641 blocks = findsections(blocks)
642 blocks = inlineliterals(blocks)
642 blocks = inlineliterals(blocks)
643 blocks = hgrole(blocks)
643 blocks = hgrole(blocks)
644 blocks = splitparagraphs(blocks)
644 blocks = splitparagraphs(blocks)
645 blocks = updatefieldlists(blocks)
645 blocks = updatefieldlists(blocks)
646 blocks = updateoptionlists(blocks)
646 blocks = updateoptionlists(blocks)
647 blocks = findadmonitions(blocks)
647 blocks = findadmonitions(blocks)
648 blocks = addmargins(blocks)
648 blocks = addmargins(blocks)
649 blocks = prunecomments(blocks)
649 blocks = prunecomments(blocks)
650 return blocks, pruned
650 return blocks, pruned
651
651
652 def formatblocks(blocks, width):
652 def formatblocks(blocks, width):
653 text = ''.join(formatblock(b, width) for b in blocks)
653 text = ''.join(formatblock(b, width) for b in blocks)
654 return text
654 return text
655
655
656 def format(text, width=80, indent=0, keep=None, style='plain', section=None):
656 def format(text, width=80, indent=0, keep=None, style='plain', section=None):
657 """Parse and format the text according to width."""
657 """Parse and format the text according to width."""
658 blocks, pruned = parse(text, indent, keep or [])
658 blocks, pruned = parse(text, indent, keep or [])
659 parents = []
659 if section:
660 if section:
660 sections = getsections(blocks)
661 sections = getsections(blocks)
661 blocks = []
662 blocks = []
662 i = 0
663 i = 0
663 while i < len(sections):
664 while i < len(sections):
664 name, nest, b = sections[i]
665 name, nest, b = sections[i]
666 del parents[nest:]
667 parents.append(name)
665 if name == section:
668 if name == section:
669 b[0]['path'] = parents[3:]
666 blocks.extend(b)
670 blocks.extend(b)
667
671
668 ## Also show all subnested sections
672 ## Also show all subnested sections
669 while i + 1 < len(sections) and sections[i + 1][1] > nest:
673 while i + 1 < len(sections) and sections[i + 1][1] > nest:
670 i += 1
674 i += 1
671 blocks.extend(sections[i][2])
675 blocks.extend(sections[i][2])
672 i += 1
676 i += 1
673
677
674 if style == 'html':
678 if style == 'html':
675 text = formathtml(blocks)
679 text = formathtml(blocks)
676 else:
680 else:
681 if len([b for b in blocks if b['type'] == 'definition']) > 1:
682 i = 0
683 while i < len(blocks):
684 if blocks[i]['type'] == 'definition':
685 if 'path' in blocks[i]:
686 blocks[i]['lines'][0] = '"%s"' % '.'.join(
687 blocks[i]['path'])
688 i += 1
677 text = ''.join(formatblock(b, width) for b in blocks)
689 text = ''.join(formatblock(b, width) for b in blocks)
678 if keep is None:
690 if keep is None:
679 return text
691 return text
680 else:
692 else:
681 return text, pruned
693 return text, pruned
682
694
683 def getsections(blocks):
695 def getsections(blocks):
684 '''return a list of (section name, nesting level, blocks) tuples'''
696 '''return a list of (section name, nesting level, blocks) tuples'''
685 nest = ""
697 nest = ""
686 level = 0
698 level = 0
687 secs = []
699 secs = []
688
700
689 def getname(b):
701 def getname(b):
690 if b['type'] == 'field':
702 if b['type'] == 'field':
691 x = b['key']
703 x = b['key']
692 else:
704 else:
693 x = b['lines'][0]
705 x = b['lines'][0]
694 x = x.lower().strip('"')
706 x = x.lower().strip('"')
695 if '(' in x:
707 if '(' in x:
696 x = x.split('(')[0]
708 x = x.split('(')[0]
697 return x
709 return x
698
710
699 for b in blocks:
711 for b in blocks:
700 if b['type'] == 'section':
712 if b['type'] == 'section':
701 i = b['underline']
713 i = b['underline']
702 if i not in nest:
714 if i not in nest:
703 nest += i
715 nest += i
704 level = nest.index(i) + 1
716 level = nest.index(i) + 1
705 nest = nest[:level]
717 nest = nest[:level]
706 secs.append((getname(b), level, [b]))
718 secs.append((getname(b), level, [b]))
707 elif b['type'] in ('definition', 'field'):
719 elif b['type'] in ('definition', 'field'):
708 i = ' '
720 i = ' '
709 if i not in nest:
721 if i not in nest:
710 nest += i
722 nest += i
711 level = nest.index(i) + 1
723 level = nest.index(i) + 1
712 nest = nest[:level]
724 nest = nest[:level]
713 secs.append((getname(b), level, [b]))
725 secs.append((getname(b), level, [b]))
714 else:
726 else:
715 if not secs:
727 if not secs:
716 # add an initial empty section
728 # add an initial empty section
717 secs = [('', 0, [])]
729 secs = [('', 0, [])]
718 secs[-1][2].append(b)
730 secs[-1][2].append(b)
719 return secs
731 return secs
720
732
721 def decorateblocks(blocks, width):
733 def decorateblocks(blocks, width):
722 '''generate a list of (section name, line text) pairs for search'''
734 '''generate a list of (section name, line text) pairs for search'''
723 lines = []
735 lines = []
724 for s in getsections(blocks):
736 for s in getsections(blocks):
725 section = s[0]
737 section = s[0]
726 text = formatblocks(s[2], width)
738 text = formatblocks(s[2], width)
727 lines.append([(section, l) for l in text.splitlines(True)])
739 lines.append([(section, l) for l in text.splitlines(True)])
728 return lines
740 return lines
729
741
730 def maketable(data, indent=0, header=False):
742 def maketable(data, indent=0, header=False):
731 '''Generate an RST table for the given table data as a list of lines'''
743 '''Generate an RST table for the given table data as a list of lines'''
732
744
733 widths = [max(encoding.colwidth(e) for e in c) for c in zip(*data)]
745 widths = [max(encoding.colwidth(e) for e in c) for c in zip(*data)]
734 indent = ' ' * indent
746 indent = ' ' * indent
735 div = indent + ' '.join('=' * w for w in widths) + '\n'
747 div = indent + ' '.join('=' * w for w in widths) + '\n'
736
748
737 out = [div]
749 out = [div]
738 for row in data:
750 for row in data:
739 l = []
751 l = []
740 for w, v in zip(widths, row):
752 for w, v in zip(widths, row):
741 if '\n' in v:
753 if '\n' in v:
742 # only remove line breaks and indentation, long lines are
754 # only remove line breaks and indentation, long lines are
743 # handled by the next tool
755 # handled by the next tool
744 v = ' '.join(e.lstrip() for e in v.split('\n'))
756 v = ' '.join(e.lstrip() for e in v.split('\n'))
745 pad = ' ' * (w - encoding.colwidth(v))
757 pad = ' ' * (w - encoding.colwidth(v))
746 l.append(v + pad)
758 l.append(v + pad)
747 out.append(indent + ' '.join(l) + "\n")
759 out.append(indent + ' '.join(l) + "\n")
748 if header and len(data) > 1:
760 if header and len(data) > 1:
749 out.insert(2, div)
761 out.insert(2, div)
750 out.append(div)
762 out.append(div)
751 return out
763 return out
@@ -1,2275 +1,2285 b''
1 Short help:
1 Short help:
2
2
3 $ hg
3 $ hg
4 Mercurial Distributed SCM
4 Mercurial Distributed SCM
5
5
6 basic commands:
6 basic commands:
7
7
8 add add the specified files on the next commit
8 add add the specified files on the next commit
9 annotate show changeset information by line for each file
9 annotate show changeset information by line for each file
10 clone make a copy of an existing repository
10 clone make a copy of an existing repository
11 commit commit the specified files or all outstanding changes
11 commit commit the specified files or all outstanding changes
12 diff diff repository (or selected files)
12 diff diff repository (or selected files)
13 export dump the header and diffs for one or more changesets
13 export dump the header and diffs for one or more changesets
14 forget forget the specified files on the next commit
14 forget forget the specified files on the next commit
15 init create a new repository in the given directory
15 init create a new repository in the given directory
16 log show revision history of entire repository or files
16 log show revision history of entire repository or files
17 merge merge another revision into working directory
17 merge merge another revision into working directory
18 pull pull changes from the specified source
18 pull pull changes from the specified source
19 push push changes to the specified destination
19 push push changes to the specified destination
20 remove remove the specified files on the next commit
20 remove remove the specified files on the next commit
21 serve start stand-alone webserver
21 serve start stand-alone webserver
22 status show changed files in the working directory
22 status show changed files in the working directory
23 summary summarize working directory state
23 summary summarize working directory state
24 update update working directory (or switch revisions)
24 update update working directory (or switch revisions)
25
25
26 (use "hg help" for the full list of commands or "hg -v" for details)
26 (use "hg help" for the full list of commands or "hg -v" for details)
27
27
28 $ hg -q
28 $ hg -q
29 add add the specified files on the next commit
29 add add the specified files on the next commit
30 annotate show changeset information by line for each file
30 annotate show changeset information by line for each file
31 clone make a copy of an existing repository
31 clone make a copy of an existing repository
32 commit commit the specified files or all outstanding changes
32 commit commit the specified files or all outstanding changes
33 diff diff repository (or selected files)
33 diff diff repository (or selected files)
34 export dump the header and diffs for one or more changesets
34 export dump the header and diffs for one or more changesets
35 forget forget the specified files on the next commit
35 forget forget the specified files on the next commit
36 init create a new repository in the given directory
36 init create a new repository in the given directory
37 log show revision history of entire repository or files
37 log show revision history of entire repository or files
38 merge merge another revision into working directory
38 merge merge another revision into working directory
39 pull pull changes from the specified source
39 pull pull changes from the specified source
40 push push changes to the specified destination
40 push push changes to the specified destination
41 remove remove the specified files on the next commit
41 remove remove the specified files on the next commit
42 serve start stand-alone webserver
42 serve start stand-alone webserver
43 status show changed files in the working directory
43 status show changed files in the working directory
44 summary summarize working directory state
44 summary summarize working directory state
45 update update working directory (or switch revisions)
45 update update working directory (or switch revisions)
46
46
47 $ hg help
47 $ hg help
48 Mercurial Distributed SCM
48 Mercurial Distributed SCM
49
49
50 list of commands:
50 list of commands:
51
51
52 add add the specified files on the next commit
52 add add the specified files on the next commit
53 addremove add all new files, delete all missing files
53 addremove add all new files, delete all missing files
54 annotate show changeset information by line for each file
54 annotate show changeset information by line for each file
55 archive create an unversioned archive of a repository revision
55 archive create an unversioned archive of a repository revision
56 backout reverse effect of earlier changeset
56 backout reverse effect of earlier changeset
57 bisect subdivision search of changesets
57 bisect subdivision search of changesets
58 bookmarks create a new bookmark or list existing bookmarks
58 bookmarks create a new bookmark or list existing bookmarks
59 branch set or show the current branch name
59 branch set or show the current branch name
60 branches list repository named branches
60 branches list repository named branches
61 bundle create a changegroup file
61 bundle create a changegroup file
62 cat output the current or given revision of files
62 cat output the current or given revision of files
63 clone make a copy of an existing repository
63 clone make a copy of an existing repository
64 commit commit the specified files or all outstanding changes
64 commit commit the specified files or all outstanding changes
65 config show combined config settings from all hgrc files
65 config show combined config settings from all hgrc files
66 copy mark files as copied for the next commit
66 copy mark files as copied for the next commit
67 diff diff repository (or selected files)
67 diff diff repository (or selected files)
68 export dump the header and diffs for one or more changesets
68 export dump the header and diffs for one or more changesets
69 files list tracked files
69 files list tracked files
70 forget forget the specified files on the next commit
70 forget forget the specified files on the next commit
71 graft copy changes from other branches onto the current branch
71 graft copy changes from other branches onto the current branch
72 grep search for a pattern in specified files and revisions
72 grep search for a pattern in specified files and revisions
73 heads show branch heads
73 heads show branch heads
74 help show help for a given topic or a help overview
74 help show help for a given topic or a help overview
75 identify identify the working directory or specified revision
75 identify identify the working directory or specified revision
76 import import an ordered set of patches
76 import import an ordered set of patches
77 incoming show new changesets found in source
77 incoming show new changesets found in source
78 init create a new repository in the given directory
78 init create a new repository in the given directory
79 log show revision history of entire repository or files
79 log show revision history of entire repository or files
80 manifest output the current or given revision of the project manifest
80 manifest output the current or given revision of the project manifest
81 merge merge another revision into working directory
81 merge merge another revision into working directory
82 outgoing show changesets not found in the destination
82 outgoing show changesets not found in the destination
83 paths show aliases for remote repositories
83 paths show aliases for remote repositories
84 phase set or show the current phase name
84 phase set or show the current phase name
85 pull pull changes from the specified source
85 pull pull changes from the specified source
86 push push changes to the specified destination
86 push push changes to the specified destination
87 recover roll back an interrupted transaction
87 recover roll back an interrupted transaction
88 remove remove the specified files on the next commit
88 remove remove the specified files on the next commit
89 rename rename files; equivalent of copy + remove
89 rename rename files; equivalent of copy + remove
90 resolve redo merges or set/view the merge status of files
90 resolve redo merges or set/view the merge status of files
91 revert restore files to their checkout state
91 revert restore files to their checkout state
92 root print the root (top) of the current working directory
92 root print the root (top) of the current working directory
93 serve start stand-alone webserver
93 serve start stand-alone webserver
94 status show changed files in the working directory
94 status show changed files in the working directory
95 summary summarize working directory state
95 summary summarize working directory state
96 tag add one or more tags for the current or given revision
96 tag add one or more tags for the current or given revision
97 tags list repository tags
97 tags list repository tags
98 unbundle apply one or more changegroup files
98 unbundle apply one or more changegroup files
99 update update working directory (or switch revisions)
99 update update working directory (or switch revisions)
100 verify verify the integrity of the repository
100 verify verify the integrity of the repository
101 version output version and copyright information
101 version output version and copyright information
102
102
103 additional help topics:
103 additional help topics:
104
104
105 config Configuration Files
105 config Configuration Files
106 dates Date Formats
106 dates Date Formats
107 diffs Diff Formats
107 diffs Diff Formats
108 environment Environment Variables
108 environment Environment Variables
109 extensions Using Additional Features
109 extensions Using Additional Features
110 filesets Specifying File Sets
110 filesets Specifying File Sets
111 glossary Glossary
111 glossary Glossary
112 hgignore Syntax for Mercurial Ignore Files
112 hgignore Syntax for Mercurial Ignore Files
113 hgweb Configuring hgweb
113 hgweb Configuring hgweb
114 merge-tools Merge Tools
114 merge-tools Merge Tools
115 multirevs Specifying Multiple Revisions
115 multirevs Specifying Multiple Revisions
116 patterns File Name Patterns
116 patterns File Name Patterns
117 phases Working with Phases
117 phases Working with Phases
118 revisions Specifying Single Revisions
118 revisions Specifying Single Revisions
119 revsets Specifying Revision Sets
119 revsets Specifying Revision Sets
120 scripting Using Mercurial from scripts and automation
120 scripting Using Mercurial from scripts and automation
121 subrepos Subrepositories
121 subrepos Subrepositories
122 templating Template Usage
122 templating Template Usage
123 urls URL Paths
123 urls URL Paths
124
124
125 (use "hg help -v" to show built-in aliases and global options)
125 (use "hg help -v" to show built-in aliases and global options)
126
126
127 $ hg -q help
127 $ hg -q help
128 add add the specified files on the next commit
128 add add the specified files on the next commit
129 addremove add all new files, delete all missing files
129 addremove add all new files, delete all missing files
130 annotate show changeset information by line for each file
130 annotate show changeset information by line for each file
131 archive create an unversioned archive of a repository revision
131 archive create an unversioned archive of a repository revision
132 backout reverse effect of earlier changeset
132 backout reverse effect of earlier changeset
133 bisect subdivision search of changesets
133 bisect subdivision search of changesets
134 bookmarks create a new bookmark or list existing bookmarks
134 bookmarks create a new bookmark or list existing bookmarks
135 branch set or show the current branch name
135 branch set or show the current branch name
136 branches list repository named branches
136 branches list repository named branches
137 bundle create a changegroup file
137 bundle create a changegroup file
138 cat output the current or given revision of files
138 cat output the current or given revision of files
139 clone make a copy of an existing repository
139 clone make a copy of an existing repository
140 commit commit the specified files or all outstanding changes
140 commit commit the specified files or all outstanding changes
141 config show combined config settings from all hgrc files
141 config show combined config settings from all hgrc files
142 copy mark files as copied for the next commit
142 copy mark files as copied for the next commit
143 diff diff repository (or selected files)
143 diff diff repository (or selected files)
144 export dump the header and diffs for one or more changesets
144 export dump the header and diffs for one or more changesets
145 files list tracked files
145 files list tracked files
146 forget forget the specified files on the next commit
146 forget forget the specified files on the next commit
147 graft copy changes from other branches onto the current branch
147 graft copy changes from other branches onto the current branch
148 grep search for a pattern in specified files and revisions
148 grep search for a pattern in specified files and revisions
149 heads show branch heads
149 heads show branch heads
150 help show help for a given topic or a help overview
150 help show help for a given topic or a help overview
151 identify identify the working directory or specified revision
151 identify identify the working directory or specified revision
152 import import an ordered set of patches
152 import import an ordered set of patches
153 incoming show new changesets found in source
153 incoming show new changesets found in source
154 init create a new repository in the given directory
154 init create a new repository in the given directory
155 log show revision history of entire repository or files
155 log show revision history of entire repository or files
156 manifest output the current or given revision of the project manifest
156 manifest output the current or given revision of the project manifest
157 merge merge another revision into working directory
157 merge merge another revision into working directory
158 outgoing show changesets not found in the destination
158 outgoing show changesets not found in the destination
159 paths show aliases for remote repositories
159 paths show aliases for remote repositories
160 phase set or show the current phase name
160 phase set or show the current phase name
161 pull pull changes from the specified source
161 pull pull changes from the specified source
162 push push changes to the specified destination
162 push push changes to the specified destination
163 recover roll back an interrupted transaction
163 recover roll back an interrupted transaction
164 remove remove the specified files on the next commit
164 remove remove the specified files on the next commit
165 rename rename files; equivalent of copy + remove
165 rename rename files; equivalent of copy + remove
166 resolve redo merges or set/view the merge status of files
166 resolve redo merges or set/view the merge status of files
167 revert restore files to their checkout state
167 revert restore files to their checkout state
168 root print the root (top) of the current working directory
168 root print the root (top) of the current working directory
169 serve start stand-alone webserver
169 serve start stand-alone webserver
170 status show changed files in the working directory
170 status show changed files in the working directory
171 summary summarize working directory state
171 summary summarize working directory state
172 tag add one or more tags for the current or given revision
172 tag add one or more tags for the current or given revision
173 tags list repository tags
173 tags list repository tags
174 unbundle apply one or more changegroup files
174 unbundle apply one or more changegroup files
175 update update working directory (or switch revisions)
175 update update working directory (or switch revisions)
176 verify verify the integrity of the repository
176 verify verify the integrity of the repository
177 version output version and copyright information
177 version output version and copyright information
178
178
179 additional help topics:
179 additional help topics:
180
180
181 config Configuration Files
181 config Configuration Files
182 dates Date Formats
182 dates Date Formats
183 diffs Diff Formats
183 diffs Diff Formats
184 environment Environment Variables
184 environment Environment Variables
185 extensions Using Additional Features
185 extensions Using Additional Features
186 filesets Specifying File Sets
186 filesets Specifying File Sets
187 glossary Glossary
187 glossary Glossary
188 hgignore Syntax for Mercurial Ignore Files
188 hgignore Syntax for Mercurial Ignore Files
189 hgweb Configuring hgweb
189 hgweb Configuring hgweb
190 merge-tools Merge Tools
190 merge-tools Merge Tools
191 multirevs Specifying Multiple Revisions
191 multirevs Specifying Multiple Revisions
192 patterns File Name Patterns
192 patterns File Name Patterns
193 phases Working with Phases
193 phases Working with Phases
194 revisions Specifying Single Revisions
194 revisions Specifying Single Revisions
195 revsets Specifying Revision Sets
195 revsets Specifying Revision Sets
196 scripting Using Mercurial from scripts and automation
196 scripting Using Mercurial from scripts and automation
197 subrepos Subrepositories
197 subrepos Subrepositories
198 templating Template Usage
198 templating Template Usage
199 urls URL Paths
199 urls URL Paths
200
200
201 Test extension help:
201 Test extension help:
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
203 Using Additional Features
203 Using Additional Features
204 """""""""""""""""""""""""
204 """""""""""""""""""""""""
205
205
206 Mercurial has the ability to add new features through the use of
206 Mercurial has the ability to add new features through the use of
207 extensions. Extensions may add new commands, add options to existing
207 extensions. Extensions may add new commands, add options to existing
208 commands, change the default behavior of commands, or implement hooks.
208 commands, change the default behavior of commands, or implement hooks.
209
209
210 To enable the "foo" extension, either shipped with Mercurial or in the
210 To enable the "foo" extension, either shipped with Mercurial or in the
211 Python search path, create an entry for it in your configuration file,
211 Python search path, create an entry for it in your configuration file,
212 like this:
212 like this:
213
213
214 [extensions]
214 [extensions]
215 foo =
215 foo =
216
216
217 You may also specify the full path to an extension:
217 You may also specify the full path to an extension:
218
218
219 [extensions]
219 [extensions]
220 myfeature = ~/.hgext/myfeature.py
220 myfeature = ~/.hgext/myfeature.py
221
221
222 See "hg help config" for more information on configuration files.
222 See "hg help config" for more information on configuration files.
223
223
224 Extensions are not loaded by default for a variety of reasons: they can
224 Extensions are not loaded by default for a variety of reasons: they can
225 increase startup overhead; they may be meant for advanced usage only; they
225 increase startup overhead; they may be meant for advanced usage only; they
226 may provide potentially dangerous abilities (such as letting you destroy
226 may provide potentially dangerous abilities (such as letting you destroy
227 or modify history); they might not be ready for prime time; or they may
227 or modify history); they might not be ready for prime time; or they may
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
229 to activate extensions as needed.
229 to activate extensions as needed.
230
230
231 To explicitly disable an extension enabled in a configuration file of
231 To explicitly disable an extension enabled in a configuration file of
232 broader scope, prepend its path with !:
232 broader scope, prepend its path with !:
233
233
234 [extensions]
234 [extensions]
235 # disabling extension bar residing in /path/to/extension/bar.py
235 # disabling extension bar residing in /path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
237 # ditto, but no path was supplied for extension baz
237 # ditto, but no path was supplied for extension baz
238 baz = !
238 baz = !
239
239
240 enabled extensions:
240 enabled extensions:
241
241
242 children command to display child changesets (DEPRECATED)
242 children command to display child changesets (DEPRECATED)
243 rebase command to move sets of revisions to a different ancestor
243 rebase command to move sets of revisions to a different ancestor
244
244
245 disabled extensions:
245 disabled extensions:
246
246
247 acl hooks for controlling repository access
247 acl hooks for controlling repository access
248 blackbox log repository events to a blackbox for debugging
248 blackbox log repository events to a blackbox for debugging
249 bugzilla hooks for integrating with the Bugzilla bug tracker
249 bugzilla hooks for integrating with the Bugzilla bug tracker
250 censor erase file content at a given revision
250 censor erase file content at a given revision
251 churn command to display statistics about repository history
251 churn command to display statistics about repository history
252 color colorize output from some commands
252 color colorize output from some commands
253 convert import revisions from foreign VCS repositories into
253 convert import revisions from foreign VCS repositories into
254 Mercurial
254 Mercurial
255 eol automatically manage newlines in repository files
255 eol automatically manage newlines in repository files
256 extdiff command to allow external programs to compare revisions
256 extdiff command to allow external programs to compare revisions
257 factotum http authentication with factotum
257 factotum http authentication with factotum
258 gpg commands to sign and verify changesets
258 gpg commands to sign and verify changesets
259 hgcia hooks for integrating with the CIA.vc notification service
259 hgcia hooks for integrating with the CIA.vc notification service
260 hgk browse the repository in a graphical way
260 hgk browse the repository in a graphical way
261 highlight syntax highlighting for hgweb (requires Pygments)
261 highlight syntax highlighting for hgweb (requires Pygments)
262 histedit interactive history editing
262 histedit interactive history editing
263 keyword expand keywords in tracked files
263 keyword expand keywords in tracked files
264 largefiles track large binary files
264 largefiles track large binary files
265 mq manage a stack of patches
265 mq manage a stack of patches
266 notify hooks for sending email push notifications
266 notify hooks for sending email push notifications
267 pager browse command output with an external pager
267 pager browse command output with an external pager
268 patchbomb command to send changesets as (a series of) patch emails
268 patchbomb command to send changesets as (a series of) patch emails
269 purge command to delete untracked files from the working
269 purge command to delete untracked files from the working
270 directory
270 directory
271 record commands to interactively select changes for
271 record commands to interactively select changes for
272 commit/qrefresh
272 commit/qrefresh
273 relink recreates hardlinks between repository clones
273 relink recreates hardlinks between repository clones
274 schemes extend schemes with shortcuts to repository swarms
274 schemes extend schemes with shortcuts to repository swarms
275 share share a common history between several working directories
275 share share a common history between several working directories
276 shelve save and restore changes to the working directory
276 shelve save and restore changes to the working directory
277 strip strip changesets and their descendants from history
277 strip strip changesets and their descendants from history
278 transplant command to transplant changesets from another branch
278 transplant command to transplant changesets from another branch
279 win32mbcs allow the use of MBCS paths with problematic encodings
279 win32mbcs allow the use of MBCS paths with problematic encodings
280 zeroconf discover and advertise repositories on the local network
280 zeroconf discover and advertise repositories on the local network
281 Test short command list with verbose option
281 Test short command list with verbose option
282
282
283 $ hg -v help shortlist
283 $ hg -v help shortlist
284 Mercurial Distributed SCM
284 Mercurial Distributed SCM
285
285
286 basic commands:
286 basic commands:
287
287
288 add add the specified files on the next commit
288 add add the specified files on the next commit
289 annotate, blame
289 annotate, blame
290 show changeset information by line for each file
290 show changeset information by line for each file
291 clone make a copy of an existing repository
291 clone make a copy of an existing repository
292 commit, ci commit the specified files or all outstanding changes
292 commit, ci commit the specified files or all outstanding changes
293 diff diff repository (or selected files)
293 diff diff repository (or selected files)
294 export dump the header and diffs for one or more changesets
294 export dump the header and diffs for one or more changesets
295 forget forget the specified files on the next commit
295 forget forget the specified files on the next commit
296 init create a new repository in the given directory
296 init create a new repository in the given directory
297 log, history show revision history of entire repository or files
297 log, history show revision history of entire repository or files
298 merge merge another revision into working directory
298 merge merge another revision into working directory
299 pull pull changes from the specified source
299 pull pull changes from the specified source
300 push push changes to the specified destination
300 push push changes to the specified destination
301 remove, rm remove the specified files on the next commit
301 remove, rm remove the specified files on the next commit
302 serve start stand-alone webserver
302 serve start stand-alone webserver
303 status, st show changed files in the working directory
303 status, st show changed files in the working directory
304 summary, sum summarize working directory state
304 summary, sum summarize working directory state
305 update, up, checkout, co
305 update, up, checkout, co
306 update working directory (or switch revisions)
306 update working directory (or switch revisions)
307
307
308 global options ([+] can be repeated):
308 global options ([+] can be repeated):
309
309
310 -R --repository REPO repository root directory or name of overlay bundle
310 -R --repository REPO repository root directory or name of overlay bundle
311 file
311 file
312 --cwd DIR change working directory
312 --cwd DIR change working directory
313 -y --noninteractive do not prompt, automatically pick the first choice for
313 -y --noninteractive do not prompt, automatically pick the first choice for
314 all prompts
314 all prompts
315 -q --quiet suppress output
315 -q --quiet suppress output
316 -v --verbose enable additional output
316 -v --verbose enable additional output
317 --config CONFIG [+] set/override config option (use 'section.name=value')
317 --config CONFIG [+] set/override config option (use 'section.name=value')
318 --debug enable debugging output
318 --debug enable debugging output
319 --debugger start debugger
319 --debugger start debugger
320 --encoding ENCODE set the charset encoding (default: ascii)
320 --encoding ENCODE set the charset encoding (default: ascii)
321 --encodingmode MODE set the charset encoding mode (default: strict)
321 --encodingmode MODE set the charset encoding mode (default: strict)
322 --traceback always print a traceback on exception
322 --traceback always print a traceback on exception
323 --time time how long the command takes
323 --time time how long the command takes
324 --profile print command execution profile
324 --profile print command execution profile
325 --version output version information and exit
325 --version output version information and exit
326 -h --help display help and exit
326 -h --help display help and exit
327 --hidden consider hidden changesets
327 --hidden consider hidden changesets
328
328
329 (use "hg help" for the full list of commands)
329 (use "hg help" for the full list of commands)
330
330
331 $ hg add -h
331 $ hg add -h
332 hg add [OPTION]... [FILE]...
332 hg add [OPTION]... [FILE]...
333
333
334 add the specified files on the next commit
334 add the specified files on the next commit
335
335
336 Schedule files to be version controlled and added to the repository.
336 Schedule files to be version controlled and added to the repository.
337
337
338 The files will be added to the repository at the next commit. To undo an
338 The files will be added to the repository at the next commit. To undo an
339 add before that, see "hg forget".
339 add before that, see "hg forget".
340
340
341 If no names are given, add all files to the repository.
341 If no names are given, add all files to the repository.
342
342
343 Returns 0 if all files are successfully added.
343 Returns 0 if all files are successfully added.
344
344
345 options ([+] can be repeated):
345 options ([+] can be repeated):
346
346
347 -I --include PATTERN [+] include names matching the given patterns
347 -I --include PATTERN [+] include names matching the given patterns
348 -X --exclude PATTERN [+] exclude names matching the given patterns
348 -X --exclude PATTERN [+] exclude names matching the given patterns
349 -S --subrepos recurse into subrepositories
349 -S --subrepos recurse into subrepositories
350 -n --dry-run do not perform actions, just print output
350 -n --dry-run do not perform actions, just print output
351
351
352 (some details hidden, use --verbose to show complete help)
352 (some details hidden, use --verbose to show complete help)
353
353
354 Verbose help for add
354 Verbose help for add
355
355
356 $ hg add -hv
356 $ hg add -hv
357 hg add [OPTION]... [FILE]...
357 hg add [OPTION]... [FILE]...
358
358
359 add the specified files on the next commit
359 add the specified files on the next commit
360
360
361 Schedule files to be version controlled and added to the repository.
361 Schedule files to be version controlled and added to the repository.
362
362
363 The files will be added to the repository at the next commit. To undo an
363 The files will be added to the repository at the next commit. To undo an
364 add before that, see "hg forget".
364 add before that, see "hg forget".
365
365
366 If no names are given, add all files to the repository.
366 If no names are given, add all files to the repository.
367
367
368 An example showing how new (unknown) files are added automatically by "hg
368 An example showing how new (unknown) files are added automatically by "hg
369 add":
369 add":
370
370
371 $ ls
371 $ ls
372 foo.c
372 foo.c
373 $ hg status
373 $ hg status
374 ? foo.c
374 ? foo.c
375 $ hg add
375 $ hg add
376 adding foo.c
376 adding foo.c
377 $ hg status
377 $ hg status
378 A foo.c
378 A foo.c
379
379
380 Returns 0 if all files are successfully added.
380 Returns 0 if all files are successfully added.
381
381
382 options ([+] can be repeated):
382 options ([+] can be repeated):
383
383
384 -I --include PATTERN [+] include names matching the given patterns
384 -I --include PATTERN [+] include names matching the given patterns
385 -X --exclude PATTERN [+] exclude names matching the given patterns
385 -X --exclude PATTERN [+] exclude names matching the given patterns
386 -S --subrepos recurse into subrepositories
386 -S --subrepos recurse into subrepositories
387 -n --dry-run do not perform actions, just print output
387 -n --dry-run do not perform actions, just print output
388
388
389 global options ([+] can be repeated):
389 global options ([+] can be repeated):
390
390
391 -R --repository REPO repository root directory or name of overlay bundle
391 -R --repository REPO repository root directory or name of overlay bundle
392 file
392 file
393 --cwd DIR change working directory
393 --cwd DIR change working directory
394 -y --noninteractive do not prompt, automatically pick the first choice for
394 -y --noninteractive do not prompt, automatically pick the first choice for
395 all prompts
395 all prompts
396 -q --quiet suppress output
396 -q --quiet suppress output
397 -v --verbose enable additional output
397 -v --verbose enable additional output
398 --config CONFIG [+] set/override config option (use 'section.name=value')
398 --config CONFIG [+] set/override config option (use 'section.name=value')
399 --debug enable debugging output
399 --debug enable debugging output
400 --debugger start debugger
400 --debugger start debugger
401 --encoding ENCODE set the charset encoding (default: ascii)
401 --encoding ENCODE set the charset encoding (default: ascii)
402 --encodingmode MODE set the charset encoding mode (default: strict)
402 --encodingmode MODE set the charset encoding mode (default: strict)
403 --traceback always print a traceback on exception
403 --traceback always print a traceback on exception
404 --time time how long the command takes
404 --time time how long the command takes
405 --profile print command execution profile
405 --profile print command execution profile
406 --version output version information and exit
406 --version output version information and exit
407 -h --help display help and exit
407 -h --help display help and exit
408 --hidden consider hidden changesets
408 --hidden consider hidden changesets
409
409
410 Test help option with version option
410 Test help option with version option
411
411
412 $ hg add -h --version
412 $ hg add -h --version
413 Mercurial Distributed SCM (version *) (glob)
413 Mercurial Distributed SCM (version *) (glob)
414 (see http://mercurial.selenic.com for more information)
414 (see http://mercurial.selenic.com for more information)
415
415
416 Copyright (C) 2005-2015 Matt Mackall and others
416 Copyright (C) 2005-2015 Matt Mackall and others
417 This is free software; see the source for copying conditions. There is NO
417 This is free software; see the source for copying conditions. There is NO
418 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
418 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
419
419
420 $ hg add --skjdfks
420 $ hg add --skjdfks
421 hg add: option --skjdfks not recognized
421 hg add: option --skjdfks not recognized
422 hg add [OPTION]... [FILE]...
422 hg add [OPTION]... [FILE]...
423
423
424 add the specified files on the next commit
424 add the specified files on the next commit
425
425
426 options ([+] can be repeated):
426 options ([+] can be repeated):
427
427
428 -I --include PATTERN [+] include names matching the given patterns
428 -I --include PATTERN [+] include names matching the given patterns
429 -X --exclude PATTERN [+] exclude names matching the given patterns
429 -X --exclude PATTERN [+] exclude names matching the given patterns
430 -S --subrepos recurse into subrepositories
430 -S --subrepos recurse into subrepositories
431 -n --dry-run do not perform actions, just print output
431 -n --dry-run do not perform actions, just print output
432
432
433 (use "hg add -h" to show more help)
433 (use "hg add -h" to show more help)
434 [255]
434 [255]
435
435
436 Test ambiguous command help
436 Test ambiguous command help
437
437
438 $ hg help ad
438 $ hg help ad
439 list of commands:
439 list of commands:
440
440
441 add add the specified files on the next commit
441 add add the specified files on the next commit
442 addremove add all new files, delete all missing files
442 addremove add all new files, delete all missing files
443
443
444 (use "hg help -v ad" to show built-in aliases and global options)
444 (use "hg help -v ad" to show built-in aliases and global options)
445
445
446 Test command without options
446 Test command without options
447
447
448 $ hg help verify
448 $ hg help verify
449 hg verify
449 hg verify
450
450
451 verify the integrity of the repository
451 verify the integrity of the repository
452
452
453 Verify the integrity of the current repository.
453 Verify the integrity of the current repository.
454
454
455 This will perform an extensive check of the repository's integrity,
455 This will perform an extensive check of the repository's integrity,
456 validating the hashes and checksums of each entry in the changelog,
456 validating the hashes and checksums of each entry in the changelog,
457 manifest, and tracked files, as well as the integrity of their crosslinks
457 manifest, and tracked files, as well as the integrity of their crosslinks
458 and indices.
458 and indices.
459
459
460 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
460 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
461 information about recovery from corruption of the repository.
461 information about recovery from corruption of the repository.
462
462
463 Returns 0 on success, 1 if errors are encountered.
463 Returns 0 on success, 1 if errors are encountered.
464
464
465 (some details hidden, use --verbose to show complete help)
465 (some details hidden, use --verbose to show complete help)
466
466
467 $ hg help diff
467 $ hg help diff
468 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
468 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
469
469
470 diff repository (or selected files)
470 diff repository (or selected files)
471
471
472 Show differences between revisions for the specified files.
472 Show differences between revisions for the specified files.
473
473
474 Differences between files are shown using the unified diff format.
474 Differences between files are shown using the unified diff format.
475
475
476 Note:
476 Note:
477 diff may generate unexpected results for merges, as it will default to
477 diff may generate unexpected results for merges, as it will default to
478 comparing against the working directory's first parent changeset if no
478 comparing against the working directory's first parent changeset if no
479 revisions are specified.
479 revisions are specified.
480
480
481 When two revision arguments are given, then changes are shown between
481 When two revision arguments are given, then changes are shown between
482 those revisions. If only one revision is specified then that revision is
482 those revisions. If only one revision is specified then that revision is
483 compared to the working directory, and, when no revisions are specified,
483 compared to the working directory, and, when no revisions are specified,
484 the working directory files are compared to its parent.
484 the working directory files are compared to its parent.
485
485
486 Alternatively you can specify -c/--change with a revision to see the
486 Alternatively you can specify -c/--change with a revision to see the
487 changes in that changeset relative to its first parent.
487 changes in that changeset relative to its first parent.
488
488
489 Without the -a/--text option, diff will avoid generating diffs of files it
489 Without the -a/--text option, diff will avoid generating diffs of files it
490 detects as binary. With -a, diff will generate a diff anyway, probably
490 detects as binary. With -a, diff will generate a diff anyway, probably
491 with undesirable results.
491 with undesirable results.
492
492
493 Use the -g/--git option to generate diffs in the git extended diff format.
493 Use the -g/--git option to generate diffs in the git extended diff format.
494 For more information, read "hg help diffs".
494 For more information, read "hg help diffs".
495
495
496 Returns 0 on success.
496 Returns 0 on success.
497
497
498 options ([+] can be repeated):
498 options ([+] can be repeated):
499
499
500 -r --rev REV [+] revision
500 -r --rev REV [+] revision
501 -c --change REV change made by revision
501 -c --change REV change made by revision
502 -a --text treat all files as text
502 -a --text treat all files as text
503 -g --git use git extended diff format
503 -g --git use git extended diff format
504 --nodates omit dates from diff headers
504 --nodates omit dates from diff headers
505 --noprefix omit a/ and b/ prefixes from filenames
505 --noprefix omit a/ and b/ prefixes from filenames
506 -p --show-function show which function each change is in
506 -p --show-function show which function each change is in
507 --reverse produce a diff that undoes the changes
507 --reverse produce a diff that undoes the changes
508 -w --ignore-all-space ignore white space when comparing lines
508 -w --ignore-all-space ignore white space when comparing lines
509 -b --ignore-space-change ignore changes in the amount of white space
509 -b --ignore-space-change ignore changes in the amount of white space
510 -B --ignore-blank-lines ignore changes whose lines are all blank
510 -B --ignore-blank-lines ignore changes whose lines are all blank
511 -U --unified NUM number of lines of context to show
511 -U --unified NUM number of lines of context to show
512 --stat output diffstat-style summary of changes
512 --stat output diffstat-style summary of changes
513 --root DIR produce diffs relative to subdirectory
513 --root DIR produce diffs relative to subdirectory
514 -I --include PATTERN [+] include names matching the given patterns
514 -I --include PATTERN [+] include names matching the given patterns
515 -X --exclude PATTERN [+] exclude names matching the given patterns
515 -X --exclude PATTERN [+] exclude names matching the given patterns
516 -S --subrepos recurse into subrepositories
516 -S --subrepos recurse into subrepositories
517
517
518 (some details hidden, use --verbose to show complete help)
518 (some details hidden, use --verbose to show complete help)
519
519
520 $ hg help status
520 $ hg help status
521 hg status [OPTION]... [FILE]...
521 hg status [OPTION]... [FILE]...
522
522
523 aliases: st
523 aliases: st
524
524
525 show changed files in the working directory
525 show changed files in the working directory
526
526
527 Show status of files in the repository. If names are given, only files
527 Show status of files in the repository. If names are given, only files
528 that match are shown. Files that are clean or ignored or the source of a
528 that match are shown. Files that are clean or ignored or the source of a
529 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
529 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
530 -C/--copies or -A/--all are given. Unless options described with "show
530 -C/--copies or -A/--all are given. Unless options described with "show
531 only ..." are given, the options -mardu are used.
531 only ..." are given, the options -mardu are used.
532
532
533 Option -q/--quiet hides untracked (unknown and ignored) files unless
533 Option -q/--quiet hides untracked (unknown and ignored) files unless
534 explicitly requested with -u/--unknown or -i/--ignored.
534 explicitly requested with -u/--unknown or -i/--ignored.
535
535
536 Note:
536 Note:
537 status may appear to disagree with diff if permissions have changed or
537 status may appear to disagree with diff if permissions have changed or
538 a merge has occurred. The standard diff format does not report
538 a merge has occurred. The standard diff format does not report
539 permission changes and diff only reports changes relative to one merge
539 permission changes and diff only reports changes relative to one merge
540 parent.
540 parent.
541
541
542 If one revision is given, it is used as the base revision. If two
542 If one revision is given, it is used as the base revision. If two
543 revisions are given, the differences between them are shown. The --change
543 revisions are given, the differences between them are shown. The --change
544 option can also be used as a shortcut to list the changed files of a
544 option can also be used as a shortcut to list the changed files of a
545 revision from its first parent.
545 revision from its first parent.
546
546
547 The codes used to show the status of files are:
547 The codes used to show the status of files are:
548
548
549 M = modified
549 M = modified
550 A = added
550 A = added
551 R = removed
551 R = removed
552 C = clean
552 C = clean
553 ! = missing (deleted by non-hg command, but still tracked)
553 ! = missing (deleted by non-hg command, but still tracked)
554 ? = not tracked
554 ? = not tracked
555 I = ignored
555 I = ignored
556 = origin of the previous file (with --copies)
556 = origin of the previous file (with --copies)
557
557
558 Returns 0 on success.
558 Returns 0 on success.
559
559
560 options ([+] can be repeated):
560 options ([+] can be repeated):
561
561
562 -A --all show status of all files
562 -A --all show status of all files
563 -m --modified show only modified files
563 -m --modified show only modified files
564 -a --added show only added files
564 -a --added show only added files
565 -r --removed show only removed files
565 -r --removed show only removed files
566 -d --deleted show only deleted (but tracked) files
566 -d --deleted show only deleted (but tracked) files
567 -c --clean show only files without changes
567 -c --clean show only files without changes
568 -u --unknown show only unknown (not tracked) files
568 -u --unknown show only unknown (not tracked) files
569 -i --ignored show only ignored files
569 -i --ignored show only ignored files
570 -n --no-status hide status prefix
570 -n --no-status hide status prefix
571 -C --copies show source of copied files
571 -C --copies show source of copied files
572 -0 --print0 end filenames with NUL, for use with xargs
572 -0 --print0 end filenames with NUL, for use with xargs
573 --rev REV [+] show difference from revision
573 --rev REV [+] show difference from revision
574 --change REV list the changed files of a revision
574 --change REV list the changed files of a revision
575 -I --include PATTERN [+] include names matching the given patterns
575 -I --include PATTERN [+] include names matching the given patterns
576 -X --exclude PATTERN [+] exclude names matching the given patterns
576 -X --exclude PATTERN [+] exclude names matching the given patterns
577 -S --subrepos recurse into subrepositories
577 -S --subrepos recurse into subrepositories
578
578
579 (some details hidden, use --verbose to show complete help)
579 (some details hidden, use --verbose to show complete help)
580
580
581 $ hg -q help status
581 $ hg -q help status
582 hg status [OPTION]... [FILE]...
582 hg status [OPTION]... [FILE]...
583
583
584 show changed files in the working directory
584 show changed files in the working directory
585
585
586 $ hg help foo
586 $ hg help foo
587 abort: no such help topic: foo
587 abort: no such help topic: foo
588 (try "hg help --keyword foo")
588 (try "hg help --keyword foo")
589 [255]
589 [255]
590
590
591 $ hg skjdfks
591 $ hg skjdfks
592 hg: unknown command 'skjdfks'
592 hg: unknown command 'skjdfks'
593 Mercurial Distributed SCM
593 Mercurial Distributed SCM
594
594
595 basic commands:
595 basic commands:
596
596
597 add add the specified files on the next commit
597 add add the specified files on the next commit
598 annotate show changeset information by line for each file
598 annotate show changeset information by line for each file
599 clone make a copy of an existing repository
599 clone make a copy of an existing repository
600 commit commit the specified files or all outstanding changes
600 commit commit the specified files or all outstanding changes
601 diff diff repository (or selected files)
601 diff diff repository (or selected files)
602 export dump the header and diffs for one or more changesets
602 export dump the header and diffs for one or more changesets
603 forget forget the specified files on the next commit
603 forget forget the specified files on the next commit
604 init create a new repository in the given directory
604 init create a new repository in the given directory
605 log show revision history of entire repository or files
605 log show revision history of entire repository or files
606 merge merge another revision into working directory
606 merge merge another revision into working directory
607 pull pull changes from the specified source
607 pull pull changes from the specified source
608 push push changes to the specified destination
608 push push changes to the specified destination
609 remove remove the specified files on the next commit
609 remove remove the specified files on the next commit
610 serve start stand-alone webserver
610 serve start stand-alone webserver
611 status show changed files in the working directory
611 status show changed files in the working directory
612 summary summarize working directory state
612 summary summarize working directory state
613 update update working directory (or switch revisions)
613 update update working directory (or switch revisions)
614
614
615 (use "hg help" for the full list of commands or "hg -v" for details)
615 (use "hg help" for the full list of commands or "hg -v" for details)
616 [255]
616 [255]
617
617
618
618
619 $ cat > helpext.py <<EOF
619 $ cat > helpext.py <<EOF
620 > import os
620 > import os
621 > from mercurial import cmdutil, commands
621 > from mercurial import cmdutil, commands
622 >
622 >
623 > cmdtable = {}
623 > cmdtable = {}
624 > command = cmdutil.command(cmdtable)
624 > command = cmdutil.command(cmdtable)
625 >
625 >
626 > @command('nohelp',
626 > @command('nohelp',
627 > [('', 'longdesc', 3, 'x'*90),
627 > [('', 'longdesc', 3, 'x'*90),
628 > ('n', '', None, 'normal desc'),
628 > ('n', '', None, 'normal desc'),
629 > ('', 'newline', '', 'line1\nline2')],
629 > ('', 'newline', '', 'line1\nline2')],
630 > 'hg nohelp',
630 > 'hg nohelp',
631 > norepo=True)
631 > norepo=True)
632 > @command('debugoptDEP', [('', 'dopt', None, 'option is DEPRECATED')])
632 > @command('debugoptDEP', [('', 'dopt', None, 'option is DEPRECATED')])
633 > @command('debugoptEXP', [('', 'eopt', None, 'option is EXPERIMENTAL')])
633 > @command('debugoptEXP', [('', 'eopt', None, 'option is EXPERIMENTAL')])
634 > def nohelp(ui, *args, **kwargs):
634 > def nohelp(ui, *args, **kwargs):
635 > pass
635 > pass
636 >
636 >
637 > EOF
637 > EOF
638 $ echo '[extensions]' >> $HGRCPATH
638 $ echo '[extensions]' >> $HGRCPATH
639 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
639 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
640
640
641 Test command with no help text
641 Test command with no help text
642
642
643 $ hg help nohelp
643 $ hg help nohelp
644 hg nohelp
644 hg nohelp
645
645
646 (no help text available)
646 (no help text available)
647
647
648 options:
648 options:
649
649
650 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
650 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
651 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
651 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
652 -n -- normal desc
652 -n -- normal desc
653 --newline VALUE line1 line2
653 --newline VALUE line1 line2
654
654
655 (some details hidden, use --verbose to show complete help)
655 (some details hidden, use --verbose to show complete help)
656
656
657 $ hg help -k nohelp
657 $ hg help -k nohelp
658 Commands:
658 Commands:
659
659
660 nohelp hg nohelp
660 nohelp hg nohelp
661
661
662 Extension Commands:
662 Extension Commands:
663
663
664 nohelp (no help text available)
664 nohelp (no help text available)
665
665
666 Test that default list of commands omits extension commands
666 Test that default list of commands omits extension commands
667
667
668 $ hg help
668 $ hg help
669 Mercurial Distributed SCM
669 Mercurial Distributed SCM
670
670
671 list of commands:
671 list of commands:
672
672
673 add add the specified files on the next commit
673 add add the specified files on the next commit
674 addremove add all new files, delete all missing files
674 addremove add all new files, delete all missing files
675 annotate show changeset information by line for each file
675 annotate show changeset information by line for each file
676 archive create an unversioned archive of a repository revision
676 archive create an unversioned archive of a repository revision
677 backout reverse effect of earlier changeset
677 backout reverse effect of earlier changeset
678 bisect subdivision search of changesets
678 bisect subdivision search of changesets
679 bookmarks create a new bookmark or list existing bookmarks
679 bookmarks create a new bookmark or list existing bookmarks
680 branch set or show the current branch name
680 branch set or show the current branch name
681 branches list repository named branches
681 branches list repository named branches
682 bundle create a changegroup file
682 bundle create a changegroup file
683 cat output the current or given revision of files
683 cat output the current or given revision of files
684 clone make a copy of an existing repository
684 clone make a copy of an existing repository
685 commit commit the specified files or all outstanding changes
685 commit commit the specified files or all outstanding changes
686 config show combined config settings from all hgrc files
686 config show combined config settings from all hgrc files
687 copy mark files as copied for the next commit
687 copy mark files as copied for the next commit
688 diff diff repository (or selected files)
688 diff diff repository (or selected files)
689 export dump the header and diffs for one or more changesets
689 export dump the header and diffs for one or more changesets
690 files list tracked files
690 files list tracked files
691 forget forget the specified files on the next commit
691 forget forget the specified files on the next commit
692 graft copy changes from other branches onto the current branch
692 graft copy changes from other branches onto the current branch
693 grep search for a pattern in specified files and revisions
693 grep search for a pattern in specified files and revisions
694 heads show branch heads
694 heads show branch heads
695 help show help for a given topic or a help overview
695 help show help for a given topic or a help overview
696 identify identify the working directory or specified revision
696 identify identify the working directory or specified revision
697 import import an ordered set of patches
697 import import an ordered set of patches
698 incoming show new changesets found in source
698 incoming show new changesets found in source
699 init create a new repository in the given directory
699 init create a new repository in the given directory
700 log show revision history of entire repository or files
700 log show revision history of entire repository or files
701 manifest output the current or given revision of the project manifest
701 manifest output the current or given revision of the project manifest
702 merge merge another revision into working directory
702 merge merge another revision into working directory
703 outgoing show changesets not found in the destination
703 outgoing show changesets not found in the destination
704 paths show aliases for remote repositories
704 paths show aliases for remote repositories
705 phase set or show the current phase name
705 phase set or show the current phase name
706 pull pull changes from the specified source
706 pull pull changes from the specified source
707 push push changes to the specified destination
707 push push changes to the specified destination
708 recover roll back an interrupted transaction
708 recover roll back an interrupted transaction
709 remove remove the specified files on the next commit
709 remove remove the specified files on the next commit
710 rename rename files; equivalent of copy + remove
710 rename rename files; equivalent of copy + remove
711 resolve redo merges or set/view the merge status of files
711 resolve redo merges or set/view the merge status of files
712 revert restore files to their checkout state
712 revert restore files to their checkout state
713 root print the root (top) of the current working directory
713 root print the root (top) of the current working directory
714 serve start stand-alone webserver
714 serve start stand-alone webserver
715 status show changed files in the working directory
715 status show changed files in the working directory
716 summary summarize working directory state
716 summary summarize working directory state
717 tag add one or more tags for the current or given revision
717 tag add one or more tags for the current or given revision
718 tags list repository tags
718 tags list repository tags
719 unbundle apply one or more changegroup files
719 unbundle apply one or more changegroup files
720 update update working directory (or switch revisions)
720 update update working directory (or switch revisions)
721 verify verify the integrity of the repository
721 verify verify the integrity of the repository
722 version output version and copyright information
722 version output version and copyright information
723
723
724 enabled extensions:
724 enabled extensions:
725
725
726 helpext (no help text available)
726 helpext (no help text available)
727
727
728 additional help topics:
728 additional help topics:
729
729
730 config Configuration Files
730 config Configuration Files
731 dates Date Formats
731 dates Date Formats
732 diffs Diff Formats
732 diffs Diff Formats
733 environment Environment Variables
733 environment Environment Variables
734 extensions Using Additional Features
734 extensions Using Additional Features
735 filesets Specifying File Sets
735 filesets Specifying File Sets
736 glossary Glossary
736 glossary Glossary
737 hgignore Syntax for Mercurial Ignore Files
737 hgignore Syntax for Mercurial Ignore Files
738 hgweb Configuring hgweb
738 hgweb Configuring hgweb
739 merge-tools Merge Tools
739 merge-tools Merge Tools
740 multirevs Specifying Multiple Revisions
740 multirevs Specifying Multiple Revisions
741 patterns File Name Patterns
741 patterns File Name Patterns
742 phases Working with Phases
742 phases Working with Phases
743 revisions Specifying Single Revisions
743 revisions Specifying Single Revisions
744 revsets Specifying Revision Sets
744 revsets Specifying Revision Sets
745 scripting Using Mercurial from scripts and automation
745 scripting Using Mercurial from scripts and automation
746 subrepos Subrepositories
746 subrepos Subrepositories
747 templating Template Usage
747 templating Template Usage
748 urls URL Paths
748 urls URL Paths
749
749
750 (use "hg help -v" to show built-in aliases and global options)
750 (use "hg help -v" to show built-in aliases and global options)
751
751
752
752
753 Test list of internal help commands
753 Test list of internal help commands
754
754
755 $ hg help debug
755 $ hg help debug
756 debug commands (internal and unsupported):
756 debug commands (internal and unsupported):
757
757
758 debugancestor
758 debugancestor
759 find the ancestor revision of two revisions in a given index
759 find the ancestor revision of two revisions in a given index
760 debugbuilddag
760 debugbuilddag
761 builds a repo with a given DAG from scratch in the current
761 builds a repo with a given DAG from scratch in the current
762 empty repo
762 empty repo
763 debugbundle lists the contents of a bundle
763 debugbundle lists the contents of a bundle
764 debugcheckstate
764 debugcheckstate
765 validate the correctness of the current dirstate
765 validate the correctness of the current dirstate
766 debugcommands
766 debugcommands
767 list all available commands and options
767 list all available commands and options
768 debugcomplete
768 debugcomplete
769 returns the completion list associated with the given command
769 returns the completion list associated with the given command
770 debugdag format the changelog or an index DAG as a concise textual
770 debugdag format the changelog or an index DAG as a concise textual
771 description
771 description
772 debugdata dump the contents of a data file revision
772 debugdata dump the contents of a data file revision
773 debugdate parse and display a date
773 debugdate parse and display a date
774 debugdirstate
774 debugdirstate
775 show the contents of the current dirstate
775 show the contents of the current dirstate
776 debugdiscovery
776 debugdiscovery
777 runs the changeset discovery protocol in isolation
777 runs the changeset discovery protocol in isolation
778 debugfileset parse and apply a fileset specification
778 debugfileset parse and apply a fileset specification
779 debugfsinfo show information detected about current filesystem
779 debugfsinfo show information detected about current filesystem
780 debuggetbundle
780 debuggetbundle
781 retrieves a bundle from a repo
781 retrieves a bundle from a repo
782 debugignore display the combined ignore pattern
782 debugignore display the combined ignore pattern
783 debugindex dump the contents of an index file
783 debugindex dump the contents of an index file
784 debugindexdot
784 debugindexdot
785 dump an index DAG as a graphviz dot file
785 dump an index DAG as a graphviz dot file
786 debuginstall test Mercurial installation
786 debuginstall test Mercurial installation
787 debugknown test whether node ids are known to a repo
787 debugknown test whether node ids are known to a repo
788 debuglocks show or modify state of locks
788 debuglocks show or modify state of locks
789 debugnamecomplete
789 debugnamecomplete
790 complete "names" - tags, open branch names, bookmark names
790 complete "names" - tags, open branch names, bookmark names
791 debugobsolete
791 debugobsolete
792 create arbitrary obsolete marker
792 create arbitrary obsolete marker
793 debugoptDEP (no help text available)
793 debugoptDEP (no help text available)
794 debugoptEXP (no help text available)
794 debugoptEXP (no help text available)
795 debugpathcomplete
795 debugpathcomplete
796 complete part or all of a tracked path
796 complete part or all of a tracked path
797 debugpushkey access the pushkey key/value protocol
797 debugpushkey access the pushkey key/value protocol
798 debugpvec (no help text available)
798 debugpvec (no help text available)
799 debugrebuilddirstate
799 debugrebuilddirstate
800 rebuild the dirstate as it would look like for the given
800 rebuild the dirstate as it would look like for the given
801 revision
801 revision
802 debugrebuildfncache
802 debugrebuildfncache
803 rebuild the fncache file
803 rebuild the fncache file
804 debugrename dump rename information
804 debugrename dump rename information
805 debugrevlog show data and statistics about a revlog
805 debugrevlog show data and statistics about a revlog
806 debugrevspec parse and apply a revision specification
806 debugrevspec parse and apply a revision specification
807 debugsetparents
807 debugsetparents
808 manually set the parents of the current working directory
808 manually set the parents of the current working directory
809 debugsub (no help text available)
809 debugsub (no help text available)
810 debugsuccessorssets
810 debugsuccessorssets
811 show set of successors for revision
811 show set of successors for revision
812 debugwalk show how files match on given patterns
812 debugwalk show how files match on given patterns
813 debugwireargs
813 debugwireargs
814 (no help text available)
814 (no help text available)
815
815
816 (use "hg help -v debug" to show built-in aliases and global options)
816 (use "hg help -v debug" to show built-in aliases and global options)
817
817
818
818
819 Test list of commands with command with no help text
819 Test list of commands with command with no help text
820
820
821 $ hg help helpext
821 $ hg help helpext
822 helpext extension - no help text available
822 helpext extension - no help text available
823
823
824 list of commands:
824 list of commands:
825
825
826 nohelp (no help text available)
826 nohelp (no help text available)
827
827
828 (use "hg help -v helpext" to show built-in aliases and global options)
828 (use "hg help -v helpext" to show built-in aliases and global options)
829
829
830
830
831 test deprecated and experimental options are hidden in command help
831 test deprecated and experimental options are hidden in command help
832 $ hg help debugoptDEP
832 $ hg help debugoptDEP
833 hg debugoptDEP
833 hg debugoptDEP
834
834
835 (no help text available)
835 (no help text available)
836
836
837 options:
837 options:
838
838
839 (some details hidden, use --verbose to show complete help)
839 (some details hidden, use --verbose to show complete help)
840
840
841 $ hg help debugoptEXP
841 $ hg help debugoptEXP
842 hg debugoptEXP
842 hg debugoptEXP
843
843
844 (no help text available)
844 (no help text available)
845
845
846 options:
846 options:
847
847
848 (some details hidden, use --verbose to show complete help)
848 (some details hidden, use --verbose to show complete help)
849
849
850 test deprecated and experimental options is shown with -v
850 test deprecated and experimental options is shown with -v
851 $ hg help -v debugoptDEP | grep dopt
851 $ hg help -v debugoptDEP | grep dopt
852 --dopt option is DEPRECATED
852 --dopt option is DEPRECATED
853 $ hg help -v debugoptEXP | grep eopt
853 $ hg help -v debugoptEXP | grep eopt
854 --eopt option is EXPERIMENTAL
854 --eopt option is EXPERIMENTAL
855
855
856 #if gettext
856 #if gettext
857 test deprecated option is hidden with translation with untranslated description
857 test deprecated option is hidden with translation with untranslated description
858 (use many globy for not failing on changed transaction)
858 (use many globy for not failing on changed transaction)
859 $ LANGUAGE=sv hg help debugoptDEP
859 $ LANGUAGE=sv hg help debugoptDEP
860 hg debugoptDEP
860 hg debugoptDEP
861
861
862 (*) (glob)
862 (*) (glob)
863
863
864 options:
864 options:
865
865
866 (some details hidden, use --verbose to show complete help)
866 (some details hidden, use --verbose to show complete help)
867 #endif
867 #endif
868
868
869 Test commands that collide with topics (issue4240)
869 Test commands that collide with topics (issue4240)
870
870
871 $ hg config -hq
871 $ hg config -hq
872 hg config [-u] [NAME]...
872 hg config [-u] [NAME]...
873
873
874 show combined config settings from all hgrc files
874 show combined config settings from all hgrc files
875 $ hg showconfig -hq
875 $ hg showconfig -hq
876 hg config [-u] [NAME]...
876 hg config [-u] [NAME]...
877
877
878 show combined config settings from all hgrc files
878 show combined config settings from all hgrc files
879
879
880 Test a help topic
880 Test a help topic
881
881
882 $ hg help revs
882 $ hg help revs
883 Specifying Single Revisions
883 Specifying Single Revisions
884 """""""""""""""""""""""""""
884 """""""""""""""""""""""""""
885
885
886 Mercurial supports several ways to specify individual revisions.
886 Mercurial supports several ways to specify individual revisions.
887
887
888 A plain integer is treated as a revision number. Negative integers are
888 A plain integer is treated as a revision number. Negative integers are
889 treated as sequential offsets from the tip, with -1 denoting the tip, -2
889 treated as sequential offsets from the tip, with -1 denoting the tip, -2
890 denoting the revision prior to the tip, and so forth.
890 denoting the revision prior to the tip, and so forth.
891
891
892 A 40-digit hexadecimal string is treated as a unique revision identifier.
892 A 40-digit hexadecimal string is treated as a unique revision identifier.
893
893
894 A hexadecimal string less than 40 characters long is treated as a unique
894 A hexadecimal string less than 40 characters long is treated as a unique
895 revision identifier and is referred to as a short-form identifier. A
895 revision identifier and is referred to as a short-form identifier. A
896 short-form identifier is only valid if it is the prefix of exactly one
896 short-form identifier is only valid if it is the prefix of exactly one
897 full-length identifier.
897 full-length identifier.
898
898
899 Any other string is treated as a bookmark, tag, or branch name. A bookmark
899 Any other string is treated as a bookmark, tag, or branch name. A bookmark
900 is a movable pointer to a revision. A tag is a permanent name associated
900 is a movable pointer to a revision. A tag is a permanent name associated
901 with a revision. A branch name denotes the tipmost open branch head of
901 with a revision. A branch name denotes the tipmost open branch head of
902 that branch - or if they are all closed, the tipmost closed head of the
902 that branch - or if they are all closed, the tipmost closed head of the
903 branch. Bookmark, tag, and branch names must not contain the ":"
903 branch. Bookmark, tag, and branch names must not contain the ":"
904 character.
904 character.
905
905
906 The reserved name "tip" always identifies the most recent revision.
906 The reserved name "tip" always identifies the most recent revision.
907
907
908 The reserved name "null" indicates the null revision. This is the revision
908 The reserved name "null" indicates the null revision. This is the revision
909 of an empty repository, and the parent of revision 0.
909 of an empty repository, and the parent of revision 0.
910
910
911 The reserved name "." indicates the working directory parent. If no
911 The reserved name "." indicates the working directory parent. If no
912 working directory is checked out, it is equivalent to null. If an
912 working directory is checked out, it is equivalent to null. If an
913 uncommitted merge is in progress, "." is the revision of the first parent.
913 uncommitted merge is in progress, "." is the revision of the first parent.
914
914
915 Test repeated config section name
916
917 $ hg help config.host
918 "http_proxy.host"
919 Host name and (optional) port of the proxy server, for example
920 "myproxy:8000".
921
922 "smtp.host"
923 Host name of mail server, e.g. "mail.example.com".
924
915 Test templating help
925 Test templating help
916
926
917 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
927 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
918 desc String. The text of the changeset description.
928 desc String. The text of the changeset description.
919 diffstat String. Statistics of changes with the following format:
929 diffstat String. Statistics of changes with the following format:
920 firstline Any text. Returns the first line of text.
930 firstline Any text. Returns the first line of text.
921 nonempty Any text. Returns '(none)' if the string is empty.
931 nonempty Any text. Returns '(none)' if the string is empty.
922
932
923 Test help hooks
933 Test help hooks
924
934
925 $ cat > helphook1.py <<EOF
935 $ cat > helphook1.py <<EOF
926 > from mercurial import help
936 > from mercurial import help
927 >
937 >
928 > def rewrite(topic, doc):
938 > def rewrite(topic, doc):
929 > return doc + '\nhelphook1\n'
939 > return doc + '\nhelphook1\n'
930 >
940 >
931 > def extsetup(ui):
941 > def extsetup(ui):
932 > help.addtopichook('revsets', rewrite)
942 > help.addtopichook('revsets', rewrite)
933 > EOF
943 > EOF
934 $ cat > helphook2.py <<EOF
944 $ cat > helphook2.py <<EOF
935 > from mercurial import help
945 > from mercurial import help
936 >
946 >
937 > def rewrite(topic, doc):
947 > def rewrite(topic, doc):
938 > return doc + '\nhelphook2\n'
948 > return doc + '\nhelphook2\n'
939 >
949 >
940 > def extsetup(ui):
950 > def extsetup(ui):
941 > help.addtopichook('revsets', rewrite)
951 > help.addtopichook('revsets', rewrite)
942 > EOF
952 > EOF
943 $ echo '[extensions]' >> $HGRCPATH
953 $ echo '[extensions]' >> $HGRCPATH
944 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
954 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
945 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
955 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
946 $ hg help revsets | grep helphook
956 $ hg help revsets | grep helphook
947 helphook1
957 helphook1
948 helphook2
958 helphook2
949
959
950 Test keyword search help
960 Test keyword search help
951
961
952 $ cat > prefixedname.py <<EOF
962 $ cat > prefixedname.py <<EOF
953 > '''matched against word "clone"
963 > '''matched against word "clone"
954 > '''
964 > '''
955 > EOF
965 > EOF
956 $ echo '[extensions]' >> $HGRCPATH
966 $ echo '[extensions]' >> $HGRCPATH
957 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
967 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
958 $ hg help -k clone
968 $ hg help -k clone
959 Topics:
969 Topics:
960
970
961 config Configuration Files
971 config Configuration Files
962 extensions Using Additional Features
972 extensions Using Additional Features
963 glossary Glossary
973 glossary Glossary
964 phases Working with Phases
974 phases Working with Phases
965 subrepos Subrepositories
975 subrepos Subrepositories
966 urls URL Paths
976 urls URL Paths
967
977
968 Commands:
978 Commands:
969
979
970 bookmarks create a new bookmark or list existing bookmarks
980 bookmarks create a new bookmark or list existing bookmarks
971 clone make a copy of an existing repository
981 clone make a copy of an existing repository
972 paths show aliases for remote repositories
982 paths show aliases for remote repositories
973 update update working directory (or switch revisions)
983 update update working directory (or switch revisions)
974
984
975 Extensions:
985 Extensions:
976
986
977 prefixedname matched against word "clone"
987 prefixedname matched against word "clone"
978 relink recreates hardlinks between repository clones
988 relink recreates hardlinks between repository clones
979
989
980 Extension Commands:
990 Extension Commands:
981
991
982 qclone clone main and patch repository at same time
992 qclone clone main and patch repository at same time
983
993
984 Test unfound topic
994 Test unfound topic
985
995
986 $ hg help nonexistingtopicthatwillneverexisteverever
996 $ hg help nonexistingtopicthatwillneverexisteverever
987 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
997 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
988 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
998 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
989 [255]
999 [255]
990
1000
991 Test unfound keyword
1001 Test unfound keyword
992
1002
993 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1003 $ hg help --keyword nonexistingwordthatwillneverexisteverever
994 abort: no matches
1004 abort: no matches
995 (try "hg help" for a list of topics)
1005 (try "hg help" for a list of topics)
996 [255]
1006 [255]
997
1007
998 Test omit indicating for help
1008 Test omit indicating for help
999
1009
1000 $ cat > addverboseitems.py <<EOF
1010 $ cat > addverboseitems.py <<EOF
1001 > '''extension to test omit indicating.
1011 > '''extension to test omit indicating.
1002 >
1012 >
1003 > This paragraph is never omitted (for extension)
1013 > This paragraph is never omitted (for extension)
1004 >
1014 >
1005 > .. container:: verbose
1015 > .. container:: verbose
1006 >
1016 >
1007 > This paragraph is omitted,
1017 > This paragraph is omitted,
1008 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1018 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1009 >
1019 >
1010 > This paragraph is never omitted, too (for extension)
1020 > This paragraph is never omitted, too (for extension)
1011 > '''
1021 > '''
1012 >
1022 >
1013 > from mercurial import help, commands
1023 > from mercurial import help, commands
1014 > testtopic = """This paragraph is never omitted (for topic).
1024 > testtopic = """This paragraph is never omitted (for topic).
1015 >
1025 >
1016 > .. container:: verbose
1026 > .. container:: verbose
1017 >
1027 >
1018 > This paragraph is omitted,
1028 > This paragraph is omitted,
1019 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1029 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1020 >
1030 >
1021 > This paragraph is never omitted, too (for topic)
1031 > This paragraph is never omitted, too (for topic)
1022 > """
1032 > """
1023 > def extsetup(ui):
1033 > def extsetup(ui):
1024 > help.helptable.append((["topic-containing-verbose"],
1034 > help.helptable.append((["topic-containing-verbose"],
1025 > "This is the topic to test omit indicating.",
1035 > "This is the topic to test omit indicating.",
1026 > lambda : testtopic))
1036 > lambda : testtopic))
1027 > EOF
1037 > EOF
1028 $ echo '[extensions]' >> $HGRCPATH
1038 $ echo '[extensions]' >> $HGRCPATH
1029 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1039 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1030 $ hg help addverboseitems
1040 $ hg help addverboseitems
1031 addverboseitems extension - extension to test omit indicating.
1041 addverboseitems extension - extension to test omit indicating.
1032
1042
1033 This paragraph is never omitted (for extension)
1043 This paragraph is never omitted (for extension)
1034
1044
1035 This paragraph is never omitted, too (for extension)
1045 This paragraph is never omitted, too (for extension)
1036
1046
1037 (some details hidden, use --verbose to show complete help)
1047 (some details hidden, use --verbose to show complete help)
1038
1048
1039 no commands defined
1049 no commands defined
1040 $ hg help -v addverboseitems
1050 $ hg help -v addverboseitems
1041 addverboseitems extension - extension to test omit indicating.
1051 addverboseitems extension - extension to test omit indicating.
1042
1052
1043 This paragraph is never omitted (for extension)
1053 This paragraph is never omitted (for extension)
1044
1054
1045 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1055 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1046 extension)
1056 extension)
1047
1057
1048 This paragraph is never omitted, too (for extension)
1058 This paragraph is never omitted, too (for extension)
1049
1059
1050 no commands defined
1060 no commands defined
1051 $ hg help topic-containing-verbose
1061 $ hg help topic-containing-verbose
1052 This is the topic to test omit indicating.
1062 This is the topic to test omit indicating.
1053 """"""""""""""""""""""""""""""""""""""""""
1063 """"""""""""""""""""""""""""""""""""""""""
1054
1064
1055 This paragraph is never omitted (for topic).
1065 This paragraph is never omitted (for topic).
1056
1066
1057 This paragraph is never omitted, too (for topic)
1067 This paragraph is never omitted, too (for topic)
1058
1068
1059 (some details hidden, use --verbose to show complete help)
1069 (some details hidden, use --verbose to show complete help)
1060 $ hg help -v topic-containing-verbose
1070 $ hg help -v topic-containing-verbose
1061 This is the topic to test omit indicating.
1071 This is the topic to test omit indicating.
1062 """"""""""""""""""""""""""""""""""""""""""
1072 """"""""""""""""""""""""""""""""""""""""""
1063
1073
1064 This paragraph is never omitted (for topic).
1074 This paragraph is never omitted (for topic).
1065
1075
1066 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1076 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1067 topic)
1077 topic)
1068
1078
1069 This paragraph is never omitted, too (for topic)
1079 This paragraph is never omitted, too (for topic)
1070
1080
1071 Test section lookup
1081 Test section lookup
1072
1082
1073 $ hg help revset.merge
1083 $ hg help revset.merge
1074 "merge()"
1084 "merge()"
1075 Changeset is a merge changeset.
1085 Changeset is a merge changeset.
1076
1086
1077 $ hg help glossary.dag
1087 $ hg help glossary.dag
1078 DAG
1088 DAG
1079 The repository of changesets of a distributed version control system
1089 The repository of changesets of a distributed version control system
1080 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1090 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1081 of nodes and edges, where nodes correspond to changesets and edges
1091 of nodes and edges, where nodes correspond to changesets and edges
1082 imply a parent -> child relation. This graph can be visualized by
1092 imply a parent -> child relation. This graph can be visualized by
1083 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1093 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1084 limited by the requirement for children to have at most two parents.
1094 limited by the requirement for children to have at most two parents.
1085
1095
1086
1096
1087 $ hg help hgrc.paths
1097 $ hg help hgrc.paths
1088 "paths"
1098 "paths"
1089 -------
1099 -------
1090
1100
1091 Assigns symbolic names to repositories. The left side is the symbolic
1101 Assigns symbolic names to repositories. The left side is the symbolic
1092 name, and the right gives the directory or URL that is the location of the
1102 name, and the right gives the directory or URL that is the location of the
1093 repository. Default paths can be declared by setting the following
1103 repository. Default paths can be declared by setting the following
1094 entries.
1104 entries.
1095
1105
1096 "default"
1106 "default"
1097 Directory or URL to use when pulling if no source is specified.
1107 Directory or URL to use when pulling if no source is specified.
1098 Default is set to repository from which the current repository was
1108 Default is set to repository from which the current repository was
1099 cloned.
1109 cloned.
1100
1110
1101 "default-push"
1111 "default-push"
1102 Optional. Directory or URL to use when pushing if no destination is
1112 Optional. Directory or URL to use when pushing if no destination is
1103 specified.
1113 specified.
1104
1114
1105 Custom paths can be defined by assigning the path to a name that later can
1115 Custom paths can be defined by assigning the path to a name that later can
1106 be used from the command line. Example:
1116 be used from the command line. Example:
1107
1117
1108 [paths]
1118 [paths]
1109 my_path = http://example.com/path
1119 my_path = http://example.com/path
1110
1120
1111 To push to the path defined in "my_path" run the command:
1121 To push to the path defined in "my_path" run the command:
1112
1122
1113 hg push my_path
1123 hg push my_path
1114
1124
1115 $ hg help glossary.mcguffin
1125 $ hg help glossary.mcguffin
1116 abort: help section not found
1126 abort: help section not found
1117 [255]
1127 [255]
1118
1128
1119 $ hg help glossary.mc.guffin
1129 $ hg help glossary.mc.guffin
1120 abort: help section not found
1130 abort: help section not found
1121 [255]
1131 [255]
1122
1132
1123 $ hg help template.files
1133 $ hg help template.files
1124 files List of strings. All files modified, added, or removed by
1134 files List of strings. All files modified, added, or removed by
1125 this changeset.
1135 this changeset.
1126
1136
1127 Test dynamic list of merge tools only shows up once
1137 Test dynamic list of merge tools only shows up once
1128 $ hg help merge-tools
1138 $ hg help merge-tools
1129 Merge Tools
1139 Merge Tools
1130 """""""""""
1140 """""""""""
1131
1141
1132 To merge files Mercurial uses merge tools.
1142 To merge files Mercurial uses merge tools.
1133
1143
1134 A merge tool combines two different versions of a file into a merged file.
1144 A merge tool combines two different versions of a file into a merged file.
1135 Merge tools are given the two files and the greatest common ancestor of
1145 Merge tools are given the two files and the greatest common ancestor of
1136 the two file versions, so they can determine the changes made on both
1146 the two file versions, so they can determine the changes made on both
1137 branches.
1147 branches.
1138
1148
1139 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1149 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1140 backout" and in several extensions.
1150 backout" and in several extensions.
1141
1151
1142 Usually, the merge tool tries to automatically reconcile the files by
1152 Usually, the merge tool tries to automatically reconcile the files by
1143 combining all non-overlapping changes that occurred separately in the two
1153 combining all non-overlapping changes that occurred separately in the two
1144 different evolutions of the same initial base file. Furthermore, some
1154 different evolutions of the same initial base file. Furthermore, some
1145 interactive merge programs make it easier to manually resolve conflicting
1155 interactive merge programs make it easier to manually resolve conflicting
1146 merges, either in a graphical way, or by inserting some conflict markers.
1156 merges, either in a graphical way, or by inserting some conflict markers.
1147 Mercurial does not include any interactive merge programs but relies on
1157 Mercurial does not include any interactive merge programs but relies on
1148 external tools for that.
1158 external tools for that.
1149
1159
1150 Available merge tools
1160 Available merge tools
1151 =====================
1161 =====================
1152
1162
1153 External merge tools and their properties are configured in the merge-
1163 External merge tools and their properties are configured in the merge-
1154 tools configuration section - see hgrc(5) - but they can often just be
1164 tools configuration section - see hgrc(5) - but they can often just be
1155 named by their executable.
1165 named by their executable.
1156
1166
1157 A merge tool is generally usable if its executable can be found on the
1167 A merge tool is generally usable if its executable can be found on the
1158 system and if it can handle the merge. The executable is found if it is an
1168 system and if it can handle the merge. The executable is found if it is an
1159 absolute or relative executable path or the name of an application in the
1169 absolute or relative executable path or the name of an application in the
1160 executable search path. The tool is assumed to be able to handle the merge
1170 executable search path. The tool is assumed to be able to handle the merge
1161 if it can handle symlinks if the file is a symlink, if it can handle
1171 if it can handle symlinks if the file is a symlink, if it can handle
1162 binary files if the file is binary, and if a GUI is available if the tool
1172 binary files if the file is binary, and if a GUI is available if the tool
1163 requires a GUI.
1173 requires a GUI.
1164
1174
1165 There are some internal merge tools which can be used. The internal merge
1175 There are some internal merge tools which can be used. The internal merge
1166 tools are:
1176 tools are:
1167
1177
1168 ":dump"
1178 ":dump"
1169 Creates three versions of the files to merge, containing the contents of
1179 Creates three versions of the files to merge, containing the contents of
1170 local, other and base. These files can then be used to perform a merge
1180 local, other and base. These files can then be used to perform a merge
1171 manually. If the file to be merged is named "a.txt", these files will
1181 manually. If the file to be merged is named "a.txt", these files will
1172 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1182 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1173 they will be placed in the same directory as "a.txt".
1183 they will be placed in the same directory as "a.txt".
1174
1184
1175 ":fail"
1185 ":fail"
1176 Rather than attempting to merge files that were modified on both
1186 Rather than attempting to merge files that were modified on both
1177 branches, it marks them as unresolved. The resolve command must be used
1187 branches, it marks them as unresolved. The resolve command must be used
1178 to resolve these conflicts.
1188 to resolve these conflicts.
1179
1189
1180 ":local"
1190 ":local"
1181 Uses the local version of files as the merged version.
1191 Uses the local version of files as the merged version.
1182
1192
1183 ":merge"
1193 ":merge"
1184 Uses the internal non-interactive simple merge algorithm for merging
1194 Uses the internal non-interactive simple merge algorithm for merging
1185 files. It will fail if there are any conflicts and leave markers in the
1195 files. It will fail if there are any conflicts and leave markers in the
1186 partially merged file. Markers will have two sections, one for each side
1196 partially merged file. Markers will have two sections, one for each side
1187 of merge.
1197 of merge.
1188
1198
1189 ":merge3"
1199 ":merge3"
1190 Uses the internal non-interactive simple merge algorithm for merging
1200 Uses the internal non-interactive simple merge algorithm for merging
1191 files. It will fail if there are any conflicts and leave markers in the
1201 files. It will fail if there are any conflicts and leave markers in the
1192 partially merged file. Marker will have three sections, one from each
1202 partially merged file. Marker will have three sections, one from each
1193 side of the merge and one for the base content.
1203 side of the merge and one for the base content.
1194
1204
1195 ":other"
1205 ":other"
1196 Uses the other version of files as the merged version.
1206 Uses the other version of files as the merged version.
1197
1207
1198 ":prompt"
1208 ":prompt"
1199 Asks the user which of the local or the other version to keep as the
1209 Asks the user which of the local or the other version to keep as the
1200 merged version.
1210 merged version.
1201
1211
1202 ":tagmerge"
1212 ":tagmerge"
1203 Uses the internal tag merge algorithm (experimental).
1213 Uses the internal tag merge algorithm (experimental).
1204
1214
1205 ":union"
1215 ":union"
1206 Uses the internal non-interactive simple merge algorithm for merging
1216 Uses the internal non-interactive simple merge algorithm for merging
1207 files. It will use both left and right sides for conflict regions. No
1217 files. It will use both left and right sides for conflict regions. No
1208 markers are inserted.
1218 markers are inserted.
1209
1219
1210 Internal tools are always available and do not require a GUI but will by
1220 Internal tools are always available and do not require a GUI but will by
1211 default not handle symlinks or binary files.
1221 default not handle symlinks or binary files.
1212
1222
1213 Choosing a merge tool
1223 Choosing a merge tool
1214 =====================
1224 =====================
1215
1225
1216 Mercurial uses these rules when deciding which merge tool to use:
1226 Mercurial uses these rules when deciding which merge tool to use:
1217
1227
1218 1. If a tool has been specified with the --tool option to merge or
1228 1. If a tool has been specified with the --tool option to merge or
1219 resolve, it is used. If it is the name of a tool in the merge-tools
1229 resolve, it is used. If it is the name of a tool in the merge-tools
1220 configuration, its configuration is used. Otherwise the specified tool
1230 configuration, its configuration is used. Otherwise the specified tool
1221 must be executable by the shell.
1231 must be executable by the shell.
1222 2. If the "HGMERGE" environment variable is present, its value is used and
1232 2. If the "HGMERGE" environment variable is present, its value is used and
1223 must be executable by the shell.
1233 must be executable by the shell.
1224 3. If the filename of the file to be merged matches any of the patterns in
1234 3. If the filename of the file to be merged matches any of the patterns in
1225 the merge-patterns configuration section, the first usable merge tool
1235 the merge-patterns configuration section, the first usable merge tool
1226 corresponding to a matching pattern is used. Here, binary capabilities
1236 corresponding to a matching pattern is used. Here, binary capabilities
1227 of the merge tool are not considered.
1237 of the merge tool are not considered.
1228 4. If ui.merge is set it will be considered next. If the value is not the
1238 4. If ui.merge is set it will be considered next. If the value is not the
1229 name of a configured tool, the specified value is used and must be
1239 name of a configured tool, the specified value is used and must be
1230 executable by the shell. Otherwise the named tool is used if it is
1240 executable by the shell. Otherwise the named tool is used if it is
1231 usable.
1241 usable.
1232 5. If any usable merge tools are present in the merge-tools configuration
1242 5. If any usable merge tools are present in the merge-tools configuration
1233 section, the one with the highest priority is used.
1243 section, the one with the highest priority is used.
1234 6. If a program named "hgmerge" can be found on the system, it is used -
1244 6. If a program named "hgmerge" can be found on the system, it is used -
1235 but it will by default not be used for symlinks and binary files.
1245 but it will by default not be used for symlinks and binary files.
1236 7. If the file to be merged is not binary and is not a symlink, then
1246 7. If the file to be merged is not binary and is not a symlink, then
1237 internal ":merge" is used.
1247 internal ":merge" is used.
1238 8. The merge of the file fails and must be resolved before commit.
1248 8. The merge of the file fails and must be resolved before commit.
1239
1249
1240 Note:
1250 Note:
1241 After selecting a merge program, Mercurial will by default attempt to
1251 After selecting a merge program, Mercurial will by default attempt to
1242 merge the files using a simple merge algorithm first. Only if it
1252 merge the files using a simple merge algorithm first. Only if it
1243 doesn't succeed because of conflicting changes Mercurial will actually
1253 doesn't succeed because of conflicting changes Mercurial will actually
1244 execute the merge program. Whether to use the simple merge algorithm
1254 execute the merge program. Whether to use the simple merge algorithm
1245 first can be controlled by the premerge setting of the merge tool.
1255 first can be controlled by the premerge setting of the merge tool.
1246 Premerge is enabled by default unless the file is binary or a symlink.
1256 Premerge is enabled by default unless the file is binary or a symlink.
1247
1257
1248 See the merge-tools and ui sections of hgrc(5) for details on the
1258 See the merge-tools and ui sections of hgrc(5) for details on the
1249 configuration of merge tools.
1259 configuration of merge tools.
1250
1260
1251 Test usage of section marks in help documents
1261 Test usage of section marks in help documents
1252
1262
1253 $ cd "$TESTDIR"/../doc
1263 $ cd "$TESTDIR"/../doc
1254 $ python check-seclevel.py
1264 $ python check-seclevel.py
1255 $ cd $TESTTMP
1265 $ cd $TESTTMP
1256
1266
1257 #if serve
1267 #if serve
1258
1268
1259 Test the help pages in hgweb.
1269 Test the help pages in hgweb.
1260
1270
1261 Dish up an empty repo; serve it cold.
1271 Dish up an empty repo; serve it cold.
1262
1272
1263 $ hg init "$TESTTMP/test"
1273 $ hg init "$TESTTMP/test"
1264 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1274 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1265 $ cat hg.pid >> $DAEMON_PIDS
1275 $ cat hg.pid >> $DAEMON_PIDS
1266
1276
1267 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1277 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1268 200 Script output follows
1278 200 Script output follows
1269
1279
1270 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1280 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1271 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1281 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1272 <head>
1282 <head>
1273 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1283 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1274 <meta name="robots" content="index, nofollow" />
1284 <meta name="robots" content="index, nofollow" />
1275 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1285 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1276 <script type="text/javascript" src="/static/mercurial.js"></script>
1286 <script type="text/javascript" src="/static/mercurial.js"></script>
1277
1287
1278 <title>Help: Index</title>
1288 <title>Help: Index</title>
1279 </head>
1289 </head>
1280 <body>
1290 <body>
1281
1291
1282 <div class="container">
1292 <div class="container">
1283 <div class="menu">
1293 <div class="menu">
1284 <div class="logo">
1294 <div class="logo">
1285 <a href="http://mercurial.selenic.com/">
1295 <a href="http://mercurial.selenic.com/">
1286 <img src="/static/hglogo.png" alt="mercurial" /></a>
1296 <img src="/static/hglogo.png" alt="mercurial" /></a>
1287 </div>
1297 </div>
1288 <ul>
1298 <ul>
1289 <li><a href="/shortlog">log</a></li>
1299 <li><a href="/shortlog">log</a></li>
1290 <li><a href="/graph">graph</a></li>
1300 <li><a href="/graph">graph</a></li>
1291 <li><a href="/tags">tags</a></li>
1301 <li><a href="/tags">tags</a></li>
1292 <li><a href="/bookmarks">bookmarks</a></li>
1302 <li><a href="/bookmarks">bookmarks</a></li>
1293 <li><a href="/branches">branches</a></li>
1303 <li><a href="/branches">branches</a></li>
1294 </ul>
1304 </ul>
1295 <ul>
1305 <ul>
1296 <li class="active">help</li>
1306 <li class="active">help</li>
1297 </ul>
1307 </ul>
1298 </div>
1308 </div>
1299
1309
1300 <div class="main">
1310 <div class="main">
1301 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1311 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1302 <form class="search" action="/log">
1312 <form class="search" action="/log">
1303
1313
1304 <p><input name="rev" id="search1" type="text" size="30" /></p>
1314 <p><input name="rev" id="search1" type="text" size="30" /></p>
1305 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1315 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1306 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1316 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1307 </form>
1317 </form>
1308 <table class="bigtable">
1318 <table class="bigtable">
1309 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1319 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1310
1320
1311 <tr><td>
1321 <tr><td>
1312 <a href="/help/config">
1322 <a href="/help/config">
1313 config
1323 config
1314 </a>
1324 </a>
1315 </td><td>
1325 </td><td>
1316 Configuration Files
1326 Configuration Files
1317 </td></tr>
1327 </td></tr>
1318 <tr><td>
1328 <tr><td>
1319 <a href="/help/dates">
1329 <a href="/help/dates">
1320 dates
1330 dates
1321 </a>
1331 </a>
1322 </td><td>
1332 </td><td>
1323 Date Formats
1333 Date Formats
1324 </td></tr>
1334 </td></tr>
1325 <tr><td>
1335 <tr><td>
1326 <a href="/help/diffs">
1336 <a href="/help/diffs">
1327 diffs
1337 diffs
1328 </a>
1338 </a>
1329 </td><td>
1339 </td><td>
1330 Diff Formats
1340 Diff Formats
1331 </td></tr>
1341 </td></tr>
1332 <tr><td>
1342 <tr><td>
1333 <a href="/help/environment">
1343 <a href="/help/environment">
1334 environment
1344 environment
1335 </a>
1345 </a>
1336 </td><td>
1346 </td><td>
1337 Environment Variables
1347 Environment Variables
1338 </td></tr>
1348 </td></tr>
1339 <tr><td>
1349 <tr><td>
1340 <a href="/help/extensions">
1350 <a href="/help/extensions">
1341 extensions
1351 extensions
1342 </a>
1352 </a>
1343 </td><td>
1353 </td><td>
1344 Using Additional Features
1354 Using Additional Features
1345 </td></tr>
1355 </td></tr>
1346 <tr><td>
1356 <tr><td>
1347 <a href="/help/filesets">
1357 <a href="/help/filesets">
1348 filesets
1358 filesets
1349 </a>
1359 </a>
1350 </td><td>
1360 </td><td>
1351 Specifying File Sets
1361 Specifying File Sets
1352 </td></tr>
1362 </td></tr>
1353 <tr><td>
1363 <tr><td>
1354 <a href="/help/glossary">
1364 <a href="/help/glossary">
1355 glossary
1365 glossary
1356 </a>
1366 </a>
1357 </td><td>
1367 </td><td>
1358 Glossary
1368 Glossary
1359 </td></tr>
1369 </td></tr>
1360 <tr><td>
1370 <tr><td>
1361 <a href="/help/hgignore">
1371 <a href="/help/hgignore">
1362 hgignore
1372 hgignore
1363 </a>
1373 </a>
1364 </td><td>
1374 </td><td>
1365 Syntax for Mercurial Ignore Files
1375 Syntax for Mercurial Ignore Files
1366 </td></tr>
1376 </td></tr>
1367 <tr><td>
1377 <tr><td>
1368 <a href="/help/hgweb">
1378 <a href="/help/hgweb">
1369 hgweb
1379 hgweb
1370 </a>
1380 </a>
1371 </td><td>
1381 </td><td>
1372 Configuring hgweb
1382 Configuring hgweb
1373 </td></tr>
1383 </td></tr>
1374 <tr><td>
1384 <tr><td>
1375 <a href="/help/merge-tools">
1385 <a href="/help/merge-tools">
1376 merge-tools
1386 merge-tools
1377 </a>
1387 </a>
1378 </td><td>
1388 </td><td>
1379 Merge Tools
1389 Merge Tools
1380 </td></tr>
1390 </td></tr>
1381 <tr><td>
1391 <tr><td>
1382 <a href="/help/multirevs">
1392 <a href="/help/multirevs">
1383 multirevs
1393 multirevs
1384 </a>
1394 </a>
1385 </td><td>
1395 </td><td>
1386 Specifying Multiple Revisions
1396 Specifying Multiple Revisions
1387 </td></tr>
1397 </td></tr>
1388 <tr><td>
1398 <tr><td>
1389 <a href="/help/patterns">
1399 <a href="/help/patterns">
1390 patterns
1400 patterns
1391 </a>
1401 </a>
1392 </td><td>
1402 </td><td>
1393 File Name Patterns
1403 File Name Patterns
1394 </td></tr>
1404 </td></tr>
1395 <tr><td>
1405 <tr><td>
1396 <a href="/help/phases">
1406 <a href="/help/phases">
1397 phases
1407 phases
1398 </a>
1408 </a>
1399 </td><td>
1409 </td><td>
1400 Working with Phases
1410 Working with Phases
1401 </td></tr>
1411 </td></tr>
1402 <tr><td>
1412 <tr><td>
1403 <a href="/help/revisions">
1413 <a href="/help/revisions">
1404 revisions
1414 revisions
1405 </a>
1415 </a>
1406 </td><td>
1416 </td><td>
1407 Specifying Single Revisions
1417 Specifying Single Revisions
1408 </td></tr>
1418 </td></tr>
1409 <tr><td>
1419 <tr><td>
1410 <a href="/help/revsets">
1420 <a href="/help/revsets">
1411 revsets
1421 revsets
1412 </a>
1422 </a>
1413 </td><td>
1423 </td><td>
1414 Specifying Revision Sets
1424 Specifying Revision Sets
1415 </td></tr>
1425 </td></tr>
1416 <tr><td>
1426 <tr><td>
1417 <a href="/help/scripting">
1427 <a href="/help/scripting">
1418 scripting
1428 scripting
1419 </a>
1429 </a>
1420 </td><td>
1430 </td><td>
1421 Using Mercurial from scripts and automation
1431 Using Mercurial from scripts and automation
1422 </td></tr>
1432 </td></tr>
1423 <tr><td>
1433 <tr><td>
1424 <a href="/help/subrepos">
1434 <a href="/help/subrepos">
1425 subrepos
1435 subrepos
1426 </a>
1436 </a>
1427 </td><td>
1437 </td><td>
1428 Subrepositories
1438 Subrepositories
1429 </td></tr>
1439 </td></tr>
1430 <tr><td>
1440 <tr><td>
1431 <a href="/help/templating">
1441 <a href="/help/templating">
1432 templating
1442 templating
1433 </a>
1443 </a>
1434 </td><td>
1444 </td><td>
1435 Template Usage
1445 Template Usage
1436 </td></tr>
1446 </td></tr>
1437 <tr><td>
1447 <tr><td>
1438 <a href="/help/urls">
1448 <a href="/help/urls">
1439 urls
1449 urls
1440 </a>
1450 </a>
1441 </td><td>
1451 </td><td>
1442 URL Paths
1452 URL Paths
1443 </td></tr>
1453 </td></tr>
1444 <tr><td>
1454 <tr><td>
1445 <a href="/help/topic-containing-verbose">
1455 <a href="/help/topic-containing-verbose">
1446 topic-containing-verbose
1456 topic-containing-verbose
1447 </a>
1457 </a>
1448 </td><td>
1458 </td><td>
1449 This is the topic to test omit indicating.
1459 This is the topic to test omit indicating.
1450 </td></tr>
1460 </td></tr>
1451
1461
1452 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1462 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1453
1463
1454 <tr><td>
1464 <tr><td>
1455 <a href="/help/add">
1465 <a href="/help/add">
1456 add
1466 add
1457 </a>
1467 </a>
1458 </td><td>
1468 </td><td>
1459 add the specified files on the next commit
1469 add the specified files on the next commit
1460 </td></tr>
1470 </td></tr>
1461 <tr><td>
1471 <tr><td>
1462 <a href="/help/annotate">
1472 <a href="/help/annotate">
1463 annotate
1473 annotate
1464 </a>
1474 </a>
1465 </td><td>
1475 </td><td>
1466 show changeset information by line for each file
1476 show changeset information by line for each file
1467 </td></tr>
1477 </td></tr>
1468 <tr><td>
1478 <tr><td>
1469 <a href="/help/clone">
1479 <a href="/help/clone">
1470 clone
1480 clone
1471 </a>
1481 </a>
1472 </td><td>
1482 </td><td>
1473 make a copy of an existing repository
1483 make a copy of an existing repository
1474 </td></tr>
1484 </td></tr>
1475 <tr><td>
1485 <tr><td>
1476 <a href="/help/commit">
1486 <a href="/help/commit">
1477 commit
1487 commit
1478 </a>
1488 </a>
1479 </td><td>
1489 </td><td>
1480 commit the specified files or all outstanding changes
1490 commit the specified files or all outstanding changes
1481 </td></tr>
1491 </td></tr>
1482 <tr><td>
1492 <tr><td>
1483 <a href="/help/diff">
1493 <a href="/help/diff">
1484 diff
1494 diff
1485 </a>
1495 </a>
1486 </td><td>
1496 </td><td>
1487 diff repository (or selected files)
1497 diff repository (or selected files)
1488 </td></tr>
1498 </td></tr>
1489 <tr><td>
1499 <tr><td>
1490 <a href="/help/export">
1500 <a href="/help/export">
1491 export
1501 export
1492 </a>
1502 </a>
1493 </td><td>
1503 </td><td>
1494 dump the header and diffs for one or more changesets
1504 dump the header and diffs for one or more changesets
1495 </td></tr>
1505 </td></tr>
1496 <tr><td>
1506 <tr><td>
1497 <a href="/help/forget">
1507 <a href="/help/forget">
1498 forget
1508 forget
1499 </a>
1509 </a>
1500 </td><td>
1510 </td><td>
1501 forget the specified files on the next commit
1511 forget the specified files on the next commit
1502 </td></tr>
1512 </td></tr>
1503 <tr><td>
1513 <tr><td>
1504 <a href="/help/init">
1514 <a href="/help/init">
1505 init
1515 init
1506 </a>
1516 </a>
1507 </td><td>
1517 </td><td>
1508 create a new repository in the given directory
1518 create a new repository in the given directory
1509 </td></tr>
1519 </td></tr>
1510 <tr><td>
1520 <tr><td>
1511 <a href="/help/log">
1521 <a href="/help/log">
1512 log
1522 log
1513 </a>
1523 </a>
1514 </td><td>
1524 </td><td>
1515 show revision history of entire repository or files
1525 show revision history of entire repository or files
1516 </td></tr>
1526 </td></tr>
1517 <tr><td>
1527 <tr><td>
1518 <a href="/help/merge">
1528 <a href="/help/merge">
1519 merge
1529 merge
1520 </a>
1530 </a>
1521 </td><td>
1531 </td><td>
1522 merge another revision into working directory
1532 merge another revision into working directory
1523 </td></tr>
1533 </td></tr>
1524 <tr><td>
1534 <tr><td>
1525 <a href="/help/pull">
1535 <a href="/help/pull">
1526 pull
1536 pull
1527 </a>
1537 </a>
1528 </td><td>
1538 </td><td>
1529 pull changes from the specified source
1539 pull changes from the specified source
1530 </td></tr>
1540 </td></tr>
1531 <tr><td>
1541 <tr><td>
1532 <a href="/help/push">
1542 <a href="/help/push">
1533 push
1543 push
1534 </a>
1544 </a>
1535 </td><td>
1545 </td><td>
1536 push changes to the specified destination
1546 push changes to the specified destination
1537 </td></tr>
1547 </td></tr>
1538 <tr><td>
1548 <tr><td>
1539 <a href="/help/remove">
1549 <a href="/help/remove">
1540 remove
1550 remove
1541 </a>
1551 </a>
1542 </td><td>
1552 </td><td>
1543 remove the specified files on the next commit
1553 remove the specified files on the next commit
1544 </td></tr>
1554 </td></tr>
1545 <tr><td>
1555 <tr><td>
1546 <a href="/help/serve">
1556 <a href="/help/serve">
1547 serve
1557 serve
1548 </a>
1558 </a>
1549 </td><td>
1559 </td><td>
1550 start stand-alone webserver
1560 start stand-alone webserver
1551 </td></tr>
1561 </td></tr>
1552 <tr><td>
1562 <tr><td>
1553 <a href="/help/status">
1563 <a href="/help/status">
1554 status
1564 status
1555 </a>
1565 </a>
1556 </td><td>
1566 </td><td>
1557 show changed files in the working directory
1567 show changed files in the working directory
1558 </td></tr>
1568 </td></tr>
1559 <tr><td>
1569 <tr><td>
1560 <a href="/help/summary">
1570 <a href="/help/summary">
1561 summary
1571 summary
1562 </a>
1572 </a>
1563 </td><td>
1573 </td><td>
1564 summarize working directory state
1574 summarize working directory state
1565 </td></tr>
1575 </td></tr>
1566 <tr><td>
1576 <tr><td>
1567 <a href="/help/update">
1577 <a href="/help/update">
1568 update
1578 update
1569 </a>
1579 </a>
1570 </td><td>
1580 </td><td>
1571 update working directory (or switch revisions)
1581 update working directory (or switch revisions)
1572 </td></tr>
1582 </td></tr>
1573
1583
1574 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1584 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1575
1585
1576 <tr><td>
1586 <tr><td>
1577 <a href="/help/addremove">
1587 <a href="/help/addremove">
1578 addremove
1588 addremove
1579 </a>
1589 </a>
1580 </td><td>
1590 </td><td>
1581 add all new files, delete all missing files
1591 add all new files, delete all missing files
1582 </td></tr>
1592 </td></tr>
1583 <tr><td>
1593 <tr><td>
1584 <a href="/help/archive">
1594 <a href="/help/archive">
1585 archive
1595 archive
1586 </a>
1596 </a>
1587 </td><td>
1597 </td><td>
1588 create an unversioned archive of a repository revision
1598 create an unversioned archive of a repository revision
1589 </td></tr>
1599 </td></tr>
1590 <tr><td>
1600 <tr><td>
1591 <a href="/help/backout">
1601 <a href="/help/backout">
1592 backout
1602 backout
1593 </a>
1603 </a>
1594 </td><td>
1604 </td><td>
1595 reverse effect of earlier changeset
1605 reverse effect of earlier changeset
1596 </td></tr>
1606 </td></tr>
1597 <tr><td>
1607 <tr><td>
1598 <a href="/help/bisect">
1608 <a href="/help/bisect">
1599 bisect
1609 bisect
1600 </a>
1610 </a>
1601 </td><td>
1611 </td><td>
1602 subdivision search of changesets
1612 subdivision search of changesets
1603 </td></tr>
1613 </td></tr>
1604 <tr><td>
1614 <tr><td>
1605 <a href="/help/bookmarks">
1615 <a href="/help/bookmarks">
1606 bookmarks
1616 bookmarks
1607 </a>
1617 </a>
1608 </td><td>
1618 </td><td>
1609 create a new bookmark or list existing bookmarks
1619 create a new bookmark or list existing bookmarks
1610 </td></tr>
1620 </td></tr>
1611 <tr><td>
1621 <tr><td>
1612 <a href="/help/branch">
1622 <a href="/help/branch">
1613 branch
1623 branch
1614 </a>
1624 </a>
1615 </td><td>
1625 </td><td>
1616 set or show the current branch name
1626 set or show the current branch name
1617 </td></tr>
1627 </td></tr>
1618 <tr><td>
1628 <tr><td>
1619 <a href="/help/branches">
1629 <a href="/help/branches">
1620 branches
1630 branches
1621 </a>
1631 </a>
1622 </td><td>
1632 </td><td>
1623 list repository named branches
1633 list repository named branches
1624 </td></tr>
1634 </td></tr>
1625 <tr><td>
1635 <tr><td>
1626 <a href="/help/bundle">
1636 <a href="/help/bundle">
1627 bundle
1637 bundle
1628 </a>
1638 </a>
1629 </td><td>
1639 </td><td>
1630 create a changegroup file
1640 create a changegroup file
1631 </td></tr>
1641 </td></tr>
1632 <tr><td>
1642 <tr><td>
1633 <a href="/help/cat">
1643 <a href="/help/cat">
1634 cat
1644 cat
1635 </a>
1645 </a>
1636 </td><td>
1646 </td><td>
1637 output the current or given revision of files
1647 output the current or given revision of files
1638 </td></tr>
1648 </td></tr>
1639 <tr><td>
1649 <tr><td>
1640 <a href="/help/config">
1650 <a href="/help/config">
1641 config
1651 config
1642 </a>
1652 </a>
1643 </td><td>
1653 </td><td>
1644 show combined config settings from all hgrc files
1654 show combined config settings from all hgrc files
1645 </td></tr>
1655 </td></tr>
1646 <tr><td>
1656 <tr><td>
1647 <a href="/help/copy">
1657 <a href="/help/copy">
1648 copy
1658 copy
1649 </a>
1659 </a>
1650 </td><td>
1660 </td><td>
1651 mark files as copied for the next commit
1661 mark files as copied for the next commit
1652 </td></tr>
1662 </td></tr>
1653 <tr><td>
1663 <tr><td>
1654 <a href="/help/files">
1664 <a href="/help/files">
1655 files
1665 files
1656 </a>
1666 </a>
1657 </td><td>
1667 </td><td>
1658 list tracked files
1668 list tracked files
1659 </td></tr>
1669 </td></tr>
1660 <tr><td>
1670 <tr><td>
1661 <a href="/help/graft">
1671 <a href="/help/graft">
1662 graft
1672 graft
1663 </a>
1673 </a>
1664 </td><td>
1674 </td><td>
1665 copy changes from other branches onto the current branch
1675 copy changes from other branches onto the current branch
1666 </td></tr>
1676 </td></tr>
1667 <tr><td>
1677 <tr><td>
1668 <a href="/help/grep">
1678 <a href="/help/grep">
1669 grep
1679 grep
1670 </a>
1680 </a>
1671 </td><td>
1681 </td><td>
1672 search for a pattern in specified files and revisions
1682 search for a pattern in specified files and revisions
1673 </td></tr>
1683 </td></tr>
1674 <tr><td>
1684 <tr><td>
1675 <a href="/help/heads">
1685 <a href="/help/heads">
1676 heads
1686 heads
1677 </a>
1687 </a>
1678 </td><td>
1688 </td><td>
1679 show branch heads
1689 show branch heads
1680 </td></tr>
1690 </td></tr>
1681 <tr><td>
1691 <tr><td>
1682 <a href="/help/help">
1692 <a href="/help/help">
1683 help
1693 help
1684 </a>
1694 </a>
1685 </td><td>
1695 </td><td>
1686 show help for a given topic or a help overview
1696 show help for a given topic or a help overview
1687 </td></tr>
1697 </td></tr>
1688 <tr><td>
1698 <tr><td>
1689 <a href="/help/identify">
1699 <a href="/help/identify">
1690 identify
1700 identify
1691 </a>
1701 </a>
1692 </td><td>
1702 </td><td>
1693 identify the working directory or specified revision
1703 identify the working directory or specified revision
1694 </td></tr>
1704 </td></tr>
1695 <tr><td>
1705 <tr><td>
1696 <a href="/help/import">
1706 <a href="/help/import">
1697 import
1707 import
1698 </a>
1708 </a>
1699 </td><td>
1709 </td><td>
1700 import an ordered set of patches
1710 import an ordered set of patches
1701 </td></tr>
1711 </td></tr>
1702 <tr><td>
1712 <tr><td>
1703 <a href="/help/incoming">
1713 <a href="/help/incoming">
1704 incoming
1714 incoming
1705 </a>
1715 </a>
1706 </td><td>
1716 </td><td>
1707 show new changesets found in source
1717 show new changesets found in source
1708 </td></tr>
1718 </td></tr>
1709 <tr><td>
1719 <tr><td>
1710 <a href="/help/manifest">
1720 <a href="/help/manifest">
1711 manifest
1721 manifest
1712 </a>
1722 </a>
1713 </td><td>
1723 </td><td>
1714 output the current or given revision of the project manifest
1724 output the current or given revision of the project manifest
1715 </td></tr>
1725 </td></tr>
1716 <tr><td>
1726 <tr><td>
1717 <a href="/help/nohelp">
1727 <a href="/help/nohelp">
1718 nohelp
1728 nohelp
1719 </a>
1729 </a>
1720 </td><td>
1730 </td><td>
1721 (no help text available)
1731 (no help text available)
1722 </td></tr>
1732 </td></tr>
1723 <tr><td>
1733 <tr><td>
1724 <a href="/help/outgoing">
1734 <a href="/help/outgoing">
1725 outgoing
1735 outgoing
1726 </a>
1736 </a>
1727 </td><td>
1737 </td><td>
1728 show changesets not found in the destination
1738 show changesets not found in the destination
1729 </td></tr>
1739 </td></tr>
1730 <tr><td>
1740 <tr><td>
1731 <a href="/help/paths">
1741 <a href="/help/paths">
1732 paths
1742 paths
1733 </a>
1743 </a>
1734 </td><td>
1744 </td><td>
1735 show aliases for remote repositories
1745 show aliases for remote repositories
1736 </td></tr>
1746 </td></tr>
1737 <tr><td>
1747 <tr><td>
1738 <a href="/help/phase">
1748 <a href="/help/phase">
1739 phase
1749 phase
1740 </a>
1750 </a>
1741 </td><td>
1751 </td><td>
1742 set or show the current phase name
1752 set or show the current phase name
1743 </td></tr>
1753 </td></tr>
1744 <tr><td>
1754 <tr><td>
1745 <a href="/help/recover">
1755 <a href="/help/recover">
1746 recover
1756 recover
1747 </a>
1757 </a>
1748 </td><td>
1758 </td><td>
1749 roll back an interrupted transaction
1759 roll back an interrupted transaction
1750 </td></tr>
1760 </td></tr>
1751 <tr><td>
1761 <tr><td>
1752 <a href="/help/rename">
1762 <a href="/help/rename">
1753 rename
1763 rename
1754 </a>
1764 </a>
1755 </td><td>
1765 </td><td>
1756 rename files; equivalent of copy + remove
1766 rename files; equivalent of copy + remove
1757 </td></tr>
1767 </td></tr>
1758 <tr><td>
1768 <tr><td>
1759 <a href="/help/resolve">
1769 <a href="/help/resolve">
1760 resolve
1770 resolve
1761 </a>
1771 </a>
1762 </td><td>
1772 </td><td>
1763 redo merges or set/view the merge status of files
1773 redo merges or set/view the merge status of files
1764 </td></tr>
1774 </td></tr>
1765 <tr><td>
1775 <tr><td>
1766 <a href="/help/revert">
1776 <a href="/help/revert">
1767 revert
1777 revert
1768 </a>
1778 </a>
1769 </td><td>
1779 </td><td>
1770 restore files to their checkout state
1780 restore files to their checkout state
1771 </td></tr>
1781 </td></tr>
1772 <tr><td>
1782 <tr><td>
1773 <a href="/help/root">
1783 <a href="/help/root">
1774 root
1784 root
1775 </a>
1785 </a>
1776 </td><td>
1786 </td><td>
1777 print the root (top) of the current working directory
1787 print the root (top) of the current working directory
1778 </td></tr>
1788 </td></tr>
1779 <tr><td>
1789 <tr><td>
1780 <a href="/help/tag">
1790 <a href="/help/tag">
1781 tag
1791 tag
1782 </a>
1792 </a>
1783 </td><td>
1793 </td><td>
1784 add one or more tags for the current or given revision
1794 add one or more tags for the current or given revision
1785 </td></tr>
1795 </td></tr>
1786 <tr><td>
1796 <tr><td>
1787 <a href="/help/tags">
1797 <a href="/help/tags">
1788 tags
1798 tags
1789 </a>
1799 </a>
1790 </td><td>
1800 </td><td>
1791 list repository tags
1801 list repository tags
1792 </td></tr>
1802 </td></tr>
1793 <tr><td>
1803 <tr><td>
1794 <a href="/help/unbundle">
1804 <a href="/help/unbundle">
1795 unbundle
1805 unbundle
1796 </a>
1806 </a>
1797 </td><td>
1807 </td><td>
1798 apply one or more changegroup files
1808 apply one or more changegroup files
1799 </td></tr>
1809 </td></tr>
1800 <tr><td>
1810 <tr><td>
1801 <a href="/help/verify">
1811 <a href="/help/verify">
1802 verify
1812 verify
1803 </a>
1813 </a>
1804 </td><td>
1814 </td><td>
1805 verify the integrity of the repository
1815 verify the integrity of the repository
1806 </td></tr>
1816 </td></tr>
1807 <tr><td>
1817 <tr><td>
1808 <a href="/help/version">
1818 <a href="/help/version">
1809 version
1819 version
1810 </a>
1820 </a>
1811 </td><td>
1821 </td><td>
1812 output version and copyright information
1822 output version and copyright information
1813 </td></tr>
1823 </td></tr>
1814 </table>
1824 </table>
1815 </div>
1825 </div>
1816 </div>
1826 </div>
1817
1827
1818 <script type="text/javascript">process_dates()</script>
1828 <script type="text/javascript">process_dates()</script>
1819
1829
1820
1830
1821 </body>
1831 </body>
1822 </html>
1832 </html>
1823
1833
1824
1834
1825 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1835 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1826 200 Script output follows
1836 200 Script output follows
1827
1837
1828 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1838 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1829 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1839 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1830 <head>
1840 <head>
1831 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1841 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1832 <meta name="robots" content="index, nofollow" />
1842 <meta name="robots" content="index, nofollow" />
1833 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1843 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1834 <script type="text/javascript" src="/static/mercurial.js"></script>
1844 <script type="text/javascript" src="/static/mercurial.js"></script>
1835
1845
1836 <title>Help: add</title>
1846 <title>Help: add</title>
1837 </head>
1847 </head>
1838 <body>
1848 <body>
1839
1849
1840 <div class="container">
1850 <div class="container">
1841 <div class="menu">
1851 <div class="menu">
1842 <div class="logo">
1852 <div class="logo">
1843 <a href="http://mercurial.selenic.com/">
1853 <a href="http://mercurial.selenic.com/">
1844 <img src="/static/hglogo.png" alt="mercurial" /></a>
1854 <img src="/static/hglogo.png" alt="mercurial" /></a>
1845 </div>
1855 </div>
1846 <ul>
1856 <ul>
1847 <li><a href="/shortlog">log</a></li>
1857 <li><a href="/shortlog">log</a></li>
1848 <li><a href="/graph">graph</a></li>
1858 <li><a href="/graph">graph</a></li>
1849 <li><a href="/tags">tags</a></li>
1859 <li><a href="/tags">tags</a></li>
1850 <li><a href="/bookmarks">bookmarks</a></li>
1860 <li><a href="/bookmarks">bookmarks</a></li>
1851 <li><a href="/branches">branches</a></li>
1861 <li><a href="/branches">branches</a></li>
1852 </ul>
1862 </ul>
1853 <ul>
1863 <ul>
1854 <li class="active"><a href="/help">help</a></li>
1864 <li class="active"><a href="/help">help</a></li>
1855 </ul>
1865 </ul>
1856 </div>
1866 </div>
1857
1867
1858 <div class="main">
1868 <div class="main">
1859 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1869 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1860 <h3>Help: add</h3>
1870 <h3>Help: add</h3>
1861
1871
1862 <form class="search" action="/log">
1872 <form class="search" action="/log">
1863
1873
1864 <p><input name="rev" id="search1" type="text" size="30" /></p>
1874 <p><input name="rev" id="search1" type="text" size="30" /></p>
1865 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1875 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1866 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1876 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1867 </form>
1877 </form>
1868 <div id="doc">
1878 <div id="doc">
1869 <p>
1879 <p>
1870 hg add [OPTION]... [FILE]...
1880 hg add [OPTION]... [FILE]...
1871 </p>
1881 </p>
1872 <p>
1882 <p>
1873 add the specified files on the next commit
1883 add the specified files on the next commit
1874 </p>
1884 </p>
1875 <p>
1885 <p>
1876 Schedule files to be version controlled and added to the
1886 Schedule files to be version controlled and added to the
1877 repository.
1887 repository.
1878 </p>
1888 </p>
1879 <p>
1889 <p>
1880 The files will be added to the repository at the next commit. To
1890 The files will be added to the repository at the next commit. To
1881 undo an add before that, see &quot;hg forget&quot;.
1891 undo an add before that, see &quot;hg forget&quot;.
1882 </p>
1892 </p>
1883 <p>
1893 <p>
1884 If no names are given, add all files to the repository.
1894 If no names are given, add all files to the repository.
1885 </p>
1895 </p>
1886 <p>
1896 <p>
1887 An example showing how new (unknown) files are added
1897 An example showing how new (unknown) files are added
1888 automatically by &quot;hg add&quot;:
1898 automatically by &quot;hg add&quot;:
1889 </p>
1899 </p>
1890 <pre>
1900 <pre>
1891 \$ ls (re)
1901 \$ ls (re)
1892 foo.c
1902 foo.c
1893 \$ hg status (re)
1903 \$ hg status (re)
1894 ? foo.c
1904 ? foo.c
1895 \$ hg add (re)
1905 \$ hg add (re)
1896 adding foo.c
1906 adding foo.c
1897 \$ hg status (re)
1907 \$ hg status (re)
1898 A foo.c
1908 A foo.c
1899 </pre>
1909 </pre>
1900 <p>
1910 <p>
1901 Returns 0 if all files are successfully added.
1911 Returns 0 if all files are successfully added.
1902 </p>
1912 </p>
1903 <p>
1913 <p>
1904 options ([+] can be repeated):
1914 options ([+] can be repeated):
1905 </p>
1915 </p>
1906 <table>
1916 <table>
1907 <tr><td>-I</td>
1917 <tr><td>-I</td>
1908 <td>--include PATTERN [+]</td>
1918 <td>--include PATTERN [+]</td>
1909 <td>include names matching the given patterns</td></tr>
1919 <td>include names matching the given patterns</td></tr>
1910 <tr><td>-X</td>
1920 <tr><td>-X</td>
1911 <td>--exclude PATTERN [+]</td>
1921 <td>--exclude PATTERN [+]</td>
1912 <td>exclude names matching the given patterns</td></tr>
1922 <td>exclude names matching the given patterns</td></tr>
1913 <tr><td>-S</td>
1923 <tr><td>-S</td>
1914 <td>--subrepos</td>
1924 <td>--subrepos</td>
1915 <td>recurse into subrepositories</td></tr>
1925 <td>recurse into subrepositories</td></tr>
1916 <tr><td>-n</td>
1926 <tr><td>-n</td>
1917 <td>--dry-run</td>
1927 <td>--dry-run</td>
1918 <td>do not perform actions, just print output</td></tr>
1928 <td>do not perform actions, just print output</td></tr>
1919 </table>
1929 </table>
1920 <p>
1930 <p>
1921 global options ([+] can be repeated):
1931 global options ([+] can be repeated):
1922 </p>
1932 </p>
1923 <table>
1933 <table>
1924 <tr><td>-R</td>
1934 <tr><td>-R</td>
1925 <td>--repository REPO</td>
1935 <td>--repository REPO</td>
1926 <td>repository root directory or name of overlay bundle file</td></tr>
1936 <td>repository root directory or name of overlay bundle file</td></tr>
1927 <tr><td></td>
1937 <tr><td></td>
1928 <td>--cwd DIR</td>
1938 <td>--cwd DIR</td>
1929 <td>change working directory</td></tr>
1939 <td>change working directory</td></tr>
1930 <tr><td>-y</td>
1940 <tr><td>-y</td>
1931 <td>--noninteractive</td>
1941 <td>--noninteractive</td>
1932 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1942 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1933 <tr><td>-q</td>
1943 <tr><td>-q</td>
1934 <td>--quiet</td>
1944 <td>--quiet</td>
1935 <td>suppress output</td></tr>
1945 <td>suppress output</td></tr>
1936 <tr><td>-v</td>
1946 <tr><td>-v</td>
1937 <td>--verbose</td>
1947 <td>--verbose</td>
1938 <td>enable additional output</td></tr>
1948 <td>enable additional output</td></tr>
1939 <tr><td></td>
1949 <tr><td></td>
1940 <td>--config CONFIG [+]</td>
1950 <td>--config CONFIG [+]</td>
1941 <td>set/override config option (use 'section.name=value')</td></tr>
1951 <td>set/override config option (use 'section.name=value')</td></tr>
1942 <tr><td></td>
1952 <tr><td></td>
1943 <td>--debug</td>
1953 <td>--debug</td>
1944 <td>enable debugging output</td></tr>
1954 <td>enable debugging output</td></tr>
1945 <tr><td></td>
1955 <tr><td></td>
1946 <td>--debugger</td>
1956 <td>--debugger</td>
1947 <td>start debugger</td></tr>
1957 <td>start debugger</td></tr>
1948 <tr><td></td>
1958 <tr><td></td>
1949 <td>--encoding ENCODE</td>
1959 <td>--encoding ENCODE</td>
1950 <td>set the charset encoding (default: ascii)</td></tr>
1960 <td>set the charset encoding (default: ascii)</td></tr>
1951 <tr><td></td>
1961 <tr><td></td>
1952 <td>--encodingmode MODE</td>
1962 <td>--encodingmode MODE</td>
1953 <td>set the charset encoding mode (default: strict)</td></tr>
1963 <td>set the charset encoding mode (default: strict)</td></tr>
1954 <tr><td></td>
1964 <tr><td></td>
1955 <td>--traceback</td>
1965 <td>--traceback</td>
1956 <td>always print a traceback on exception</td></tr>
1966 <td>always print a traceback on exception</td></tr>
1957 <tr><td></td>
1967 <tr><td></td>
1958 <td>--time</td>
1968 <td>--time</td>
1959 <td>time how long the command takes</td></tr>
1969 <td>time how long the command takes</td></tr>
1960 <tr><td></td>
1970 <tr><td></td>
1961 <td>--profile</td>
1971 <td>--profile</td>
1962 <td>print command execution profile</td></tr>
1972 <td>print command execution profile</td></tr>
1963 <tr><td></td>
1973 <tr><td></td>
1964 <td>--version</td>
1974 <td>--version</td>
1965 <td>output version information and exit</td></tr>
1975 <td>output version information and exit</td></tr>
1966 <tr><td>-h</td>
1976 <tr><td>-h</td>
1967 <td>--help</td>
1977 <td>--help</td>
1968 <td>display help and exit</td></tr>
1978 <td>display help and exit</td></tr>
1969 <tr><td></td>
1979 <tr><td></td>
1970 <td>--hidden</td>
1980 <td>--hidden</td>
1971 <td>consider hidden changesets</td></tr>
1981 <td>consider hidden changesets</td></tr>
1972 </table>
1982 </table>
1973
1983
1974 </div>
1984 </div>
1975 </div>
1985 </div>
1976 </div>
1986 </div>
1977
1987
1978 <script type="text/javascript">process_dates()</script>
1988 <script type="text/javascript">process_dates()</script>
1979
1989
1980
1990
1981 </body>
1991 </body>
1982 </html>
1992 </html>
1983
1993
1984
1994
1985 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
1995 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
1986 200 Script output follows
1996 200 Script output follows
1987
1997
1988 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1998 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1989 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1999 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1990 <head>
2000 <head>
1991 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2001 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1992 <meta name="robots" content="index, nofollow" />
2002 <meta name="robots" content="index, nofollow" />
1993 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2003 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1994 <script type="text/javascript" src="/static/mercurial.js"></script>
2004 <script type="text/javascript" src="/static/mercurial.js"></script>
1995
2005
1996 <title>Help: remove</title>
2006 <title>Help: remove</title>
1997 </head>
2007 </head>
1998 <body>
2008 <body>
1999
2009
2000 <div class="container">
2010 <div class="container">
2001 <div class="menu">
2011 <div class="menu">
2002 <div class="logo">
2012 <div class="logo">
2003 <a href="http://mercurial.selenic.com/">
2013 <a href="http://mercurial.selenic.com/">
2004 <img src="/static/hglogo.png" alt="mercurial" /></a>
2014 <img src="/static/hglogo.png" alt="mercurial" /></a>
2005 </div>
2015 </div>
2006 <ul>
2016 <ul>
2007 <li><a href="/shortlog">log</a></li>
2017 <li><a href="/shortlog">log</a></li>
2008 <li><a href="/graph">graph</a></li>
2018 <li><a href="/graph">graph</a></li>
2009 <li><a href="/tags">tags</a></li>
2019 <li><a href="/tags">tags</a></li>
2010 <li><a href="/bookmarks">bookmarks</a></li>
2020 <li><a href="/bookmarks">bookmarks</a></li>
2011 <li><a href="/branches">branches</a></li>
2021 <li><a href="/branches">branches</a></li>
2012 </ul>
2022 </ul>
2013 <ul>
2023 <ul>
2014 <li class="active"><a href="/help">help</a></li>
2024 <li class="active"><a href="/help">help</a></li>
2015 </ul>
2025 </ul>
2016 </div>
2026 </div>
2017
2027
2018 <div class="main">
2028 <div class="main">
2019 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2029 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2020 <h3>Help: remove</h3>
2030 <h3>Help: remove</h3>
2021
2031
2022 <form class="search" action="/log">
2032 <form class="search" action="/log">
2023
2033
2024 <p><input name="rev" id="search1" type="text" size="30" /></p>
2034 <p><input name="rev" id="search1" type="text" size="30" /></p>
2025 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2035 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2026 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2036 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2027 </form>
2037 </form>
2028 <div id="doc">
2038 <div id="doc">
2029 <p>
2039 <p>
2030 hg remove [OPTION]... FILE...
2040 hg remove [OPTION]... FILE...
2031 </p>
2041 </p>
2032 <p>
2042 <p>
2033 aliases: rm
2043 aliases: rm
2034 </p>
2044 </p>
2035 <p>
2045 <p>
2036 remove the specified files on the next commit
2046 remove the specified files on the next commit
2037 </p>
2047 </p>
2038 <p>
2048 <p>
2039 Schedule the indicated files for removal from the current branch.
2049 Schedule the indicated files for removal from the current branch.
2040 </p>
2050 </p>
2041 <p>
2051 <p>
2042 This command schedules the files to be removed at the next commit.
2052 This command schedules the files to be removed at the next commit.
2043 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2053 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2044 files, see &quot;hg forget&quot;.
2054 files, see &quot;hg forget&quot;.
2045 </p>
2055 </p>
2046 <p>
2056 <p>
2047 -A/--after can be used to remove only files that have already
2057 -A/--after can be used to remove only files that have already
2048 been deleted, -f/--force can be used to force deletion, and -Af
2058 been deleted, -f/--force can be used to force deletion, and -Af
2049 can be used to remove files from the next revision without
2059 can be used to remove files from the next revision without
2050 deleting them from the working directory.
2060 deleting them from the working directory.
2051 </p>
2061 </p>
2052 <p>
2062 <p>
2053 The following table details the behavior of remove for different
2063 The following table details the behavior of remove for different
2054 file states (columns) and option combinations (rows). The file
2064 file states (columns) and option combinations (rows). The file
2055 states are Added [A], Clean [C], Modified [M] and Missing [!]
2065 states are Added [A], Clean [C], Modified [M] and Missing [!]
2056 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2066 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2057 (from branch) and Delete (from disk):
2067 (from branch) and Delete (from disk):
2058 </p>
2068 </p>
2059 <table>
2069 <table>
2060 <tr><td>opt/state</td>
2070 <tr><td>opt/state</td>
2061 <td>A</td>
2071 <td>A</td>
2062 <td>C</td>
2072 <td>C</td>
2063 <td>M</td>
2073 <td>M</td>
2064 <td>!</td></tr>
2074 <td>!</td></tr>
2065 <tr><td>none</td>
2075 <tr><td>none</td>
2066 <td>W</td>
2076 <td>W</td>
2067 <td>RD</td>
2077 <td>RD</td>
2068 <td>W</td>
2078 <td>W</td>
2069 <td>R</td></tr>
2079 <td>R</td></tr>
2070 <tr><td>-f</td>
2080 <tr><td>-f</td>
2071 <td>R</td>
2081 <td>R</td>
2072 <td>RD</td>
2082 <td>RD</td>
2073 <td>RD</td>
2083 <td>RD</td>
2074 <td>R</td></tr>
2084 <td>R</td></tr>
2075 <tr><td>-A</td>
2085 <tr><td>-A</td>
2076 <td>W</td>
2086 <td>W</td>
2077 <td>W</td>
2087 <td>W</td>
2078 <td>W</td>
2088 <td>W</td>
2079 <td>R</td></tr>
2089 <td>R</td></tr>
2080 <tr><td>-Af</td>
2090 <tr><td>-Af</td>
2081 <td>R</td>
2091 <td>R</td>
2082 <td>R</td>
2092 <td>R</td>
2083 <td>R</td>
2093 <td>R</td>
2084 <td>R</td></tr>
2094 <td>R</td></tr>
2085 </table>
2095 </table>
2086 <p>
2096 <p>
2087 Note that remove never deletes files in Added [A] state from the
2097 Note that remove never deletes files in Added [A] state from the
2088 working directory, not even if option --force is specified.
2098 working directory, not even if option --force is specified.
2089 </p>
2099 </p>
2090 <p>
2100 <p>
2091 Returns 0 on success, 1 if any warnings encountered.
2101 Returns 0 on success, 1 if any warnings encountered.
2092 </p>
2102 </p>
2093 <p>
2103 <p>
2094 options ([+] can be repeated):
2104 options ([+] can be repeated):
2095 </p>
2105 </p>
2096 <table>
2106 <table>
2097 <tr><td>-A</td>
2107 <tr><td>-A</td>
2098 <td>--after</td>
2108 <td>--after</td>
2099 <td>record delete for missing files</td></tr>
2109 <td>record delete for missing files</td></tr>
2100 <tr><td>-f</td>
2110 <tr><td>-f</td>
2101 <td>--force</td>
2111 <td>--force</td>
2102 <td>remove (and delete) file even if added or modified</td></tr>
2112 <td>remove (and delete) file even if added or modified</td></tr>
2103 <tr><td>-S</td>
2113 <tr><td>-S</td>
2104 <td>--subrepos</td>
2114 <td>--subrepos</td>
2105 <td>recurse into subrepositories</td></tr>
2115 <td>recurse into subrepositories</td></tr>
2106 <tr><td>-I</td>
2116 <tr><td>-I</td>
2107 <td>--include PATTERN [+]</td>
2117 <td>--include PATTERN [+]</td>
2108 <td>include names matching the given patterns</td></tr>
2118 <td>include names matching the given patterns</td></tr>
2109 <tr><td>-X</td>
2119 <tr><td>-X</td>
2110 <td>--exclude PATTERN [+]</td>
2120 <td>--exclude PATTERN [+]</td>
2111 <td>exclude names matching the given patterns</td></tr>
2121 <td>exclude names matching the given patterns</td></tr>
2112 </table>
2122 </table>
2113 <p>
2123 <p>
2114 global options ([+] can be repeated):
2124 global options ([+] can be repeated):
2115 </p>
2125 </p>
2116 <table>
2126 <table>
2117 <tr><td>-R</td>
2127 <tr><td>-R</td>
2118 <td>--repository REPO</td>
2128 <td>--repository REPO</td>
2119 <td>repository root directory or name of overlay bundle file</td></tr>
2129 <td>repository root directory or name of overlay bundle file</td></tr>
2120 <tr><td></td>
2130 <tr><td></td>
2121 <td>--cwd DIR</td>
2131 <td>--cwd DIR</td>
2122 <td>change working directory</td></tr>
2132 <td>change working directory</td></tr>
2123 <tr><td>-y</td>
2133 <tr><td>-y</td>
2124 <td>--noninteractive</td>
2134 <td>--noninteractive</td>
2125 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2135 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2126 <tr><td>-q</td>
2136 <tr><td>-q</td>
2127 <td>--quiet</td>
2137 <td>--quiet</td>
2128 <td>suppress output</td></tr>
2138 <td>suppress output</td></tr>
2129 <tr><td>-v</td>
2139 <tr><td>-v</td>
2130 <td>--verbose</td>
2140 <td>--verbose</td>
2131 <td>enable additional output</td></tr>
2141 <td>enable additional output</td></tr>
2132 <tr><td></td>
2142 <tr><td></td>
2133 <td>--config CONFIG [+]</td>
2143 <td>--config CONFIG [+]</td>
2134 <td>set/override config option (use 'section.name=value')</td></tr>
2144 <td>set/override config option (use 'section.name=value')</td></tr>
2135 <tr><td></td>
2145 <tr><td></td>
2136 <td>--debug</td>
2146 <td>--debug</td>
2137 <td>enable debugging output</td></tr>
2147 <td>enable debugging output</td></tr>
2138 <tr><td></td>
2148 <tr><td></td>
2139 <td>--debugger</td>
2149 <td>--debugger</td>
2140 <td>start debugger</td></tr>
2150 <td>start debugger</td></tr>
2141 <tr><td></td>
2151 <tr><td></td>
2142 <td>--encoding ENCODE</td>
2152 <td>--encoding ENCODE</td>
2143 <td>set the charset encoding (default: ascii)</td></tr>
2153 <td>set the charset encoding (default: ascii)</td></tr>
2144 <tr><td></td>
2154 <tr><td></td>
2145 <td>--encodingmode MODE</td>
2155 <td>--encodingmode MODE</td>
2146 <td>set the charset encoding mode (default: strict)</td></tr>
2156 <td>set the charset encoding mode (default: strict)</td></tr>
2147 <tr><td></td>
2157 <tr><td></td>
2148 <td>--traceback</td>
2158 <td>--traceback</td>
2149 <td>always print a traceback on exception</td></tr>
2159 <td>always print a traceback on exception</td></tr>
2150 <tr><td></td>
2160 <tr><td></td>
2151 <td>--time</td>
2161 <td>--time</td>
2152 <td>time how long the command takes</td></tr>
2162 <td>time how long the command takes</td></tr>
2153 <tr><td></td>
2163 <tr><td></td>
2154 <td>--profile</td>
2164 <td>--profile</td>
2155 <td>print command execution profile</td></tr>
2165 <td>print command execution profile</td></tr>
2156 <tr><td></td>
2166 <tr><td></td>
2157 <td>--version</td>
2167 <td>--version</td>
2158 <td>output version information and exit</td></tr>
2168 <td>output version information and exit</td></tr>
2159 <tr><td>-h</td>
2169 <tr><td>-h</td>
2160 <td>--help</td>
2170 <td>--help</td>
2161 <td>display help and exit</td></tr>
2171 <td>display help and exit</td></tr>
2162 <tr><td></td>
2172 <tr><td></td>
2163 <td>--hidden</td>
2173 <td>--hidden</td>
2164 <td>consider hidden changesets</td></tr>
2174 <td>consider hidden changesets</td></tr>
2165 </table>
2175 </table>
2166
2176
2167 </div>
2177 </div>
2168 </div>
2178 </div>
2169 </div>
2179 </div>
2170
2180
2171 <script type="text/javascript">process_dates()</script>
2181 <script type="text/javascript">process_dates()</script>
2172
2182
2173
2183
2174 </body>
2184 </body>
2175 </html>
2185 </html>
2176
2186
2177
2187
2178 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2188 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2179 200 Script output follows
2189 200 Script output follows
2180
2190
2181 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2191 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2182 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2192 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2183 <head>
2193 <head>
2184 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2194 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2185 <meta name="robots" content="index, nofollow" />
2195 <meta name="robots" content="index, nofollow" />
2186 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2196 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2187 <script type="text/javascript" src="/static/mercurial.js"></script>
2197 <script type="text/javascript" src="/static/mercurial.js"></script>
2188
2198
2189 <title>Help: revisions</title>
2199 <title>Help: revisions</title>
2190 </head>
2200 </head>
2191 <body>
2201 <body>
2192
2202
2193 <div class="container">
2203 <div class="container">
2194 <div class="menu">
2204 <div class="menu">
2195 <div class="logo">
2205 <div class="logo">
2196 <a href="http://mercurial.selenic.com/">
2206 <a href="http://mercurial.selenic.com/">
2197 <img src="/static/hglogo.png" alt="mercurial" /></a>
2207 <img src="/static/hglogo.png" alt="mercurial" /></a>
2198 </div>
2208 </div>
2199 <ul>
2209 <ul>
2200 <li><a href="/shortlog">log</a></li>
2210 <li><a href="/shortlog">log</a></li>
2201 <li><a href="/graph">graph</a></li>
2211 <li><a href="/graph">graph</a></li>
2202 <li><a href="/tags">tags</a></li>
2212 <li><a href="/tags">tags</a></li>
2203 <li><a href="/bookmarks">bookmarks</a></li>
2213 <li><a href="/bookmarks">bookmarks</a></li>
2204 <li><a href="/branches">branches</a></li>
2214 <li><a href="/branches">branches</a></li>
2205 </ul>
2215 </ul>
2206 <ul>
2216 <ul>
2207 <li class="active"><a href="/help">help</a></li>
2217 <li class="active"><a href="/help">help</a></li>
2208 </ul>
2218 </ul>
2209 </div>
2219 </div>
2210
2220
2211 <div class="main">
2221 <div class="main">
2212 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2222 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2213 <h3>Help: revisions</h3>
2223 <h3>Help: revisions</h3>
2214
2224
2215 <form class="search" action="/log">
2225 <form class="search" action="/log">
2216
2226
2217 <p><input name="rev" id="search1" type="text" size="30" /></p>
2227 <p><input name="rev" id="search1" type="text" size="30" /></p>
2218 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2228 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2219 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2229 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2220 </form>
2230 </form>
2221 <div id="doc">
2231 <div id="doc">
2222 <h1>Specifying Single Revisions</h1>
2232 <h1>Specifying Single Revisions</h1>
2223 <p>
2233 <p>
2224 Mercurial supports several ways to specify individual revisions.
2234 Mercurial supports several ways to specify individual revisions.
2225 </p>
2235 </p>
2226 <p>
2236 <p>
2227 A plain integer is treated as a revision number. Negative integers are
2237 A plain integer is treated as a revision number. Negative integers are
2228 treated as sequential offsets from the tip, with -1 denoting the tip,
2238 treated as sequential offsets from the tip, with -1 denoting the tip,
2229 -2 denoting the revision prior to the tip, and so forth.
2239 -2 denoting the revision prior to the tip, and so forth.
2230 </p>
2240 </p>
2231 <p>
2241 <p>
2232 A 40-digit hexadecimal string is treated as a unique revision
2242 A 40-digit hexadecimal string is treated as a unique revision
2233 identifier.
2243 identifier.
2234 </p>
2244 </p>
2235 <p>
2245 <p>
2236 A hexadecimal string less than 40 characters long is treated as a
2246 A hexadecimal string less than 40 characters long is treated as a
2237 unique revision identifier and is referred to as a short-form
2247 unique revision identifier and is referred to as a short-form
2238 identifier. A short-form identifier is only valid if it is the prefix
2248 identifier. A short-form identifier is only valid if it is the prefix
2239 of exactly one full-length identifier.
2249 of exactly one full-length identifier.
2240 </p>
2250 </p>
2241 <p>
2251 <p>
2242 Any other string is treated as a bookmark, tag, or branch name. A
2252 Any other string is treated as a bookmark, tag, or branch name. A
2243 bookmark is a movable pointer to a revision. A tag is a permanent name
2253 bookmark is a movable pointer to a revision. A tag is a permanent name
2244 associated with a revision. A branch name denotes the tipmost open branch head
2254 associated with a revision. A branch name denotes the tipmost open branch head
2245 of that branch - or if they are all closed, the tipmost closed head of the
2255 of that branch - or if they are all closed, the tipmost closed head of the
2246 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2256 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2247 </p>
2257 </p>
2248 <p>
2258 <p>
2249 The reserved name &quot;tip&quot; always identifies the most recent revision.
2259 The reserved name &quot;tip&quot; always identifies the most recent revision.
2250 </p>
2260 </p>
2251 <p>
2261 <p>
2252 The reserved name &quot;null&quot; indicates the null revision. This is the
2262 The reserved name &quot;null&quot; indicates the null revision. This is the
2253 revision of an empty repository, and the parent of revision 0.
2263 revision of an empty repository, and the parent of revision 0.
2254 </p>
2264 </p>
2255 <p>
2265 <p>
2256 The reserved name &quot;.&quot; indicates the working directory parent. If no
2266 The reserved name &quot;.&quot; indicates the working directory parent. If no
2257 working directory is checked out, it is equivalent to null. If an
2267 working directory is checked out, it is equivalent to null. If an
2258 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2268 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2259 parent.
2269 parent.
2260 </p>
2270 </p>
2261
2271
2262 </div>
2272 </div>
2263 </div>
2273 </div>
2264 </div>
2274 </div>
2265
2275
2266 <script type="text/javascript">process_dates()</script>
2276 <script type="text/javascript">process_dates()</script>
2267
2277
2268
2278
2269 </body>
2279 </body>
2270 </html>
2280 </html>
2271
2281
2272
2282
2273 $ killdaemons.py
2283 $ killdaemons.py
2274
2284
2275 #endif
2285 #endif
General Comments 0
You need to be logged in to leave comments. Login now