aboutsummaryrefslogtreecommitdiff
path: root/b4/mbox.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-31 15:09:47 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-31 15:09:47 -0400
commit63d5313664c96cdfcee345f5c880f9973a3ee1da (patch)
tree896d310748c1a079552199eb67c4e77ed5bfb6b3 /b4/mbox.py
parente7564108c7e68094f1a6320f4166185a3e29cac1 (diff)
downloadb4-63d5313664c96cdfcee345f5c880f9973a3ee1da.tar.gz
Refactor how we handle trailers
With the addition of b4 trailers it became pretty obvious that the way we originally implemented trailers didn't age well. This refactor does the following: - introduces LoreTrailer class to replace passing trailers as tuples - reimplements trailer-order with strict adherence to chain-of-custody rules - adds tests to most common trailer follow-up/ordering cases Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/mbox.py')
-rw-r--r--b4/mbox.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/b4/mbox.py b/b4/mbox.py
index 9a6ea9c..c2e1555 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -121,9 +121,9 @@ def make_am(msgs, cmdargs, msgid):
# Only check cover letter or first patch
if not lmsg or lmsg.counter > 1:
continue
- for trailer in list(lmsg.followup_trailers):
- if trailer[0].lower() == 'obsoleted-by':
- lmsg.followup_trailers.remove(trailer)
+ for ltr in list(lmsg.followup_trailers):
+ if ltr.lname == 'obsoleted-by':
+ lmsg.followup_trailers.remove(ltr)
if warned:
continue
logger.critical('---')
@@ -136,10 +136,10 @@ def make_am(msgs, cmdargs, msgid):
logger.critical('---')
logger.critical('NOTE: Some trailers were sent to the cover letter:')
tseen = set()
- for trailer in lser.patches[0].followup_trailers:
- if tuple(trailer[:2]) not in tseen:
- logger.critical(' %s: %s', trailer[0], trailer[1])
- tseen.add(tuple(trailer[:2]))
+ for ltr in lser.patches[0].followup_trailers:
+ if ltr not in tseen:
+ logger.critical(' %s', ltr.as_string(omit_extinfo=True))
+ tseen.add(ltr)
logger.critical('NOTE: Rerun with -t to apply them to all patches')
if len(lser.trailer_mismatches):
logger.critical('---')
@@ -526,9 +526,9 @@ def get_extra_series(msgs: list, direction: int = 1, wantvers: Optional[int] = N
# Does it have an Obsoleted-by: trailer?
rmsg = b4.LoreMessage(msg)
trailers, mismatches = rmsg.get_trailers()
- for tl in trailers:
- if tl[0].lower() == 'obsoleted-by':
- for chunk in tl[1].split('/'):
+ for ltr in trailers:
+ if ltr.lname == 'obsoleted-by':
+ for chunk in ltr.value.split('/'):
if chunk.find('@') > 0 and chunk not in seen_msgids:
obsoleted.append(chunk)
break