Made the patch utility return information to distinguish already patched files from successful patch application, and modified our checks extensions to signal when patches have been applied and a ccommand needs to be re-run.
- Legacy-Id: 18386
This commit is contained in:
parent
bc75565969
commit
16fb382943
|
@ -319,6 +319,15 @@ def maybe_patch_library(app_configs, **kwargs):
|
||||||
"\tTarget files: %s\n") % (library_path, ', '.join(force_str(i.target) for i in patch_set.items)),
|
"\tTarget files: %s\n") % (library_path, ', '.join(force_str(i.target) for i in patch_set.items)),
|
||||||
id="datatracker.W0002",
|
id="datatracker.W0002",
|
||||||
))
|
))
|
||||||
|
else:
|
||||||
|
# Patch succeeded or was a no-op
|
||||||
|
if not patch_set.already_patched:
|
||||||
|
errors.append(
|
||||||
|
checks.Error("Found an unpatched file, and applied the patch in %s" % (patch_file),
|
||||||
|
hint="You will need to re-run the command now that the patch in place.",
|
||||||
|
id="datatracker.E0022",
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
errors.append(checks.Warning(
|
errors.append(checks.Warning(
|
||||||
"Could not parse patch file '%s'"%patch_file,
|
"Could not parse patch file '%s'"%patch_file,
|
||||||
|
|
|
@ -930,6 +930,7 @@ class PatchSet(object):
|
||||||
if validhunks < len(p.hunks):
|
if validhunks < len(p.hunks):
|
||||||
if self._match_file_hunks(filename, p.hunks):
|
if self._match_file_hunks(filename, p.hunks):
|
||||||
warning("already patched %s" % filename)
|
warning("already patched %s" % filename)
|
||||||
|
self.already_patched = True
|
||||||
else:
|
else:
|
||||||
warning("source file is different - %s" % filename)
|
warning("source file is different - %s" % filename)
|
||||||
errors += 1
|
errors += 1
|
||||||
|
@ -1175,9 +1176,9 @@ def main():
|
||||||
|
|
||||||
#pprint(patch)
|
#pprint(patch)
|
||||||
if options.revert:
|
if options.revert:
|
||||||
patch.revert(options.strip, root=options.directory) or sys.exit(-1)
|
patch.revert(options.strip, root=options.directory.encode()) or sys.exit(-1)
|
||||||
else:
|
else:
|
||||||
patch.apply(options.strip, root=options.directory) or sys.exit(-1)
|
patch.apply(options.strip, root=options.directory.encode()) or sys.exit(-1)
|
||||||
|
|
||||||
# todo: document and test line ends handling logic - patch.py detects proper line-endings
|
# todo: document and test line ends handling logic - patch.py detects proper line-endings
|
||||||
# for inserted hunks and issues a warning if patched file has incosistent line ends
|
# for inserted hunks and issues a warning if patched file has incosistent line ends
|
||||||
|
|
Loading…
Reference in a new issue