[PATCH b4 v2 37/44] review-tui: do not let a failed tracking load skip the branch restore

Christian Brauner <[email protected]> Fri, 31 Jul 2026 23:59:18 +0200
Newsgroups org.kernel.linux.tools
Message-ID <20260731-work-b4-editor-branch-guard-v2-37-243fd19d322d@kernel.org>
load_tracking() exits rather than raises on a branch with no tracking
commit, and SystemExit is not an Exception, so it unwound out of
run_tracking_tui(). Catch it next to Exception; it is worth a warning,
not the session.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 src/b4/review_tui/_entry.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/b4/review_tui/_entry.py b/src/b4/review_tui/_entry.py
index 31c6257..605fb12 100644
--- a/src/b4/review_tui/_entry.py
+++ b/src/b4/review_tui/_entry.py
@@ -186,6 +186,9 @@ def run_tracking_tui(
             # Sync status from tracking commit to DB.  The ReviewApp writes
             # status changes (e.g. 'replied') into the tracking commit JSON,
             # so we read it back here and propagate to the SQLite database.
+            # load_tracking() exits rather than raising on a branch with no
+            # tracking commit, and SystemExit is not an Exception, so catch it
+            # too -- letting it out of here takes the whole TUI down with it.
             try:
                 _cover_text, tracking = b4.review.load_tracking(topdir, branch_name)
                 tracking_status = tracking.get('series', {}).get('status')
@@ -196,7 +199,7 @@ def run_tracking_tui(
                         conn, focus_change_id, tracking_status, revision=revision
                     )
                     conn.close()
-            except Exception as ex:
+            except (Exception, SystemExit) as ex:
                 logger.warning('Could not sync tracking status: %s', ex)
 
             # Put the user back before the tracking list comes up again.

-- 
2.53.0