diff options
author | Samuel Huang <huangs@chromium.org> | 2018-04-30 22:47:52 +0000 |
---|---|---|
committer | Edward Lesmes <ehmaldonado@google.com> | 2021-07-23 22:17:29 +0000 |
commit | 6951a286379338eaa10a712989541ca77c0c2a9c (patch) | |
tree | 2b4b9f8addfe9aa37804bb52929a235a10b23239 /zucchini.h | |
parent | 93ffc913ec7d369818a109b9ca6de7adb278e163 (diff) | |
download | zucchini-6951a286379338eaa10a712989541ca77c0c2a9c.tar.gz |
[Zucchini] Introduce Imposed Ensemble Matcher.
Previously Zucchini-gen uses built-in heuristics to perform element
matching for ensemble patch generation. This CL adds an option
(accessible via the -impose parameter) to specify elements in "old"
and "new", and how they match. This allows the default heuristics to be
overridden, and enables external applications (who perhaps have better
ideas of element matching, e.g., have access to archiving programs) to
better use Zucchini to patch archives.
Zucchini-match is updated to prints the -impose command line to repeat
its results. Also, ElementMatch::ToString() is added.
Change-Id: I541b64722904c2fcd19ed75246d87e0268fbf86c
Reviewed-on: https://chromium-review.googlesource.com/1027191
Reviewed-by: Samuel Huang <huangs@chromium.org>
Reviewed-by: Greg Thompson <grt@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554909}
NOKEYCHECK=True
GitOrigin-RevId: 73a64ffde3f3b64df576aa1f2b5baebf7ec964ba
Diffstat (limited to 'zucchini.h')
-rw-r--r-- | zucchini.h | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -5,6 +5,8 @@ #ifndef COMPONENTS_ZUCCHINI_ZUCCHINI_H_ #define COMPONENTS_ZUCCHINI_ZUCCHINI_H_ +#include <string> + #include "components/zucchini/buffer_view.h" #include "components/zucchini/patch_reader.h" #include "components/zucchini/patch_writer.h" @@ -31,12 +33,25 @@ enum Code { } // namespace status -// Generates ensemble patch from |old_image| to |new_image|, and writes it to -// |patch_writer|. +// Generates ensemble patch from |old_image| to |new_image| using the default +// element detection and matching heuristics, writes the results to +// |patch_writer|, and returns a status::Code. status::Code GenerateEnsemble(ConstBufferView old_image, ConstBufferView new_image, EnsemblePatchWriter* patch_writer); +// Same as GenerateEnsemble(), but if |imposed_matches| is non-empty, then +// overrides default element detection and matching heuristics with custom +// element matching encoded in |imposed_matches|, which should be formatted as: +// "#+#=#+#,#+#=#+#,..." (e.g., "1+2=3+4", "1+2=3+4,5+6=7+8"), +// where "#+#=#+#" encodes a match as 4 unsigned integers: +// [offset in "old", size in "old", offset in "new", size in "new"]. +status::Code GenerateEnsembleWithImposedMatches( + ConstBufferView old_image, + ConstBufferView new_image, + std::string imposed_matches, + EnsemblePatchWriter* patch_writer); + // Generates raw patch from |old_image| to |new_image|, and writes it to // |patch_writer|. status::Code GenerateRaw(ConstBufferView old_image, |