[darcs-users] Feedback on hunk splitting with Darcs 2.4 beta 1

Florent Becker florent.becker at ens-lyon.org
Sat Jan 16 09:38:51 UTC 2010


>> Here's a "screenshot" of what it looked like for me:
>>
>> ####################
>> Interactive hunk edit:
>>  - Edit the first set of lines to insert a new change before the current one.
>>  - Edit the second set of lines to insert a new change after the current one.
>> ===
>> ===
>>         use Data::Dumper;
>>         warn Dumper ('foo!');
>> ===
>>
>> #####################
>>
>> First, it's not clear what "set of lines" refer to. Is it referring to the
>> "===" lines? I wouldn't call those sets. Maybe it is referring to the content between
>> the === lines. But there nothing between the first two === lines, so referring to nothing
>> as a "set of lines" is also confusing.

I think I tend to never edit the first set of lines. If this is common,
maybe the help should emphasize on the second one. Also, the interactive
selection after the edit should somehow convey the idea that you are
choosing among hunks coming from the edit ('should i record this change
[from interactive edit]?'). The header of the edit should also mention
the fact that the hunks will be offered by interactive selection.

I think that a good complement to this feature would be
revert-from-within-record. ie:
>do you want to record this changes? [ynq…]
:revert
>do you really want to revert this change? [yn]
y
>this change is going to be reverted from the working directory after
>this patch is recorded.
That way, you can distinguish between part of the hunk you keep for a
later patch (answer 'n') and mistakes you correct at record time (answer
':revert').

> I'm going to try and do this now if you and Isaac will bear with me
> (with Ganesh correcting me if I say something stupid).  Perhaps in light
> of my explanation you'd be willing to offer up a solution?
> 
> Here are the ideas:
> 
> 1. The hunk editor turns your hunk patch into a sequence of hunk patches
> 
> 2. Any empty patch in that sequence is filtered out.
> 
> 3. You can make arbitrary edits in the hunk editor.  One example use of
>    this would be to clean up trailing whitespace on the spot.
> 
I actually use that quite frequently, so allowing only splitting of
hunks would be a step backwards for me

> One idea I had was to change the UI to look like this...
> 
> ####################
> Interactive hunk edit:
>  - Changes outside of the EDIT regions will be ignored
> === BEFORE PATCH 0
> some lines removed
> some other lines removed
> === BEFORE PATCH 1 (EDIT BELOW) =======================================
> some lines removed
> some other lines removed
> === AFTER PATCH 1 
> some lines added
> some lines added
> === AFTER PATCH 2 (EDIT ABOVE) =======================================
> some lines added
> some lines added
> ===
> #####################
>

What about:
####################
Interactive hunk edit:
- Changes outside of the EDIT regions will be ignored
- The changes in the file will be split into three patches,
  PATCH 0, PATCH 1 and PATCH 2, together equivalent to your changes
- After your edits, you can select what to keep among PATCH{0,1,2}
=== REFERENCE OLD STATE, do not edit --v ========
some lines removed
some other lines removed
=== PATCH 0 is between this state --^ and that state --v (EDIT BELOW) ==
some lines removed
some other lines removed
=== PATCH 1 is between this state --^ and that state --v (EDIT BELOW) ==
some lines added
some lines added
=== PATCH 2 is between this state --^ and that state --+ ===============
===         (REFERENCE NEW STATE BELOW, do not edit)   v ===============
some lines added
some lines added
=== (REFERENCE NEW STATE ABOVE, do not edit --^ )
#####################
Is it possible to put a magic line before the 'Interactive hunk edit:'
bit so that emacs and vim go into darcs-interactive-edit-mode and
put the uneditable bits in a suitable color (such as grey)? This mode
could also have a keybinding for 'replace current line with
corresponding line from OLD' and 'replace with corresponding line from
NEW'. These would make hunk splitting even easier.

Florent



More information about the darcs-users mailing list