##// END OF EJS Templates
releasenotes: use stringutil.wrap() instead of handcrafted TextWrapper wrapper...
Yuya Nishihara -
r40279:96e50dfd default
parent child Browse files
Show More
@@ -16,7 +16,6 b' from __future__ import absolute_import'
16 16 import difflib
17 17 import errno
18 18 import re
19 import textwrap
20 19
21 20 from mercurial.i18n import _
22 21 from mercurial import (
@@ -29,6 +28,9 b' from mercurial import ('
29 28 scmutil,
30 29 util,
31 30 )
31 from mercurial.utils import (
32 stringutil,
33 )
32 34
33 35 cmdtable = {}
34 36 command = registrar.command(cmdtable)
@@ -58,20 +60,6 b" RE_ISSUE = br'\\bissue ?[0-9]{4,6}(?![0-9"
58 60
59 61 BULLET_SECTION = _('Other Changes')
60 62
61 if pycompat.ispy3:
62 class byteswrapper(object):
63 def __init__(self, **kwargs):
64 for k in kwargs:
65 v = kwargs[k]
66 if not isinstance(v, str) and isinstance(v, bytes):
67 kwargs[k] = v.decode('utf8')
68 self._tw = textwrap.TextWrapper(**kwargs)
69 def wrap(self, data):
70 return [
71 l.encode('utf8') for l in self._tw.wrap(data.decode('utf8'))]
72 else:
73 byteswrapper = textwrap.TextWrapper
74
75 63 class parsedreleasenotes(object):
76 64 def __init__(self):
77 65 self.sections = {}
@@ -457,11 +445,11 b' def serializenotes(sections, notes):'
457 445 lines.append('-' * len(title))
458 446 lines.append('')
459 447
460 wrapper = byteswrapper(width=78)
461 448 for i, para in enumerate(paragraphs):
462 449 if i:
463 450 lines.append('')
464 lines.extend(wrapper.wrap(' '.join(para)))
451 lines.extend(stringutil.wrap(' '.join(para),
452 width=78).splitlines())
465 453
466 454 lines.append('')
467 455
@@ -479,17 +467,17 b' def serializenotes(sections, notes):'
479 467 lines.append('')
480 468
481 469 for paragraphs in nontitled:
482 wrapper = byteswrapper(initial_indent='* ',
483 subsequent_indent=' ',
484 width=78)
485 lines.extend(wrapper.wrap(' '.join(paragraphs[0])))
470 lines.extend(stringutil.wrap(' '.join(paragraphs[0]),
471 width=78,
472 initindent='* ',
473 hangindent=' ').splitlines())
486 474
487 wrapper = byteswrapper(initial_indent=' ',
488 subsequent_indent=' ',
489 width=78)
490 475 for para in paragraphs[1:]:
491 476 lines.append('')
492 lines.extend(wrapper.wrap(' '.join(para)))
477 lines.extend(stringutil.wrap(' '.join(para),
478 width=78,
479 initindent=' ',
480 hangindent=' ').splitlines())
493 481
494 482 lines.append('')
495 483
General Comments 0
You need to be logged in to leave comments. Login now