Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fizzy apply #125

Merged
merged 17 commits into from
Nov 28, 2021
Merged

Fizzy apply #125

merged 17 commits into from
Nov 28, 2021

Conversation

anatawa12
Copy link
Contributor

Closes #112

@wumpz
Copy link
Collaborator

wumpz commented Nov 21, 2021

Sorry. Fortgot about this patch. I will look into it.

@wumpz
Copy link
Collaborator

wumpz commented Nov 21, 2021

Could you first resolve the conflicts? Strangely I am not able to resolve it using Github.

@anatawa12
Copy link
Contributor Author

Could you first resolve the conflicts? Strangely I am not able to resolve it using Github.

Yes. i'll resolve conflicts and add more documentation about fuzzy patch.

Co-authored-by: cowwoc <cowwoc2020@gmail.com>
@cowwoc
Copy link
Contributor

cowwoc commented Nov 24, 2021

The new documentation look good to me. Thank you!

@wumpz wumpz merged commit 37f9eaf into java-diff-utils:master Nov 28, 2021
@wumpz
Copy link
Collaborator

wumpz commented Nov 28, 2021

Merged. Thx for the improvement. Could this something for the Wiki documentation?

@meteorcloudy
Copy link

meteorcloudy commented Oct 5, 2023

We are using applyFuzzy in Bazel (see bazelbuild/bazel#17897), but it's leading to a problem of applying a clean patch with multiple chunks: kythe/kythe#5864

My debugging shows there is something wrong about calculating the defaultPosition at

for (AbstractDelta<T> delta : getDeltas()) {
ctx.defaultPosition = delta.getSource().getPosition() + lastPatchDelta;
int patchPosition = findPositionFuzzy(ctx, delta);
if (0 <= patchPosition) {
delta.applyFuzzyToAt(ctx.result, ctx.currentFuzz, patchPosition);
lastPatchDelta = patchPosition - delta.getSource().getPosition();
ctx.lastPatchEnd = delta.getSource().last() + lastPatchDelta;
} else {

Do I understand correctly that lastPatchDelta means the offset we should apply to the next delta after applying the previous one? If so it probably should not be lastPatchDelta = patchPosition - delta.getSource().getPosition(); since the new chunk could be smaller.

The problematic patch I encountered is:

--- src/include/souffle/utility/FileUtil.h
+++ src/include/souffle/utility/FileUtil.h
@@ -20,23 +20,16 @@
 #include <climits>
 #include <cstdio>
 #include <cstdlib>
-#include <filesystem>
 #include <fstream>
 #include <map>
-#include <optional>
 #include <sstream>
 #include <string>
 #include <utility>
 #include <sys/stat.h>

-// -------------------------------------------------------------------------------
-//                               File Utils
-// -------------------------------------------------------------------------------
-
 #ifndef _WIN32
 #include <unistd.h>
 #else
-#define NOMINMAX
 #define NOGDI
 #include <fcntl.h>
 #include <io.h>
@@ -44,11 +37,21 @@
 #include <windows.h>

 // -------------------------------------------------------------------------------
-//                               Windows
+//                               File Utils
 // -------------------------------------------------------------------------------

+#define X_OK 1 /* execute permission - unsupported in windows*/
+
 #define PATH_MAX 260

+/**
+ * access and realpath are missing on windows, we use their windows equivalents
+ * as work-arounds.
+ */
+inline int access(const char* path, int mode) {
+    return _access(path, mode);
+}
+
 inline char* realpath(const char* path, char* resolved_path) {
     return _fullpath(resolved_path, path, PATH_MAX);
 }

on https://github.com/souffle-lang/souffle/tree/cc8ea091721fcfb60bed45a0edf571ad9d0c58a5/src/include/souffle/utility/FileUtil.h

copybara-service bot pushed a commit to bazelbuild/bazel that referenced this pull request Oct 6, 2023
Apply the chunks separately and in reverse order to workaround an issue in applyFuzzy.
See java-diff-utils/java-diff-utils#125 (comment)

Fixes #17897 (comment)

RELNOTES: None
PiperOrigin-RevId: 571336806
Change-Id: I8eb6b859d1ce8fb990d9237f728198af34e0d393
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for fuzzy patches
4 participants