Thursday, March 6, 2008

How to make the hunk compare editor more informative

Quick intro:

I've been working with the Apply Patch wizard recently. Following bugs has been fixed:
But the real goal is to address 3 bugs reported by Stefan Xenos:
Before I start working with them I will need to solve these:

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.

Flow:


Screens (currently):


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 "[02]" in the second line, but the line has been changed to "[02] 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