[U-Boot] [PATCH 1/2] patman: Cache the CC list from MakeCcFile() for use in ShowActions()

Currently we go through and generate the CC list for patches twice. This gets slow when (in a future CL) we add a call to get_maintainer.pl on Linux. Instead of doing things twice, just cache the CC list when it is first generated.
Signed-off-by: Doug Anderson dianders@chromium.org --- tools/patman/patman.py | 6 ++++-- tools/patman/series.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py index cfe06d0..de8314a 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -140,14 +140,16 @@ else: options.count + options.start): ok = False
+ cc_file = series.MakeCcFile(options.process_tags) + # Email the patches out (giving the user time to check / cancel) cmd = '' if ok or options.ignore_errors: - cc_file = series.MakeCcFile(options.process_tags) cmd = gitutil.EmailPatches(series, cover_fname, args, options.dry_run, cc_file) - os.remove(cc_file)
# For a dry run, just show our actions as a sanity check if options.dry_run: series.ShowActions(args, cmd, options.process_tags) + + os.remove(cc_file) diff --git a/tools/patman/series.py b/tools/patman/series.py index d2971f4..ad8288d 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -46,6 +46,11 @@ class Series(dict): self.notes = [] self.changes = {}
+ # Written in MakeCcFile() + # key: name of patch file + # value: list of email addresses + self._generated_cc = {} + # These make us more like a dictionary def __setattr__(self, name, value): self[name] = value @@ -109,10 +114,7 @@ class Series(dict): for upto in range(len(args)): commit = self.commits[upto] print col.Color(col.GREEN, ' %s' % args[upto]) - cc_list = [] - if process_tags: - cc_list += gitutil.BuildEmailList(commit.tags) - cc_list += gitutil.BuildEmailList(commit.cc_list) + cc_list = list(self._generated_cc[commit.patch])
# Skip items in To list if 'to' in self: @@ -202,6 +204,8 @@ class Series(dict): def MakeCcFile(self, process_tags): """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 Return: @@ -216,6 +220,7 @@ class Series(dict): list += gitutil.BuildEmailList(commit.tags) list += gitutil.BuildEmailList(commit.cc_list) print >>fd, commit.patch, ', '.join(list) + self._generated_cc[commit.patch] = list
fd.close() return fname

If we're sending a cover letter make sure to CC everyone that we're CCing on each of the individual patches.
Signed-off-by: Doug Anderson dianders@chromium.org --- tools/patman/patman.py | 2 +- tools/patman/series.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py index de8314a..4181d80 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -140,7 +140,7 @@ else: options.count + options.start): ok = False
- cc_file = series.MakeCcFile(options.process_tags) + cc_file = series.MakeCcFile(options.process_tags, cover_fname)
# Email the patches out (giving the user time to check / cancel) cmd = '' diff --git a/tools/patman/series.py b/tools/patman/series.py index ad8288d..083af0f 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -19,6 +19,7 @@ # MA 02111-1307 USA #
+import itertools import os
import gitutil @@ -138,6 +139,9 @@ class Series(dict): print 'Prefix:\t ', self.get('prefix') if self.cover: print 'Cover: %d lines' % len(self.cover) + all_ccs = itertools.chain(*self._generated_cc.values()) + for email in set(all_ccs): + print ' Cc: ',email if cmd: print 'Git command: %s' % cmd
@@ -201,27 +205,33 @@ class Series(dict): str = 'Change log exists, but no version is set' print col.Color(col.RED, str)
- def MakeCcFile(self, process_tags): + 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) + all_ccs += list print >>fd, commit.patch, ', '.join(list) self._generated_cc[commit.patch] = list
+ if cover_fname: + print >>fd, cover_fname, ', '.join(set(all_ccs)) + fd.close() return fname

On Fri, Nov 30, 2012 at 4:25 PM, Doug Anderson dianders@chromium.org wrote:
If we're sending a cover letter make sure to CC everyone that we're CCing on each of the individual patches.
Signed-off-by: Doug Anderson dianders@chromium.org
Looks good, but can you please add a note to the README under the 'Where Patches Are Sent' header which mentions where the cover letter is sent?
tools/patman/patman.py | 2 +- tools/patman/series.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py index de8314a..4181d80 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -140,7 +140,7 @@ else: options.count + options.start): ok = False
- cc_file = series.MakeCcFile(options.process_tags)
cc_file = series.MakeCcFile(options.process_tags, cover_fname)
# Email the patches out (giving the user time to check / cancel) cmd = ''
diff --git a/tools/patman/series.py b/tools/patman/series.py index ad8288d..083af0f 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -19,6 +19,7 @@ # MA 02111-1307 USA #
+import itertools import os
import gitutil @@ -138,6 +139,9 @@ class Series(dict): print 'Prefix:\t ', self.get('prefix') if self.cover: print 'Cover: %d lines' % len(self.cover)
all_ccs = itertools.chain(*self._generated_cc.values())
for email in set(all_ccs):
print ' Cc: ',email if cmd: print 'Git command: %s' % cmd
@@ -201,27 +205,33 @@ class Series(dict): str = 'Change log exists, but no version is set' print col.Color(col.RED, str)
- def MakeCcFile(self, process_tags):
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)
all_ccs += list print >>fd, commit.patch, ', '.join(list) self._generated_cc[commit.patch] = list
if cover_fname:
print >>fd, cover_fname, ', '.join(set(all_ccs))
fd.close() return fname
-- 1.7.7.3
Regards, Simon

Simon,
Thanks for the review!
On Mon, Dec 3, 2012 at 3:00 PM, Simon Glass sjg@chromium.org wrote:
On Fri, Nov 30, 2012 at 4:25 PM, Doug Anderson dianders@chromium.org wrote:
If we're sending a cover letter make sure to CC everyone that we're CCing on each of the individual patches.
Signed-off-by: Doug Anderson dianders@chromium.org
Looks good, but can you please add a note to the README under the 'Where Patches Are Sent' header which mentions where the cover letter is sent?
Good suggestion. Done.
tools/patman/patman.py | 2 +- tools/patman/series.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py index de8314a..4181d80 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -140,7 +140,7 @@ else: options.count + options.start): ok = False
- cc_file = series.MakeCcFile(options.process_tags)
cc_file = series.MakeCcFile(options.process_tags, cover_fname)
# Email the patches out (giving the user time to check / cancel) cmd = ''
diff --git a/tools/patman/series.py b/tools/patman/series.py index ad8288d..083af0f 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -19,6 +19,7 @@ # MA 02111-1307 USA #
+import itertools import os
import gitutil @@ -138,6 +139,9 @@ class Series(dict): print 'Prefix:\t ', self.get('prefix') if self.cover: print 'Cover: %d lines' % len(self.cover)
all_ccs = itertools.chain(*self._generated_cc.values())
for email in set(all_ccs):
print ' Cc: ',email if cmd: print 'Git command: %s' % cmd
@@ -201,27 +205,33 @@ class Series(dict): str = 'Change log exists, but no version is set' print col.Color(col.RED, str)
- def MakeCcFile(self, process_tags):
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)
all_ccs += list print >>fd, commit.patch, ', '.join(list) self._generated_cc[commit.patch] = list
if cover_fname:
print >>fd, cover_fname, ', '.join(set(all_ccs))
fd.close() return fname
-- 1.7.7.3
Regards, Simon

On Fri, Nov 30, 2012 at 4:25 PM, Doug Anderson dianders@chromium.org wrote:
Currently we go through and generate the CC list for patches twice. This gets slow when (in a future CL) we add a call to get_maintainer.pl on Linux. Instead of doing things twice, just cache the CC list when it is first generated.
Signed-off-by: Doug Anderson dianders@chromium.org\
Acked-by: Simon Glass sjg@chromium.org

Currently we go through and generate the CC list for patches twice. This gets slow when (in a future CL) we add a call to get_maintainer.pl on Linux. Instead of doing things twice, just cache the CC list when it is first generated.
Signed-off-by: Doug Anderson dianders@chromium.org --- Changes in v2: None
tools/patman/patman.py | 6 ++++-- tools/patman/series.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py index cfe06d0..de8314a 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -140,14 +140,16 @@ else: options.count + options.start): ok = False
+ cc_file = series.MakeCcFile(options.process_tags) + # Email the patches out (giving the user time to check / cancel) cmd = '' if ok or options.ignore_errors: - cc_file = series.MakeCcFile(options.process_tags) cmd = gitutil.EmailPatches(series, cover_fname, args, options.dry_run, cc_file) - os.remove(cc_file)
# For a dry run, just show our actions as a sanity check if options.dry_run: series.ShowActions(args, cmd, options.process_tags) + + os.remove(cc_file) diff --git a/tools/patman/series.py b/tools/patman/series.py index d2971f4..ad8288d 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -46,6 +46,11 @@ class Series(dict): self.notes = [] self.changes = {}
+ # Written in MakeCcFile() + # key: name of patch file + # value: list of email addresses + self._generated_cc = {} + # These make us more like a dictionary def __setattr__(self, name, value): self[name] = value @@ -109,10 +114,7 @@ class Series(dict): for upto in range(len(args)): commit = self.commits[upto] print col.Color(col.GREEN, ' %s' % args[upto]) - cc_list = [] - if process_tags: - cc_list += gitutil.BuildEmailList(commit.tags) - cc_list += gitutil.BuildEmailList(commit.cc_list) + cc_list = list(self._generated_cc[commit.patch])
# Skip items in To list if 'to' in self: @@ -202,6 +204,8 @@ class Series(dict): def MakeCcFile(self, process_tags): """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 Return: @@ -216,6 +220,7 @@ class Series(dict): list += gitutil.BuildEmailList(commit.tags) list += gitutil.BuildEmailList(commit.cc_list) print >>fd, commit.patch, ', '.join(list) + self._generated_cc[commit.patch] = list
fd.close() return fname

If we're sending a cover letter make sure to CC everyone that we're CCing on each of the individual patches.
Signed-off-by: Doug Anderson dianders@chromium.org --- Changes in v2: - Added requested comment in the README to document this.
tools/patman/README | 3 +++ tools/patman/patman.py | 2 +- tools/patman/series.py | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/patman/README b/tools/patman/README index dc3957c..5b6eba0 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -226,6 +226,9 @@ Date: Mon Nov 7 23:18:44 2011 -0500 will create a patch which is copied to x86, arm, sandbox, mikef, ag and afleming.
+If you have a cover letter it will get sent to the union of the CC lists of +all of the other patches. +
Example Work Flow ================= diff --git a/tools/patman/patman.py b/tools/patman/patman.py index de8314a..4181d80 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -140,7 +140,7 @@ else: options.count + options.start): ok = False
- cc_file = series.MakeCcFile(options.process_tags) + cc_file = series.MakeCcFile(options.process_tags, cover_fname)
# Email the patches out (giving the user time to check / cancel) cmd = '' diff --git a/tools/patman/series.py b/tools/patman/series.py index ad8288d..083af0f 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -19,6 +19,7 @@ # MA 02111-1307 USA #
+import itertools import os
import gitutil @@ -138,6 +139,9 @@ class Series(dict): print 'Prefix:\t ', self.get('prefix') if self.cover: print 'Cover: %d lines' % len(self.cover) + all_ccs = itertools.chain(*self._generated_cc.values()) + for email in set(all_ccs): + print ' Cc: ',email if cmd: print 'Git command: %s' % cmd
@@ -201,27 +205,33 @@ class Series(dict): str = 'Change log exists, but no version is set' print col.Color(col.RED, str)
- def MakeCcFile(self, process_tags): + 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) + all_ccs += list print >>fd, commit.patch, ', '.join(list) self._generated_cc[commit.patch] = list
+ if cover_fname: + print >>fd, cover_fname, ', '.join(set(all_ccs)) + fd.close() return fname

On Mon, Dec 3, 2012 at 4:40 PM, Doug Anderson dianders@chromium.org wrote:
If we're sending a cover letter make sure to CC everyone that we're CCing on each of the individual patches.
Signed-off-by: Doug Anderson dianders@chromium.org
Acked-by: Simon Glass sjg@chromium.org

On Tue, Dec 4, 2012 at 1:54 PM, Simon Glass sjg@chromium.org wrote:
On Mon, Dec 3, 2012 at 4:40 PM, Doug Anderson dianders@chromium.org wrote:
If we're sending a cover letter make sure to CC everyone that we're CCing on each of the individual patches.
Signed-off-by: Doug Anderson dianders@chromium.org
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-x86, thanks.

On Tue, Dec 4, 2012 at 1:40 PM, Doug Anderson dianders@chromium.org wrote:
Currently we go through and generate the CC list for patches twice. This gets slow when (in a future CL) we add a call to get_maintainer.pl on Linux. Instead of doing things twice, just cache the CC list when it is first generated.
Signed-off-by: Doug Anderson dianders@chromium.org
Changes in v2: None
Applied to u-boot-x86, thanks.
tools/patman/patman.py | 6 ++++-- tools/patman/series.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py index cfe06d0..de8314a 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -140,14 +140,16 @@ else: options.count + options.start): ok = False
- cc_file = series.MakeCcFile(options.process_tags)
- # Email the patches out (giving the user time to check / cancel) cmd = '' if ok or options.ignore_errors:
cc_file = series.MakeCcFile(options.process_tags) cmd = gitutil.EmailPatches(series, cover_fname, args, options.dry_run, cc_file)
os.remove(cc_file)
# For a dry run, just show our actions as a sanity check if options.dry_run: series.ShowActions(args, cmd, options.process_tags)
- os.remove(cc_file)
diff --git a/tools/patman/series.py b/tools/patman/series.py index d2971f4..ad8288d 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -46,6 +46,11 @@ class Series(dict): self.notes = [] self.changes = {}
# Written in MakeCcFile()
# key: name of patch file
# value: list of email addresses
self._generated_cc = {}
- # These make us more like a dictionary def __setattr__(self, name, value): self[name] = value
@@ -109,10 +114,7 @@ class Series(dict): for upto in range(len(args)): commit = self.commits[upto] print col.Color(col.GREEN, ' %s' % args[upto])
cc_list = []
if process_tags:
cc_list += gitutil.BuildEmailList(commit.tags)
cc_list += gitutil.BuildEmailList(commit.cc_list)
cc_list = list(self._generated_cc[commit.patch]) # Skip items in To list if 'to' in self:
@@ -202,6 +204,8 @@ class Series(dict): def MakeCcFile(self, process_tags): """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 Return:
@@ -216,6 +220,7 @@ class Series(dict): list += gitutil.BuildEmailList(commit.tags) list += gitutil.BuildEmailList(commit.cc_list) print >>fd, commit.patch, ', '.join(list)
self._generated_cc[commit.patch] = list fd.close() return fname
-- 1.7.7.3
participants (2)
-
Doug Anderson
-
Simon Glass