summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2024-01-08 14:34:47 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2024-02-19 17:28:40 +0100
commit2a80de47cdc1933777bd5848584017a3fffdbf28 (patch)
tree8b45b00bde79dba1ab9c1b1e77824d128f9fb279
parent02c13d9e1d85e74142f3ff71f40739e7e81d1ad1 (diff)
Fix resetboring's failure to spot hspace-only changes
The 6.7 review for QSql included a file where all that had changed was some s/Type& name/Type &name/ fixes. This arose because there was no other change to the lines in question and the initial scan of the new lines thus concluded nothing boring had changed, so there was no point recording the line for comparison to old lines. Retain at least one representation of each non-trivial line to match, so that we do catch cases where the only boring change is to spacing. Package the non-trivial line check (previously used when reversing strip) in a function since we're reusing it; and include backslash in its list of trivia, since that arises in trivial lines of a macro body. Change-Id: I10443bd1494932696f176f90b663035a772ca805 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rwxr-xr-xscripts/api-review/resetboring.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/api-review/resetboring.py b/scripts/api-review/resetboring.py
index a42856f0..a54d1873 100755
--- a/scripts/api-review/resetboring.py
+++ b/scripts/api-review/resetboring.py
@@ -295,6 +295,8 @@ class Selector(object): # Select interesting changes, discard boring.
hybrid = list(self.__new[hunk[0][3]:hunk[-1][4]])
# Tools to remove boring differences:
bore = self.Censor()
+ # Lines with only space and punctuators tend to produce false matches:
+ relevant = lambda t: set(t).difference('{\t \n};\\')
# Associate each line, involved in either side of the change,
# with a canonical form; and some in old with their .strip():
@@ -306,14 +308,20 @@ class Selector(object): # Select interesting changes, discard boring.
seq.append(mini)
if seq:
change[line] = tuple(seq)
- # else: line contains no boring changes
+ elif relevant(line):
+ # No boring changes in line, except maybe to spacing.
+ # Record last (probably only) representation of it, so
+ # we can undo mere spacing changes - but only for
+ # relevant lines, since trivial ones are typically
+ # adjacent to Real Change.
+ change[line] = (mini,)
for line in self.__old[hunk[0][1]:hunk[-1][2]]:
for mini in bore.minimize(line):
try: seq = origin[mini]
except KeyError: seq = origin[mini] = []
seq.append(line)
- # Interesting lines might have merely changed indentation:
- if set(line).difference('{\t \n};'):
+ # Relevant lines might have merely changed indentation:
+ if relevant(line):
key = line.strip()
try: was = unstrip[key]
except KeyError: unstrip[key] = line