Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 2 | # Copyright (c) 2011 The Chromium OS Authors. |
| 3 | # |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 4 | |
Sean Anderson | 48f46d6 | 2020-05-04 16:28:34 -0400 | [diff] [blame] | 5 | from __future__ import print_function |
| 6 | |
| 7 | import collections |
Simon Glass | 620639c | 2023-03-08 10:52:54 -0800 | [diff] [blame] | 8 | import concurrent.futures |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 9 | import itertools |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 10 | import os |
Simon Glass | 620639c | 2023-03-08 10:52:54 -0800 | [diff] [blame] | 11 | import sys |
| 12 | import time |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 13 | |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 14 | from patman import get_maintainer |
| 15 | from patman import gitutil |
| 16 | from patman import settings |
Simon Glass | 131444f | 2023-02-23 18:18:04 -0700 | [diff] [blame] | 17 | from u_boot_pylib import terminal |
| 18 | from u_boot_pylib import tools |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 19 | |
| 20 | # Series-xxx tags that we understand |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 21 | valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name', |
Sean Anderson | dc1cd13 | 2021-10-22 19:07:04 -0400 | [diff] [blame] | 22 | 'cover_cc', 'process_log', 'links', 'patchwork_url', 'postfix'] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 23 | |
| 24 | class Series(dict): |
| 25 | """Holds information about a patch series, including all tags. |
| 26 | |
| 27 | Vars: |
| 28 | cc: List of aliases/emails to Cc all patches to |
| 29 | commits: List of Commit objects, one for each patch |
| 30 | cover: List of lines in the cover letter |
| 31 | notes: List of lines in the notes |
| 32 | changes: (dict) List of changes for each version, The key is |
| 33 | the integer version number |
Simon Glass | 29c5abc | 2013-05-02 14:46:02 +0000 | [diff] [blame] | 34 | allow_overwrite: Allow tags to overwrite an existing tag |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 35 | """ |
| 36 | def __init__(self): |
| 37 | self.cc = [] |
| 38 | self.to = [] |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 39 | self.cover_cc = [] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 40 | self.commits = [] |
| 41 | self.cover = None |
| 42 | self.notes = [] |
| 43 | self.changes = {} |
Simon Glass | 29c5abc | 2013-05-02 14:46:02 +0000 | [diff] [blame] | 44 | self.allow_overwrite = False |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 45 | |
Doug Anderson | 507e8e8 | 2012-12-03 14:40:42 +0000 | [diff] [blame] | 46 | # Written in MakeCcFile() |
| 47 | # key: name of patch file |
| 48 | # value: list of email addresses |
| 49 | self._generated_cc = {} |
| 50 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 51 | # These make us more like a dictionary |
| 52 | def __setattr__(self, name, value): |
| 53 | self[name] = value |
| 54 | |
| 55 | def __getattr__(self, name): |
| 56 | return self[name] |
| 57 | |
| 58 | def AddTag(self, commit, line, name, value): |
| 59 | """Add a new Series-xxx tag along with its value. |
| 60 | |
| 61 | Args: |
| 62 | line: Source line containing tag (useful for debug/error messages) |
| 63 | name: Tag name (part after 'Series-') |
| 64 | value: Tag value (part after 'Series-xxx: ') |
Simon Glass | 8093a8f | 2020-10-29 21:46:25 -0600 | [diff] [blame] | 65 | |
| 66 | Returns: |
| 67 | String warning if something went wrong, else None |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 68 | """ |
| 69 | # If we already have it, then add to our list |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 70 | name = name.replace('-', '_') |
Simon Glass | 29c5abc | 2013-05-02 14:46:02 +0000 | [diff] [blame] | 71 | if name in self and not self.allow_overwrite: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 72 | values = value.split(',') |
| 73 | values = [str.strip() for str in values] |
| 74 | if type(self[name]) != type([]): |
| 75 | raise ValueError("In %s: line '%s': Cannot add another value " |
| 76 | "'%s' to series '%s'" % |
| 77 | (commit.hash, line, values, self[name])) |
| 78 | self[name] += values |
| 79 | |
| 80 | # Otherwise just set the value |
| 81 | elif name in valid_series: |
Albert ARIBAUD | 77ec8bc | 2016-02-02 10:24:53 +0100 | [diff] [blame] | 82 | if name=="notes": |
| 83 | self[name] = [value] |
| 84 | else: |
| 85 | self[name] = value |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 86 | else: |
Simon Glass | 8093a8f | 2020-10-29 21:46:25 -0600 | [diff] [blame] | 87 | return ("In %s: line '%s': Unknown 'Series-%s': valid " |
Simon Glass | e7ecd3f | 2012-09-27 15:06:02 +0000 | [diff] [blame] | 88 | "options are %s" % (commit.hash, line, name, |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 89 | ', '.join(valid_series))) |
Simon Glass | 8093a8f | 2020-10-29 21:46:25 -0600 | [diff] [blame] | 90 | return None |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 91 | |
| 92 | def AddCommit(self, commit): |
| 93 | """Add a commit into our list of commits |
| 94 | |
| 95 | We create a list of tags in the commit subject also. |
| 96 | |
| 97 | Args: |
| 98 | commit: Commit object to add |
| 99 | """ |
Simon Glass | 530ac27 | 2022-01-29 14:14:07 -0700 | [diff] [blame] | 100 | commit.check_tags() |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 101 | self.commits.append(commit) |
| 102 | |
| 103 | def ShowActions(self, args, cmd, process_tags): |
| 104 | """Show what actions we will/would perform |
| 105 | |
| 106 | Args: |
| 107 | args: List of patch files we created |
| 108 | cmd: The git command we would have run |
| 109 | process_tags: Process tags as if they were aliases |
| 110 | """ |
Simon Glass | 761648b | 2022-01-29 14:14:11 -0700 | [diff] [blame] | 111 | to_set = set(gitutil.build_email_list(self.to)); |
| 112 | cc_set = set(gitutil.build_email_list(self.cc)); |
Peter Tyser | c6af802 | 2015-01-26 11:42:21 -0600 | [diff] [blame] | 113 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 114 | col = terminal.Color() |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 115 | print('Dry run, so not doing much. But I would do this:') |
| 116 | print() |
| 117 | print('Send a total of %d patch%s with %scover letter.' % ( |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 118 | len(args), '' if len(args) == 1 else 'es', |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 119 | self.get('cover') and 'a ' or 'no ')) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 120 | |
| 121 | # TODO: Colour the patches according to whether they passed checks |
| 122 | for upto in range(len(args)): |
| 123 | commit = self.commits[upto] |
Simon Glass | f45d374 | 2022-01-29 14:14:17 -0700 | [diff] [blame] | 124 | print(col.build(col.GREEN, ' %s' % args[upto])) |
Doug Anderson | 507e8e8 | 2012-12-03 14:40:42 +0000 | [diff] [blame] | 125 | cc_list = list(self._generated_cc[commit.patch]) |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 126 | for email in sorted(set(cc_list) - to_set - cc_set): |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 127 | if email == None: |
Simon Glass | 547cba6 | 2022-02-11 13:23:18 -0700 | [diff] [blame] | 128 | email = col.build(col.YELLOW, '<alias not found>') |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 129 | if email: |
Simon Glass | 22c5834 | 2017-05-29 15:31:23 -0600 | [diff] [blame] | 130 | print(' Cc: ', email) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 131 | print |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 132 | for item in sorted(to_set): |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 133 | print('To:\t ', item) |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 134 | for item in sorted(cc_set - to_set): |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 135 | print('Cc:\t ', item) |
| 136 | print('Version: ', self.get('version')) |
| 137 | print('Prefix:\t ', self.get('prefix')) |
Sean Anderson | dc1cd13 | 2021-10-22 19:07:04 -0400 | [diff] [blame] | 138 | print('Postfix:\t ', self.get('postfix')) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 139 | if self.cover: |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 140 | print('Cover: %d lines' % len(self.cover)) |
Simon Glass | 761648b | 2022-01-29 14:14:11 -0700 | [diff] [blame] | 141 | cover_cc = gitutil.build_email_list(self.get('cover_cc', '')) |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 142 | all_ccs = itertools.chain(cover_cc, *self._generated_cc.values()) |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 143 | for email in sorted(set(all_ccs) - to_set - cc_set): |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 144 | print(' Cc: ', email) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 145 | if cmd: |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 146 | print('Git command: %s' % cmd) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 147 | |
| 148 | def MakeChangeLog(self, commit): |
| 149 | """Create a list of changes for each version. |
| 150 | |
| 151 | Return: |
| 152 | The change log as a list of strings, one per line |
| 153 | |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 154 | Changes in v4: |
Otavio Salvador | cc1fbaa | 2012-08-18 07:46:04 +0000 | [diff] [blame] | 155 | - Jog the dial back closer to the widget |
| 156 | |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 157 | Changes in v2: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 158 | - Fix the widget |
| 159 | - Jog the dial |
| 160 | |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 161 | If there are no new changes in a patch, a note will be added |
| 162 | |
| 163 | (no changes since v2) |
| 164 | |
| 165 | Changes in v2: |
| 166 | - Fix the widget |
| 167 | - Jog the dial |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 168 | """ |
Sean Anderson | 48f46d6 | 2020-05-04 16:28:34 -0400 | [diff] [blame] | 169 | # Collect changes from the series and this commit |
| 170 | changes = collections.defaultdict(list) |
| 171 | for version, changelist in self.changes.items(): |
| 172 | changes[version] += changelist |
| 173 | if commit: |
| 174 | for version, changelist in commit.changes.items(): |
| 175 | changes[version] += [[commit, text] for text in changelist] |
| 176 | |
| 177 | versions = sorted(changes, reverse=True) |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 178 | newest_version = 1 |
| 179 | if 'version' in self: |
| 180 | newest_version = max(newest_version, int(self.version)) |
| 181 | if versions: |
| 182 | newest_version = max(newest_version, versions[0]) |
| 183 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 184 | final = [] |
Simon Glass | ec1d042 | 2013-03-26 13:09:44 +0000 | [diff] [blame] | 185 | process_it = self.get('process_log', '').split(',') |
| 186 | process_it = [item.strip() for item in process_it] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 187 | need_blank = False |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 188 | for version in versions: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 189 | out = [] |
Sean Anderson | 48f46d6 | 2020-05-04 16:28:34 -0400 | [diff] [blame] | 190 | for this_commit, text in changes[version]: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 191 | if commit and this_commit != commit: |
| 192 | continue |
Simon Glass | ec1d042 | 2013-03-26 13:09:44 +0000 | [diff] [blame] | 193 | if 'uniq' not in process_it or text not in out: |
| 194 | out.append(text) |
Simon Glass | ec1d042 | 2013-03-26 13:09:44 +0000 | [diff] [blame] | 195 | if 'sort' in process_it: |
| 196 | out = sorted(out) |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 197 | have_changes = len(out) > 0 |
| 198 | line = 'Changes in v%d:' % version |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 199 | if have_changes: |
| 200 | out.insert(0, line) |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 201 | if version < newest_version and len(final) == 0: |
| 202 | out.insert(0, '') |
| 203 | out.insert(0, '(no changes since v%d)' % version) |
| 204 | newest_version = 0 |
| 205 | # Only add a new line if we output something |
| 206 | if need_blank: |
| 207 | out.insert(0, '') |
| 208 | need_blank = False |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 209 | final += out |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 210 | need_blank = need_blank or have_changes |
| 211 | |
| 212 | if len(final) > 0: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 213 | final.append('') |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 214 | elif newest_version != 1: |
| 215 | final = ['(no changes since v1)', ''] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 216 | return final |
| 217 | |
| 218 | def DoChecks(self): |
| 219 | """Check that each version has a change log |
| 220 | |
| 221 | Print an error if something is wrong. |
| 222 | """ |
| 223 | col = terminal.Color() |
| 224 | if self.get('version'): |
| 225 | changes_copy = dict(self.changes) |
Otavio Salvador | fe07d07 | 2012-08-13 10:08:22 +0000 | [diff] [blame] | 226 | for version in range(1, int(self.version) + 1): |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 227 | if self.changes.get(version): |
| 228 | del changes_copy[version] |
| 229 | else: |
Otavio Salvador | fe07d07 | 2012-08-13 10:08:22 +0000 | [diff] [blame] | 230 | if version > 1: |
| 231 | str = 'Change log missing for v%d' % version |
Simon Glass | f45d374 | 2022-01-29 14:14:17 -0700 | [diff] [blame] | 232 | print(col.build(col.RED, str)) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 233 | for version in changes_copy: |
| 234 | str = 'Change log for unknown version v%d' % version |
Simon Glass | f45d374 | 2022-01-29 14:14:17 -0700 | [diff] [blame] | 235 | print(col.build(col.RED, str)) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 236 | elif self.changes: |
| 237 | str = 'Change log exists, but no version is set' |
Simon Glass | f45d374 | 2022-01-29 14:14:17 -0700 | [diff] [blame] | 238 | print(col.build(col.RED, str)) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 239 | |
Simon Glass | 77f57df | 2023-03-08 10:52:53 -0800 | [diff] [blame] | 240 | def GetCcForCommit(self, commit, process_tags, warn_on_error, |
| 241 | add_maintainers, limit, get_maintainer_script, |
| 242 | all_skips): |
| 243 | """Get the email CCs to use with a particular commit |
| 244 | |
| 245 | Uses subject tags and get_maintainers.pl script to find people to cc |
| 246 | on a patch |
| 247 | |
| 248 | Args: |
| 249 | commit (Commit): Commit to process |
| 250 | process_tags (bool): Process tags as if they were aliases |
| 251 | warn_on_error (bool): True to print a warning when an alias fails to |
| 252 | match, False to ignore it. |
| 253 | add_maintainers (bool or list of str): Either: |
| 254 | True/False to call the get_maintainers to CC maintainers |
| 255 | List of maintainers to include (for testing) |
| 256 | limit (int): Limit the length of the Cc list (None if no limit) |
| 257 | get_maintainer_script (str): The file name of the get_maintainer.pl |
| 258 | script (or compatible). |
| 259 | all_skips (set of str): Updated to include the set of bouncing email |
| 260 | addresses that were dropped from the output. This is essentially |
| 261 | a return value from this function. |
| 262 | |
| 263 | Returns: |
| 264 | list of str: List of email addresses to cc |
| 265 | """ |
| 266 | cc = [] |
| 267 | if process_tags: |
| 268 | cc += gitutil.build_email_list(commit.tags, |
| 269 | warn_on_error=warn_on_error) |
| 270 | cc += gitutil.build_email_list(commit.cc_list, |
| 271 | warn_on_error=warn_on_error) |
| 272 | if type(add_maintainers) == type(cc): |
| 273 | cc += add_maintainers |
| 274 | elif add_maintainers: |
| 275 | cc += get_maintainer.get_maintainer(get_maintainer_script, |
| 276 | commit.patch) |
| 277 | all_skips |= set(cc) & set(settings.bounces) |
| 278 | cc = list(set(cc) - set(settings.bounces)) |
| 279 | if limit is not None: |
| 280 | cc = cc[:limit] |
| 281 | return cc |
| 282 | |
Simon Glass | 1f975b9 | 2021-01-23 08:56:15 -0700 | [diff] [blame] | 283 | def MakeCcFile(self, process_tags, cover_fname, warn_on_error, |
Maxim Cournoyer | 3ef23e9 | 2022-12-20 00:28:46 -0500 | [diff] [blame] | 284 | add_maintainers, limit, get_maintainer_script): |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 285 | """Make a cc file for us to use for per-commit Cc automation |
| 286 | |
Doug Anderson | 507e8e8 | 2012-12-03 14:40:42 +0000 | [diff] [blame] | 287 | Also stores in self._generated_cc to make ShowActions() faster. |
| 288 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 289 | Args: |
Simon Glass | 77f57df | 2023-03-08 10:52:53 -0800 | [diff] [blame] | 290 | process_tags (bool): Process tags as if they were aliases |
| 291 | cover_fname (str): If non-None the name of the cover letter. |
| 292 | warn_on_error (bool): True to print a warning when an alias fails to |
| 293 | match, False to ignore it. |
| 294 | add_maintainers (bool or list of str): Either: |
Simon Glass | b712eed | 2017-05-29 15:31:29 -0600 | [diff] [blame] | 295 | True/False to call the get_maintainers to CC maintainers |
| 296 | List of maintainers to include (for testing) |
Simon Glass | 77f57df | 2023-03-08 10:52:53 -0800 | [diff] [blame] | 297 | limit (int): Limit the length of the Cc list (None if no limit) |
| 298 | get_maintainer_script (str): The file name of the get_maintainer.pl |
Maxim Cournoyer | 3ef23e9 | 2022-12-20 00:28:46 -0500 | [diff] [blame] | 299 | script (or compatible). |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 300 | Return: |
| 301 | Filename of temp file created |
| 302 | """ |
Chris Packham | e8d2a12 | 2017-09-01 20:57:53 +1200 | [diff] [blame] | 303 | col = terminal.Color() |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 304 | # Look for commit tags (of the form 'xxx:' at the start of the subject) |
| 305 | fname = '/tmp/patman.%d' % os.getpid() |
Simon Glass | f544a2d | 2019-10-31 07:42:51 -0600 | [diff] [blame] | 306 | fd = open(fname, 'w', encoding='utf-8') |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 307 | all_ccs = [] |
Simon Glass | 77f57df | 2023-03-08 10:52:53 -0800 | [diff] [blame] | 308 | all_skips = set() |
Simon Glass | 620639c | 2023-03-08 10:52:54 -0800 | [diff] [blame] | 309 | with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor: |
| 310 | for i, commit in enumerate(self.commits): |
| 311 | commit.seq = i |
| 312 | commit.future = executor.submit( |
| 313 | self.GetCcForCommit, commit, process_tags, warn_on_error, |
| 314 | add_maintainers, limit, get_maintainer_script, all_skips) |
| 315 | |
| 316 | # Show progress any commits that are taking forever |
| 317 | lastlen = 0 |
| 318 | while True: |
| 319 | left = [commit for commit in self.commits |
| 320 | if not commit.future.done()] |
| 321 | if not left: |
| 322 | break |
| 323 | names = ', '.join(f'{c.seq + 1}:{c.subject}' |
| 324 | for c in left[:2]) |
| 325 | out = f'\r{len(left)} remaining: {names}'[:79] |
| 326 | spaces = ' ' * (lastlen - len(out)) |
| 327 | if lastlen: # Don't print anything the first time |
| 328 | print(out, spaces, end='') |
| 329 | sys.stdout.flush() |
| 330 | lastlen = len(out) |
| 331 | time.sleep(.25) |
| 332 | print(f'\rdone{" " * lastlen}\r', end='') |
| 333 | print('Cc processing complete') |
| 334 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 335 | for commit in self.commits: |
Simon Glass | 620639c | 2023-03-08 10:52:54 -0800 | [diff] [blame] | 336 | cc = commit.future.result() |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 337 | all_ccs += cc |
Dmitry Torokhov | ef7f67d | 2019-10-21 20:09:56 -0700 | [diff] [blame] | 338 | print(commit.patch, '\0'.join(sorted(set(cc))), file=fd) |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 339 | self._generated_cc[commit.patch] = cc |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 340 | |
Simon Glass | 77f57df | 2023-03-08 10:52:53 -0800 | [diff] [blame] | 341 | for x in sorted(all_skips): |
| 342 | print(col.build(col.YELLOW, f'Skipping "{x}"')) |
| 343 | |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 344 | if cover_fname: |
Simon Glass | 761648b | 2022-01-29 14:14:11 -0700 | [diff] [blame] | 345 | cover_cc = gitutil.build_email_list(self.get('cover_cc', '')) |
Simon Glass | 39ed6bb | 2020-02-27 18:49:23 -0700 | [diff] [blame] | 346 | cover_cc = list(set(cover_cc + all_ccs)) |
| 347 | if limit is not None: |
| 348 | cover_cc = cover_cc[:limit] |
Simon Glass | 9dfb311 | 2020-11-08 20:36:18 -0700 | [diff] [blame] | 349 | cc_list = '\0'.join([x for x in sorted(cover_cc)]) |
Robert Beckett | 3356f2c | 2019-11-13 18:39:45 +0000 | [diff] [blame] | 350 | print(cover_fname, cc_list, file=fd) |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 351 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 352 | fd.close() |
| 353 | return fname |
| 354 | |
| 355 | def AddChange(self, version, commit, info): |
| 356 | """Add a new change line to a version. |
| 357 | |
| 358 | This will later appear in the change log. |
| 359 | |
| 360 | Args: |
| 361 | version: version number to add change list to |
| 362 | info: change line for this version |
| 363 | """ |
| 364 | if not self.changes.get(version): |
| 365 | self.changes[version] = [] |
| 366 | self.changes[version].append([commit, info]) |
| 367 | |
| 368 | def GetPatchPrefix(self): |
| 369 | """Get the patch version string |
| 370 | |
| 371 | Return: |
| 372 | Patch string, like 'RFC PATCH v5' or just 'PATCH' |
| 373 | """ |
Simon Glass | 761648b | 2022-01-29 14:14:11 -0700 | [diff] [blame] | 374 | git_prefix = gitutil.get_default_subject_prefix() |
Wu, Josh | 9873b91 | 2015-04-15 10:25:18 +0800 | [diff] [blame] | 375 | if git_prefix: |
Paul Burton | a5edb44 | 2016-09-27 16:03:49 +0100 | [diff] [blame] | 376 | git_prefix = '%s][' % git_prefix |
Wu, Josh | 9873b91 | 2015-04-15 10:25:18 +0800 | [diff] [blame] | 377 | else: |
| 378 | git_prefix = '' |
| 379 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 380 | version = '' |
| 381 | if self.get('version'): |
| 382 | version = ' v%s' % self['version'] |
| 383 | |
| 384 | # Get patch name prefix |
| 385 | prefix = '' |
| 386 | if self.get('prefix'): |
| 387 | prefix = '%s ' % self['prefix'] |
Sean Anderson | dc1cd13 | 2021-10-22 19:07:04 -0400 | [diff] [blame] | 388 | |
| 389 | postfix = '' |
| 390 | if self.get('postfix'): |
| 391 | postfix = ' %s' % self['postfix'] |
| 392 | return '%s%sPATCH%s%s' % (git_prefix, prefix, postfix, version) |