Commit 2181830f11c2bbfea31e5f3f957577a619fc3776

Authored by Peter Tyser
Committed by Simon Glass
1 parent 1f32ae9578

patman: Make dry-run output match real functionality

When run with the --dry-run argument patman prints out information
showing what it would do.  This information currently doesn't line up
with what patman/git send-email really do.  Some basic examples:
- If an email address is addressed via "Series-cc" and "Patch-cc" patman
  shows that email address would be CC-ed two times.
- If an email address is addressed via "Series-to" and "Patch-cc" patman
  shows that email address would be sent TO and CC-ed.
- If an email address is addressed from a combination of tag aliases,
  get_maintainer.pl output, "Series-cc", "Patch-cc", etc patman shows
  that the email address would be CC-ed multiple times.

Patman currently does try to send duplicate emails like the --dry-run
output shows, but "git send-email" intelligently removes duplicate
addresses so this patch shouldn't change the non-dry-run functionality.

Change patman's output and email addressing to line up with the
"git send-email" logic.  This trims down patman's dry-run output and
prevents confusion about what patman will do when emails are actually
sent.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 10 additions and 14 deletions Side-by-side Diff

tools/patman/gitutil.py
... ... @@ -392,7 +392,8 @@
392 392 "Or do something like this\n"
393 393 "git config sendemail.to u-boot@lists.denx.de")
394 394 return
395   - cc = BuildEmailList(series.get('cc'), '--cc', alias, raise_on_error)
  395 + cc = BuildEmailList(list(set(series.get('cc')) - set(series.get('to'))),
  396 + '--cc', alias, raise_on_error)
396 397 if self_only:
397 398 to = BuildEmailList([os.getenv('USER')], '--to', alias, raise_on_error)
398 399 cc = []
tools/patman/series.py
... ... @@ -94,6 +94,9 @@
94 94 cmd: The git command we would have run
95 95 process_tags: Process tags as if they were aliases
96 96 """
  97 + to_set = set(gitutil.BuildEmailList(self.to));
  98 + cc_set = set(gitutil.BuildEmailList(self.cc));
  99 +
97 100 col = terminal.Color()
98 101 print 'Dry run, so not doing much. But I would do this:'
99 102 print
100 103  
101 104  
... ... @@ -106,24 +109,16 @@
106 109 commit = self.commits[upto]
107 110 print col.Color(col.GREEN, ' %s' % args[upto])
108 111 cc_list = list(self._generated_cc[commit.patch])
109   -
110   - # Skip items in To list
111   - if 'to' in self:
112   - try:
113   - map(cc_list.remove, gitutil.BuildEmailList(self.to))
114   - except ValueError:
115   - pass
116   -
117   - for email in cc_list:
  112 + for email in set(cc_list) - to_set - cc_set:
118 113 if email == None:
119 114 email = col.Color(col.YELLOW, "<alias '%s' not found>"
120 115 % tag)
121 116 if email:
122 117 print ' Cc: ',email
123 118 print
124   - for item in gitutil.BuildEmailList(self.get('to', '<none>')):
  119 + for item in to_set:
125 120 print 'To:\t ', item
126   - for item in gitutil.BuildEmailList(self.cc):
  121 + for item in cc_set - to_set:
127 122 print 'Cc:\t ', item
128 123 print 'Version: ', self.get('version')
129 124 print 'Prefix:\t ', self.get('prefix')
... ... @@ -131,7 +126,7 @@
131 126 print 'Cover: %d lines' % len(self.cover)
132 127 cover_cc = gitutil.BuildEmailList(self.get('cover_cc', ''))
133 128 all_ccs = itertools.chain(cover_cc, *self._generated_cc.values())
134   - for email in set(all_ccs):
  129 + for email in set(all_ccs) - to_set - cc_set:
135 130 print ' Cc: ',email
136 131 if cmd:
137 132 print 'Git command: %s' % cmd
... ... @@ -230,7 +225,7 @@
230 225 if add_maintainers:
231 226 list += get_maintainer.GetMaintainer(commit.patch)
232 227 all_ccs += list
233   - print >>fd, commit.patch, ', '.join(list)
  228 + print >>fd, commit.patch, ', '.join(set(list))
234 229 self._generated_cc[commit.patch] = list
235 230  
236 231 if cover_fname: