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