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

login
register
mail settings
Submitter Doug Anderson
Date Dec. 4, 2012, 12:40 a.m.
Message ID <1354581643-32469-1-git-send-email-dianders@chromium.org>
Download mbox | patch
Permalink /patch/203521/
State Accepted
Commit d94566a1115d35f87db793d2daaa79823528937c
Delegated to: Simon Glass
Headers show

Comments

Doug Anderson - Dec. 4, 2012, 12:40 a.m.
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(-)
Simon Glass - Dec. 4, 2012, 12:54 a.m.
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>
Simon Glass - Jan. 31, 2013, 11:50 p.m.
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
>
Simon Glass - Jan. 31, 2013, 11:50 p.m.
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.

Patch

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