diff mbox series

[b4,1/2] mbox.py::make_am: simplify check for early return

Message ID 20230415-am-cherry-pick-suggestion-v1-1-8951a2274256@gmail.com (mailing list archive)
State Accepted
Headers show
Series am, shazam: allow cherry-picking an out-of-series patch | expand

Commit Message

Philippe Blain April 15, 2023, 7:30 p.m. UTC
In mbox.py::make_am, we check if the 'lser' LoreSeries returned by
lmbx.get_series is empty, and return early with a different critical
message depending on wether wantver was given or not.

Simplify the logic a bit by using a nested if instead of two subsequent
ones. This will make the following commit's diff simpler.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 b4/mbox.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/b4/mbox.py b/b4/mbox.py
index 7060564..05c40e9 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -57,11 +57,11 @@  def make_am(msgs: List[email.message.Message], cmdargs: argparse.Namespace, msgi
         reroll = False
 
     lser = lmbx.get_series(revision=wantver, sloppytrailers=cmdargs.sloppytrailers, reroll=reroll)
-    if lser is None and wantver is None:
-        logger.critical('No patches found.')
-        return
     if lser is None:
-        logger.critical('Unable to find revision %s', wantver)
+        if wantver is None:
+            logger.critical('No patches found.')
+        else:
+            logger.critical('Unable to find revision %s', wantver)
         return
     if len(lmbx.series) > 1 and not wantver:
         logger.info('Will use the latest revision: v%s', lser.revision)