From: Simon Glass Date: Tue, 14 May 2019 21:53:51 +0000 (-0600) Subject: patman: Sort series output for repeatabily X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=b644c66f693c82750077b6f7530dde79f2ad7523;p=u-boot.git patman: Sort series output for repeatabily We use sets to produce the list of To and Cc lines for a series. This does not result in stable ordering of the recipients. Sort each list to ensure that the output is repeatable. This is necessary for tests. Signed-off-by: Simon Glass --- diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 2c4392dbc1..f7d5ad68f6 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -183,10 +183,10 @@ class TestFunctional(unittest.TestCase): self.assertEqual('Prefix:\t RFC', lines[line + 3]) self.assertEqual('Cover: 4 lines', lines[line + 4]) line += 5 - self.assertEqual(' Cc: %s' % mel.encode('utf-8'), lines[line + 0]) - self.assertEqual(' Cc: %s' % rick, lines[line + 1]) - self.assertEqual(' Cc: %s' % fred, lines[line + 2]) - self.assertEqual(' Cc: %s' % ed.encode('utf-8'), lines[line + 3]) + self.assertEqual(' Cc: %s' % fred, lines[line + 0]) + self.assertEqual(' Cc: %s' % ed.encode('utf-8'), lines[line + 1]) + self.assertEqual(' Cc: %s' % mel.encode('utf-8'), lines[line + 2]) + self.assertEqual(' Cc: %s' % rick, lines[line + 3]) expected = ('Git command: git send-email --annotate ' '--in-reply-to="%s" --to "u-boot@lists.denx.de" ' '--cc "%s" --cc-cmd "%s --cc-cmd %s" %s %s' @@ -197,8 +197,8 @@ class TestFunctional(unittest.TestCase): self.assertEqual(('%s %s, %s' % (args[0], rick, stefan)) .encode('utf-8'), cc_lines[0]) - self.assertEqual(('%s %s, %s, %s, %s' % (args[1], fred, rick, stefan, - ed)).encode('utf-8'), cc_lines[1]) + self.assertEqual(('%s %s, %s, %s, %s' % (args[1], fred, ed, rick, + stefan)).encode('utf-8'), cc_lines[1]) expected = ''' This is a test of how the cover diff --git a/tools/patman/series.py b/tools/patman/series.py index 0b71a896cb..bbb30d849e 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -115,16 +115,16 @@ class Series(dict): commit = self.commits[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: + for email in sorted(set(cc_list) - to_set - cc_set): if email == None: email = col.Color(col.YELLOW, "" % tag) if email: print(' Cc: ', email) print - for item in to_set: + for item in sorted(to_set): print('To:\t ', item) - for item in cc_set - to_set: + for item in sorted(cc_set - to_set): print('Cc:\t ', item) print('Version: ', self.get('version')) print('Prefix:\t ', self.get('prefix')) @@ -132,7 +132,7 @@ class Series(dict): 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: + for email in sorted(set(all_ccs) - to_set - cc_set): print(' Cc: ', email) if cmd: print('Git command: %s' % cmd) @@ -243,7 +243,7 @@ class Series(dict): if limit is not None: cc = cc[:limit] all_ccs += cc - print(commit.patch, ', '.join(set(cc)), file=fd) + print(commit.patch, ', '.join(sorted(set(cc))), file=fd) self._generated_cc[commit.patch] = cc if cover_fname: @@ -251,7 +251,7 @@ class Series(dict): cover_cc = [m.encode('utf-8') if type(m) != str else m for m in cover_cc] cc_list = ', '.join([tools.ToUnicode(x) - for x in set(cover_cc + all_ccs)]) + for x in sorted(set(cover_cc + all_ccs))]) print(cover_fname, cc_list.encode('utf-8'), file=fd) fd.close()