annotate hgext/releasenotes.py @ 51676:031d66801d5f

typing: add a trivial type hint to `mercurial/posix.py` to avoid an @overload Since hg 3dbc7b1ecaba, pytype added an `@overload` for this function, without a type on the parameter. That's wrong, and undermines the hints on the non-trivial functions.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 10 Jul 2024 18:05:40 -0400
parents 9ed17632ad83
children f4733654f144
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 # Copyright 2017-present Gregory Szorc <gregory.szorc@gmail.com>
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2 #
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 # This software may be used and distributed according to the terms of the
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 # GNU General Public License version 2 or any later version.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 """generate release notes from commit messages (EXPERIMENTAL)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 It is common to maintain files detailing changes in a project between
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9 releases. Maintaining these files can be difficult and time consuming.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 The :hg:`releasenotes` command provided by this extension makes the
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 process simpler by automating it.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 """
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14
33881
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
15 import difflib
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 import re
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 from mercurial.i18n import _
43085
eef9a2d67051 py3: manually import pycompat.open into files that need it
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43077
diff changeset
19 from mercurial.pycompat import open
46113
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45055
diff changeset
20 from mercurial.node import hex
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 from mercurial import (
43898
023ad45e2fd2 releasenotes: extract helper for checking for incompatible arguments
Martin von Zweigbergk <martinvonz@google.com>
parents: 43117
diff changeset
22 cmdutil,
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
23 config,
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 error,
48116
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 47847
diff changeset
25 logcmdutil,
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 minirst,
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 registrar,
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
28 util,
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29 )
45055
4c1b4805db57 pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents: 44194
diff changeset
30 from mercurial.utils import (
4c1b4805db57 pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents: 44194
diff changeset
31 procutil,
4c1b4805db57 pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents: 44194
diff changeset
32 stringutil,
4c1b4805db57 pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents: 44194
diff changeset
33 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 cmdtable = {}
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 command = registrar.command(cmdtable)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37
34812
bc2caa4b4480 releasenotes: move import of fuzzywuzzy to import level
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34811
diff changeset
38 try:
47847
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
39 # Silence a warning about python-Levenshtein.
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
40 #
49851
a47e86e8fd51 releasenotes: fix a typo in a comment
Matt Harbison <matt_harbison@yahoo.com>
parents: 49849
diff changeset
41 # We don't need the performance that much and it gets annoying in tests.
47847
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
42 import warnings
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
43
47847
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
44 with warnings.catch_warnings():
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
45 warnings.filterwarnings(
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
46 action="ignore",
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
47 message=".*python-Levenshtein.*",
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
48 category=UserWarning,
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
49 module="fuzzywuzzy.fuzz",
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
50 )
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
51
49849
de9ffb82ef4d typing: suppress a bunch of potential import-error cases in extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 49519
diff changeset
52 import fuzzywuzzy.fuzz as fuzz # pytype: disable=import-error
47847
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
53
8843de648aed pyoxidized: silence the fuzzywuzzy warning about python-Levenshtein
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46639
diff changeset
54 fuzz.token_set_ratio
34812
bc2caa4b4480 releasenotes: move import of fuzzywuzzy to import level
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34811
diff changeset
55 except ImportError:
bc2caa4b4480 releasenotes: move import of fuzzywuzzy to import level
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34811
diff changeset
56 fuzz = None
bc2caa4b4480 releasenotes: move import of fuzzywuzzy to import level
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34811
diff changeset
57
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60 # be specifying the version(s) of Mercurial they are tested with, or
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 # leave the attribute unspecified.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
62 testedwith = b'ships-with-hg-core'
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64 DEFAULT_SECTIONS = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
65 (b'feature', _(b'New Features')),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
66 (b'bc', _(b'Backwards Compatibility Changes')),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
67 (b'fix', _(b'Bug Fixes')),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
68 (b'perf', _(b'Performance Improvements')),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
69 (b'api', _(b'API Changes')),
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70 ]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71
49519
943509a58d29 releasenotes: use re.MULTILINE mode when checking admonitions
Craig Ozancin <c.ozancin@gmail.com>
parents: 49306
diff changeset
72 RE_DIRECTIVE = re.compile(br'^\.\. ([a-zA-Z0-9_]+)::\s*([^$]+)?$', re.MULTILINE)
40235
a7cdd81f191b releasenotes: fix remaining bytes/unicode issues caught by tests
Augie Fackler <augie@google.com>
parents: 40234
diff changeset
73 RE_ISSUE = br'\bissue ?[0-9]{4,6}(?![0-9])\b'
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
75 BULLET_SECTION = _(b'Other Changes')
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
77
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48913
diff changeset
78 class parsedreleasenotes:
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79 def __init__(self):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
80 self.sections = {}
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
81
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
82 def __contains__(self, section):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
83 return section in self.sections
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
84
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
85 def __iter__(self):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
86 return iter(sorted(self.sections))
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
87
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
88 def addtitleditem(self, section, title, paragraphs):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
89 """Add a titled release note entry."""
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
90 self.sections.setdefault(section, ([], []))
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91 self.sections[section][0].append((title, paragraphs))
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
92
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
93 def addnontitleditem(self, section, paragraphs):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94 """Adds a non-titled release note entry.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
96 Will be rendered as a bullet point.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97 """
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
98 self.sections.setdefault(section, ([], []))
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99 self.sections[section][1].append(paragraphs)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
100
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 def titledforsection(self, section):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102 """Returns titled entries in a section.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
103
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104 Returns a list of (title, paragraphs) tuples describing sub-sections.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
105 """
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
106 return self.sections.get(section, ([], []))[0]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
107
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108 def nontitledforsection(self, section):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
109 """Returns non-titled, bulleted paragraphs in a section."""
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
110 return self.sections.get(section, ([], []))[1]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
111
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 def hastitledinsection(self, section, title):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
113 return any(t[0] == title for t in self.titledforsection(section))
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
114
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 def merge(self, ui, other):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
116 """Merge another instance into this one.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
117
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118 This is used to combine multiple sources of release notes together.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
119 """
34813
288fad8c55f9 releasenotes: show a warning if fuzzywuzzy is not present
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34812
diff changeset
120 if not fuzz:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
121 ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
122 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
123 b"module 'fuzzywuzzy' not found, merging of similar "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
124 b"releasenotes is disabled\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
125 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
126 )
34813
288fad8c55f9 releasenotes: show a warning if fuzzywuzzy is not present
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34812
diff changeset
127
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128 for section in other:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
129 existingnotes = converttitled(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
130 self.titledforsection(section)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
131 ) + convertnontitled(self.nontitledforsection(section))
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
132 for title, paragraphs in other.titledforsection(section):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133 if self.hastitledinsection(section, title):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134 # TODO prompt for resolution if different and running in
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135 # interactive mode.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
136 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
137 _(b'%s already exists in %s section; ignoring\n')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
138 % (title, section)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
139 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
140 continue
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
141
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
142 incoming_str = converttitled([(title, paragraphs)])[0]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
143 if section == b'fix':
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
144 issue = getissuenum(incoming_str)
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
145 if issue:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
146 if findissue(ui, existingnotes, issue):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
147 continue
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
148
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
149 if similar(ui, existingnotes, incoming_str):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
150 continue
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
151
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
152 self.addtitleditem(section, title, paragraphs)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
153
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
154 for paragraphs in other.nontitledforsection(section):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
155 if paragraphs in self.nontitledforsection(section):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
156 continue
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
157
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
158 incoming_str = convertnontitled([paragraphs])[0]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
159 if section == b'fix':
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
160 issue = getissuenum(incoming_str)
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
161 if issue:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
162 if findissue(ui, existingnotes, issue):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
163 continue
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
164
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
165 if similar(ui, existingnotes, incoming_str):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
166 continue
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
167
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 self.addnontitleditem(section, paragraphs)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
170
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48913
diff changeset
171 class releasenotessections:
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
172 def __init__(self, ui, repo=None):
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
173 if repo:
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
174 sections = util.sortdict(DEFAULT_SECTIONS)
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
175 custom_sections = getcustomadmonitions(repo)
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
176 if custom_sections:
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
177 sections.update(custom_sections)
48913
f254fc73d956 global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
178 self._sections = list(sections.items())
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
179 else:
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
180 self._sections = list(DEFAULT_SECTIONS)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
181
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
182 def __iter__(self):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183 return iter(self._sections)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
184
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
185 def names(self):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186 return [t[0] for t in self._sections]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
187
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 def sectionfromtitle(self, title):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189 for name, value in self._sections:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
190 if value == title:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
191 return name
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
192
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 return None
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
195
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
196 def converttitled(titledparagraphs):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
197 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
198 Convert titled paragraphs to strings
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
199 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
200 string_list = []
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
201 for title, paragraphs in titledparagraphs:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
202 lines = []
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
203 for para in paragraphs:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
204 lines.extend(para)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
205 string_list.append(b' '.join(lines))
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
206 return string_list
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
207
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
208
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
209 def convertnontitled(nontitledparagraphs):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
210 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
211 Convert non-titled bullets to strings
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
212 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
213 string_list = []
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
214 for paragraphs in nontitledparagraphs:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
215 lines = []
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
216 for para in paragraphs:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
217 lines.extend(para)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
218 string_list.append(b' '.join(lines))
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
219 return string_list
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
220
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
221
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
222 def getissuenum(incoming_str):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
223 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
224 Returns issue number from the incoming string if it exists
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
225 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
226 issue = re.search(RE_ISSUE, incoming_str, re.IGNORECASE)
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
227 if issue:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
228 issue = issue.group()
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
229 return issue
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
230
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
231
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
232 def findissue(ui, existing, issue):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
233 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
234 Returns true if issue number already exists in notes.
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
235 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
236 if any(issue in s for s in existing):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
237 ui.write(_(b'"%s" already exists in notes; ignoring\n') % issue)
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
238 return True
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
239 else:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
240 return False
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
241
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
242
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
243 def similar(ui, existing, incoming_str):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
244 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
245 Returns true if similar note found in existing notes.
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
246 """
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
247 if len(incoming_str.split()) > 10:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
248 merge = similaritycheck(incoming_str, existing)
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
249 if not merge:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
250 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
251 _(b'"%s" already exists in notes file; ignoring\n')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
252 % incoming_str
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
253 )
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
254 return True
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
255 else:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
256 return False
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
257 else:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
258 return False
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
259
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
260
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
261 def similaritycheck(incoming_str, existingnotes):
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
262 """
34780
070ba789f4d0 releasenotes: fix documentation of similaritycheck()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34736
diff changeset
263 Returns false when note fragment can be merged to existing notes.
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
264 """
34812
bc2caa4b4480 releasenotes: move import of fuzzywuzzy to import level
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34811
diff changeset
265 # fuzzywuzzy not present
bc2caa4b4480 releasenotes: move import of fuzzywuzzy to import level
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34811
diff changeset
266 if not fuzz:
34810
44bd29168d14 releasenotes: make the import of fuzzywuzzy optional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34780
diff changeset
267 return True
44bd29168d14 releasenotes: make the import of fuzzywuzzy optional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34780
diff changeset
268
33698
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
269 merge = True
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
270 for bullet in existingnotes:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
271 score = fuzz.token_set_ratio(incoming_str, bullet)
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
272 if score > 75:
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
273 merge = False
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
274 break
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
275 return merge
3748098d072a releasenotes: add similarity check function to compare incoming notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33571
diff changeset
276
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
277
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
278 def getcustomadmonitions(repo):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
279 ctx = repo[b'.']
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
280 p = config.config()
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
281
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
282 def read(f, sections=None, remap=None):
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
283 if f in ctx:
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
284 data = ctx[f].data()
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
285 p.parse(f, data, sections, remap, read)
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
286 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
287 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
288 _(b".hgreleasenotes file \'%s\' not found") % repo.pathto(f)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
289 )
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
290
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
291 if b'.hgreleasenotes' in ctx:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
292 read(b'.hgreleasenotes')
46639
88bd085cf2f8 releasenotes: use the right API to access the 'sections'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
293 return p.items(b'sections')
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
294
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
295
33881
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
296 def checkadmonitions(ui, repo, directives, revs):
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
297 """
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
298 Checks the commit messages for admonitions and their validity.
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
299
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
300 .. abcd::
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
301
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
302 First paragraph under this admonition
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
303
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
304 For this commit message, using `hg releasenotes -r . --check`
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
305 returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
306
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
307 As admonition 'abcd' is neither present in default nor custom admonitions
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
308 """
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
309 for rev in revs:
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
310 ctx = repo[rev]
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
311 admonition = re.search(RE_DIRECTIVE, ctx.description())
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
312 if admonition:
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
313 if admonition.group(1) in directives:
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
314 continue
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
315 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
316 ui.write(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43105
diff changeset
317 _(b"Invalid admonition '%s' present in changeset %s\n")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
318 % (admonition.group(1), ctx.hex()[:12])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
319 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
320 sim = lambda x: difflib.SequenceMatcher(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
321 None, admonition.group(1), x
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
322 ).ratio()
33881
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
323
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
324 similar = [s for s in directives if sim(s) > 0.6]
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
325 if len(similar) == 1:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
326 ui.write(_(b"(did you mean %s?)\n") % similar[0])
33881
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
327 elif similar:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
328 ss = b", ".join(sorted(similar))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
329 ui.write(_(b"(did you mean one of %s?)\n") % ss)
33881
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
330
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
331
33940
2a37459aedf2 releasenotes: view admonition titles using -l flag
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33881
diff changeset
332 def _getadmonitionlist(ui, sections):
2a37459aedf2 releasenotes: view admonition titles using -l flag
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33881
diff changeset
333 for section in sections:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
334 ui.write(b"%s: %s\n" % (section[0], section[1]))
33940
2a37459aedf2 releasenotes: view admonition titles using -l flag
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33881
diff changeset
335
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
336
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
337 def parsenotesfromrevisions(repo, directives, revs):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
338 notes = parsedreleasenotes()
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
339
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
340 for rev in revs:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
341 ctx = repo[rev]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
342
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
343 blocks, pruned = minirst.parse(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
344 ctx.description(), admonitions=directives
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
345 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
346
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
347 for i, block in enumerate(blocks):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
348 if block[b'type'] != b'admonition':
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
349 continue
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
350
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
351 directive = block[b'admonitiontitle']
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
352 title = block[b'lines'][0].strip() if block[b'lines'] else None
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
353
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
354 if i + 1 == len(blocks):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
355 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
356 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
357 b'changeset %s: release notes directive %s '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
358 b'lacks content'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
359 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
360 % (ctx, directive)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
361 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
362
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
363 # Now search ahead and find all paragraphs attached to this
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
364 # admonition.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
365 paragraphs = []
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
366 for j in range(i + 1, len(blocks)):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
367 pblock = blocks[j]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
368
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
369 # Margin blocks may appear between paragraphs. Ignore them.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
370 if pblock[b'type'] == b'margin':
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
371 continue
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
372
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
373 if pblock[b'type'] == b'admonition':
36770
a5891e94bfe1 releasenotes: allow notes for multiple directives in a single changeset
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 36769
diff changeset
374 break
a5891e94bfe1 releasenotes: allow notes for multiple directives in a single changeset
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 36769
diff changeset
375
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
376 if pblock[b'type'] != b'paragraph':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
377 repo.ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
378 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
379 b'changeset %s: unexpected block in release '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
380 b'notes directive %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
381 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
382 % (ctx, directive)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
383 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
384
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
385 if pblock[b'indent'] > 0:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
386 paragraphs.append(pblock[b'lines'])
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
387 else:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
388 break
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
389
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
390 # TODO consider using title as paragraph for more concise notes.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
391 if not paragraphs:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
392 repo.ui.warn(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43105
diff changeset
393 _(b"error parsing releasenotes for revision: '%s'\n")
46113
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45055
diff changeset
394 % hex(ctx.node())
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
395 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
396 if title:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
397 notes.addtitleditem(directive, title, paragraphs)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
398 else:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
399 notes.addnontitleditem(directive, paragraphs)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
400
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
401 return notes
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
402
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
403
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
404 def parsereleasenotesfile(sections, text):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
405 """Parse text content containing generated release notes."""
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
406 notes = parsedreleasenotes()
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
407
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
408 blocks = minirst.parse(text)[0]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
409
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
410 def gatherparagraphsbullets(offset, title=False):
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
411 notefragment = []
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
412
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
413 for i in range(offset + 1, len(blocks)):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
414 block = blocks[i]
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
415
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
416 if block[b'type'] == b'margin':
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
417 continue
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
418 elif block[b'type'] == b'section':
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
419 break
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
420 elif block[b'type'] == b'bullet':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
421 if block[b'indent'] != 0:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
422 raise error.Abort(_(b'indented bullet lists not supported'))
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
423 if title:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
424 lines = [l[1:].strip() for l in block[b'lines']]
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
425 notefragment.append(lines)
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
426 continue
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
427 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
428 lines = [[l[1:].strip() for l in block[b'lines']]]
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
429
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
430 for block in blocks[i + 1 :]:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
431 if block[b'type'] in (b'bullet', b'section'):
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
432 break
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
433 if block[b'type'] == b'paragraph':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
434 lines.append(block[b'lines'])
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
435 notefragment.append(lines)
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
436 continue
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
437 elif block[b'type'] != b'paragraph':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
438 raise error.Abort(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43105
diff changeset
439 _(b'unexpected block type in release notes: %s')
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
440 % block[b'type']
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
441 )
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
442 if title:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
443 notefragment.append(block[b'lines'])
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
444
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
445 return notefragment
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
446
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
447 currentsection = None
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
448 for i, block in enumerate(blocks):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
449 if block[b'type'] != b'section':
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
450 continue
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
451
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
452 title = block[b'lines'][0]
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
453
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
454 # TODO the parsing around paragraphs and bullet points needs some
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
455 # work.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
456 if block[b'underline'] == b'=': # main section
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
457 name = sections.sectionfromtitle(title)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
458 if not name:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
459 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
460 _(b'unknown release notes section: %s') % title
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
461 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
462
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
463 currentsection = name
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
464 bullet_points = gatherparagraphsbullets(i)
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
465 if bullet_points:
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
466 for para in bullet_points:
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
467 notes.addnontitleditem(currentsection, para)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
468
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
469 elif block[b'underline'] == b'-': # sub-section
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
470 if title == BULLET_SECTION:
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
471 bullet_points = gatherparagraphsbullets(i)
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
472 for para in bullet_points:
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
473 notes.addnontitleditem(currentsection, para)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
474 else:
33012
5814db57941c releasenotes: improve parsing around bullet points
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 32778
diff changeset
475 paragraphs = gatherparagraphsbullets(i, True)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
476 notes.addtitleditem(currentsection, title, paragraphs)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
477 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
478 raise error.Abort(_(b'unsupported section type for %s') % title)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
479
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
480 return notes
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
481
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
482
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
483 def serializenotes(sections, notes):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
484 """Serialize release notes from parsed fragments and notes.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
485
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
486 This function essentially takes the output of ``parsenotesfromrevisions()``
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
487 and ``parserelnotesfile()`` and produces output combining the 2.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
488 """
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
489 lines = []
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
490
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
491 for sectionname, sectiontitle in sections:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
492 if sectionname not in notes:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
493 continue
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
494
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
495 lines.append(sectiontitle)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
496 lines.append(b'=' * len(sectiontitle))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
497 lines.append(b'')
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
498
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
499 # First pass to emit sub-sections.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
500 for title, paragraphs in notes.titledforsection(sectionname):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
501 lines.append(title)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
502 lines.append(b'-' * len(title))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
503 lines.append(b'')
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
504
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
505 for i, para in enumerate(paragraphs):
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
506 if i:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
507 lines.append(b'')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
508 lines.extend(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
509 stringutil.wrap(b' '.join(para), width=78).splitlines()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
510 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
511
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
512 lines.append(b'')
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
513
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
514 # Second pass to emit bullet list items.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
515
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
516 # If the section has titled and non-titled items, we can't
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
517 # simply emit the bullet list because it would appear to come
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
518 # from the last title/section. So, we emit a new sub-section
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
519 # for the non-titled items.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
520 nontitled = notes.nontitledforsection(sectionname)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
521 if notes.titledforsection(sectionname) and nontitled:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
522 # TODO make configurable.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
523 lines.append(BULLET_SECTION)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
524 lines.append(b'-' * len(BULLET_SECTION))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
525 lines.append(b'')
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
526
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
527 for paragraphs in nontitled:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
528 lines.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
529 stringutil.wrap(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
530 b' '.join(paragraphs[0]),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
531 width=78,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
532 initindent=b'* ',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
533 hangindent=b' ',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
534 ).splitlines()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
535 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
536
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
537 for para in paragraphs[1:]:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
538 lines.append(b'')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
539 lines.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
540 stringutil.wrap(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
541 b' '.join(para),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
542 width=78,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
543 initindent=b' ',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
544 hangindent=b' ',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
545 ).splitlines()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
546 )
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
547
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
548 lines.append(b'')
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
549
33784
589fda7895da releasenotes: minor bug fix for index error while serializing
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33698
diff changeset
550 if lines and lines[-1]:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
551 lines.append(b'')
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
552
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
553 return b'\n'.join(lines)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
554
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
555
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
556 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
557 b'releasenotes',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
558 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
559 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
560 b'r',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
561 b'rev',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
562 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
563 _(b'revisions to process for release notes'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
564 _(b'REV'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
565 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
566 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
567 b'c',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
568 b'check',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
569 False,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
570 _(b'checks for validity of admonitions (if any)'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
571 _(b'REV'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
572 ),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
573 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
574 b'l',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
575 b'list',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
576 False,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
577 _(b'list the available admonitions with their title'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
578 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
579 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
580 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
581 _(b'hg releasenotes [-r REV] [-c] FILE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
582 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
583 )
33881
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
584 def releasenotes(ui, repo, file_=None, **opts):
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
585 """parse release notes from commit messages into an output file
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
586
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
587 Given an output file and set of revisions, this command will parse commit
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
588 messages for release notes then add them to the output file.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
589
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
590 Release notes are defined in commit messages as ReStructuredText
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
591 directives. These have the form::
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
592
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
593 .. directive:: title
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
594
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
595 content
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
596
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
597 Each ``directive`` maps to an output section in a generated release notes
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
598 file, which itself is ReStructuredText. For example, the ``.. feature::``
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
599 directive would map to a ``New Features`` section.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
600
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
601 Release note directives can be either short-form or long-form. In short-
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
602 form, ``title`` is omitted and the release note is rendered as a bullet
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
603 list. In long form, a sub-section with the title ``title`` is added to the
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
604 section.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
605
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
606 The ``FILE`` argument controls the output file to write gathered release
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
607 notes to. The format of the file is::
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
608
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
609 Section 1
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
610 =========
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
611
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
612 ...
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
613
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
614 Section 2
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
615 =========
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
616
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
617 ...
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
618
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
619 Only sections with defined release notes are emitted.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
620
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
621 If a section only has short-form notes, it will consist of bullet list::
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
622
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
623 Section
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
624 =======
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
625
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
626 * Release note 1
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
627 * Release note 2
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
628
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
629 If a section has long-form notes, sub-sections will be emitted::
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
630
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
631 Section
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
632 =======
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
633
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
634 Note 1 Title
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
635 ------------
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
636
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
637 Description of the first long-form note.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
638
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
639 Note 2 Title
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
640 ------------
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
641
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
642 Description of the second long-form note.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
643
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
644 If the ``FILE`` argument points to an existing file, that file will be
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
645 parsed for release notes having the format that would be generated by this
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
646 command. The notes from the processed commit messages will be *merged*
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
647 into this parsed set.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
648
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
649 During release notes merging:
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
650
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
651 * Duplicate items are automatically ignored
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
652 * Items that are different are automatically ignored if the similarity is
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
653 greater than a threshold.
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
654
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
655 This means that the release notes file can be updated independently from
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
656 this command and changes should not be lost when running this command on
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
657 that file. A particular use case for this is to tweak the wording of a
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
658 release note after it has been added to the release notes file.
34341
01e8ab4b6573 releasenotes: update docstrings with information on additional flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34340
diff changeset
659
01e8ab4b6573 releasenotes: update docstrings with information on additional flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34340
diff changeset
660 The -c/--check option checks the commit message for invalid admonitions.
01e8ab4b6573 releasenotes: update docstrings with information on additional flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34340
diff changeset
661
01e8ab4b6573 releasenotes: update docstrings with information on additional flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34340
diff changeset
662 The -l/--list option, presents the user with a list of existing available
01e8ab4b6573 releasenotes: update docstrings with information on additional flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34340
diff changeset
663 admonitions along with their title. This also includes the custom
01e8ab4b6573 releasenotes: update docstrings with information on additional flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34340
diff changeset
664 admonitions (if any).
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
665 """
35003
e68dd1909af3 py3: handle keyword arguments in hgext/releasenotes.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34813
diff changeset
666
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
667 sections = releasenotessections(ui, repo)
34340
741a511492d3 releasenotes: raise error on simultaneous usage of flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33940
diff changeset
668
50883
9ed17632ad83 releasenotes: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49851
diff changeset
669 cmdutil.check_incompatible_arguments(opts, 'list', ['rev', 'check'])
34340
741a511492d3 releasenotes: raise error on simultaneous usage of flags
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33940
diff changeset
670
50883
9ed17632ad83 releasenotes: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49851
diff changeset
671 if opts.get('list'):
33940
2a37459aedf2 releasenotes: view admonition titles using -l flag
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33881
diff changeset
672 return _getadmonitionlist(ui, sections)
2a37459aedf2 releasenotes: view admonition titles using -l flag
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33881
diff changeset
673
50883
9ed17632ad83 releasenotes: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49851
diff changeset
674 rev = opts.get('rev')
48116
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 47847
diff changeset
675 revs = logcmdutil.revrange(repo, [rev or b'not public()'])
50883
9ed17632ad83 releasenotes: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49851
diff changeset
676 if opts.get('check'):
33881
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
677 return checkadmonitions(ui, repo, sections.names(), revs)
6a49c74b1e8f releasenotes: add check flag for use of admonitions and its validity
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33784
diff changeset
678
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
679 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
680
34404
159a6f7e09a9 releasenotes: display release notes when no filename is specified
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34341
diff changeset
681 if file_ is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
682 ui.pager(b'releasenotes')
34404
159a6f7e09a9 releasenotes: display release notes when no filename is specified
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34341
diff changeset
683 return ui.write(serializenotes(sections, incoming))
159a6f7e09a9 releasenotes: display release notes when no filename is specified
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 34341
diff changeset
684
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
685 try:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
686 with open(file_, b'rb') as fh:
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
687 notes = parsereleasenotesfile(sections, fh.read())
49306
2e726c934fcd py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents: 48946
diff changeset
688 except FileNotFoundError:
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
689 notes = parsedreleasenotes()
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
690
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
691 notes.merge(ui, incoming)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
692
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
693 with open(file_, b'wb') as fh:
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
694 fh.write(serializenotes(sections, notes))
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
695
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
696
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
697 @command(b'debugparsereleasenotes', norepo=True)
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
698 def debugparsereleasenotes(ui, path, repo=None):
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
699 """parse release notes and print resulting data structure"""
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
700 if path == b'-':
45055
4c1b4805db57 pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents: 44194
diff changeset
701 text = procutil.stdin.read()
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
702 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
703 with open(path, b'rb') as fh:
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
704 text = fh.read()
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
705
33571
9a944e908ecf releasenotes: add custom admonitions support for release notes
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33012
diff changeset
706 sections = releasenotessections(ui, repo)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
707
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
708 notes = parsereleasenotesfile(sections, text)
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
709
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
710 for section in notes:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
711 ui.write(_(b'section: %s\n') % section)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
712 for title, paragraphs in notes.titledforsection(section):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
713 ui.write(_(b' subsection: %s\n') % title)
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
714 for para in paragraphs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
715 ui.write(_(b' paragraph: %s\n') % b' '.join(para))
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
716
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
717 for paragraphs in notes.nontitledforsection(section):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
718 ui.write(_(b' bullet point:\n'))
32778
91e355a0408b releasenotes: command to manage release notes files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
719 for para in paragraphs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
720 ui.write(_(b' paragraph: %s\n') % b' '.join(para))