Issue126

Title I wish I could split a hunk in two when recording it.
Priority wishlist Status need-eg
Superseder Nosy List beschmi, dagit, droundy, kowey, markstos, pupeno, tommy, zandr, zooko
Assigned To Topics

Created on 2006-02-04.02:07:07 by zooko, last changed 2008-06-09.17:44:54 by zooko.

Messages
msg5002 (view) Author: zooko Date: 2008-06-09.17:44:51
Zandr just mentioned that he wished for this feature.  (He wasn't previously
aware of this ticket or of the fact that other people have wished for the same
thing.)

Currently we have two candidate user interfaces for this.  One is that there is
a new interactive command available in the "darcs record" prompt.  The other is
that you can drop into a text editor to configure the hunks how you like before
going on with the record.

I think the former should be attempted first to see if it is sufficient, because
it feels simpler to learn and use than the latter.  My current proposal is as
follows:

Add a command to the 'darcs record' prompt which you get after it displays the
next hunk.  Currently your choices are record, don't record, don't care, skip
the rest of the file, record all of the rest of the file, etc..  Add one more
option: split this hunk into two equal-sized pieces.  If you choose that
command, then now you are no longer looking at the original hunk, you are now
looking at the first half of it, and you are in the exact same mode -- ready to
choose record, don't-record, split-this-hunk-in-two, etc.

My intuition is that this interface, while being extremely simple to learn and
use, would suffice for 90% of the use cases.
msg3210 (view) Author: kowey Date: 2008-02-07.18:03:56
On 07/02/2008, Eric Kow <eric.kow@gmail.com> wrote:
> One principle is that interactive hunk-splitting should be just that
> (no actually
> modifying the hunks).  I can't justify this principle other than
> thinking that it would
> just make life simpler for us.

Come to think of it, maybe I *can* justify this behaviour.  By
enforcing a don't-change-the-hunks rule, we guarantee to the user that
they have not accidentally changed something whilst trying to split a
hunk.  (yeah, we could also flag any changes, but would the user
actually notice?)
msg3205 (view) Author: kowey Date: 2008-02-07.17:58:09
On 07/02/2008, Mark Stosberg <bugs@darcs.net> wrote:
> Would anyone like to propose a specific UI for how we could implement this?

As for interactive hunk editing, here are some thoughts (since you ask
for them).
One principle is that interactive hunk-splitting should be just that
(no actually
modifying the hunks).  I can't justify this principle other than
thinking that it would
just make life simpler for us.

We could rearrange the presentation so that all lines are together, for example
instead of presenting something like

-removed1
-removed2
-removed3
+added1
+added2

We would present the following text to the user.

'Put **HUNK** anywhere you would like to see a hunk boundary.  Change
only the hunk boundaries. Do not modify the hunks themselves, or darcs
record will not understand the changes)

** HUNK **
-removed1
+added1

-removed2
+added2

-removed3
msg3184 (view) Author: zooko Date: 2008-02-07.17:22:38
The following is off the top of my head and is a "wish".

Maybe when you are doing "darcs record" and you are looking at a hunk, and you
see that the hunk contains two logically separate changes, you can hit the key
to split the hunk, and then it will show you a new hunk (replacing the one that
you were just looking at) which is the first half of the one that you were just
looking at.

That might be sufficient!
msg3183 (view) Author: markstos Date: 2008-02-07.17:06:52
Would anyone like to propose a specific UI for how we could implement this? 

I have sometimes wanted this myself, but not strongly. I have difficultly
visualizing how this could work in away that feels worth using.
msg1729 (view) Author: dan_b Date: 2007-06-18.23:22:33
Oh, it's not just me, then.  Interactive patch editing would be overkill for my
needs, though: I'd be happy with a regex (or something) that caused darcs to
split a hunk whenever it encountered it.  For example, for editing Perl files I
might set it to '^sub ', or for Lisp to '^('.
msg1269 (view) Author: pupeno Date: 2006-11-25.16:49:22
I just want to say that I also would like to have this feature. I wanted several
times in different situations. In my last case I was working in a big refactor
of some piece of code and one function was done and tested. Hours of works I
didn't want to miss. But I don't want to record all, there's a lot of trash
around that function. Even the original code would continue to run if I add this
function maintaining, so it makes sense to just record it.
msg1098 (view) Author: kowey Date: 2006-10-15.14:27:04
interactive hunk editiing
Import of RT #172 (Merge)

guest <nothingmuch@woobling.org> 2005-01-12
-------------------------------------------
Subject: interactive hunk editiing

Sometimes i edit too much before recording.

I'd like to be able to get a large hunk, and then break it up manually
with my editor.

For example, given

+paragraph
+
+paragraph2

I'd like to be able to muck the diff into something like

__HUNK_BEGIN__
+paragraph
__HUNK__END__
__HUNK__BEGIN__
+paragraph2
__HUNK_END__

and then have darcs generate 3 hunks, one for the first paragraph, one for the
second, and one for the white space in the middle, and splice these into the
queue of patches.
msg473 (view) Author: zooko Date: 2006-02-06.17:52:05
Suppose I fix a bug like this:

-void splodge(int c) {
+void splodge(long c) {

And I also add a new function:

+int blorf() { return s_blorfulocity / s_RAT; }

Then when I run darcs record it will offer me to record this hunk

-void splodge(int c) {
+int blorf() { return s_blorfulocity / s_RAT; }
+
+void splodge(long c) {

I don't want to record that hunk!

What I want is to record those two conceptual changes in two separate patches.
msg461 (view) Author: kowey Date: 2006-02-04.05:26:08
See also RT #172
http://otherbugs.darcs.net//Ticket/Display.html?id=172
msg460 (view) Author: dagit Date: 2006-02-04.05:06:13
On Feb 3, 2006, at 6:07 PM, Zooko wrote:

>
> New submission from Zooko <zooko@zooko.com>:
>
> I've often wished for this.  Also my co-worker Rob just wished for it.

Could you give an example?  The idea of "splitting a hunk" makes no  
sense to me.

Thanks,
Jason
msg459 (view) Author: zooko Date: 2006-02-04.02:07:05
I've often wished for this.  Also my co-worker Rob just wished for it.

Browse related patches: unstable | stable

History
Date User Action Args
2008-06-09 17:44:54zookosetnosy: + zandr
messages: + msg5002
2008-02-07 18:03:57koweysetnosy: droundy, tommy, beschmi, kowey, markstos, zooko, dagit, pupeno
messages: + msg3210
2008-02-07 17:58:10koweysetnosy: droundy, tommy, beschmi, kowey, markstos, zooko, dagit, pupeno
messages: + msg3205
2008-02-07 17:22:38zookosetnosy: droundy, tommy, beschmi, kowey, markstos, zooko, dagit, pupeno
messages: + msg3184
2008-02-07 17:06:53markstossetstatus: chatting -> need-eg
nosy: + markstos
messages: + msg3183
2007-06-18 23:22:34dan_bsetnosy: + beschmi
messages: + msg1729
2006-11-25 16:49:32pupenosetnosy: + pupeno
messages: + msg1269
2006-10-15 14:27:09koweysetnosy: droundy, tommy, kowey, zooko, dagit
messages: + msg1098
2006-10-15 14:09:21koweylinkissue114 superseder
2006-02-06 17:52:07zookosetnosy: droundy, tommy, kowey, zooko, dagit
messages: + msg473
2006-02-04 05:26:09koweysetnosy: + kowey
messages: + msg461
2006-02-04 05:06:14dagitsetstatus: unread -> chatting
nosy: + dagit
messages: + msg460
2006-02-04 02:07:07zookocreate