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