annotate contrib/relnotes @ 41720:6704696141b8

templates: adding a config() function for template customization This allows templates to be written such that users can customize them easily, or that they can be customized based on other configuration of the system. For enterprise deployments, we often have complex template aliases, and right now the only way individual users can customize those is by replacing the whole template alias (which means they won't get company-wide updates to it anymore, plus most users don't want to have to get a complex template right). With this change, they can just set a config option which feeds into our templates for common changes (e.g. whether to limit commit descriptions to the width of their terminal or not). To work around the issue of having to register the config options, I declared a dedicated section [templateconfig] for these options to be dynamically declared. They can still reference any other config option that's registered elsewhere. I only did string, bool and int at this time - list and date would add other complications with parsing the default so I'll leave that as an exercise to the reader :) Differential Revision: https://phab.mercurial-scm.org/D5959
author rdamazio@google.com
date Wed, 13 Feb 2019 18:34:08 -0800
parents 530d211ae9a8
children 99e231afc29c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
1 #!/usr/bin/env python3
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
2 """Generate release notes from our commit log.
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
3
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
4 This uses the relnotes extension directives when they're available,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
5 and falls back to our old pre-relnotes logic that used to live in the
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
6 release-tools repo.
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
7 """
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
8 import argparse
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
9 import re
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
10 import subprocess
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
11
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
12 rules = {
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
13 # keep
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
14 r"\(issue": 100,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
15 r"\(BC\)": 100,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
16 r"\(API\)": 100,
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
17 r"\(SEC\)": 100,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
18 # core commands, bump up
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
19 r"(commit|files|log|pull|push|patch|status|tag|summary)(|s|es):": 20,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
20 r"(annotate|alias|branch|bookmark|clone|graft|import|verify).*:": 20,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
21 # extensions, bump up
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
22 r"(mq|shelve|rebase):": 20,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
23 # newsy
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
24 r": deprecate": 20,
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
25 r": new.*(extension|flag|module)": 10,
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
26 r"( ability|command|feature|option|support)": 10,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
27 # experimental
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
28 r"hg-experimental": 20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
29 r"(from|graduate).*experimental": 15,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
30 r"(hide|mark).*experimental": -10,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
31 # bug-like?
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
32 r"(fix|don't break|improve)": 7,
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
33 r"(not|n't|avoid|fix|prevent).*crash": 10,
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
34 r"vulnerab": 10,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
35 # boring stuff, bump down
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
36 r"^contrib": -5,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
37 r"debug": -5,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
38 r"help": -5,
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
39 r"minor": -5,
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
40 r"(doc|metavar|bundle2|obsolete|obsmarker|rpm|setup|debug\S+:)": -15,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
41 r"(check-code|check-commit|check-config|import-checker)": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
42 r"(flake8|lintian|pyflakes|pylint)": -20,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
43 # cleanups and refactoring
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
44 r"(clean ?up|white ?space|spelling|quoting)": -20,
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
45 r"(flatten|dedent|indent|nesting|unnest)": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
46 r"(typo|hint|note|comment|TODO|FIXME)": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
47 r"(style:|convention|one-?liner)": -20,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
48 r"(argument|absolute_import|attribute|assignment|mutable)": -15,
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
49 r"(scope|True|False)": -10,
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
50 r"(unused|useless|unnecessar|superfluous|duplicate|deprecated)": -10,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
51 r"(redundant|pointless|confusing|uninitialized|meaningless|dead)": -10,
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
52 r": (drop|remove|delete|rip out)": -10,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
53 r": (inherit|rename|simplify|naming|inline)": -10,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
54 r"(correct doc|docstring|document .* method)": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
55 r"(abstract|factor|extract|prepare|split|replace| import)": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
56 r": add.*(function|method|implementation|example)": -10,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
57 r": (move|extract) .* (to|into|from|out of)": -20,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
58 r": implement ": -5,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
59 r": use .* implementation": -20,
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
60 r": use .* instead of": -20,
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
61 # code
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
62 r"_": -10,
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
63 r"__": -5,
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
64 r"\(\)": -5,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
65 r"\S\S\S+\.\S\S\S\S+": -5,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
66 # dumb keywords
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
67 r"\S+/\S+:": -10,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
68 r"\S+\.\S+:": -10,
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
69 # python compatibility
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
70 r"[Pp]y(|thon) ?[23]": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
71 r"pycompat": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
72 r"(coerce|convert|encode) .*to (byte|sys|)(s|str|string)": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
73 # tests
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
74 r"^test(|s|ing|runner|-\S+):": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
75 r"^(f|hghave|run-tests):": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
76 r"add.* tests?": -20,
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
77 r"(buildbot|fuzz|mock|ratchet)": -10,
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
78 # drop
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
79 r"^i18n-": -50,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
80 r"^i18n:.*(hint|comment)": -50,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
81 r"perf:": -50,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
82 r"Added.*for changeset": -50,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
83 r"^_": -50,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
84 }
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
85
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
86 cutoff = 10
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
87 commits = []
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
88
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
89 groupings = [
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
90 (r"util|parsers|repo|ctx|context|revlog|filelog|alias|cmdutil", "core"),
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
91 (r"revset|template|ui|dirstate|hook|i18n|transaction|wire|vfs", "core"),
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
92 (r"dispatch|exchange|localrepo|streamclone|color|pager", "core"),
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
93 (r"hgweb|paper|coal|gitweb|monoblue|spartan", "hgweb"),
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
94 (r"pull|push|revert|resolve|annotate|bookmark|branch|clone", "commands"),
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
95 (r"commands|commit|config|files|graft|import|log|merge|patch", "commands"),
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
96 (r"phases|status|summary|amend|tag|help|verify", "commands"),
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
97 (r"rebase|mq|convert|eol|histedit|largefiles", "extensions"),
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
98 (r"shelve|unshelve", "extensions"),
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
99 ]
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
100
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
101 def wikify(desc):
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
102 desc = desc.replace("(issue", "(Bts:issue")
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
103 desc = re.sub(r"\b([0-9a-f]{12})\b", r"Cset:\1", desc)
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
104 # stop ParseError from being recognized as a (nonexistent) wiki page
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
105 desc = re.sub(r" ([A-Z][a-z]+[A-Z][a-z]+)\b", r" !\1", desc)
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
106 # prevent wiki markup of magic methods
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
107 desc = re.sub(r"\b(\S*__\S*)\b", r"`\1`", desc)
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
108 return desc
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
109
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
110 def main():
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
111 desc = "example: %(prog)s 4.7.2 --stoprev 4.8rc0"
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
112 ap = argparse.ArgumentParser(description=desc)
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
113 ap.add_argument(
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
114 "startrev",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
115 metavar="REV",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
116 type=str,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
117 help=(
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
118 "Starting revision for the release notes. This revision "
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
119 "won't be included, but later revisions will."
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
120 ),
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
121 )
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
122 ap.add_argument(
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
123 "--stoprev",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
124 metavar="REV",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
125 type=str,
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
126 default="@",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
127 help=(
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
128 "Stop revision for release notes. This revision will be included,"
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
129 " but no later revisions will. This revision needs to be "
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
130 "a descendant of startrev."
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
131 ),
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
132 )
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
133 args = ap.parse_args()
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
134 fromext = subprocess.check_output(
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
135 [
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
136 "hg",
39365
659e2bbd0c20 relnotes: enable extension when running releasenotes command
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39352
diff changeset
137 "--config",
659e2bbd0c20 relnotes: enable extension when running releasenotes command
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39352
diff changeset
138 "extensions.releasenotes=",
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
139 "releasenotes",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
140 "-r",
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
141 "only(%s, %s)" % (args.stoprev, args.startrev),
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
142 ]
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
143 ).decode("utf-8")
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
144 # Find all release notes from un-relnotes-flagged commits.
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
145 for entry in sorted(
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
146 subprocess.check_output(
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
147 [
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
148 "hg",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
149 "log",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
150 "-r",
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
151 "only(%s, %s) - merge()" % (args.stoprev, args.startrev),
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
152 "-T",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
153 r"{desc|firstline}\n",
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
154 ]
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
155 )
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
156 .decode("utf-8")
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
157 .splitlines()
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
158 ):
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
159 desc = entry.replace("`", "'")
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
160
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
161 score = 0
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
162 for rule, val in rules.items():
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
163 if re.search(rule, desc):
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
164 score += val
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
165
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
166 if score >= cutoff:
41518
530d211ae9a8 relnotes: more improvements
Anton Shestakov <av6@dwimlabs.net>
parents: 40452
diff changeset
167 commits.append(wikify(desc))
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
168 # Group unflagged notes.
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
169 groups = {}
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
170 bcs = []
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
171 apis = []
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
172
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
173 for d in commits:
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
174 if "(BC)" in d:
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
175 bcs.append(d)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
176 if "(API)" in d:
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
177 apis.append(d)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
178 for rule, g in groupings:
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
179 if re.match(rule, d):
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
180 groups.setdefault(g, []).append(d)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
181 break
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
182 else:
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
183 groups.setdefault("unsorted", []).append(d)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
184 print(fromext)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
185 # print legacy release notes sections
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
186 for g in sorted(groups):
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
187 print("\n=== %s ===" % g)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
188 for d in sorted(groups[g]):
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
189 print(" * %s" % d)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
190
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
191 if bcs:
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
192 print("\n=== Behavior Changes ===\n")
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
193
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
194 for d in sorted(bcs):
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
195 print(" * %s" % d)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
196
40452
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
197 if apis:
683e99f0b30c relnotes: various tweaks for release notes
Anton Shestakov <av6@dwimlabs.net>
parents: 39365
diff changeset
198 print("\n=== Internal API Changes ===\n")
39352
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
199
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
200 for d in sorted(apis):
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
201 print(" * %s" % d)
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
202
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
203 if __name__ == "__main__":
035517d48865 contrib: import the relnotes script from the release-tools repo
Augie Fackler <augie@google.com>
parents:
diff changeset
204 main()