[Patchew-devel] [PATCH] series-diff: tweak replacement of ignored text

Paolo Bonzini pbonzini at redhat.com
Fri Apr 6 09:51:36 UTC 2018


Sometimes the "@@" lines end without a function name.  In that case there is no
space after the second "@@".  Tweak the regular expression to cover that case,
checking for end-of-line as an alternative to the space.  For consistency,
anchor the regexes to the beginning of the line as well.
---
 mods/diff.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mods/diff.py b/mods/diff.py
index 197e31e..4896f41 100644
--- a/mods/diff.py
+++ b/mods/diff.py
@@ -77,10 +77,10 @@ class DiffModule(PatchewModule):
             filtered = ""
             sep = ""
             for l in m.get_body().splitlines():
-                for pat, repl in [(r"index [0-9a-f]+\.\.[0-9a-f]+",
+                for pat, repl in [(r"^index [0-9a-f]+\.\.[0-9a-f]+",
                                    r"index XXXXXXX..XXXXXXX"),
-                                  (r"@@ -[0-9]+,[0-9]+ \+[0-9]+,[0-9]+ @@ ",
-                                   r"@@ -XXX,XX +XXX,XX @@ ")]:
+                                   (r"^@@ -[0-9]+,[0-9]+ \+[0-9]+,[0-9]+ @@( |$)",
+                                   r"@@ -XXX,XX +XXX,XX @@\1")]:
                     l = re.sub(pat, repl, l)
                 filtered += sep + l
                 sep = "\n"
-- 
2.16.2




More information about the Patchew-devel mailing list