[darcs-users] Hunk merging and interactive edit
Theam Yong Chew
senatorzergling at gmail.com
Thu Apr 28 10:51:52 UTC 2011
Hi all,
I have a question about better presentation of patches/hunks and
interactive editing.
Suppose I initially have the following function in my file (all
transcripts slighted edited for readability):
==== Transcript ================
~/temp/scm/dr3 $ cat > separate
function foo (){
...
}
~/temp/scm/dr3 $ darcs add separate
~/temp/scm/dr3 $ darcs rec separate -a -m "Initial edit."
Recording changes in "separate":
Finished recording patch 'Initial edit.'
==============================
I then edit the file, adding a new function before foo, and changing
foo itself slightly. I consider this 2 different but related
edits. The file "separate" now looks like this:
======File "separate"==========
function test(){
...
}
function foo (arg){
...
}
==============================
During darcs record, I would like the edit to be recorded as 2 hunks,
so using the "interactive editor" (press e, see final output below
[1]), I defined 2 separate operations and then record (press y) the 2
hunks into 1 patch. Unfortunately, my hints through the interactive
edit have not had any effect because the 2 separate hunks get merged
again.
====== Transcript ============
~/temp/scm/dr3 $ darcs rec separate
hunk ./separate 1
-function foo (){
+function test(){
+ ...
+}
+
+function foo (arg){
Shall I record this change? (1/1) [ynWesfvplxdaqjk], or ? for help: e
hunk ./separate 1
+function test(){
+ ...
+}
+
Shall I record this change? (1/2) [ynWesfvplxdaqjk], or ? for help: y
hunk ./separate 5
-function foo (){
+function foo (arg){
Shall I record this change? (2/2) [ynWesfvplxdaqjk], or ? for help: y
What is the patch name? 2 changes.
Do you want to add a long comment? [yn]n
Finished recording patch '2 changes.'
~/temp/scm/dr3 $ darcs cha -v --last=1
Thu Apr 28 15:20:41 New Zealand Standard Time
* 2 changes.
hunk ./separate 1
-function foo (){
+function test(){
+ ...
+}
+
+function foo (arg){
==============================
I know it would've required 2 different patches to highlight this, but
often it makes sense to group related hunks into the same patch. This
is probably not a straight-forward thing to resolve, since the merging
behaviour is often the desired behaviour. What do you suggest I try?
Yong.
[1] Final output of interactive edit:
Interactive hunk edit:
- Edit the section marked 'AFTER'
- Arbitrary editing is supported
- This will only affect the patch, not your working copy
- Hints:
- To split added text, delete the part you want to postpone
- To split removed text, copy back the part you want to retain
========================== BEFORE (reference) ==========================
function foo (){
============================= AFTER (edit) =============================
function test(){
...
}
function foo (){
============================= (edit above) =============================
More information about the darcs-users
mailing list