I've been working with the Apply Patch wizard recently. Following bugs has been fixed:
- 217070: [Apply Patch] Show matched hunks in Apply Patch wizard
- 205761: [Patch] Indicate the fuzz factor used to match
- 221146: [Patch] "Apply patch" should sort hunks by insertion points
- 205918: [Patch] Folding "Patch options" on the Apply Patch wizard
- 190844: [Apply Patch] Hunk compare editor needs to provide more information
- 196228: [Viewers] Hunk compare editor should help the user when context lines don't match
- 202944: [Viewers] Please provide an "auto-merge" button in the text and java compare editors
- 205762: [Patch] Indicate the offset used to match
- 217075: [Apply Patch] Show initial insertion point for a hunk
- 217076: [Apply Patch] Show which context lines has been applied with a fuzz factor
Especially the 217076 appeared to be a hard nut to crack. There has been a short discussion in one of the bugs from Stefan about how the editor should look like. I agree with one of the comments there that it would be great to have an editor to play with, but let me first quickly present changes made so far. This could also to a good place to start the discussion again.
This is what user sees in the editor when trying to apply a conflicting patch. The patch consists of 3 hunks. By a conflict in this case I mean a change made to one of context lines (see Fig 2).
Fig 1. The editor indicating that there is a conflict. "I can't apply the first hunk".
Let us see what is the problem. Double-clicking of the hunk loads its content and shows that the patcher expects "" in the second line, but the line has been changed to " CHANGE". The line is actually the second line of context for the first hunk. If it doesn't match the hunk cannot be applied.
Fig 2. The editor showing details of a conflict.
Below is a proposition how conflicts can be shown in the editor*.
Fig 2a. The editor showing details of a conflict marked red.
Click the newly arrived "Show matched" option. This will allow us to see whole patch.
Fig 3. The editor showing full structure of the patch.
Clicking "Guess" results in the fuzz factor set to 2. This is how many lines need to be ignored to successfully apply the conflicting hunk.
Fig 4. The editor after guessing the fuzz. "Fuzz factor factor to the rescue!".
Double click on the hunk to see the details.
Fig 5. The editor showing details of the conflicting hunk after the fuzz applied. "I can apply the hunk if the fuzz factor is 2".
I though that maybe using a fuzz factor should be indicated with yellow:
Fig 5a. The editor* showing the context lines matched with a fuzz factor marked yellow.
The user can also inspect other hunks to check if everything's fine.
Fig 6. The editor showing details of a matched hunk. "I can apply this one smoothly".
* both screen shots for figuers 2a and 5a are show a different patch, but I hope they still give the idea