[PATCH 4/7] patman: Allow showing progress on archived series

Simon Glass sjg at chromium.org
Sat May 24 19:06:52 CEST 2025


Sometimes it is useful to include archived series in the progress report
so you can see all the work completed. Add a flag for this.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/patman/cmdline.py      |  1 +
 tools/patman/control.py      |  2 +-
 tools/patman/cser_helper.py  | 18 +++++++++++------
 tools/patman/cseries.py      |  9 ++++++---
 tools/patman/test_cseries.py | 38 +++++++++++++++++++++++++++++++++---
 5 files changed, 55 insertions(+), 13 deletions(-)

diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py
index 18bcece211f..3095b67e009 100644
--- a/tools/patman/cmdline.py
+++ b/tools/patman/cmdline.py
@@ -289,6 +289,7 @@ def add_series_subparser(subparsers):
                       help='Show all series versions, not just the latest')
     prog.add_argument('-l', '--list-patches', action='store_true',
                       help='List patch subject and status')
+    _add_archived(prog)
 
     ren = series_subparsers.add_parser('rename')
     ren.add_argument('-N', '--new-name', help='New name for the series')
diff --git a/tools/patman/control.py b/tools/patman/control.py
index d898a4482af..57d2dbe8edd 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -184,7 +184,7 @@ def do_series(args, test_db=None, pwork=None, cser=None):
                               args.patch)
         elif args.subcmd == 'progress':
             cser.progress(args.series, args.show_all_versions,
-                          args.list_patches)
+                          args.list_patches, args.include_archived)
         elif args.subcmd == 'rm':
             cser.remove(args.series, dry_run=args.dry_run)
         elif args.subcmd == 'rm-version':
diff --git a/tools/patman/cser_helper.py b/tools/patman/cser_helper.py
index 39f291cb3ec..dd2cfc5cbf0 100644
--- a/tools/patman/cser_helper.py
+++ b/tools/patman/cser_helper.py
@@ -1156,6 +1156,7 @@ class CseriesHelper:
         states = defaultdict(int)
         count = len(pwc)
         ok = True
+        cmt = None
         for seq, item in enumerate(pwc.values()):
             if series:
                 cmt = series.commits[seq]
@@ -1178,7 +1179,8 @@ class CseriesHelper:
                 subject = item.subject
 
             line = (f'{seq:3} {col_state}{pad} {comments.rjust(3)} '
-                    f'{patch_id:7} {oid(cmt.hash)} {subject}')
+                    f"{patch_id:7} {oid(cmt.hash) if cmt else ' ' * HASH_LEN} "
+                    f'{subject}')
             lines.append(line)
             states[item.state] += 1
         out = ''
@@ -1187,7 +1189,7 @@ class CseriesHelper:
             state_totals[state] += freq
         name = ''
         if not list_patches:
-            name = desc or series.desc
+            name = desc or (series.desc if series else '')
             name = self.col.build(self.col.YELLOW, name[:41].ljust(41))
             if not ok:
                 out = '*' + out[1:]
@@ -1402,7 +1404,7 @@ class CseriesHelper:
             return await self._sync_all(client, pwork, to_fetch)
 
     def _progress_one(self, ser, show_all_versions, list_patches,
-                      state_totals):
+                      state_totals, use_metadata=True):
         """Show progress information for all versions in a series
 
         Args:
@@ -1414,6 +1416,8 @@ class CseriesHelper:
             state_totals (dict): Holds totals for each state across all patches
                 key (str): state name
                 value (int): Number of patches in that state
+            use_metadata (bool): True to read the series metadata from the
+                branch
 
         Return: tuple
             int: Number of series shown
@@ -1441,10 +1445,12 @@ class CseriesHelper:
             _, pwc = self._series_get_version_stats(ser.idnum, ver)
             count = len(pwc)
             branch = self._join_name_version(ser.name, ver)
-            series = patchstream.get_metadata(branch, 0, count,
-                                              git_dir=self.gitdir)
+            series = None
+            if use_metadata:
+                series = patchstream.get_metadata(branch, 0, count,
+                                                  git_dir=self.gitdir)
+                self._copy_db_fields_to(series, ser)
             svinfo = self.get_ser_ver(ser.idnum, ver)
-            self._copy_db_fields_to(series, ser)
 
             ok = self._list_patches(
                 branch, pwc, series, svinfo.name, svinfo.cover_id,
diff --git a/tools/patman/cseries.py b/tools/patman/cseries.py
index 717a2504962..7064c33b6ee 100644
--- a/tools/patman/cseries.py
+++ b/tools/patman/cseries.py
@@ -556,7 +556,8 @@ class Cseries(cser_helper.CseriesHelper):
         # environment.
         cros_subprocess.Popen(['xdg-open', url])
 
-    def progress(self, series, show_all_versions, list_patches):
+    def progress(self, series, show_all_versions, list_patches,
+                 include_archived):
         """Show progress information for all versions in a series
 
         Args:
@@ -566,6 +567,7 @@ class Cseries(cser_helper.CseriesHelper):
                 False to show only the final version
             list_patches (bool): True to list all patches for each series,
                 False to just show the series summary on a single line
+            include_archived (bool): True to include archived series also
         """
         with terminal.pager():
             state_totals = defaultdict(int)
@@ -581,7 +583,7 @@ class Cseries(cser_helper.CseriesHelper):
 
             total_patches = 0
             total_series = 0
-            sdict = self.db.series_get_dict()
+            sdict = self.db.series_get_dict(include_archived)
             border = None
             total_need_scan = 0
             if not list_patches:
@@ -593,7 +595,8 @@ class Cseries(cser_helper.CseriesHelper):
             for name in sorted(sdict):
                 ser = sdict[name]
                 num_series, num_patches, need_scan = self._progress_one(
-                    ser, show_all_versions, list_patches, state_totals)
+                    ser, show_all_versions, list_patches, state_totals,
+                    not include_archived)
                 total_need_scan += need_scan
                 if list_patches:
                     print()
diff --git a/tools/patman/test_cseries.py b/tools/patman/test_cseries.py
index d6cd042e990..ab59ae7c9a3 100644
--- a/tools/patman/test_cseries.py
+++ b/tools/patman/test_cseries.py
@@ -720,7 +720,7 @@ Tested-by: Mary Smith <msmith at wibble.com>   # yak
         self.setup_second()
 
         self.db_close()
-        args = Namespace(subcmd='ls')
+        args = Namespace(subcmd='ls', include_archived=False)
         with terminal.capture() as (out, _):
             control.do_series(args, test_db=self.tmpdir, pwork=True)
         lines = out.getvalue().splitlines()
@@ -780,6 +780,7 @@ Tested-by: Mary Smith <msmith at wibble.com>   # yak
 
         self.db_close()
         args.subcmd = 'ls'
+        args.include_archived = False
         with terminal.capture() as (out, _):
             control.do_series(args, test_db=self.tmpdir, pwork=True)
         lines = out.getvalue().splitlines()
@@ -2996,7 +2997,8 @@ Date:   .*
 
         with self.stage('latest versions'):
             args = Namespace(subcmd='progress', series='second',
-                             show_all_versions=False, list_patches=True)
+                             show_all_versions=False, list_patches=True,
+                             include_archived=False)
             with terminal.capture() as (out, _):
                 control.do_series(args, test_db=self.tmpdir, pwork=True)
             lines = iter(out.getvalue().splitlines())
@@ -3033,7 +3035,8 @@ Date:   .*
 
         with self.stage('progress with patches'):
             args = Namespace(subcmd='progress', series=None,
-                             show_all_versions=False, list_patches=True)
+                             show_all_versions=False, list_patches=True,
+                             include_archived=False)
             with terminal.capture() as (out, _):
                 control.do_series(args, test_db=self.tmpdir, pwork=True)
             lines = iter(out.getvalue().splitlines())
@@ -3048,6 +3051,35 @@ Date:   .*
             self._check_first(lines)
             self._check_second(lines, True)
 
+    def test_series_progress_all_archived(self):
+        """Test showing progress for all cseries including archived ones"""
+        self.setup_second()
+        self.cser.archive('first')
+
+        with self.stage('progress without archived'):
+            with terminal.capture() as (out, _):
+                self.run_args('series', 'progress', pwork=True)
+            itr = iter(out.getvalue().splitlines())
+            self.assertEqual(
+                'Name             Description                               Count  Status',
+                next(itr))
+            self.assertTrue(next(itr).startswith('--'))
+            self.assertEqual(
+                'second2          The name of the cover letter              '
+                '    3  1:accepted 1:changes 1:rejected', next(itr))
+
+        with self.stage('progress with archived'):
+            with terminal.capture() as (out, _):
+                self.run_args('series', 'progress', '--include-archived',
+                              pwork=True)
+            lines = out.getvalue().splitlines()
+            self.assertEqual(
+                'first                                                      '
+                '    2  2:unknown', lines[2])
+            self.assertEqual(
+                'second2          The name of the cover letter              '
+                '    3  1:accepted 1:changes 1:rejected', lines[3])
+
     def test_series_progress_no_patches(self):
         """Test showing progress for all cseries without patches"""
         self.setup_second()
-- 
2.43.0

base-commit: e3ced530e543c9f24cbc66430abc6109ce8df015
branch: pate


More information about the U-Boot mailing list