fix(tools): skip degenerate identical hunks in V4A validation
The apply phase already skips a hunk whose -/+ lines are identical (patch_parser.py '(search_lines == replace_lines): continue'), but the validation phase lacked the guard: such a hunk reached fuzzy_find_and_replace, whose identical-strings error names old_string/new_string — parameters that don't exist in patch mode — and failed the whole atomic patch that apply would have accepted. Mirror the apply-phase skip in validation; regression test drives a mixed degenerate+live patch end-to-end (short text dodges the is_already_applied >=8-char rescue).
This commit is contained in:
@@ -323,6 +323,14 @@ def _validate_operations(
|
||||
replace_lines = [l.content for l in hunk.lines if l.prefix in {' ', '+'}]
|
||||
replacement = '\n'.join(replace_lines)
|
||||
|
||||
if search_lines == replace_lines:
|
||||
# Degenerate hunk whose -/+ lines are identical: the apply
|
||||
# phase skips it as a no-op, so validation must not fail it
|
||||
# — fuzzy_find_and_replace would reject the identical
|
||||
# search/replacement with old_string/new_string guidance
|
||||
# that has no meaning in V4A patch mode.
|
||||
continue
|
||||
|
||||
new_simulated, count, _strategy, match_error = fuzzy_find_and_replace(
|
||||
simulated, search_pattern, replacement, replace_all=False
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user