From 67263e2056108e471d684c3cef9e719724b51220 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 2 Sep 2010 12:53:27 -0700 Subject: Refactor diff sequence API Instead of making the sequence itself responsible for the equivalence function, use an external function that is supplied by the caller. This cleans up the code because we now say cmp.equals(a, ai, b, bi) instead of a.equals(ai, b, bi). This refactoring also removes the odd concept of creating different types of sequences to have different behaviors for whitespace ignoring. Instead DiffComparator now supports singleton functions that apply a particular equivalence algorithm to a type of sequence. Change-Id: I559f494d81cdc6f06bfb4208f60780c0ae251df9 Signed-off-by: Shawn O. Pearce --- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java | 13 +++++-------- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) (limited to 'org.eclipse.jgit.pgm/src') diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java index 7a4aed71ea..a5f801b296 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java @@ -55,10 +55,7 @@ import java.util.List; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffFormatter; -import org.eclipse.jgit.diff.RawTextIgnoreAllWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreLeadingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreTrailingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreWhitespaceChange; +import org.eclipse.jgit.diff.RawTextComparator; import org.eclipse.jgit.diff.RenameDetector; import org.eclipse.jgit.dircache.DirCacheIterator; import org.eclipse.jgit.lib.ObjectId; @@ -109,22 +106,22 @@ class Diff extends TextBuiltin { @Option(name = "--ignore-space-at-eol") void ignoreSpaceAtEol(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreTrailingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_TRAILING); } @Option(name = "--ignore-leading-space") void ignoreLeadingSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreLeadingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_LEADING); } @Option(name = "-b", aliases = { "--ignore-space-change" }) void ignoreSpaceChange(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreWhitespaceChange.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_CHANGE); } @Option(name = "-w", aliases = { "--ignore-all-space" }) void ignoreAllSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreAllWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_ALL); } @Option(name = "-U", aliases = { "--unified" }, metaVar = "metaVar_linesOfContext") diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 92cb70d4c4..0ce774b27d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -58,10 +58,7 @@ import java.util.Set; import java.util.TimeZone; import org.eclipse.jgit.diff.DiffFormatter; -import org.eclipse.jgit.diff.RawTextIgnoreAllWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreLeadingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreTrailingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreWhitespaceChange; +import org.eclipse.jgit.diff.RawTextComparator; import org.eclipse.jgit.diff.RenameDetector; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; @@ -106,22 +103,22 @@ class Log extends RevWalkTextBuiltin { @Option(name = "--ignore-space-at-eol") void ignoreSpaceAtEol(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreTrailingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_TRAILING); } @Option(name = "--ignore-leading-space") void ignoreLeadingSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreLeadingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_LEADING); } @Option(name = "-b", aliases = { "--ignore-space-change" }) void ignoreSpaceChange(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreWhitespaceChange.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_CHANGE); } @Option(name = "-w", aliases = { "--ignore-all-space" }) void ignoreAllSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreAllWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_ALL); } @Option(name = "-U", aliases = { "--unified" }, metaVar = "metaVar_linesOfContext") -- cgit v1.2.3