NeilBrown [Mon, 19 Aug 2013 05:03:37 +0000 (15:03 +1000)]
merge: fix reporting of empty "conflicts".
The important part of this patch is the end in print_merge().
If one conflict follows another with nothing in between,
then we really should try to mark up that 'nothingness' as
a resolved conflict.
The other parts as just cleaning up isolate_conflicts a bit more
as I tried to figure out what was happening.
NeilBrown [Mon, 19 Aug 2013 01:15:53 +0000 (11:15 +1000)]
Browser: Don't highlight spaces so much.
Highlighting spaces is very noisy and doesn't help very much.
We only really need to differentiate spaces from tabs and highlighting
tabs is enough for that.
We continue to highlight spaces that are adjacent to tabs, but not
other spaces.
NeilBrown [Thu, 28 Mar 2013 01:53:57 +0000 (12:53 +1100)]
Extract version information from 'git' if possible.
The version number (and date) reported by "wiggle -V" now
includes information from 'git' if the code was build from a
git repo rather than from a tar-ball.
Suggested-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Fri, 22 Mar 2013 04:12:49 +0000 (15:12 +1100)]
merge: be more careful about aligning hunk-headers with newlines.
When matching a diff to a file, it would be very confusing.
if the last match from one hunk were on the same line of the
original as the first match of the next hunk.
So we try to align hunk-headers with newlines.
In particular, we often find Unmatched and Extraneous
sections together. There can be encoded in any order.
If the Extraneous section contains a hunk-header,
we want to make sure that if there is a newline anywhere
in the unmatched section, then the Unmatched that is placed
before the hunk-headers Extraneous ends on a newline.
There was code the attempted this, but it was too simplistic
and would sometimes move outside the regions that it should
have been examine, which would lead to various bugs.
The tests case which demonstrated this is added to the
test suite.
Reported-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Fri, 22 Mar 2013 04:04:48 +0000 (15:04 +1100)]
csl_join should merge adjacent matches.
When diffing against a patch we treat each hunk separately
and join the result.
This joining doesn't merge adjacent matches so it doesn't really
tell the full story of where the matches are and how big
they are. This can confuse other code, particularly when
examining hunk headers to create the merger.
NeilBrown [Fri, 1 Mar 2013 08:09:35 +0000 (19:09 +1100)]
vpatch: allow a word to have text before the newline.
Previously we don't print out ends_line() words at all.
But soon a word might have some content plus a newline at
the end.
So restructure the display to print non-newline characters
from any word.
Note that we cannot have characters *after* a newline.
Doing that would break too much of wiggle's formating
assumptions.
NeilBrown [Fri, 1 Mar 2013 08:05:27 +0000 (19:05 +1100)]
Allow a word to have an unmatched prefix and suffix.
i.e. The part of a word that is tested for matching is
shorted than the whole word that is printed. There can
be a prefix and a suffix. In a future patch, an option
will be availble to include most spaces as prefix or suffix
of nearby non-space.
NeilBrown [Fri, 1 Mar 2013 07:46:00 +0000 (18:46 +1100)]
vpatch: restructure draw_mside.
We have the end-of-line handing code in the middle of
a 'while', and the only return from the function is at
the end of the eol handling. And there is nothing after the "while".
So move the eol handling code out of the while, and just put
a "break" in place of it.
NeilBrown [Fri, 1 Mar 2013 05:02:15 +0000 (16:02 +1100)]
merge: Remove noise from --show-wiggles output.
When --show-wiggles is used with whole files (current, orig, new) and
extraneous text in orig/new (Which isn't a change, so should be
ignored) is treated as a wiggle and causes a conflict to be shown.
Obviously not good.
So insist that any show-wiggle conflict contains at leas a Changed or
a Conflict. Also allow Changed and Unmatched to be 'near' each other,
not only on the same line, to signal a wiggle. Current 'near' measure
is 3 lines.
NeilBrown [Thu, 14 Feb 2013 06:31:18 +0000 (17:31 +1100)]
Add valgrind testing of parts of vpatch.
With --self-test, browsing a simple merge will simply
display at every line.
"make vtest" will run this for every merge in the test suite
and use valgrind to look for problems.
NeilBrown [Thu, 14 Feb 2013 05:30:29 +0000 (16:30 +1100)]
bestmatch: improve poor matches.
If the bestmatch doens't include all of the lines in a hunk, try to
find matches between the unmatch parts of the hunk, and surrounding
text in the original.
This is particularly useful when some of the context is just blank
lines. The best-match algorithm might ignore blank lines because they
aren't big enough to justify much distance from the rest of the match.
NeilBrown [Wed, 13 Feb 2013 23:45:57 +0000 (10:45 +1100)]
merge: remove useless context from the end of a conflict.
If we are close to the end-of-file, then don't expect
too many unchanged lines.
And allow zero lines of context in the merge if it is unchanged out
side the merge.
Update various tests to match - all clear improvements.
NeilBrown [Wed, 13 Feb 2013 23:22:18 +0000 (10:22 +1100)]
merge: remove useless context at the start of a conflict.
There are two fixes here.
The first allows the newline at the end of an unchanged region to be
the 'first' newline found so that if there are several others to
provide backup, it will be used.
The second allows the start-of-file to be strong enough context to
not require three full lines of explicit context.
Then we change a lot of the self-tests to match. In each case the
result is a clear improvement.
NeilBrown [Wed, 6 Feb 2013 23:38:15 +0000 (10:38 +1100)]
diff: make rediffing of patches more precise.
When wiggle is given a patch, it splits it into a 'before' and an
'after' section and creates a diff between those.
The hunks in the patch are separated by headers and it is assumed that
these headers will line up in the result.
However: if one hunk removes a chunk of test and another hunk adds
that chunk of text, the chunk may appear more significant than the
hunk headers, so it will line up, and the hunk headers won't
This creates a mess as one of the current tests shows, and as a
newly added test demonstrates quite neatly.
So if we are re-diffing a patch, find the hunk headers and only
diff the bits between them.
This allows the new test to work, and improves the result of the old
test.
NeilBrown [Wed, 14 Nov 2012 23:59:04 +0000 (10:59 +1100)]
vpatch: allow mode setting keys to toggle back to 'merge'.
When I set the mode to anything other than 'merge', I usually want to
then go straight back to 'merge'. And if someone does it by mistake,
a toggle function is easier to guess.
So make all mode setting commands toggle between their mode, and
'merge'.
NeilBrown [Wed, 14 Nov 2012 23:17:38 +0000 (10:17 +1100)]
vpatch: highlight conflicts better.
You can only tell the difference between a conflict and a
change by the conflict starting with '|', not '-'.
So make that '|' more visible, because conflicts are important.
NeilBrown [Wed, 14 Nov 2012 23:07:19 +0000 (10:07 +1100)]
vpatch: update display correctly when editing the merge.
If an edit changes the merge so that we don't need to show
two separate streams any more, then the display must be updated
to not show the stream.
And the reverse.
NeilBrown [Tue, 13 Nov 2012 03:38:03 +0000 (14:38 +1100)]
vpatch: change args to visible()
The type and stream passed to visible() are always generate from
a merge and an mpos in the same way. So pass the merge and mpos
instead.
This makes more information available to visible() which will be used
in a future patch.
NeilBrown [Tue, 13 Nov 2012 02:59:41 +0000 (13:59 +1100)]
vpatch: avoid extra blanks when cursor is in alternate pane.
When cursor is in the 'diff' pane of the 'merge' view, the line it is
on might not be visible in the main pane. This can cause ugly a_void
lines to appear.
So make sure there point we refresh is a visible point.
NeilBrown [Tue, 13 Nov 2012 01:19:26 +0000 (12:19 +1100)]
vpatch: highlight spaces when they might be important.
If a wiggle is needed due to white-space issues, it is good
to show them.
So in cases where that might be happening - unmatches space or
extraneous space - highlight spaces as inverse-video and tabs as
underlines.
NeilBrown [Tue, 13 Nov 2012 00:39:33 +0000 (11:39 +1100)]
vpatch: make ctrl-G search-again-forward, not just search-again.
As ctrl-S doesn't work (as I haven't enabled 'raw' mode), you cannot
search forward during a reverse search. So change ctrl-G to do that
rather than search-again-in-current-direction, which isn't really useful.
NeilBrown [Tue, 13 Nov 2012 00:16:09 +0000 (11:16 +1100)]
vpatch: fix check_line to stop at hunk headers.
check_line() includes invisible bits because they could in some sense
be part of 'this' line. It ignore hunk headers, but it really should stop
at them, because nothing before could be related to this line.
This fixes a problem where 'N' and 'P' would find hunk headers
which isn't really helpful.
NeilBrown [Mon, 12 Nov 2012 23:57:45 +0000 (10:57 +1100)]
vpatch: ensure searching for 'next change' works.
Now that AlreadyApplied may not cause multiple streams in the
merge window, we need to be more carefuly about searching for changes.
i.e. we need to check each line to see if it is at-or-near an
interesting change.
NeilBrown [Mon, 12 Nov 2012 23:33:40 +0000 (10:33 +1100)]
vpatch: revise the exact meaning of 'CHANGES'.
The 'CHANGES' flag now means that a change is visible at this point
in the merge. i.e. two streams need to be displayed instead of just one.
In particular, this means that an AlreadyApplied line removal will not
appear at all in the 'merge' window, but will trigger the 'diff' subwindow
to be displayed.
NeilBrown [Sun, 11 Nov 2012 22:25:12 +0000 (09:25 +1100)]
Browse: ensure we erase all of old type name when updating position data.
Top-right of the merge window identifies the current location in
the merge. It is variable length and right justified, so we need to make
sure we erase start of old value before writing new value.
Old code only allowed for a difference of three which didn't cope
with, for example, change from AlreadyApplied to Changed.
So be more thorough.
Manpreet Singh [Sat, 6 Oct 2012 02:51:05 +0000 (19:51 -0700)]
FreeBSD/*BSD build fixes for wiggle attached and a bug
To build wiggle on FreeBSD/*BSD/Mac
a) endian.h must be included from machine/endian.h.
b) A small fix to dotest is needed to avoid an infinite loop.
c) bash may not always be at /usr/bin/bash
Chris Peterson [Mon, 25 Jun 2012 13:29:37 +0000 (06:29 -0700)]
Fix some new compiler warnings.
hi Neil, I pulled wiggle's latest head from git and tried to compile on Mac
OS X. I ran into some problems when I tried to compile with -O3 without
-ggdb.
gcc -Werror treated some uninitialized variable warnings as errors. Some of
the warnings look like real bugs, but many were false positives. Compiling
with -O3 and -ggdb makes all the warnings "go away." :)
I've attached a patch to fix the following valid warnings:
cc1: warnings being treated as errors
parse.c: In function `parse_patch':
parse.c:268: warning: `c' may be used uninitialized in this function
vpatch.c: In function `next_melmnt':
vpatch.c:418: warning: `e.hash' may be used uninitialized in this function
vpatch.c: In function `prev_melmnt':
vpatch.c:472: warning: `e.hash' may be used uninitialized in this function
vpatch.c: In function `draw_mside':
vpatch.c:838: warning: `tag_attr' may be used uninitialized in this function
vpatch.c:837: warning: `tag' may be used uninitialized in this function
vpatch.c:1334: warning: `e' may be used uninitialized in this function
NeilBrown [Tue, 15 May 2012 12:04:03 +0000 (22:04 +1000)]
merge: make some conflicts less conflicting.
If a 'conflict' has an empty 'before' section, then it is probably
to separate things - and insertion in the original (unmatched) and
and insertion in the result.
So split it into those two, but leave the result marked as a Conflict
as the order of the insertions is not clear.
For now this mostly affects -B which can display the conflict
more effectively.
Neil Brown [Mon, 14 May 2012 01:01:11 +0000 (11:01 +1000)]
Merge: allow merging a multi-patch patchfile.
If
wiggle -p -r patchfilename
is given, multiple patches - each identifying the target
file - are read from patchfilename and each is applied to the
relevant file. Note that '-r' is required with this usage of
-p.
Neil Brown [Sun, 13 May 2012 23:17:35 +0000 (09:17 +1000)]
main: only pass training args to extract/do_diff/do_merge.
subtract/add optind to argc/argv before passing along. That way
sub-functions don't need to access optind directly, and it will allow
us to pass other arg strings that are independent of optind.
Neil Brown [Fri, 11 May 2012 09:42:24 +0000 (19:42 +1000)]
Browser: improve decision on when to split window for merger view.
Now that we are tracking in_conflict in the broswer we "know" when
we are in a conflict and so can only display the split window then,
rather than keeping some hysteresis until we leave any changes behind.
This makes large jumps ('N' 'P') display better.
Also don't allow hunk headers to look like a 'wiggled' section, because
they aren't really.
Neil Brown [Fri, 11 May 2012 03:36:37 +0000 (13:36 +1000)]
Browse: avoid display problems when changing view-mode.
If we change mode so that the current end-of-line is no longer
visible, the display gets confused and add extra lines. So when mode
changes, move backward then forward to ensure we are on a visibile
line.
Neil Brown [Thu, 10 May 2012 07:09:52 +0000 (17:09 +1000)]
isolate_conflicts: don't look for eol that cannot be there.
When looking for 'wiggles' we need to track whole lines
in the original file. But when looking for an end-of-line
we shouldn't look at an merge-item that doesn't even
exist in the original file.
Reported-by: Chris Peterson <cpeterso@cpeterso.com> Signed-off-by: NeilBrown <neilb@suse.de>