Fix some cherry-picking corner cases
PATCH 1/1 Fix some cherry-picking corner cases
Handle several corner cases when trying to cherrypick from incomplete series.
Reported-by Krzysztof Kozlowski <[email protected]>
Signed-off-by Konstantin Ryabitsev <[email protected]>
--- b4/__init__.py | 12 ++++++++---- b4/mbox.py | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-)
b4/__init__.py +8 -4
@@ -504,10 +504,14 @@ class LoreSeries: at = 1 atterrors = list() for lmsg in self.patches[1:]: - if cherrypick is not None and at not in cherrypick: - at += 1 - logger.debug(' skipped: [%s/%s] (not in cherrypick)', at, self.expected) - continue + if cherrypick is not None: + if at not in cherrypick: + at += 1 + logger.debug(' skipped: [%s/%s] (not in cherrypick)', at, self.expected) + continue + if lmsg is None: + logger.critical('CRITICAL: [%s/%s] is missing, cannot cherrypick', at, self.expected) + raise KeyError('Cherrypick not in series') if lmsg is not None: if self.has_cover and covertrailers and self.patches[0].followup_trailers: lmsg.followup_trailers += self.patches[0].followup_trailers
b4/mbox.py +12 -8
@@ -86,12 +86,12 @@ def mbox_to_am(mboxfile, cmdargs): at = 0 for lmsg in lser.patches[1:]: at += 1 - if lmsg.msgid == msgid: + if lmsg and lmsg.msgid == msgid: cherrypick = [at] - cmdargs.cherrypick = '5' + cmdargs.cherrypick = f'<{msgid}>' break if not len(cherrypick): - logger.critical('Specified msgid is not present in the series, cannot cherry-pick') + logger.critical('Specified msgid is not present in the series, cannot cherrypick') sys.exit(1) elif cmdargs.cherrypick.find('*') >= 0: # Globbing on subject
@@ -110,10 +110,14 @@ def mbox_to_am(mboxfile, cmdargs): logger.critical('Writing %s', am_filename) mbx = mailbox.mbox(am_filename) - am_mbx = lser.save_am_mbox(mbx, noaddtrailers=cmdargs.noaddtrailers, - covertrailers=covertrailers, trailer_order=config['trailer-order'], - addmysob=cmdargs.addmysob, addlink=cmdargs.addlink, - linkmask=config['linkmask'], cherrypick=cherrypick) + try: + am_mbx = lser.save_am_mbox(mbx, noaddtrailers=cmdargs.noaddtrailers, + covertrailers=covertrailers, trailer_order=config['trailer-order'], + addmysob=cmdargs.addmysob, addlink=cmdargs.addlink, + linkmask=config['linkmask'], cherrypick=cherrypick) + except KeyError: + sys.exit(1) + logger.info('---') if cherrypick is None:
@@ -153,7 +157,7 @@ def mbox_to_am(mboxfile, cmdargs): logger.info('Prepared a fake commit range for 3-way merge (%.12s..%.12s)', rstart, rend) logger.critical('---') - if not lser.complete: + if not lser.complete and not cmdargs.cherrypick: logger.critical('WARNING: Thread incomplete!') if lser.has_cover and not cmdargs.nocover:
Signature · 1 line
2.26.2