+# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2011 The Chromium OS Authors.
#
-# SPDX-License-Identifier: GPL-2.0+
-#
+
+from __future__ import print_function
import itertools
import os
import get_maintainer
import gitutil
+import settings
import terminal
# Series-xxx tags that we understand
# Otherwise just set the value
elif name in valid_series:
- self[name] = value
+ if name=="notes":
+ self[name] = [value]
+ else:
+ self[name] = value
else:
raise ValueError("In %s: line '%s': Unknown 'Series-%s': valid "
"options are %s" % (commit.hash, line, name,
cc_set = set(gitutil.BuildEmailList(self.cc));
col = terminal.Color()
- print 'Dry run, so not doing much. But I would do this:'
- print
- print 'Send a total of %d patch%s with %scover letter.' % (
+ print('Dry run, so not doing much. But I would do this:')
+ print()
+ print('Send a total of %d patch%s with %scover letter.' % (
len(args), '' if len(args) == 1 else 'es',
- self.get('cover') and 'a ' or 'no ')
+ self.get('cover') and 'a ' or 'no '))
# TODO: Colour the patches according to whether they passed checks
for upto in range(len(args)):
commit = self.commits[upto]
- print col.Color(col.GREEN, ' %s' % args[upto])
+ print(col.Color(col.GREEN, ' %s' % args[upto]))
cc_list = list(self._generated_cc[commit.patch])
for email in set(cc_list) - to_set - cc_set:
if email == None:
email = col.Color(col.YELLOW, "<alias '%s' not found>"
% tag)
if email:
- print ' Cc: ',email
+ print(' Cc: ', email)
print
for item in to_set:
- print 'To:\t ', item
+ print('To:\t ', item)
for item in cc_set - to_set:
- print 'Cc:\t ', item
- print 'Version: ', self.get('version')
- print 'Prefix:\t ', self.get('prefix')
+ print('Cc:\t ', item)
+ print('Version: ', self.get('version'))
+ print('Prefix:\t ', self.get('prefix'))
if self.cover:
- print 'Cover: %d lines' % len(self.cover)
+ print('Cover: %d lines' % len(self.cover))
cover_cc = gitutil.BuildEmailList(self.get('cover_cc', ''))
all_ccs = itertools.chain(cover_cc, *self._generated_cc.values())
for email in set(all_ccs) - to_set - cc_set:
- print ' Cc: ',email
+ print(' Cc: ', email)
if cmd:
- print 'Git command: %s' % cmd
+ print('Git command: %s' % cmd)
def MakeChangeLog(self, commit):
"""Create a list of changes for each version.
else:
if version > 1:
str = 'Change log missing for v%d' % version
- print col.Color(col.RED, str)
+ print(col.Color(col.RED, str))
for version in changes_copy:
str = 'Change log for unknown version v%d' % version
- print col.Color(col.RED, str)
+ print(col.Color(col.RED, str))
elif self.changes:
str = 'Change log exists, but no version is set'
- print col.Color(col.RED, str)
+ print(col.Color(col.RED, str))
def MakeCcFile(self, process_tags, cover_fname, raise_on_error,
add_maintainers):
cover_fname: If non-None the name of the cover letter.
raise_on_error: True to raise an error when an alias fails to match,
False to just print a message.
- add_maintainers: Call the get_maintainers to CC maintainers
+ add_maintainers: Either:
+ True/False to call the get_maintainers to CC maintainers
+ List of maintainers to include (for testing)
Return:
Filename of temp file created
"""
+ col = terminal.Color()
# Look for commit tags (of the form 'xxx:' at the start of the subject)
fname = '/tmp/patman.%d' % os.getpid()
fd = open(fname, 'w')
all_ccs = []
for commit in self.commits:
- list = []
+ cc = []
if process_tags:
- list += gitutil.BuildEmailList(commit.tags,
+ cc += gitutil.BuildEmailList(commit.tags,
raise_on_error=raise_on_error)
- list += gitutil.BuildEmailList(commit.cc_list,
+ cc += gitutil.BuildEmailList(commit.cc_list,
raise_on_error=raise_on_error)
- if add_maintainers:
- list += get_maintainer.GetMaintainer(commit.patch)
- all_ccs += list
- print >>fd, commit.patch, ', '.join(set(list))
- self._generated_cc[commit.patch] = list
+ if type(add_maintainers) == type(cc):
+ cc += add_maintainers
+ elif add_maintainers:
+ cc += get_maintainer.GetMaintainer(commit.patch)
+ for x in set(cc) & set(settings.bounces):
+ print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
+ cc = set(cc) - set(settings.bounces)
+ cc = [m.encode('utf-8') if type(m) != str else m for m in cc]
+ all_ccs += cc
+ print(commit.patch, ', '.join(set(cc)), file=fd)
+ self._generated_cc[commit.patch] = cc
if cover_fname:
cover_cc = gitutil.BuildEmailList(self.get('cover_cc', ''))
- print >>fd, cover_fname, ', '.join(set(cover_cc + all_ccs))
+ cover_cc = [m.encode('utf-8') if type(m) != str else m
+ for m in cover_cc]
+ cc_list = ', '.join([x.decode('utf-8')
+ for x in set(cover_cc + all_ccs)])
+ print(cover_fname, cc_list.encode('utf-8'), file=fd)
fd.close()
return fname
"""
git_prefix = gitutil.GetDefaultSubjectPrefix()
if git_prefix:
- git_prefix = '%s][' % git_prefix
+ git_prefix = '%s][' % git_prefix
else:
git_prefix = ''