def MakeCcFile(self, process_tags, cover_fname): """Make a cc file for us to use for per-commit Cc automation Also stores in self._generated_cc to make ShowActions() faster. Args: process_tags: Process tags as if they were aliases cover_fname: If non-None the name of the cover letter. Return: Filename of temp file created """ # 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 = [] if process_tags: list += gitutil.BuildEmailList(commit.tags) list += gitutil.BuildEmailList(commit.cc_list) list += get_maintainer.GetMaintainer(commit.patch) all_ccs += list print >> fd, commit.patch, ', '.join(list) self._generated_cc[commit.patch] = list if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) print >> fd, cover_fname, ', '.join(set(cover_cc + all_ccs)) fd.close() return fname
def MakeCcFile(self, process_tags, cover_fname, raise_on_error, add_maintainers, limit): """Make a cc file for us to use for per-commit Cc automation Also stores in self._generated_cc to make ShowActions() faster. Args: process_tags: Process tags as if they were aliases 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: Either: True/False to call the get_maintainers to CC maintainers List of maintainers to include (for testing) limit: Limit the length of the Cc list 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', encoding='utf-8') all_ccs = [] for commit in self.commits: cc = [] if process_tags: cc += gitutil.BuildEmailList(commit.tags, raise_on_error=raise_on_error) cc += gitutil.BuildEmailList(commit.cc_list, raise_on_error=raise_on_error) 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 = [tools.FromUnicode(m) for m in cc] if limit is not None: cc = cc[:limit] all_ccs += cc print(commit.patch, '\0'.join(sorted(set(cc))), file=fd) self._generated_cc[commit.patch] = cc if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) cover_cc = [tools.FromUnicode(m) for m in cover_cc] cover_cc = list(set(cover_cc + all_ccs)) if limit is not None: cover_cc = cover_cc[:limit] cc_list = '\0'.join([tools.ToUnicode(x) for x in sorted(cover_cc)]) print(cover_fname, cc_list, file=fd) fd.close() return fname
def MakeCcFile(self, process_tags, cover_fname, raise_on_error, add_maintainers): """Make a cc file for us to use for per-commit Cc automation Also stores in self._generated_cc to make ShowActions() faster. Args: process_tags: Process tags as if they were aliases 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: Either: True/False to call the get_maintainers to CC maintainers List of maintainers to include (for testing) Return: Filename of temp file created """ # 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: cc = [] if process_tags: cc += gitutil.BuildEmailList(commit.tags, raise_on_error=raise_on_error) cc += gitutil.BuildEmailList(commit.cc_list, raise_on_error=raise_on_error) if type(add_maintainers) == type(cc): cc += add_maintainers elif add_maintainers: cc += get_maintainer.GetMaintainer(commit.patch) 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', '')) 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
def MakeCcFile(self, process_tags, cover_fname, raise_on_error, add_maintainers): """Make a cc file for us to use for per-commit Cc automation Also stores in self._generated_cc to make ShowActions() faster. Args: process_tags: Process tags as if they were aliases 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 Return: Filename of temp file created """ # 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 = [] if process_tags: list += gitutil.BuildEmailList(commit.tags, raise_on_error=raise_on_error) list += gitutil.BuildEmailList(commit.cc_list, raise_on_error=raise_on_error) if add_maintainers: list += get_maintainer.GetMaintainer(commit.patch) all_ccs += list print(commit.patch, ', '.join(set(list)), file=fd) self._generated_cc[commit.patch] = list if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) print(cover_fname, ', '.join(set(cover_cc + all_ccs)), file=fd) fd.close() return fname