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>
Neil Brown [Thu, 10 May 2012 06:44:07 +0000 (16:44 +1000)]
Browser: add a more effective cursor.
Create a proper cursor structure to track where on the screen we are.
Record the width of the current symbol so 'backward' works better.
Allow movement master start and end of line by going to previous or
next line.
Allow 'search' to locate the actual string, not just the line.
Neil Brown [Tue, 8 May 2012 09:56:38 +0000 (19:56 +1000)]
merge: avoid including large Unmatched sections in a conflict.
A large Unmatched section can just distract from the real conflict
and doesn't give useful information.
So if we can close the conflict before a big Unmatched,
do so.
Neil Brown [Tue, 8 May 2012 08:54:11 +0000 (18:54 +1000)]
Encourage more context into conflict reports.
Conflict reports currently don't contain much surrounding
'Extraneous' text. When the patch didn't really apply at all,
this context is very useful.
So encourage at least 3 lines of context from Extraneous or
Unchanged texts.
If it mostly comes from Unchanged text it isn't quite so useful,
so reduce the requirement.
Update self-tests to match. In most cases these are an improvement.
In a couple of case we maybe get a bit more context than really
necessary, but that is better than not enough.
Neil Brown [Tue, 8 May 2012 07:09:07 +0000 (17:09 +1000)]
Improve handling of hunk-header when merging.
If we are merging a patch, the patch will contain a number of
hunk-headers (essentially the @@ NN,MM @@) lines.
These should never appear in the merge, and must always line up with
end-of-line in the original as they represent a number of lines having
been deleted.
So:
Cause these to each create a simple Extraneous merger, never
combined with adjacent texts
exclude them from any conflicts in isolate_conflict, so they
can never appear in a merge
Ensure that a preceeding 'Unmatched' finishes on an end-of-line.
Also update lots of self tests with improved results.
Neil Brown [Tue, 8 May 2012 06:18:31 +0000 (16:18 +1000)]
Ensure that a hunk-header never appears in the middle of an Extraneous range.
A hunk header is always Extraneous. However Extraneous text before it is
quite separate and is best kept separate.
Start a new Extraneous merger with each hunk header will make it easier
to detect hunk headers and handle them better.
Neil Brown [Mon, 7 May 2012 21:59:27 +0000 (07:59 +1000)]
Add --show-wiggle flag.
--show-wiggle modifies --merge so that chunks which need to be
wiggled into place are presented as full conflicts with an
extra stanza which shows what the resulting wiggle would look like.
Neil Brown [Mon, 7 May 2012 21:59:27 +0000 (07:59 +1000)]
Introduce xmalloc and use it.
Instead of sometimes calling die() when malloc fails and
sometimes not, introduce xmalloc() which always reports a message
and dies, and use it uniformly.
Neil Brown [Mon, 22 Aug 2011 08:08:02 +0000 (18:08 +1000)]
nul terminate stream read from a file.
Though we carry around the length of a string and so will not normally
need a nul terminator, we sometimes use sscanf which cannot take a
length and so needs nul termination.