Skip to content

Support fuzzy patch #6

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

Merged
merged 8 commits into from
Nov 7, 2019
Merged

Support fuzzy patch #6

merged 8 commits into from
Nov 7, 2019

Conversation

uilianries
Copy link
Member

@uilianries uilianries commented Oct 24, 2019

fixes #5

Should close conan-io/conan#5963 too

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries uilianries marked this pull request as ready for review October 25, 2019 18:26
Copy link

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your fix here and, although I've tried to, I cannot make a patch file that would break your implementation.


I have one consideration about this. If I use the patch file (see the non-matching line `YYYY')....

diff --git a/Jamroot b/Jamroot
index a6981dd..0c08f09 100644
--- a/Jamroot
+++ b/Jamroot
@@ -1,3 +1,4 @@
 X
 YYYY
+V
 Z

... IMO it is also a fuzzy patch and should behave the same. I see that the library, for this use case, returns an error from the # validate before patching section. Should we add the logic to the validation and fail? Is there any reason why it allows a fuzzy patch after the changed section but not before?

@uilianries
Copy link
Member Author

I see. I think it's because the hunk @@ -1,3 +1,4 @@

The original file starts at line 1 and is 3 lines size. The initial validation didn't detect the my patch because it only checked the first 3 lines, ignoring Z.
In your case, YYYY comes into the original hunk.

We need to change the patch applying, but also the initial validation. The question is, should we add an option to allow fuzzy patch? We are breakingthe original behavior with this patch.

@jgsogo
Copy link

jgsogo commented Oct 28, 2019

From my point of view:

  1. FIX: a fuzzy-patch after the actual changes in the patch-file should fail (as it is failing if the fuzzy is before the actual changes). If we had had this behavior before, the issue with boost wouldn't have happened.
  2. FEATURE: add an argument/option to allow fuzzy patches. But this feature could wait.

@uilianries
Copy link
Member Author

Fair enough! I'll check the bug again. Thanks for reporting this new case.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Copy link

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we accept fuzzy patches, it should we as an opt-in (using an option), by default it is safer for us to fail

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@jgsogo jgsogo self-assigned this Oct 29, 2019
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Copy link

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks a lot, @uilianries

I know there are lots of use-cases to test, but I agree we should go step by step and assume that everything is working if anyone has reported it... (my head is thinking about patches removing lines, patches substituting one line by another, adding more than one line, removing several,... 🔬 😅 ).

@jgsogo jgsogo requested a review from czoido October 31, 2019 19:32
@uilianries
Copy link
Member Author

@jgsogo Thanks for reviewing!! 💪

@jgsogo jgsogo assigned lasote and unassigned jgsogo Nov 6, 2019
@lasote lasote merged commit 7017c57 into master Nov 7, 2019
@lasote
Copy link

lasote commented Nov 7, 2019

Released patch-ng==1.17.2

@uilianries
Copy link
Member Author

thanks! I gonna restart that PR in Conan

@lasote lasote removed their assignment Nov 11, 2019
@jgsogo jgsogo deleted the hotfix/fuzzy-patch branch March 4, 2020 11:14
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.

[bug] conan.patch incorrectly applied [bug] conan.patch incorrectly applied
3 participants