# HG changeset patch # User Martin Geisler # Date 2009-12-13 21:37:30 # Node ID 6f30c35766d6dd69fc7f9075c2dd099d832fae67 # Parent a46478b80ea3f946d061677f035a2a4d649e615d minirst: don't test regexps twice We know the regexps match since splitparagraphs used them too. diff --git a/mercurial/minirst.py b/mercurial/minirst.py --- a/mercurial/minirst.py +++ b/mercurial/minirst.py @@ -226,20 +226,17 @@ def formatblock(block, width): initindent = subindent = indent if block['type'] == 'bullet': m = _bulletre.match(block['lines'][0]) - if m: - subindent = indent + m.end() * ' ' + subindent = indent + m.end() * ' ' elif block['type'] == 'field': m = _fieldre.match(block['lines'][0]) - if m: - key, spaces, rest = m.groups() - # Turn ":foo: bar" into "foo bar". - block['lines'][0] = '%s %s%s' % (key, spaces, rest) - subindent = indent + (2 + len(key) + len(spaces)) * ' ' + key, spaces, rest = m.groups() + # Turn ":foo: bar" into "foo bar". + block['lines'][0] = '%s %s%s' % (key, spaces, rest) + subindent = indent + (2 + len(key) + len(spaces)) * ' ' elif block['type'] == 'option': m = _optionre.match(block['lines'][0]) - if m: - option, arg, rest = m.groups() - subindent = indent + (len(option) + len(arg)) * ' ' + option, arg, rest = m.groups() + subindent = indent + (len(option) + len(arg)) * ' ' text = ' '.join(map(str.strip, block['lines'])) return textwrap.fill(text, width=width,