[Concept,23/32] patman: Wire up per-upstream send settings in commands

Message ID 20260226200106.1727176-24-sjg@u-boot.org
State New
Headers
Series patman: Add multi-upstream support |

Commit Message

Simon Glass Feb. 26, 2026, 8 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add -I/--identity, -t/--series-to, -m/--no-maintainers and --no-tags
options to 'upstream add' and thread them through to the database.

In cseries.send(), look up the series' upstream send settings and
apply them to args before sending: set identity, series_to,
add_maintainers and process_tags as appropriate.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 tools/patman/cmdline.py | 12 ++++++++++++
 tools/patman/control.py |  6 +++++-
 tools/patman/cseries.py | 34 +++++++++++++++++++++++++++-------
 3 files changed, 44 insertions(+), 8 deletions(-)
  

Patch

diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py
index 3fef37e738d..6141f106fde 100644
--- a/tools/patman/cmdline.py
+++ b/tools/patman/cmdline.py
@@ -423,6 +423,18 @@  def add_upstream_subparser(subparsers):
         '-p', '--patchwork-url',
         help='URL of patchwork server for this upstream, e.g. '
              "'https://patchwork.ozlabs.org'")
+    uadd.add_argument(
+        '-I', '--identity',
+        help="Git sendemail identity to use, e.g. 'chromium'")
+    uadd.add_argument(
+        '-t', '--series-to',
+        help="Patman alias for the To address, e.g. 'u-boot'")
+    uadd.add_argument(
+        '-m', '--no-maintainers', action='store_true', default=False,
+        help='Skip get_maintainer.pl for this upstream')
+    uadd.add_argument(
+        '--no-tags', action='store_true', default=False,
+        help='Skip subject-tag alias processing for this upstream')
     uadd.add_argument(
         'project_name', nargs='?',
         help="Patchwork project name, e.g. 'U-Boot'")
diff --git a/tools/patman/control.py b/tools/patman/control.py
index 352c76bd14e..689fd732dec 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -252,7 +252,11 @@  def upstream(args, test_db=None):
         if args.subcmd == 'add':
             cser.upstream_add(args.remote_name, args.url,
                               args.project_name,
-                              patchwork_url=args.patchwork_url)
+                              patchwork_url=args.patchwork_url,
+                              identity=args.identity,
+                              series_to=args.series_to,
+                              no_maintainers=args.no_maintainers,
+                              no_tags=args.no_tags)
         elif args.subcmd == 'default':
             if args.unset:
                 cser.upstream_set_default(None)
diff --git a/tools/patman/cseries.py b/tools/patman/cseries.py
index 871e14458a8..36f0b432073 100644
--- a/tools/patman/cseries.py
+++ b/tools/patman/cseries.py
@@ -932,14 +932,21 @@  class Cseries(cser_helper.CseriesHelper):
         if not ser.idnum:
             raise ValueError(f"Series '{ser.name}' not found in database")
 
-        if not getattr(args, 'identity', None):
-            ups = self.get_series_upstream(name)
-            if ups:
-                identity = self.db.upstream_get_identity(ups)
-                if identity:
+        ups = self.get_series_upstream(name)
+        if ups:
+            settings = self.db.upstream_get_send_settings(ups)
+            if settings:
+                identity, series_to, no_maintainers, no_tags = settings
+                if identity and not getattr(args, 'identity', None):
                     args.identity = identity
                     print(f"Using sendemail identity '{identity}'"
                           f" from upstream '{ups}'")
+                if series_to:
+                    args.series_to = series_to
+                if no_maintainers:
+                    args.add_maintainers = False
+                if no_tags:
+                    args.process_tags = False
 
         args.branch = self._get_branch_name(ser.name, version)
         likely_sent = send.send(args, git_dir=self.gitdir, cwd=self.topdir)
@@ -1159,7 +1166,8 @@  class Cseries(cser_helper.CseriesHelper):
                 tout.info('Dry run completed')
 
     def upstream_add(self, name, url, project=None, pwork=None,
-                     patchwork_url=None, identity=None):
+                     patchwork_url=None, identity=None, series_to=None,
+                     no_maintainers=False, no_tags=False):
         """Add a new upstream tree
 
         Args:
@@ -1171,8 +1179,14 @@  class Cseries(cser_helper.CseriesHelper):
             patchwork_url (str or None): URL of the patchwork server for
                 this upstream
             identity (str or None): Git sendemail identity to use
+            series_to (str or None): Patman alias for the To address
+            no_maintainers (bool): True to skip get_maintainer.pl
+            no_tags (bool): True to skip subject-tag alias processing
         """
-        self.db.upstream_add(name, url, patchwork_url, identity=identity)
+        self.db.upstream_add(name, url, patchwork_url, identity=identity,
+                             series_to=series_to,
+                             no_maintainers=no_maintainers,
+                             no_tags=no_tags)
         if project:
             if not pwork:
                 if not patchwork_url:
@@ -1186,6 +1200,12 @@  class Cseries(cser_helper.CseriesHelper):
             msg += f" patchwork '{patchwork_url}'"
         if identity:
             msg += f" identity '{identity}'"
+        if series_to:
+            msg += f" to '{series_to}'"
+        if no_maintainers:
+            msg += ' no-maintainers'
+        if no_tags:
+            msg += ' no-tags'
         if project:
             msg += f" project '{project}'"
         tout.notice(msg)