Highlight line-level (aka word) differences in files

We now highlight any changed words within a line replace edit,
making the actual changes stand out against the surrounding context
that makes up the line.

The highlight is computed by constructing a string that covers the
entire replaced region and then running the Myers diff algorithm
over the individual characters of those two regions.

To avoid tiny edits interleaved at every other character in a
sentance we combine two neighboring character edits together if
there are only 1 or 2 characters between them.  There are probably
many ways to improve on this algorithm to avoid some nasty corner
display cases, but this rule is good enough for now.

The highlight data is computed and stored as part of the diff cache,
which requires a schema change in this commit.  So existing diff
cache records will be flushed on the next server start, and they
will be recomputed on demand.

Bug: issue 169
Change-Id: I69142ebef600e8c3c65821272dad3ee04a497654
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-01-30 19:41:17 -08:00
parent 0e4f33b82f
commit 7dafe19aee
14 changed files with 482 additions and 45 deletions

View File

@@ -35,7 +35,7 @@ import java.io.Serializable;
import javax.annotation.Nullable;
public class PatchListKey implements Serializable {
static final long serialVersionUID = 9L;
static final long serialVersionUID = 10L;
private transient ObjectId oldId;
private transient ObjectId newId;