diff mbox series

[b4] am: Build patch series when additional patches appear in a thread

Message ID 20231207-series-from-non-reply-reply-v1-1-cb02de53857c@intel.com
State New, archived
Headers show
Series [b4] am: Build patch series when additional patches appear in a thread | expand

Commit Message

Ira Weiny Dec. 8, 2023, 5:42 a.m. UTC
Dan reported that am/shazam cherry-pick was failing with a particular
CXL series.[1]

	$ b4 shazam -S -P _ 20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com
	Grabbing thread from lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/t.mbox.gz
	Checking for newer revisions
	Grabbing search results from lore.kernel.org
	Analyzing 8 messages in the thread
	Specified msgid is not present in the series, cannot cherrypick

The reason is series processing failed to detect that a non reply follow
on message containing a patch was not a replacement for the original.
The way this patch was submitted (without a 'Re:' subject prefix) is
actually a good thing.  This is because a reply would have implied a v2
to the original patch rather than a follow on patch as intended.

Teach b4 to interpret a thread like this by adding the additional patch
to the series with a warning.  The series can then be applied as normal
or with a cherry-pick as was necessary in this case.

A run after the fix looks like this:

	$ b4 shazam -S -P _ 20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com
	Grabbing thread from lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/t.mbox.gz
	Checking for newer revisions
	Grabbing search results from lore.kernel.org
	Analyzing 8 messages in the thread
	WARNING: duplicate messages found at index 1
	   Subject 1: cxl/cdat: Free correct buffer on checksum error
	   Subject 2: cxl/pci: Get rid of pointer arithmetic reading CDAT table
	  2 is not a reply... assume additional patch
	Checking attestation on all messages, may take a moment...
	---
	  ✓ [PATCH] cxl/cdat: Free correct buffer on checksum error
	    ✗ No key: ed25519/ira.weiny@intel.com
	    ✓ Signed: DKIM/intel.com
	    + Reviewed-by: Robert Richter <rrichter@amd.com> (✓ DKIM/amd.com)
	    + Reviewed-by: Fan Ni <fan.ni@samsung.com> (✗ DKIM/gmail.com)
	    + Reviewed-by: Dave Jiang <dave.jiang@intel.com> (✓ DKIM/intel.com)
	---
	Total patches: 1 (cherrypicked: <20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com>)
	---
	 Base: using specified base-commit 7475e51b87969e01a6812eac713a1c8310372e8a
	Applying: cxl/cdat: Free correct buffer on checksum error

[1] https://lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/

Reported-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 b4/__init__.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)


---
base-commit: 433a845ce33f33c2ded6875447bf18e186ea1865
change-id: 20231207-series-from-non-reply-reply-110e4881ba0f

Best regards,

Comments

Dan Williams Dec. 8, 2023, 5:55 a.m. UTC | #1
Ira Weiny wrote:
> Dan reported that am/shazam cherry-pick was failing with a particular
> CXL series.[1]
> 
> 	$ b4 shazam -S -P _ 20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com
> 	Grabbing thread from lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/t.mbox.gz
> 	Checking for newer revisions
> 	Grabbing search results from lore.kernel.org
> 	Analyzing 8 messages in the thread
> 	Specified msgid is not present in the series, cannot cherrypick
> 
> The reason is series processing failed to detect that a non reply follow
> on message containing a patch was not a replacement for the original.
> The way this patch was submitted (without a 'Re:' subject prefix) is
> actually a good thing.  This is because a reply would have implied a v2
> to the original patch rather than a follow on patch as intended.
> 
> Teach b4 to interpret a thread like this by adding the additional patch
> to the series with a warning.  The series can then be applied as normal
> or with a cherry-pick as was necessary in this case.
> 
> A run after the fix looks like this:
> 
> 	$ b4 shazam -S -P _ 20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com
> 	Grabbing thread from lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/t.mbox.gz
> 	Checking for newer revisions
> 	Grabbing search results from lore.kernel.org
> 	Analyzing 8 messages in the thread
> 	WARNING: duplicate messages found at index 1
> 	   Subject 1: cxl/cdat: Free correct buffer on checksum error
> 	   Subject 2: cxl/pci: Get rid of pointer arithmetic reading CDAT table
> 	  2 is not a reply... assume additional patch
> 	Checking attestation on all messages, may take a moment...
> 	---
> 	  ✓ [PATCH] cxl/cdat: Free correct buffer on checksum error
> 	    ✗ No key: ed25519/ira.weiny@intel.com
> 	    ✓ Signed: DKIM/intel.com
> 	    + Reviewed-by: Robert Richter <rrichter@amd.com> (✓ DKIM/amd.com)
> 	    + Reviewed-by: Fan Ni <fan.ni@samsung.com> (✗ DKIM/gmail.com)
> 	    + Reviewed-by: Dave Jiang <dave.jiang@intel.com> (✓ DKIM/intel.com)
> 	---
> 	Total patches: 1 (cherrypicked: <20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com>)
> 	---
> 	 Base: using specified base-commit 7475e51b87969e01a6812eac713a1c8310372e8a
> 	Applying: cxl/cdat: Free correct buffer on checksum error
> 
> [1] https://lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/
> 
> Reported-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>

Tested-by: Dan Williams <dan.j.williams@intel.com>

Thanks!
Konstantin Ryabitsev Jan. 23, 2024, 11:10 p.m. UTC | #2
On Thu, 07 Dec 2023 21:42:37 -0800, Ira Weiny wrote:
> Dan reported that am/shazam cherry-pick was failing with a particular
> CXL series.[1]
> 
> 	$ b4 shazam -S -P _ 20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com
> 	Grabbing thread from lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/t.mbox.gz
> 	Checking for newer revisions
> 	Grabbing search results from lore.kernel.org
> 	Analyzing 8 messages in the thread
> 	Specified msgid is not present in the series, cannot cherrypick
> 
> [...]

Applied, thanks!

[1/1] am: Build patch series when additional patches appear in a thread
      commit: 76426faacd9216b0a7115262c0058eb29e2d1d69

Best regards,
diff mbox series

Patch

diff --git a/b4/__init__.py b/b4/__init__.py
index 7d665f9e2c0a..f87daf838b4f 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -481,10 +481,20 @@  class LoreSeries:
         if self.patches[lmsg.counter] is not None:
             # Okay, weird, is the one in there a reply?
             omsg = self.patches[lmsg.counter]
+
+            logger.warn('WARNING: duplicate messages found at index %s', lmsg.counter)
+            logger.warn('   Subject 1: %s', lmsg.subject)
+            logger.warn('   Subject 2: %s', omsg.subject)
             if omsg.reply or (omsg.counters_inferred and not lmsg.counters_inferred):
                 # Replace that one with this one
-                logger.debug('  replacing existing: %s', omsg.subject)
+                logger.warn('  2 is a reply... replacing existing: %s', omsg.subject)
+                self.patches[lmsg.counter] = lmsg
+            else:
+                logger.warn('  2 is not a reply... assume additional patch')
+                self.patches.append(None)
+                self.expected = self.expected + 1
                 self.patches[lmsg.counter] = lmsg
+                self.patches[lmsg.counter + 1] = omsg
         else:
             self.patches[lmsg.counter] = lmsg
         self.complete = not (None in self.patches[1:])