Show More
@@ -3950,13 +3950,16 b' def remove(ui, repo, *pats, **opts):' | |||||
3950 | file states (columns) and option combinations (rows). The file |
|
3950 | file states (columns) and option combinations (rows). The file | |
3951 | states are Added [A], Clean [C], Modified [M] and Missing [!] (as |
|
3951 | states are Added [A], Clean [C], Modified [M] and Missing [!] (as | |
3952 | reported by :hg:`status`). The actions are Warn, Remove (from |
|
3952 | reported by :hg:`status`). The actions are Warn, Remove (from | |
3953 |
branch) and Delete (from disk): |
|
3953 | branch) and Delete (from disk): | |
3954 |
|
3954 | |||
|
3955 | ======= == == == == | |||
3955 | A C M ! |
|
3956 | A C M ! | |
|
3957 | ======= == == == == | |||
3956 | none W RD W R |
|
3958 | none W RD W R | |
3957 | -f R RD RD R |
|
3959 | -f R RD RD R | |
3958 | -A W W W R |
|
3960 | -A W W W R | |
3959 | -Af R R R R |
|
3961 | -Af R R R R | |
|
3962 | ======= == == == == | |||
3960 |
|
3963 | |||
3961 | Note that remove never deletes files in Added [A] state from the |
|
3964 | Note that remove never deletes files in Added [A] state from the | |
3962 | working directory, not even if option --force is specified. |
|
3965 | working directory, not even if option --force is specified. |
@@ -103,6 +103,7 b' def findliteralblocks(blocks):' | |||||
103 | r'((.*) +)(.*)$') |
|
103 | r'((.*) +)(.*)$') | |
104 | _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)') |
|
104 | _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)') | |
105 | _definitionre = re.compile(r'[^ ]') |
|
105 | _definitionre = re.compile(r'[^ ]') | |
|
106 | _tablere = re.compile(r'(=+\s+)*=+') | |||
106 |
|
107 | |||
107 | def splitparagraphs(blocks): |
|
108 | def splitparagraphs(blocks): | |
108 | """Split paragraphs into lists.""" |
|
109 | """Split paragraphs into lists.""" | |
@@ -251,6 +252,46 b' def prunecontainers(blocks, keep):' | |||||
251 |
|
252 | |||
252 | _sectionre = re.compile(r"""^([-=`:.'"~^_*+#])\1+$""") |
|
253 | _sectionre = re.compile(r"""^([-=`:.'"~^_*+#])\1+$""") | |
253 |
|
254 | |||
|
255 | def findtables(blocks): | |||
|
256 | '''Find simple tables | |||
|
257 | ||||
|
258 | Only simple one-line table elements are supported | |||
|
259 | ''' | |||
|
260 | ||||
|
261 | for block in blocks: | |||
|
262 | # Searching for a block that looks like this: | |||
|
263 | # | |||
|
264 | # === ==== === | |||
|
265 | # A B C | |||
|
266 | # === ==== === <- optional | |||
|
267 | # 1 2 3 | |||
|
268 | # x y z | |||
|
269 | # === ==== === | |||
|
270 | if (block['type'] == 'paragraph' and | |||
|
271 | len(block['lines']) > 4 and | |||
|
272 | _tablere.match(block['lines'][0]) and | |||
|
273 | block['lines'][0] == block['lines'][-1]): | |||
|
274 | block['type'] = 'table' | |||
|
275 | block['header'] = False | |||
|
276 | div = block['lines'][0] | |||
|
277 | columns = [x for x in xrange(len(div)) | |||
|
278 | if div[x] == '=' and (x == 0 or div[x - 1] == ' ')] | |||
|
279 | rows = [] | |||
|
280 | for l in block['lines'][1:-1]: | |||
|
281 | if l == div: | |||
|
282 | block['header'] = True | |||
|
283 | continue | |||
|
284 | row = [] | |||
|
285 | for n, start in enumerate(columns): | |||
|
286 | if n + 1 < len(columns): | |||
|
287 | row.append(l[start:columns[n + 1]].strip()) | |||
|
288 | else: | |||
|
289 | row.append(l[start:].strip()) | |||
|
290 | rows.append(row) | |||
|
291 | block['table'] = rows | |||
|
292 | ||||
|
293 | return blocks | |||
|
294 | ||||
254 | def findsections(blocks): |
|
295 | def findsections(blocks): | |
255 | """Finds sections. |
|
296 | """Finds sections. | |
256 |
|
297 | |||
@@ -392,6 +433,24 b' def formatblock(block, width):' | |||||
392 | if block['type'] == 'section': |
|
433 | if block['type'] == 'section': | |
393 | underline = encoding.colwidth(block['lines'][0]) * block['underline'] |
|
434 | underline = encoding.colwidth(block['lines'][0]) * block['underline'] | |
394 | return "%s%s\n%s%s" % (indent, block['lines'][0],indent, underline) |
|
435 | return "%s%s\n%s%s" % (indent, block['lines'][0],indent, underline) | |
|
436 | if block['type'] == 'table': | |||
|
437 | table = block['table'] | |||
|
438 | # compute column widths | |||
|
439 | widths = [max([encoding.colwidth(e) for e in c]) for c in zip(*table)] | |||
|
440 | text = '' | |||
|
441 | span = sum(widths) + len(widths) - 1 | |||
|
442 | indent = ' ' * block['indent'] | |||
|
443 | hang = ' ' * (len(indent) + span - widths[-1]) | |||
|
444 | f = ' '.join('%%-%ds' % n for n in widths) | |||
|
445 | ||||
|
446 | for row in table: | |||
|
447 | l = f % tuple(row) | |||
|
448 | l = util.wrap(l, width=width, initindent=indent, hangindent=hang) | |||
|
449 | if not text and block['header']: | |||
|
450 | text = l + '\n' + indent + '-' * (min(width, span)) + '\n' | |||
|
451 | else: | |||
|
452 | text += l + "\n" | |||
|
453 | return text | |||
395 | if block['type'] == 'definition': |
|
454 | if block['type'] == 'definition': | |
396 | term = indent + block['lines'][0] |
|
455 | term = indent + block['lines'][0] | |
397 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) |
|
456 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) | |
@@ -440,6 +499,7 b' def parse(text, indent=0, keep=None):' | |||||
440 | for b in blocks: |
|
499 | for b in blocks: | |
441 | b['indent'] += indent |
|
500 | b['indent'] += indent | |
442 | blocks = findliteralblocks(blocks) |
|
501 | blocks = findliteralblocks(blocks) | |
|
502 | blocks = findtables(blocks) | |||
443 | blocks, pruned = prunecontainers(blocks, keep or []) |
|
503 | blocks, pruned = prunecontainers(blocks, keep or []) | |
444 | blocks = findsections(blocks) |
|
504 | blocks = findsections(blocks) | |
445 | blocks = inlineliterals(blocks) |
|
505 | blocks = inlineliterals(blocks) |
@@ -231,3 +231,15 b' Empty comment above' | |||||
231 | """ |
|
231 | """ | |
232 |
|
232 | |||
233 | debugformat('comments', comments, 30) |
|
233 | debugformat('comments', comments, 30) | |
|
234 | ||||
|
235 | table = """ | |||
|
236 | === === === | |||
|
237 | a b c | |||
|
238 | === === === | |||
|
239 | 1 2 3 | |||
|
240 | foo bar baz | |||
|
241 | aa bb sdfsdfsdf this line is way too long for this cell. | |||
|
242 | === === === | |||
|
243 | """ | |||
|
244 | ||||
|
245 | debugformat('table', table, 30) |
@@ -388,3 +388,15 b' Some text.' | |||||
388 | Empty comment above |
|
388 | Empty comment above | |
389 | ---------------------------------------------------------------------- |
|
389 | ---------------------------------------------------------------------- | |
390 |
|
390 | |||
|
391 | table formatted to fit within 30 characters: | |||
|
392 | ---------------------------------------------------------------------- | |||
|
393 | a b c | |||
|
394 | ------------------------------ | |||
|
395 | 1 2 3 | |||
|
396 | foo bar baz | |||
|
397 | aa bb sdfsdfsdf this line | |||
|
398 | is way too long for | |||
|
399 | this cell. | |||
|
400 | ||||
|
401 | ---------------------------------------------------------------------- | |||
|
402 |
General Comments 0
You need to be logged in to leave comments.
Login now