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