Skip to contentSkip to conversation

patman: add option for limiting the Cc list

PATCH New Chris Packham 2 participants 3 messages May 26, 2018 – May 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 patman: add option for limiting the Cc list

Many mailing-lists consider a long Cc list a sign of spam and will either drop the message or mark it for moderation. Because patman automatically invokes get_maintainer.pl the Cc list can expand unexpectedly. Allow the user to specify a limit for the Cc list.

This limit is applied after removing any known bouncing addresses. By default no limit is applied.

---
I've fallen foul of the u-boot ML Cc limit a few times recently. I'm not sure what the actual limit is so I've left patman's default behaviour unlimited.

 tools/patman/patman.py | 4 +++-
 tools/patman/series.py | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
tools/patman/patman.py +3 -1
index 8d2c78235a7e..7dd7a1c7b61a 100755
@@ -38,6 +38,8 @@ parser.add_option('-i', '--ignore-errors', action='store_true',
 parser.add_option('-m', '--no-maintainers', action='store_false',
        dest='add_maintainers', default=True,
        help="Don't cc the file maintainers automatically")
+parser.add_option('-l', '--limit-cc', dest='limit', type='int',
+       default=0, help='Limit the cc list to LIMIT entries [default: %default]')
 parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
        default=False, help="Do a dry run (create but don't email patches)")
 parser.add_option('-p', '--project', default=project.DetectProject(),
@@ -157,7 +159,7 @@ else:
 
     cc_file = series.MakeCcFile(options.process_tags, cover_fname,
                                 not options.ignore_bad_tags,
-                                options.add_maintainers)
+                                options.add_maintainers, options.limit)
 
     # Email the patches out (giving the user time to check / cancel)
     cmd = ''
tools/patman/series.py +3 -1
index d526d4ee91d3..2066b97e73ff 100644
@@ -202,7 +202,7 @@ class Series(dict):
             print(col.Color(col.RED, str))
 
     def MakeCcFile(self, process_tags, cover_fname, raise_on_error,
-                   add_maintainers):
+                   add_maintainers, limit=0):
         """Make a cc file for us to use for per-commit Cc automation
 
         Also stores in self._generated_cc to make ShowActions() faster.
@@ -238,6 +238,8 @@ class Series(dict):
                 print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
             cc = set(cc) - set(settings.bounces)
             cc = [m.encode('utf-8') if type(m) != str else m for m in cc]
+            if limit > 0:
+                cc = cc[:limit]
             all_ccs += cc
             print(commit.patch, ', '.join(set(cc)), file=fd)
             self._generated_cc[commit.patch] = cc
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 patman: add option for limiting the Cc list

Hi Chris,

Quoted 23 lines · Chris Packham

Many mailing-lists consider a long Cc list a sign of spam and will either drop the message or mark it for moderation. Because patman automatically invokes get_maintainer.pl the Cc list can expand unexpectedly. Allow the user to specify a limit for the Cc list.

This limit is applied after removing any known bouncing addresses. By default no limit is applied.

---
I've fallen foul of the u-boot ML Cc limit a few times recently. I'm not sure what the actual limit is so I've left patman's default behaviour unlimited.

 tools/patman/patman.py | 4 +++-
 tools/patman/series.py | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
tools/patman/patman.py +0 -0
index 8d2c78235a7e..7dd7a1c7b61a 100755

tools/patman/patman.py parser.add_option('-i', '--ignore-errors', action='store_true', · line 42

Quoted 5 lines
tools/patman/patman.py +2 -0
@@ -38,6 +38,8 @@ parser.add_option('-i', '--ignore-errors', action='store_true',
 parser.add_option('-m', '--no-maintainers', action='store_false',
        dest='add_maintainers', default=True,
        help="Don't cc the file maintainers automatically")
+parser.add_option('-l', '--limit-cc', dest='limit', type='int',
+       default=0, help='Limit the cc list to LIMIT entries [default: %default]')

Could we have a default of None? If that works then I think it would be preferable, so that 0 means no CC.

Quoted 17 lines
tools/patman/patman.py +1 -1
 parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
        default=False, help="Do a dry run (create but don't email patches)")
 parser.add_option('-p', '--project', default=project.DetectProject(),
@@ -157,7 +159,7 @@ else:
 
     cc_file = series.MakeCcFile(options.process_tags, cover_fname,
                                 not options.ignore_bad_tags,
-                                options.add_maintainers)
+                                options.add_maintainers, options.limit)
 
     # Email the patches out (giving the user time to check / cancel)
     cmd = ''
tools/patman/series.py +0 -0
index d526d4ee91d3..2066b97e73ff 100644

tools/patman/series.py class Series(dict): · line 205

Quoted 5 lines
tools/patman/series.py +1 -1
@@ -202,7 +202,7 @@ class Series(dict):
             print(col.Color(col.RED, str))
 
     def MakeCcFile(self, process_tags, cover_fname, raise_on_error,
-                   add_maintainers):
+                   add_maintainers, limit=0):

Please add an arg comment for limit

Quoted 13 lines
tools/patman/series.py +2 -1
         """Make a cc file for us to use for per-commit Cc automation
 
         Also stores in self._generated_cc to make ShowActions() faster.
@@ -238,6 +238,8 @@ class Series(dict):
                 print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
             cc = set(cc) - set(settings.bounces)
             cc = [m.encode('utf-8') if type(m) != str else m for m in cc]
+            if limit > 0:
+                cc = cc[:limit]
             all_ccs += cc
             print(commit.patch, ', '.join(set(cc)), file=fd)
             self._generated_cc[commit.patch] = cc
--
Quoted 2 lines

2.17.0

Regards,
Simon

#2 lore raw

PATCH 1/1 patman: add option for limiting the Cc list

Quoted 32 lines · Simon Glass,

Hi Chris,

tools/patman/patman.py parser.add_option('-i', '--ignore-errors',

Quoted 23 lines · Chris Packham

Many mailing-lists consider a long Cc list a sign of spam and will either drop the message or mark it for moderation. Because patman automatically invokes get_maintainer.pl the Cc list can expand unexpectedly. Allow the user to specify a limit for the Cc list.

This limit is applied after removing any known bouncing addresses. By default no limit is applied.

---
I've fallen foul of the u-boot ML Cc limit a few times recently. I'm not sure what the actual limit is so I've left patman's default behaviour unlimited.

 tools/patman/patman.py | 4 +++-
 tools/patman/series.py | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
tools/patman/patman.py +0 -0
index 8d2c78235a7e..7dd7a1c7b61a 100755
@@ -38,6 +38,8 @@ parser.add_option('-i', '--ignore-errors',

action='store_true',

tools/patman/patman.py parser.add_option('-i', '--ignore-errors', action='store_true',

Quoted 5 lines
tools/patman/patman.py +2 -0
 parser.add_option('-m', '--no-maintainers', action='store_false',
        dest='add_maintainers', default=True,
        help="Don't cc the file maintainers automatically")
+parser.add_option('-l', '--limit-cc', dest='limit', type='int',
+       default=0, help='Limit the cc list to LIMIT entries [default:
Quoted 5 lines

%default]')

Could we have a default of None? If that works then I think it would be preferable, so that 0 means no CC.

That would make -m the same as -l 0. But regardless None is a better fit for unset.

Quoted 21 lines

tools/patman/patman.py parser.add_option('-i', '--ignore-errors', · line 43

Quoted 1 line
tools/patman/patman.py +0 -0
 parser.add_option('-n', '--dry-run', action='store_true',

dest='dry_run',

tools/patman/patman.py parser.add_option('-i', '--ignore-errors', · line 44

Quoted 1 line
tools/patman/patman.py +0 -0
        default=False, help="Do a dry run (create but don't email

patches)")

Quoted 17 lines
tools/patman/patman.py +1 -1
 parser.add_option('-p', '--project', default=project.DetectProject(),
@@ -157,7 +159,7 @@ else:
 
     cc_file = series.MakeCcFile(options.process_tags, cover_fname,
                                 not options.ignore_bad_tags,
-                                options.add_maintainers)
+                                options.add_maintainers, options.limit)
 
     # Email the patches out (giving the user time to check / cancel)
     cmd = ''
tools/patman/series.py +0 -0
index d526d4ee91d3..2066b97e73ff 100644
@@ -202,7 +202,7 @@ class Series(dict):
             print(col.Color(col.RED, str))
 
Quoted 6 lines

tools/patman/series.py class Series(dict): · line 205

Quoted 3 lines
tools/patman/series.py +1 -1
     def MakeCcFile(self, process_tags, cover_fname, raise_on_error,
-                   add_maintainers):
+                   add_maintainers, limit=0):

Please add an arg comment for limit

Will do. Also since there is only one caller of this which passes limit should I make this non-optional.

Quoted 20 lines

tools/patman/series.py class Series(dict): · line 240

Quoted 7 lines
tools/patman/series.py +0 -0
         """Make a cc file for us to use for per-commit Cc automation
 
         Also stores in self._generated_cc to make ShowActions() faster.
@@ -238,6 +238,8 @@ class Series(dict):
                 print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
             cc = set(cc) - set(settings.bounces)
             cc = [m.encode('utf-8') if type(m) != str else m for m in

cc]

Quoted 8 lines
tools/patman/series.py +2 -1
+            if limit > 0:
+                cc = cc[:limit]
             all_ccs += cc
             print(commit.patch, ', '.join(set(cc)), file=fd)
             self._generated_cc[commit.patch] = cc
--

2.17.0

Regards,
Simon