This implements the --unified flag for record, amend-record, revert and unrevert.
This enables to see a little more context when choosing hunks.
I have not tested it with hunk edit.
It should be possible to adapt it to darcs changes.
Test suit OK (without unit tests), user interface feedback is welcome.
3 patches for repository http://darcs.net:
Thu Mar 8 16:03:13 ART 2012 Guillaume Hoffmann <guillaumh@gmail.com>
* redundant exit line in Whatsnew
Thu Mar 8 19:39:30 ART 2012 Guillaume Hoffmann <guillaumh@gmail.com>
* change help of --unified to refer to changes in place of patches
Thu Mar 8 19:54:03 ART 2012 Guillaume Hoffmann <guillaumh@gmail.com>
* resolve issue1166 --unified flag for record, amend-record, revert and unrevert
The current bundle exhibits weird behaviour for darcs record --unified
(also revert) when a first hunk is a line add. Say I have a recorded
file that is: "1\n2\n3\n" and the changes are:
hunk ./a 1
+O
hunk ./a 4
-3
+33
darcs rec -u shows:
hunk ./a 1
+O
1
2
3
hunk ./a 4
1
2
3
-3
+33
Seems that it has the correct line number of the second hunk, but it
tries to do an unified diff agains a pristine state that doesn't have
that new first line, hence the appearance of the "3" line while it
shouldn't.
Somehow, whatsnew --unified gets it right.
I'm pushing the "redundant exit line in Whatsnew" patch since it is a
(trivial) dependency for Owen's patch750 that refactors the module
Darcs.Command.Whatnew, and has nothing to do with the 2 other patches of
this bundle.
Also changing the title of this patch bundle otherwise it will get
unnoticed.
Both Record and Whatsnew call the function
Darcs.Repository.State.unrecordedChanges to know what changes to
display, and ultimately call Darcs.PrintPatch.printFriendly (or
contextualPrintPatch but the code is the same) to print the changes with
context.
The only difference I see is that for the case of Record, printFriendly
is called with just one primitive patch and the pristine, while with
Whatsnew, contextualPrintPatch is called with the whole patch
corresponding to the unrecorded changes, and the pristine. That may
explain why hunk selection with record --unified loses track of the
right line numbers when displaying hunks.
The problem is that with record --unified (contrary to whatsnew
--unified), the function Darcs.Patch.Viewing.coolContextHunk does not
know, when displaying a hunk with context inside of a file f, what are
the previous hunks that modify f.
Hence, some hunk, displayed against the pristine state, has some line
number that is irrelevant to the state of the pristine, but that is
relevant to the state of the pristine *knowing* the previous hunks of
the file.
These patches require further work but I'm self-pushing them now to
avoid having them stuck in the pipeline for too much time, since I
believe they are a correct first step. I'm opening an issue ticket for
future work. I gave a try at fixing rec --unified last week but I got
into trouble with type witnesses, and probably some code
cleanup/restructuration will be needed in between.
mndrix> the "fix name shadowing" patch seems related to another patch of
mine ("dirty fix for compile error", itself depending upon "Tidy up
wspfr" by Andreas).
messages:
+ msg15337 title: redundant exit line in Whatsnew (and 2 more) -> resolve issue1166 --unified flag for record, amend-record, revert and unrevert